edu.sdsc.inca.util
Class ExpandablePattern

java.lang.Object
  extended byedu.sdsc.inca.util.ExpandablePattern

public class ExpandablePattern
extends java.lang.Object

A pattern (regular expression) that can return the set of strings it matches. See the JavaDoc for java.util.regex.Pattern for details of regexp syntax.


Field Summary
protected static java.lang.Exception EXPANSION_SET_TOO_BIG
           
static int MAX_EXPANSION
           
 
Constructor Summary
ExpandablePattern(java.lang.String pattern)
          Constructs a new ExpandablePattern that uses a specified regular expression.
ExpandablePattern(java.lang.String pattern, boolean glob)
          Constructs a new ExpandablePattern that uses a specified regular expresion or Glob-style pattern.
 
Method Summary
 java.util.HashSet expand()
          Returns the set of strings that a specified regular expression matches.
static java.util.HashSet expand(java.lang.String regexp)
          Returns the set of strings that a specified regular expression matches.
static java.util.HashSet expand(java.lang.String regexp, java.util.HashSet prepend)
          Returns the set of strings that a specified regular expression matches.
protected static java.util.HashSet expandCharSet(java.lang.String charSet)
          Returns the set of strings that a specified character set matches.
static void main(java.lang.String[] args)
          Interactive test program for Expandable pattern.
 boolean matches(java.lang.String s)
          Returns true iff this pattern matches s.
 java.lang.String toString()
          Returns a regular expression that matches the same strings as this pattern.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MAX_EXPANSION

public static final int MAX_EXPANSION
See Also:
Constant Field Values

EXPANSION_SET_TOO_BIG

protected static final java.lang.Exception EXPANSION_SET_TOO_BIG
Constructor Detail

ExpandablePattern

public ExpandablePattern(java.lang.String pattern)
Constructs a new ExpandablePattern that uses a specified regular expression.

Parameters:
pattern - the regular expression to use in matches

ExpandablePattern

public ExpandablePattern(java.lang.String pattern,
                         boolean glob)
Constructs a new ExpandablePattern that uses a specified regular expresion or Glob-style pattern.

Parameters:
pattern - the pattern to use in matches
glob - if true, the specified pattern is Glob-style (* and ? wildcards; . not special); otherwise, it's a regular expression.
Method Detail

expand

public java.util.HashSet expand()
                         throws java.lang.Exception
Returns the set of strings that a specified regular expression matches.

Returns:
a HashSet containing the set of matching strings
Throws:
java.lang.Exception - if the set is too large

matches

public boolean matches(java.lang.String s)
Returns true iff this pattern matches s.

Parameters:
s - the string to test
Returns:
true iff this pattern matches the given string

toString

public java.lang.String toString()
Returns a regular expression that matches the same strings as this pattern.

Returns:
a regular expression equivalent to this pattern.

expand

public static java.util.HashSet expand(java.lang.String regexp)
                                throws java.lang.Exception
Returns the set of strings that a specified regular expression matches.

Parameters:
regexp - the regular expression to expand.
Returns:
a HashSet containing the set of matching strings
Throws:
java.lang.Exception - if the set is too large

expand

public static java.util.HashSet expand(java.lang.String regexp,
                                       java.util.HashSet prepend)
                                throws java.lang.Exception
Returns the set of strings that a specified regular expression matches.

Parameters:
regexp - the regular expression to expand.
prepend - a set of strings to prepend to each string generated by the regular expression
Returns:
a HashSet containing the set of matching strings
Throws:
java.lang.Exception - if the set is too large

expandCharSet

protected static java.util.HashSet expandCharSet(java.lang.String charSet)
                                          throws java.lang.Exception
Returns the set of strings that a specified character set matches.

Parameters:
charSet - the character set to expand, not including enclosing []
Returns:
a HashSet containing the set of matching strings
Throws:
java.lang.Exception

main

public static void main(java.lang.String[] args)
Interactive test program for Expandable pattern. Repeatedly accepts a pattern from the user and prints the expansion.