dsto.dfc.swing.text.selection
Class NumberSelector

java.lang.Object
  extended by 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

Nested Class Summary
 
Nested classes/interfaces inherited from interface dsto.dfc.swing.text.selection.PatternSelector
PatternSelector.SelectAllSelector
 
Field Summary
static ValueConverter CONVERTER
          ValueConverter for this class: converts to/from String.
protected  String expr
           
protected  NumberSelectorPattern pattern
           
protected static String USAGE_TEXT
           
 
Fields inherited from interface dsto.dfc.swing.text.selection.PatternSelector
SELECT_ALL
 
Constructor Summary
NumberSelector()
           
NumberSelector(String expr)
           
 
Method Summary
protected  void compileExpr(String exprStr)
           
 ValueConverter getConverter()
          Return a converter that at least supports conversion to and from String.
 String getExpression()
           
protected static String makeErrorMessage(Throwable ex)
           
 boolean matches(double value)
           
 boolean matches(Object value)
          True if this pattern selector matches the given value.
 void setExpression(String newExpr)
          Set the value of the pattern used to match against.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

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
Constructor Detail

NumberSelector

public NumberSelector()

NumberSelector

public NumberSelector(String expr)
               throws IllegalFormatException
Throws:
IllegalFormatException
Method Detail

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