net.coderazzi.filters.gui
Class ParserModel

java.lang.Object
  extended by net.coderazzi.filters.gui.ParserModel
All Implemented Interfaces:
IParserModel

public class ParserModel
extends Object
implements IParserModel

Default ParserModel.StringTypeFormat instances, supporting all the basic java types
It also includes support for Comparator of Date instances.
The default IParser is automatically configured to use these ParserModel.StringTypeFormat instances, when created by the TableFilterHeader.
Users can add any ParserModel.StringTypeFormat or Comparator definitions, as the class is used as a singleton.

Author:
Luis M Pena - lu@coderazzi.net

Nested Class Summary
static class ParserModel.BooleanTypeFormat
          Factory to build boolean objects.
static class ParserModel.ByteTypeFormat
          Factory to build byte objects.
static class ParserModel.CharacterTypeFormat
          Factory to build character objects.
static class ParserModel.DoubleTypeFormat
          Factory to build double objects.
static class ParserModel.EnumTypeFormat
          Factory to build character objects.
static class ParserModel.FloatTypeFormat
          Factory to build float objects.
static class ParserModel.IntegerTypeFormat
          Factory to build integer objects.
static class ParserModel.LongTypeFormat
          Factory to build long objects.
static class ParserModel.ShortTypeFormat
          Factory to build short objects.
static class ParserModel.StringTypeFormat
          Factory to build string objects.
 
Field Summary
 
Fields inherited from interface net.coderazzi.filters.gui.IParserModel
COMPARATOR_PROPERTY, FORMAT_PROPERTY, IGNORE_CASE_PROPERTY
 
Constructor Summary
ParserModel()
           
 
Method Summary
 void addPropertyChangeListener(PropertyChangeListener listener)
          Adds a PropertyChangeListener.
Any property change will be transmitted as an event
 IParser createParser(IFilterEditor editor)
          Creates a text parser for the given editor.
 Comparator getComparator(Class cl)
          Returns the Comparator for the given class.
 Format getFormat(Class cl)
          Returns the ParserModel.StringTypeFormat for the given class.
 Comparator<String> getStringComparator(boolean noCase)
          Returns the Comparator used for String comparisons.
 boolean isIgnoreCase()
          Returns true if the String comparator ignores case
Note that this is redundant information, which can be retrieved from the IParserModel.getComparator(Class) method with a String.class parameter.
 void removePropertyChangeListener(PropertyChangeListener listener)
          Removes an existing PropertyChangeListener.
 void setComparator(Class cl, Comparator cmp)
          Defines the Comparator for the given class.
 void setFormat(Class cl, Format fmt)
          Defines the ParserModel.StringTypeFormat for the given class.
 void setIgnoreCase(boolean set)
          Sets a String comparator that is case sensitive/insensitive.
static Comparator<String> stringComparator(boolean ignoreCase)
          Returns a default singleton comparator for the given case flag.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ParserModel

public ParserModel()
Method Detail

addPropertyChangeListener

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

Specified by:
addPropertyChangeListener in interface IParserModel

removePropertyChangeListener

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

Specified by:
removePropertyChangeListener in interface IParserModel

createParser

public IParser createParser(IFilterEditor editor)
Description copied from interface: IParserModel
Creates a text parser for the given editor.

Specified by:
createParser in interface IParserModel

isIgnoreCase

public boolean isIgnoreCase()
Description copied from interface: IParserModel
Returns true if the String comparator ignores case
Note that this is redundant information, which can be retrieved from the IParserModel.getComparator(Class) method with a String.class parameter.

Specified by:
isIgnoreCase in interface IParserModel

setIgnoreCase

public void setIgnoreCase(boolean set)
Description copied from interface: IParserModel
Sets a String comparator that is case sensitive/insensitive.

Specified by:
setIgnoreCase in interface IParserModel

getFormat

public final Format getFormat(Class cl)
Returns the ParserModel.StringTypeFormat for the given class.

Specified by:
getFormat in interface IParserModel

setFormat

public final void setFormat(Class cl,
                            Format fmt)
Defines the ParserModel.StringTypeFormat for the given class.

Specified by:
setFormat in interface IParserModel

getComparator

public Comparator getComparator(Class cl)
Returns the Comparator for the given class.

Specified by:
getComparator in interface IParserModel

setComparator

public void setComparator(Class cl,
                          Comparator cmp)
Defines the Comparator for the given class.

Specified by:
setComparator in interface IParserModel

getStringComparator

public Comparator<String> getStringComparator(boolean noCase)
Description copied from interface: IParserModel
Returns the Comparator used for String comparisons.

Specified by:
getStringComparator in interface IParserModel

stringComparator

public static Comparator<String> stringComparator(boolean ignoreCase)
Returns a default singleton comparator for the given case flag.