org.media.mn8.util
Class SimpleExpression
java.lang.Object
|
+--org.media.mn8.util.SimpleExpression
- public class SimpleExpression
- extends java.lang.Object
The SimpleExpression class implements a simple expression parser.
The only operators of a simple expression are:
- * - match everything, like the "." in regular
expressions
- # - selects everything
It performs only two functions:
- select -selects all the apparence of the strings marked
with the select ("#") operator
- match - verifies if a string matches the pattern specified
using normal characters and the two operators.
It is intended as a simple replacement for regular expression in the case
of simple expressions.
- Version:
- $Revision: 1.28 $ $Date: 2002/03/22 18:38:24 $
- Author:
- Remus Pereni
- See Also:
String
Method Summary |
static boolean |
contains(java.lang.String target,
java.lang.String pattern)
|
protected static boolean |
isOperator(java.lang.String target)
|
protected static int |
lookAhead(java.lang.String token,
java.lang.String target,
int targetIndex)
Tries to find the token in the target string starting with the
targetIndex position. |
protected static java.lang.String[] |
makeTokens(java.lang.String pattern)
|
static boolean |
match(java.lang.String target,
java.lang.String pattern)
Specifies if a pattern matches the target string or not. |
protected static int |
operatorOccurences(java.lang.String target,
java.lang.String operator)
|
static java.util.Collection |
select(java.lang.String target,
java.lang.String pattern)
Selects a collection of strings from the target using as mask the pattern
and the two operators "#" and "*". |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
SimpleExpression
public SimpleExpression()
select
public static java.util.Collection select(java.lang.String target,
java.lang.String pattern)
- Selects a collection of strings from the target using as mask the pattern
and the two operators "#" and "*".
- Parameters:
target
- The string to be matchedpattern
- The pattern- Returns:
- A collection (Vector) of string arrays containing the selected
strings as specified through the pattern or null of none find or
specified.
- See Also:
Collection
,
Vector
match
public static boolean match(java.lang.String target,
java.lang.String pattern)
- Specifies if a pattern matches the target string or not.
- Parameters:
target
- The string to be matchedpattern
- The pattern- Returns:
- True if the pattern is present in the target, false otherway.
contains
public static boolean contains(java.lang.String target,
java.lang.String pattern)
lookAhead
protected static int lookAhead(java.lang.String token,
java.lang.String target,
int targetIndex)
- Tries to find the token in the target string starting with the
targetIndex position.
- Parameters:
token
- The token to be looked for.target
- The string where we look for the token.targetIndex
- the position in the target where we begin the search.- Returns:
- The position of the first found token in the target or -1 in
case was not found.
makeTokens
protected static java.lang.String[] makeTokens(java.lang.String pattern)
operatorOccurences
protected static int operatorOccurences(java.lang.String target,
java.lang.String operator)
isOperator
protected static boolean isOperator(java.lang.String target)
"Copyright © 2001 Internet Multicasting Services & media.org. All Rights Reserved."