Sharkysoft home

lava.string
Class WildcardExpression

java.lang.Object
  |
  +--lava.string.WildcardExpression

public class WildcardExpression
extends java.lang.Object

Tests strings against wildcard expressions.

Details: A WildcardExpression is a template for testing whether strings belong in a certain string class. WildcardExpressions can contain any number of literal characters and the two supported wildcard characters, '?' and '*', which are understood in the usual command shell fashion:

'*'
matches any sequence of characters, of any length, including zero length
'?'
matches any single character

Since:
1997
Version:
2000.11.08

Constructor Summary
WildcardExpression(java.lang.String expression)
          Sets expression string.
WildcardExpression(java.lang.String expression, java.lang.String excludes)
          Reserved.
 
Method Summary
 boolean accept(java.lang.String cand)
          Tests string.
static java.lang.String normalize(java.lang.String expression)
          Normalizes expression.
 java.lang.String toString()
          Returns string representation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

WildcardExpression

public WildcardExpression(java.lang.String expression,
                          java.lang.String excludes)
Reserved.

Details: Reserved for future implementation. Constructs a WildcardExpression using the given String. Wildcards '?' and '*' will not be allowed to match characters in the excludes string.

Parameters:
expression - the wildcard expression
excludes - a list of character that should not be wild-matched

WildcardExpression

public WildcardExpression(java.lang.String expression)
Sets expression string.

Details: Constructs a WildcardExpression using the given String.

Method Detail

normalize

public static java.lang.String normalize(java.lang.String expression)
Normalizes expression.

Details: Normalizes a wildcard expression by expressing it in canonical form. The canonical form of a wildcard expression does not contain the substrings "*?" or "**". For any given wildcard expression, the canonical form of that expression is uniquely defined. Any two equivalent wildcard expressions have the same canonical form.

Parameters:
expression - the expression to normalize
Returns:
the normalized expression

accept

public boolean accept(java.lang.String cand)
Tests string.

Details: accept tests the given string against this wildcard expression.

Parameters:
cand - the string to test
Returns:
true if the string passes, false otherwise

toString

public java.lang.String toString()
Returns string representation.

Details: toString returns this wildcard expression as a string. The returned string may not be identical to the string passed to the constructor, but it will be equivalent.

Overrides:
toString in class java.lang.Object
Returns:
string representation
Since:
2000.11.08

Sharkysoft home