net.coderazzi.filters.parser
Class FilterTextParser

java.lang.Object
  extended by net.coderazzi.filters.parser.FilterTextParser
All Implemented Interfaces:
IFilterTextParser

public class FilterTextParser
extends Object
implements IFilterTextParser

Basic implementation of a IFilterTextParser, supporting only simple operators referring to the content of a single column.
The supporter operators include:


Constructor Summary
FilterTextParser()
           
 
Method Summary
 void addPropertyChangeListener(PropertyChangeListener listener)
          Adds a PropertyChangeListener.
 Comparator<?> getComparator(Class<?> c)
          Returns the comparator provided for the given class
 String getDefaultOperator()
          Returns the default operand
 Format getFormat(Class<?> c)
          Returns the Format for a given class
 boolean isIgnoreCase()
          Returns true if it ignores case
 RowFilter parseText(String expression, int modelPosition)
          Parses the text, corresponding to a column in the table model
It returns a filter that can be applied to the table sorter.
 void removePropertyChangeListener(PropertyChangeListener listener)
          Removes an existing PropertyChangeListener
 void setComparator(Class<?> c, Comparator<?> cmp)
          Sets a specific comparator for a given class, that should override the default Compare algorithm for the given class.
 void setDefaultOperator(String s)
          Defines the default operator when the user specifies none
 void setFormat(Class<?> c, Format format)
          Provides the Format to build non basic types.
 void setIgnoreCase(boolean ignore)
          Ignores case -if the operator is string based-
 void setTableModel(TableModel model)
          Associates a TableModel to the parser.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FilterTextParser

public FilterTextParser()
Method Detail

addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener listener)
Description copied from interface: IFilterTextParser
Adds a PropertyChangeListener. Any property change will be transmitted as an event

Specified by:
addPropertyChangeListener in interface IFilterTextParser

removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener listener)
Description copied from interface: IFilterTextParser
Removes an existing PropertyChangeListener

Specified by:
removePropertyChangeListener in interface IFilterTextParser

setTableModel

public void setTableModel(TableModel model)
Description copied from interface: IFilterTextParser
Associates a TableModel to the parser. The parser can use it to extract the type associated to a given column, or to define variables -the name of the column-. The usage is specific to the final implementation.

Specified by:
setTableModel in interface IFilterTextParser

getDefaultOperator

public String getDefaultOperator()
Description copied from interface: IFilterTextParser
Returns the default operand

Specified by:
getDefaultOperator in interface IFilterTextParser

setDefaultOperator

public void setDefaultOperator(String s)
Description copied from interface: IFilterTextParser
Defines the default operator when the user specifies none

Specified by:
setDefaultOperator in interface IFilterTextParser

getFormat

public Format getFormat(Class<?> c)
Description copied from interface: IFilterTextParser
Returns the Format for a given class

Specified by:
getFormat in interface IFilterTextParser

setFormat

public void setFormat(Class<?> c,
                      Format format)
Description copied from interface: IFilterTextParser
Provides the Format to build non basic types. If a table model defines some column without specified format, only string operations will apply.
Please note that every IFilterTextParser can define its own set of predefined Formats

Specified by:
setFormat in interface IFilterTextParser

setComparator

public void setComparator(Class<?> c,
                          Comparator<?> cmp)
Description copied from interface: IFilterTextParser

Sets a specific comparator for a given class, that should override the default Compare algorithm for the given class.

If the class is not Comparable, this method should be invoked to support any comparison operator, or any operation will be invoked on the string representation of the instance.

Specified by:
setComparator in interface IFilterTextParser

getComparator

public Comparator<?> getComparator(Class<?> c)
Description copied from interface: IFilterTextParser
Returns the comparator provided for the given class

Specified by:
getComparator in interface IFilterTextParser

setIgnoreCase

public void setIgnoreCase(boolean ignore)
Description copied from interface: IFilterTextParser
Ignores case -if the operator is string based-

Specified by:
setIgnoreCase in interface IFilterTextParser

isIgnoreCase

public boolean isIgnoreCase()
Description copied from interface: IFilterTextParser
Returns true if it ignores case

Specified by:
isIgnoreCase in interface IFilterTextParser

parseText

public RowFilter parseText(String expression,
                           int modelPosition)
                    throws ParseException
Description copied from interface: IFilterTextParser
Parses the text, corresponding to a column in the table model
It returns a filter that can be applied to the table sorter.

Specified by:
parseText in interface IFilterTextParser
Parameters:
expression - the text to parse
modelPosition - the position on the table model.
Throws:
ParseException