Holger's
Java API

com.antelmann.math
Class NumberStringFilter<T extends Number & Comparable<? super T>>

java.lang.Object
  extended by com.antelmann.math.NumberStringFilter<T>
All Implemented Interfaces:
Filter<T>
Direct Known Subclasses:
NumberStringFilter.DecimalFilter, NumberStringFilter.DoubleFilter, NumberStringFilter.IntFilter, NumberStringFilter.LongFilter

@Todo(value={"support localized number formats","also support expressions with BooleanOperator"})
public abstract class NumberStringFilter<T extends Number & Comparable<? super T>>
extends Object
implements Filter<T>

compiles a filter from an input string that supports numbers and ranges in the form: '<1, 3, 5, 7-9, 11, 20-30, >=50'.

Since:
10.12.2010, 12:54:14
Author:
Holger Antelmann

Nested Class Summary
static class NumberStringFilter.DecimalFilter
           
static class NumberStringFilter.DoubleFilter
           
static class NumberStringFilter.IntFilter
           
static class NumberStringFilter.LongFilter
           
 
Field Summary
 
Fields inherited from interface com.antelmann.util.Filter
EXCLUDE_ALL_FILTER, INCLUDE_ALL_FILTER
 
Constructor Summary
NumberStringFilter(String filterString)
           
 
Method Summary
 boolean accept(T number)
          returns true only if the given entry is accepted by this filter
 Set<Map.Entry<T,RelationalOperator>> getCompiledNumbers()
           
 List<Range<T>> getCompiledRanges()
           
 String getFilterString()
           
abstract  T parseNumber(String str)
           
 void setFilterString(String filterString)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NumberStringFilter

public NumberStringFilter(String filterString)
                   throws NumberFormatException
Throws:
NumberFormatException
Method Detail

getCompiledNumbers

public Set<Map.Entry<T,RelationalOperator>> getCompiledNumbers()

getCompiledRanges

public List<Range<T>> getCompiledRanges()

accept

public boolean accept(T number)
Description copied from interface: Filter
returns true only if the given entry is accepted by this filter

Specified by:
accept in interface Filter<T extends Number & Comparable<? super T>>

getFilterString

public String getFilterString()

parseNumber

public abstract T parseNumber(String str)
                                                             throws NumberFormatException
Throws:
NumberFormatException

setFilterString

public void setFilterString(String filterString)
                     throws NumberFormatException
Throws:
NumberFormatException


(c) Holger Antelmann since 2001- all rights reserved (contact: info@antelmann.com)
see www.antelmann.com/developer for further details and available downloads