public class WildcardStringParser
extends java.lang.Object
The string masks provided are treated as case sensitive.
Null-valued string masks as well as null valued strings to be parsed, will lead to rejection.
This class is custom designed for wildcard string parsing and is several times faster than the implementation based on the Jakarta Regexp package.
This task is performed based on regular expression techniques.
The possibilities of string generation with the well-known wildcard characters stated above,
represent a subset of the possibilities of string generation with regular expressions.
The '*' corresponds to ([Union of all characters in the alphabet])*
The '?' corresponds to ([Union of all characters in the alphabet])
These expressions are not suited for textual representation at all, I must say. Is there any math tags included in HTML?
The complete meta-language for regular expressions are much larger. This fact makes it fairly straightforward to build data structures for parsing because the amount of rules of building these structures are quite limited, as stated below.
To bring this over to mathematical terms:
The parser ia a nondeterministic finite automaton (latin) representing the grammar which is stated by the string mask.
The language accepted by this automaton is the set of all strings accepted by this automaton.
The formal automaton quintuple consists of:
Examples of usage:
This example will return "Accepted!".
WildcardStringParser parser = new WildcardStringParser("*_28????.jp*");
if (parser.parseString("gupu_280915.jpg")) {
System.out.println("Accepted!");
} else {
System.out.println("Not accepted!");
}
Theories and concepts are based on the book Elements of the Theory of Computation, by Harry l. Lewis and Christos H. Papadimitriou, (c) 1981 by Prentice Hall.
| Modifier and Type | Field and Description |
|---|---|
static char[] |
ALPHABET
Deprecated.
Field ALPHABET
|
static char |
FREE_PASS_CHARACTER
Deprecated.
Field FREE_PASS_CHARACTER
|
static char |
FREE_RANGE_CHARACTER
Deprecated.
Field FREE_RANGE_CHARACTER
|
| Constructor and Description |
|---|
WildcardStringParser(java.lang.String pStringMask)
Deprecated.
Creates a wildcard string parser.
|
WildcardStringParser(java.lang.String pStringMask,
boolean pDebugging)
Deprecated.
Creates a wildcard string parser.
|
WildcardStringParser(java.lang.String pStringMask,
boolean pDebugging,
java.io.PrintStream pDebuggingPrintStream)
Deprecated.
Creates a wildcard string parser.
|
| Modifier and Type | Method and Description |
|---|---|
protected java.lang.Object |
clone()
Deprecated.
|
boolean |
equals(java.lang.Object pObject)
Deprecated.
Method equals
|
protected void |
finalize()
Deprecated.
|
java.lang.String |
getStringMask()
Deprecated.
Gets the string mask that was used when building the parser atomaton.
|
int |
hashCode()
Deprecated.
Method hashCode
|
static boolean |
isFreePassCharacter(char pCharToCheck)
Deprecated.
Tests if a certain character is the designated "free-pass" character ('?').
|
static boolean |
isFreeRangeCharacter(char pCharToCheck)
Deprecated.
Tests if a certain character is the designated "free-range" character ('*').
|
static boolean |
isInAlphabet(char pCharToCheck)
Deprecated.
Tests if a certain character is a valid character in the alphabet that is applying for this automaton.
|
static boolean |
isWildcardCharacter(char pCharToCheck)
Deprecated.
Tests if a certain character is a wildcard character ('*' or '?').
|
boolean |
parseString(java.lang.String pStringToParse)
Deprecated.
Parses a string according to the rules stated above.
|
java.lang.String |
toString()
Deprecated.
Method toString
|
public static final char[] ALPHABET
public static final char FREE_RANGE_CHARACTER
public static final char FREE_PASS_CHARACTER
public WildcardStringParser(java.lang.String pStringMask)
pStringMask - the wildcard string mask.public WildcardStringParser(java.lang.String pStringMask,
boolean pDebugging)
pStringMask - the wildcard string mask.pDebugging - true will cause debug messages to be emitted to System.out.public WildcardStringParser(java.lang.String pStringMask,
boolean pDebugging,
java.io.PrintStream pDebuggingPrintStream)
pStringMask - the wildcard string mask.pDebugging - true will cause debug messages to be emitted.pDebuggingPrintStream - the java.io.PrintStream to which the debug messages will be emitted.public static boolean isInAlphabet(char pCharToCheck)
public static boolean isFreeRangeCharacter(char pCharToCheck)
public static boolean isFreePassCharacter(char pCharToCheck)
public static boolean isWildcardCharacter(char pCharToCheck)
public java.lang.String getStringMask()
public boolean parseString(java.lang.String pStringToParse)
pStringToParse - the string to parse.true if and only if the string are accepted by the automaton.public java.lang.String toString()
toString in class java.lang.Objectpublic boolean equals(java.lang.Object pObject)
equals in class java.lang.ObjectpObject - public int hashCode()
hashCode in class java.lang.Objectprotected java.lang.Object clone()
throws java.lang.CloneNotSupportedException
clone in class java.lang.Objectjava.lang.CloneNotSupportedExceptionprotected void finalize()
throws java.lang.Throwable
finalize in class java.lang.Objectjava.lang.ThrowableCopyright © 2020. All Rights Reserved.