dsto.dfc.swing.text.selection
Class NumberSelector
java.lang.Object
dsto.dfc.swing.text.selection.NumberSelector
- All Implemented Interfaces:
- Convertable, PatternSelector, Selector, Serializable
public class NumberSelector
- extends Object
- implements PatternSelector, Convertable, Serializable
Uses patterns such as "[0:1],10,>=12,(13:*],<200" to match numbers
(int, float and double). When using ranges, '(' and ')' indicate
non-inclusivity, '[' and ']' indicate inclusivity.
Grammar:
<expr> ::= <term> (',' <term>)*
<term> ::= <comparison> | <range>
<comparison> ::= ('>' | '>=' | '<' | '<=') <number>
<range> ::= <value> | ( '[' | '(' ) <value> ':' <value> ( ')' | ']' )
<value> ::= '*' | <number>
<number> ::= [+-][0-9]+['.' [0-9]+]
- Version:
- $Revision$
- See Also:
- Serialized Form
CONVERTER
public static final ValueConverter CONVERTER
- ValueConverter for this class: converts to/from String.
USAGE_TEXT
protected static final String USAGE_TEXT
- See Also:
- Constant Field Values
expr
protected String expr
pattern
protected transient NumberSelectorPattern pattern
NumberSelector
public NumberSelector()
NumberSelector
public NumberSelector(String expr)
throws IllegalFormatException
- Throws:
IllegalFormatException
getConverter
public ValueConverter getConverter()
- Description copied from interface:
PatternSelector
- Return a converter that at least supports conversion to and from String.
- Specified by:
getConverter
in interface Convertable
- Specified by:
getConverter
in interface PatternSelector
matches
public boolean matches(Object value)
- Description copied from interface:
PatternSelector
- True if this pattern selector matches the given value.
- Specified by:
matches
in interface PatternSelector
- Specified by:
matches
in interface Selector
matches
public boolean matches(double value)
toString
public String toString()
- Overrides:
toString
in class Object
getExpression
public String getExpression()
- Specified by:
getExpression
in interface PatternSelector
setExpression
public void setExpression(String newExpr)
throws IllegalFormatException
- Description copied from interface:
PatternSelector
- Set the value of the pattern used to match against.
- Specified by:
setExpression
in interface PatternSelector
- Parameters:
newExpr
- String value
- Throws:
IllegalFormatException
makeErrorMessage
protected static String makeErrorMessage(Throwable ex)
compileExpr
protected void compileExpr(String exprStr)
throws IllegalFormatException
- Throws:
IllegalFormatException
Copyright © 2008 Commonwealth of Australia