Package com.ms.util |
![]() Previous |
![]() Contents |
![]() Index |
![]() Next |
public class WildcardExpression implements java.io.FilenameFilter { // Constructors public WildcardExpression (String expr) public WildcardExpression () public WildcardExpression (String expr, boolean escape, boolean ignoresep, boolean extended, boolean casesensitive) // Methods public synchronized boolean compile (String expr, boolean escape, boolean ignoresep, boolean extended, boolean casesensitive) public void disassemble (java.io.PrintStream o) public String toString () public boolean match (String s) public int matchex (String s) public int resume (String s) public static int matchOne (WildcardExpression[] exprs, String s) public boolean accept (java.io.File dir, String name) public boolean equals (Object obj) }
This class implements wildcard expression matching. For performance, nothing in this class is synchronized. The typical use is that an expression is compiled once (by the constructor). Compile is the only operation that modifies the state of the expression and should be synchronized with the other operations by the caller.
public WildcardExpression (String expr)Creates an expression following the typical wildcard convention.
public WildcardExpression ()Creates an empty expression. An expression must be compiled before matches can be made.
See Also: compile
public WildcardExpression (String expr, boolean escape, boolean ignoresep, boolean extended, boolean casesensitive)Creates an expression using the extended form.
See Also: compile
public boolean accept (java.io.File dir, String name)Finds files that match a wildcard string in a directory.
Return Value:
Returns a boolean value indicating whether the wildcard matches any file in the directory.
Parameter Description dir The file directory to search. name The wildcard expression to match.
public synchronized boolean compile (String expr, boolean escape, boolean ignoresep, boolean extended, boolean casesensitive)Compiles the expression for faster evaluation. The previously compiled expression is lost.
Return Value:
Returns true if the expression was compiled.
Parameter Description expr Expression to compile. escape Allow escaped wildcards in expression (for example, \*). ignoresep ? and * ignore path separators. extended Extended syntax
- *
- Matches up to a / or \.
- *+
- Matches anything.
- ?
- Matches single character, excluding a \ or /.
With ignoresep, * and *+ are synonymous and ? will match a \ or /.
casesensitive Do case-sensitive matching if true. See Also: match
public void disassemble (java.io.PrintStream o)Displays the compiled expression code in human-readable form.
Parameter Description o Stream to print the compiled expression to.
public boolean equals (Object obj)Compares wildcard expressions.
Return Value:
Returns true if the parameter is a wildcard expression and matches this class's compiled expression; otherwise it returns false.
Parameter Description obj Wildcard expression to compare.
public boolean match (String s)Evaluates the expression on the string.
Return Value:
Returns true if the expression accepts the string
public int matchex (String s)Evaluates the expression on the string.
Return Value:
Returns subexpression number if the expression accepts the string, else -1 if the string was not accepted .
public static int matchOne (WildcardExpression[] exprs, String s)Evaluates a list of expressions on a string.
Return Value:
Returns index of the expression that matched, else -1.
Parameter Description exprs List of expressions. s String to evaluate expressions on.
public int resume (String s)Resumes a previous match that stopped at a subexpression.
public String toString ()Reconstructs the original expression in extended, non-escaped form. Case-insensitive expressions are reconstituted in lower case.
Return Value:
Returns the original expression.
© 1997 Microsoft Corporation. All rights reserved. Legal Notices.