Package net.sf.eBus.util.regex
Class Component
- java.lang.Object
-
- net.sf.eBus.util.regex.Component
-
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
AnyChar,CharacterSet,Literal
public abstract class Component extends Object implements Serializable
Abstract base class for all regular expression components. Every component has a minimum and maximum match length. The component must match at least the minimum length and at most the maximum length (inclusive).- Author:
- Charles Rapp
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static intANY_CHARThis component matches any character.static intCHARACTER_SETA character set component matches only those characters in the set (positive) or not in the set (negative).static intLITERALA literal component matches exactly.protected intmIndexThe component's position within the regular expression pattern.protected intmMaximumSizeThe component's maximum possible length.protected intmMinimumSizeThe component's minimum possible length.protected intmTypeThe component's type.static intNO_MAX_MATCH_LIMITThe maximum range limit is set to this value when the the limit is infinite.
-
Constructor Summary
Constructors Modifier Constructor Description protectedComponent(int type, int minLength, int maxLength, int index)Sets the component's type, minimum and maximum length.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidappendSize(StringBuilder buffer)Adds the size to the output only if not {1, 1}.abstract booleanequalTo(char c)Returnstrueif this component is equal to the characterc; returnsfalseotherwise.abstract booleangreaterThan(char c)Returnstrueif this component is greater than the characterc; returnsfalseotherwise.intindex()Returns the component's pattern index.abstract booleanlessThan(char c)Returnstrueif this component is less than the characterc; returnsfalseotherwise.intmaximumSize()Returns the component's maximum size.intminimumSize()Returns the component's minimum size.inttype()Returns this component's type.
-
-
-
Field Detail
-
NO_MAX_MATCH_LIMIT
public static final int NO_MAX_MATCH_LIMIT
The maximum range limit is set to this value when the the limit is infinite.- See Also:
- Constant Field Values
-
LITERAL
public static final int LITERAL
A literal component matches exactly.- See Also:
- Constant Field Values
-
CHARACTER_SET
public static final int CHARACTER_SET
A character set component matches only those characters in the set (positive) or not in the set (negative).- See Also:
- Constant Field Values
-
ANY_CHAR
public static final int ANY_CHAR
This component matches any character.- See Also:
- Constant Field Values
-
mType
protected final int mType
The component's type. Must be one ofLITERAL,CHARACTER_SETorANY_CHAR.
-
mMinimumSize
protected final int mMinimumSize
The component's minimum possible length.
-
mMaximumSize
protected final int mMaximumSize
The component's maximum possible length.
-
mIndex
protected final int mIndex
The component's position within the regular expression pattern. Indexing begins at zero.
-
-
Constructor Detail
-
Component
protected Component(int type, int minLength, int maxLength, int index)Sets the component's type, minimum and maximum length.- Parameters:
type- The regular expression component type.minLength- The component's minimum length.maxLength- The component's maximum length.index- The component's position in the pattern.
-
-
Method Detail
-
type
public final int type()
Returns this component's type. Return value will be one of-
LITERAL -
CHARACTER_SET -
ANY_CHAR
- Returns:
- this component's type.
-
-
minimumSize
public final int minimumSize()
Returns the component's minimum size. This component must match at least this many times.- Returns:
- the component's minimum size.
-
maximumSize
public final int maximumSize()
Returns the component's maximum size. This component must match at most this many times (inclusive).- Returns:
- the component's maximum size.
-
index
public final int index()
Returns the component's pattern index.- Returns:
- the component's pattern index.
-
lessThan
public abstract boolean lessThan(char c)
Returnstrueif this component is less than the characterc; returnsfalseotherwise.- Parameters:
c- Test against this character.- Returns:
trueif this component is less than the characterc; returnsfalseotherwise.
-
equalTo
public abstract boolean equalTo(char c)
Returnstrueif this component is equal to the characterc; returnsfalseotherwise.- Parameters:
c- Test against this character.- Returns:
trueif this component is equal to the characterc; returnsfalseotherwise.
-
greaterThan
public abstract boolean greaterThan(char c)
Returnstrueif this component is greater than the characterc; returnsfalseotherwise.- Parameters:
c- Test against this character.- Returns:
trueif this component is greater than the characterc; returnsfalseotherwise.
-
appendSize
protected void appendSize(StringBuilder buffer)
Adds the size to the output only if not {1, 1}.- Parameters:
buffer- Append the size to this output buffer.
-
-