|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.lonniepryor.blues.util.Strings
Specification interface for identifying Strings or parts of Strings. Instances of this class may be logically combined using the AND, OR, and NOT operations. Instances may also be sequentially constructed using the Builder class. Many common use-cases are supplied via static accessor methods.
Nested Class Summary | |
static class |
Strings.Builder
Helper class for sequentially constructing the elements of a common Strings specification. |
Constructor Summary | |
protected |
Strings()
Creates a new Strings object. |
Method Summary | |
Strings |
and(Strings specification)
Returns a specification representing a logical AND of this specification on the left and the supplied specification on the right. |
static Strings |
any()
Returns a specification satisfied by any non-null string. |
protected abstract boolean |
evaluate(java.lang.String canidate,
int begin,
int end)
Returns true if the specified range satisfies this specification. |
boolean |
isSatisfiedBy(java.lang.String canidate)
Returns true if the supplied String is not null and satisfies this specification. |
boolean |
isSatisfiedBy(java.lang.String canidate,
int begin,
int end)
Returns true if the supplied String is not null and the specified range satisfies this specification. |
boolean |
isSatisfiedByAll(java.lang.String[] all)
Returns true if all of the supplied Strings satisfy this specification. |
boolean |
isSatisfiedByAny(java.lang.String[] any)
Returns true if any of the supplied Strings satisfy this specification. |
static Strings |
matching(Characters specification)
Returns a specification satisfied by strings with a single character that satisfies the specified specification. |
static Strings |
matching(java.lang.String characters)
Returns a specification satisfied by strings equal to the specified string. |
Strings |
not()
Returns a specification representing a logical NOT of this specification. |
static Strings |
notEmpty()
Returns a specification satisfied by any non-empty string. |
Strings |
or(Strings specification)
Returns a specification representing a logical OR of this specification on the left and the supplied specification on the right. |
static Strings |
parse(java.lang.String stringPattern)
Parses a string pattern containing the '' wildcard. |
static Strings |
parseExpression(java.lang.String stringPatternExpr)
Parses a logical expression as described in the Expression class, using this class's parse() method for creating values. |
java.lang.String[] |
selectAll(java.lang.String[] from)
Selects all the Strings that satisfy this specification from the supplied array. |
java.lang.String |
selectFirst(java.lang.String[] from)
Selects the first Strings that satisfies this specification from the supplied array. |
static Strings.Builder |
startingWith(Characters specification)
Returns a Builder whose resulting Strings specification will require the supplied character at the beginning of canidate strings. |
static Strings.Builder |
startingWith(java.lang.String characters)
Returns a Builder whose resulting Strings specification will require the supplied text at the beginning of canidate strings. |
static Strings.Builder |
startingWithAny()
Returns a Builder whose resulting Strings specification will allow any number of inital characters. |
static Strings.Builder |
startingWithAtLeastNumChars(int minChars)
Returns a Builder whose resulting Strings specification will require at least the supplied number of inital characters. |
static Strings |
withAtLeastNumChars(int minChars)
Returns a specification satisfied by strings of at least the specified length. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
protected Strings()
Method Detail |
public static Strings any()
public static Strings notEmpty()
public static Strings withAtLeastNumChars(int minChars)
minChars
- The minimum length of valid strings.
public static Strings matching(Characters specification)
specification
- The specification to match to.
public static Strings matching(java.lang.String characters)
characters
- The string to match to.
public static Strings.Builder startingWithAny()
public static Strings.Builder startingWithAtLeastNumChars(int minChars)
minChars
- The minimum number of charactes to require.
public static Strings.Builder startingWith(Characters specification)
specification
- The specification to match to.
public static Strings.Builder startingWith(java.lang.String characters)
characters
- The text required at the beginning of canidates.
public static Strings parse(java.lang.String stringPattern)
strings ::= wildcard | ( [ wildcard ] pattern ) pattern ::= characters [ wildcard [ pattern ] ] wildcard ::= "*" characters ::= Any sequence of characters except "*"Astriks will match zero or more characters, all other characters are matched exactly.
stringPattern
- The content of the pattern.
ParseException
- if the pattern is invalid.public static Strings parseExpression(java.lang.String stringPatternExpr)
stringPatternExpr
- The content of the pattern expression.
ParseException
- if the pattern expression is invalid.Expression
,
parse(String)
public final boolean isSatisfiedBy(java.lang.String canidate)
canidate
- The String to test.
public final boolean isSatisfiedBy(java.lang.String canidate, int begin, int end)
canidate
- The String to test.begin
- The beginning of the range (inclusive).end
- The end of the range(excusive).
protected abstract boolean evaluate(java.lang.String canidate, int begin, int end)
canidate
- The String to test.begin
- The beginning of the range (inclusive).end
- The end of the range(excusive).
public final boolean isSatisfiedByAll(java.lang.String[] all)
all
- The array of Strings to test.
public final boolean isSatisfiedByAny(java.lang.String[] any)
any
- The array of Strings to test.
public final java.lang.String selectFirst(java.lang.String[] from)
from
- The array to select from.
public final java.lang.String[] selectAll(java.lang.String[] from)
from
- The array to select from.
public final Strings and(Strings specification)
specification
- The specification to AND with.
public final Strings or(Strings specification)
specification
- The specification to OR with.
public final Strings not()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |