org.osesb.utilities.fileio
Class FileSpecifier

java.lang.Object
  extended by org.osesb.utilities.fileio.FileSpecifier

public class FileSpecifier
extends java.lang.Object

Filename specifier. Allows patterns at each level of the path. For example: d*.C*Tracker matches docutil.ClassTracker and docutil.ConstrTracker.

Note:
A final * character in the directory-path part of the pathname matches all sub-packages. So java.awt.*.Foo* matches all files that start with "Foo" in all subpackages under java.awt. To keep from recognizing subpackages, specify "?*" as the last directory entry. The specification java.awt.?*.Foo*, therefore, matches only those classes that start with Foo that are in subpackages immediately under java.awt.
By default, paths are assumed to be separated by the default seperator character for the current system ("/" for Unix, "\" for DOS). The path separator can also be specified, both when creating the specifier and when invoking the match(String, String) function. That allows a filename specifier to be created with a dot-separator, for example, and yet be successfully compared to a file system pathname.

Note:
A null pattern matches everything. The match(java.lang.String) function always returns true. However, when a null string, is compared to any pattern, the null string always returns false. (A null string matches nothing.) When a null string is compared to a null pattern, the result is false. (The null string takes precedence.)

See Also:
Specifier, PathSpecifier

Field Summary
protected  Specifier nameSpec
           
protected  PathSpecifier pathSpec
           
protected  java.lang.String pattern
           
 
Constructor Summary
FileSpecifier(java.lang.String pattern)
          Create a specifier using the default directory-seperator for the current system, where the separator is used to divide the input string.
 
Method Summary
 java.lang.String getPattern()
           
protected  void initSpec(java.util.List pList)
          Initialize this specifier
static void main(java.lang.String[] args)
          main(): for testing.
 boolean match(java.lang.String s)
          Check the string argument to see if it matches this specifier, where the default directory-seperator for the current system is used to divide the input string into directory-name segments.
 boolean match(java.lang.String path, java.lang.String separator)
          Check the string argument to see if it matches this specifier, where the specified seperator is used to divide the input string into directory-name segments.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

pathSpec

protected PathSpecifier pathSpec

nameSpec

protected Specifier nameSpec

pattern

protected java.lang.String pattern
Constructor Detail

FileSpecifier

public FileSpecifier(java.lang.String pattern)
Create a specifier using the default directory-seperator for the current system, where the separator is used to divide the input string.

Parameters:
pattern - the pattern to match (ex: j*\Foo*Bar)
Method Detail

initSpec

protected void initSpec(java.util.List pList)
Initialize this specifier

Parameters:
pList - a list of Strings
Throws:
java.lang.ClassCastException - if the list entries are not strings

match

public boolean match(java.lang.String s)
Check the string argument to see if it matches this specifier, where the default directory-seperator for the current system is used to divide the input string into directory-name segments.

Parameters:
s - the string to match
Returns:
true if the string matche this specifier

match

public boolean match(java.lang.String path,
                     java.lang.String separator)
Check the string argument to see if it matches this specifier, where the specified seperator is used to divide the input string into directory-name segments.

Parameters:
path - the directory-path string to match
separator - the directory-name separator -- "/" for Unix, "\" for DOS, "." for packages.
Returns:
true if the string matche this specifier

toString

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

getPattern

public java.lang.String getPattern()

main

public static void main(java.lang.String[] args)
main(): for testing.