facets.util
Class FileSpecifier

java.lang.Object
  extended by facets.util.Tracer
      extended by facets.util.FileSpecifier
Direct Known Subclasses:
XmlSpecifier

public class FileSpecifier
extends Tracer

Extension-based file filtering and name building.


Field Summary
static java.lang.String _dot
           
static java.lang.String _toFirstDot
           
static FileSpecifier ALL
          The *.* specifier, does not filter or add an extension.
static java.lang.String dot
           
 java.lang.String extension
          Immutable fields based on those passed to the constructor.
 java.lang.String rubric
          Immutable fields based on those passed to the constructor.
 
Constructor Summary
FileSpecifier(java.lang.String extension, java.lang.String description)
          Unique constructor.
 
Method Summary
static FileSpecifier[] filterByName(FileSpecifier[] specs, java.lang.String name)
          Attempt to filter FileSpecifiers against the name passed.
protected  java.lang.String newFileName(java.lang.Object source)
          Constructs a filename by looking at the source passed.
 java.io.File specifiedFile(java.lang.Object source)
          Returns a file named to match the specification.
 boolean specifies(java.io.File path)
          Does the file match the specification?
 java.lang.String stripExtension(java.lang.String fileName)
           
 java.lang.String toString()
           
 
Methods inherited from class facets.util.Tracer
trace, trace, trace, trace, trace, traceDebug, traceDebug, traceObjectText, traceOutput, traceOutputWithClass
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ALL

public static final FileSpecifier ALL
The *.* specifier, does not filter or add an extension.


dot

public static final java.lang.String dot
See Also:
Constant Field Values

_dot

public static final java.lang.String _dot
See Also:
Constant Field Values

_toFirstDot

public static final java.lang.String _toFirstDot
See Also:
Constant Field Values

extension

public final java.lang.String extension
Immutable fields based on those passed to the constructor.


rubric

public final java.lang.String rubric
Immutable fields based on those passed to the constructor.

Constructor Detail

FileSpecifier

public FileSpecifier(java.lang.String extension,
                     java.lang.String description)
Unique constructor.

Parameters:
extension - becomes extension
description - joined to extension to become rubric
Method Detail

specifiedFile

public final java.io.File specifiedFile(java.lang.Object source)
Returns a file named to match the specification.

Parameters:
source - either a file or typically the source of content to be stored
Returns:
a file with name ending (usually) with extension, if necessary calling newFileName(Object)

newFileName

protected java.lang.String newFileName(java.lang.Object source)
Constructs a filename by looking at the source passed.

Parameters:
source - typically the source of content to be stored in the file
Returns:
by default a file name obtained by casting source to Titled, with appropriate extension

specifies

public final boolean specifies(java.io.File path)
Does the file match the specification?

Parameters:
path - may be a directory

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

filterByName

public static FileSpecifier[] filterByName(FileSpecifier[] specs,
                                           java.lang.String name)
Attempt to filter FileSpecifiers against the name passed.

Parameters:
specs - to be filtered
name - to be checked
Returns:
all members of specs where name matches extension, or all passed if there are no matches

stripExtension

public java.lang.String stripExtension(java.lang.String fileName)