|
RSE Release 3.0 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.rse.services.clientserver.NamePatternMatcher
public class NamePatternMatcher
This class offers generic name pattern matching.
This supports one wildcard character ('*") anywhere in the name, or one at the beginning and end of the name.
This pattern matching class also optionally supports additional advanced patterns beyond the stricter PDM style. These allow for two '*'s anywhere in the name.
Quoted names are supported.
All matching is case-sensitive!
Instantiate this class for a given generic name, and then call matches(String input) for each input name to see if it matches the pattern.
To enable the advanced patterns, pass true
to the constructor.
Field Summary | |
---|---|
static int |
ALL
Example: * |
static char |
QUOTE
Example: Quoted name delimiter: " |
static int |
SCALAR
Example: ABC |
static char |
WILDCARD
Wildcard character: * |
static int |
WILDCARD_END
Example: ABC* |
static int |
WILDCARD_MIDDLE
Example: A*C |
static int |
WILDCARD_MIDDLE_END
|
static int |
WILDCARD_MIDDLE_MIDDLE
Example: A*C*F |
static int |
WILDCARD_START
Example: *ABC |
static int |
WILDCARD_START_END
Example: *ABC* |
static int |
WILDCARD_START_MIDDLE
Example: *A*F |
Constructor Summary | |
---|---|
NamePatternMatcher(String genericName)
Constructor for traditional-style only patterns, which allows for one asterisk anywhere in the name,or one asterisk each at the beginning or end of the name. |
|
NamePatternMatcher(String genericName,
boolean advanced,
boolean caseSensitive)
Constructor for traditional-style patterns PLUS advanced patterns ABC*DEF* and A*C*F. |
Method Summary | |
---|---|
int |
getPatternType()
What type of pattern is it? |
boolean |
isGeneric()
Was generic name given in the constructor a valid generic name (one or 2 '*'s)? |
boolean |
isQuoted()
Was quoted name given in the constructor a quoted name like "abcDEF"? |
boolean |
isValid()
Was generic name given in the constructor a valid scalar or generic name? |
boolean |
matches(String input)
Test if a host name matches the pattern of this generic name. |
String |
toString()
For writing this object out. |
static boolean |
verifyPattern(String genericName,
boolean advanced)
Static method to test if a given pattern is a valid generic name |
void |
writeInfo(PrintWriter stream)
For debugging/testing purposes. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final char WILDCARD
public static final char QUOTE
public static final int SCALAR
public static final int ALL
public static final int WILDCARD_END
public static final int WILDCARD_START
public static final int WILDCARD_MIDDLE
public static final int WILDCARD_START_END
public static final int WILDCARD_MIDDLE_END
public static final int WILDCARD_START_MIDDLE
public static final int WILDCARD_MIDDLE_MIDDLE
Constructor Detail |
---|
public NamePatternMatcher(String genericName)
If you don't know for sure the input is generic or valid, after
constructing call:
isValid()
to determine if given generic name was valid. isGeneric()
to determine if given generic name had a wildcard.
If curious, you can also subsequently call:
getPatternType()
to determine which type of pattern the generic name follows.
Once constructed for a valid name, you can call
matches(String)
for each name to see if it matches this generic name pattern.
Quoted names are supported.
All matching is case-sensitive!
genericName
- generic name to do pattern matching for (ie, ABC*DEF)public NamePatternMatcher(String genericName, boolean advanced, boolean caseSensitive)
If you don't know for sure the input is generic or valid, after
constructing call:
isValid()
to determine if given generic name was valid. isGeneric()
to determine if given generic name had a wildcard.
If curious, you can also subsequently call:
getPatternType()
to determine which type of pattern the generic name follows.
Once constructed for a valid name, you can call
matches(String)
for each name to see if it matches this generic name pattern.
Quoted names are supported.
genericName
- generic name to do pattern matching for (ie, ABC*DEF)advanced
- true if you want to support the advanced patterns.caseSensitive
- true if the names are case-sensitive, false if case insensitiveMethod Detail |
---|
public boolean matches(String input)
matches
in interface IMatcher
input
- Scalar name like ABCDEF
public boolean isValid()
public boolean isGeneric()
public boolean isQuoted()
public int getPatternType()
SCALAR
, ALL
, WILDCARD_END
, WILDCARD_START
, WILDCARD_MIDDLE
,
WILDCARD_START_END
, or WILDCARD_MIDDLE_END
public String toString()
toString
in class Object
public void writeInfo(PrintWriter stream)
public static boolean verifyPattern(String genericName, boolean advanced)
genericName
- pattern to testadvanced
- true if advanced pattern allowed: ABC*DEF* and A*C*F
|
RSE Release 3.0 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |