org.jminor.common.model
Class DefaultColumnSearchModel<K>

java.lang.Object
  extended by org.jminor.common.model.DefaultColumnSearchModel<K>
Type Parameters:
K - the type of the column identifier
All Implemented Interfaces:
ColumnSearchModel<K>
Direct Known Subclasses:
DefaultForeignKeySearchModel, DefaultPropertyFilterModel, DefaultPropertySearchModel

public class DefaultColumnSearchModel<K>
extends Object
implements ColumnSearchModel<K>

A default ColumnSearchModel model implementation.


Field Summary
 
Fields inherited from interface org.jminor.common.model.ColumnSearchModel
LOWER_BOUND_PROPERTY, UPPER_BOUND_PROPERTY
 
Constructor Summary
DefaultColumnSearchModel(K columnIdentifier, int type, String wildcard)
          Instantiates a DefaultColumnSearchModel.
DefaultColumnSearchModel(K columnIdentifier, int type, String wildcard, Format format)
          Instantiates a DefaultColumnSearchModel.
 
Method Summary
 void addClearedListener(ActionListener listener)
          
 void addEnabledListener(ActionListener listener)
          
 void addLowerBoundListener(ActionListener listener)
          
 void addSearchStateListener(ActionListener listener)
          
 void addSearchTypeListener(ActionListener listener)
          
 void addUpperBoundListener(ActionListener listener)
          
 void clearSearch()
          Clears the criteria values from this search model
 K getColumnIdentifier()
          
protected  Comparable getComparable(Object object)
           
 EventObserver getEnabledObserver()
          
 Format getFormat()
          
 StateObserver getLockedState()
          
 Object getLowerBound()
          
 EventObserver getLowerBoundObserver()
          
 SearchType getSearchType()
          
 EventObserver getSearchTypeObserver()
          
 int getType()
          
 Object getUpperBound()
          
 EventObserver getUpperBoundObserver()
          
static int getValueCount(SearchType searchType)
           
 String getWildcard()
           
 boolean include(Comparable comparable)
          
 boolean include(Object object)
          
 boolean isAutoEnable()
          
 boolean isAutomaticWildcard()
          
 boolean isCaseSensitive()
          
 boolean isEnabled()
          
 boolean isLocked()
          
 void removeClearedListener(ActionListener listener)
          
 void removeEnabledListener(ActionListener listener)
          
 void removeLowerBoundListener(ActionListener listener)
          
 void removeSearchStateListener(ActionListener listener)
          
 void removeSearchTypeListener(ActionListener listener)
          
 void removeUpperBoundListener(ActionListener listener)
          
 void setAutoEnable(boolean autoEnable)
          If set, this model automatically enables itself when a criteria is specified
 void setAutomaticWildcard(boolean value)
          
 void setCaseSensitive(boolean caseSensitive)
          
 void setEnabled(boolean value)
          
 void setLikeValue(Comparable value)
          A shortcut method for setting the upper bound value, searchType to LIKE and enabling this model.
 void setLocked(boolean value)
          
 void setLowerBound(boolean value)
          
 void setLowerBound(Boolean value)
          
 void setLowerBound(char value)
          
 void setLowerBound(Date value)
          
 void setLowerBound(Double value)
          
 void setLowerBound(Integer value)
          
 void setLowerBound(Object value)
          
 void setLowerBound(String value)
          
 void setLowerBound(Timestamp value)
          
 void setSearchType(SearchType searchType)
          
 void setUpperBound(boolean value)
          
 void setUpperBound(Boolean value)
          
 void setUpperBound(char value)
          
 void setUpperBound(Date value)
          
 void setUpperBound(Double value)
          
 void setUpperBound(Integer value)
          
 void setUpperBound(Object upper)
          
 void setUpperBound(String value)
          
 void setUpperBound(Timestamp value)
          
 void setWildcard(String wildcard)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultColumnSearchModel

public DefaultColumnSearchModel(K columnIdentifier,
                                int type,
                                String wildcard)
Instantiates a DefaultColumnSearchModel.

Parameters:
columnIdentifier - the column identifier
type - the column data type
wildcard - the string to use as wildcard

DefaultColumnSearchModel

public DefaultColumnSearchModel(K columnIdentifier,
                                int type,
                                String wildcard,
                                Format format)
Instantiates a DefaultColumnSearchModel.

Parameters:
columnIdentifier - the column identifier
type - the column data type
wildcard - the string to use as wildcard
format - the format to use when presenting the values, dates for example
Method Detail

getColumnIdentifier

public final K getColumnIdentifier()

Specified by:
getColumnIdentifier in interface ColumnSearchModel<K>
Returns:
the column identifier

isCaseSensitive

public final boolean isCaseSensitive()

Specified by:
isCaseSensitive in interface ColumnSearchModel<K>
Returns:
true if this filter is be case sensitive

setCaseSensitive

public final void setCaseSensitive(boolean caseSensitive)

Specified by:
setCaseSensitive in interface ColumnSearchModel<K>
Parameters:
caseSensitive - true if this search model should be case sensitive when working with strings

getFormat

public final Format getFormat()

Specified by:
getFormat in interface ColumnSearchModel<K>
Returns:
the Format object to use when formatting input, is any

setLocked

public final void setLocked(boolean value)

Specified by:
setLocked in interface ColumnSearchModel<K>
Parameters:
value - true to lock this model, false to unlock

isLocked

public final boolean isLocked()

Specified by:
isLocked in interface ColumnSearchModel<K>
Returns:
true if this model is locked

getType

public final int getType()

Specified by:
getType in interface ColumnSearchModel<K>
Returns:
the data type this search model is based on
See Also:
Types

setLikeValue

public final void setLikeValue(Comparable value)
A shortcut method for setting the upper bound value, searchType to LIKE and enabling this model.

Specified by:
setLikeValue in interface ColumnSearchModel<K>
Parameters:
value - the value to use as criteria

setUpperBound

public final void setUpperBound(Object upper)

Specified by:
setUpperBound in interface ColumnSearchModel<K>
Parameters:
upper - the new upper bound

getUpperBound

public final Object getUpperBound()

Specified by:
getUpperBound in interface ColumnSearchModel<K>
Returns:
the upper bound

setLowerBound

public final void setLowerBound(Object value)

Specified by:
setLowerBound in interface ColumnSearchModel<K>
Parameters:
value - the lower bound

getLowerBound

public final Object getLowerBound()

Specified by:
getLowerBound in interface ColumnSearchModel<K>
Returns:
the lower bound

setUpperBound

public final void setUpperBound(String value)

Specified by:
setUpperBound in interface ColumnSearchModel<K>
Parameters:
value - the upper bound

setUpperBound

public final void setUpperBound(Double value)

Specified by:
setUpperBound in interface ColumnSearchModel<K>
Parameters:
value - the upper bound

setUpperBound

public final void setUpperBound(Integer value)

Specified by:
setUpperBound in interface ColumnSearchModel<K>
Parameters:
value - the upper bound

setUpperBound

public final void setUpperBound(boolean value)

Specified by:
setUpperBound in interface ColumnSearchModel<K>
Parameters:
value - the upper bound

setUpperBound

public final void setUpperBound(char value)

Specified by:
setUpperBound in interface ColumnSearchModel<K>
Parameters:
value - the upper bound

setUpperBound

public final void setUpperBound(Boolean value)

Specified by:
setUpperBound in interface ColumnSearchModel<K>
Parameters:
value - the upper bound

setUpperBound

public final void setUpperBound(Timestamp value)

Specified by:
setUpperBound in interface ColumnSearchModel<K>
Parameters:
value - the upper bound

setUpperBound

public final void setUpperBound(Date value)

Specified by:
setUpperBound in interface ColumnSearchModel<K>
Parameters:
value - the upper bound

setLowerBound

public final void setLowerBound(String value)

Specified by:
setLowerBound in interface ColumnSearchModel<K>
Parameters:
value - the Lower bound

setLowerBound

public final void setLowerBound(Double value)

Specified by:
setLowerBound in interface ColumnSearchModel<K>
Parameters:
value - the Lower bound

setLowerBound

public final void setLowerBound(Integer value)

Specified by:
setLowerBound in interface ColumnSearchModel<K>
Parameters:
value - the Lower bound

setLowerBound

public final void setLowerBound(boolean value)

Specified by:
setLowerBound in interface ColumnSearchModel<K>
Parameters:
value - the Lower bound

setLowerBound

public final void setLowerBound(char value)

Specified by:
setLowerBound in interface ColumnSearchModel<K>
Parameters:
value - the Lower bound

setLowerBound

public final void setLowerBound(Boolean value)

Specified by:
setLowerBound in interface ColumnSearchModel<K>
Parameters:
value - the Lower bound

setLowerBound

public final void setLowerBound(Timestamp value)

Specified by:
setLowerBound in interface ColumnSearchModel<K>
Parameters:
value - the Lower bound

setLowerBound

public final void setLowerBound(Date value)

Specified by:
setLowerBound in interface ColumnSearchModel<K>
Parameters:
value - the Lower bound

getSearchType

public final SearchType getSearchType()

Specified by:
getSearchType in interface ColumnSearchModel<K>
Returns:
the search type

setSearchType

public final void setSearchType(SearchType searchType)

Specified by:
setSearchType in interface ColumnSearchModel<K>
Parameters:
searchType - the search type

getWildcard

public final String getWildcard()
Returns:
the search wildcard

setWildcard

public final void setWildcard(String wildcard)
Parameters:
wildcard - the search wildcard

isAutoEnable

public final boolean isAutoEnable()

Specified by:
isAutoEnable in interface ColumnSearchModel<K>
Returns:
true if auto enable is enabled

setAutoEnable

public final void setAutoEnable(boolean autoEnable)
If set, this model automatically enables itself when a criteria is specified

Specified by:
setAutoEnable in interface ColumnSearchModel<K>
Parameters:
autoEnable - true to enable, false to disable

isEnabled

public final boolean isEnabled()

Specified by:
isEnabled in interface ColumnSearchModel<K>
Returns:
true if this search model is enabled

setEnabled

public final void setEnabled(boolean value)

Specified by:
setEnabled in interface ColumnSearchModel<K>
Parameters:
value - true to enable, false to disable

setAutomaticWildcard

public final void setAutomaticWildcard(boolean value)

Specified by:
setAutomaticWildcard in interface ColumnSearchModel<K>
Parameters:
value - true if wildcard should automatically be added to strings

isAutomaticWildcard

public final boolean isAutomaticWildcard()

Specified by:
isAutomaticWildcard in interface ColumnSearchModel<K>
Returns:
true if wildcard is automatically be added to strings

clearSearch

public final void clearSearch()
Clears the criteria values from this search model

Specified by:
clearSearch in interface ColumnSearchModel<K>

getLockedState

public final StateObserver getLockedState()

Specified by:
getLockedState in interface ColumnSearchModel<K>
Returns:
an observer for this model's locked state

getEnabledObserver

public final EventObserver getEnabledObserver()

Specified by:
getEnabledObserver in interface ColumnSearchModel<K>
Returns:
an observer for this model's enabled state

getLowerBoundObserver

public final EventObserver getLowerBoundObserver()

Specified by:
getLowerBoundObserver in interface ColumnSearchModel<K>
Returns:
an observer for this model's lower bound

getUpperBoundObserver

public final EventObserver getUpperBoundObserver()

Specified by:
getUpperBoundObserver in interface ColumnSearchModel<K>
Returns:
an observer for this model's upper bound

addEnabledListener

public final void addEnabledListener(ActionListener listener)

Specified by:
addEnabledListener in interface ColumnSearchModel<K>
Parameters:
listener - a listener to be notified each time the enabled state changes

removeEnabledListener

public final void removeEnabledListener(ActionListener listener)

Specified by:
removeEnabledListener in interface ColumnSearchModel<K>
Parameters:
listener - the listener to remove

addUpperBoundListener

public final void addUpperBoundListener(ActionListener listener)

Specified by:
addUpperBoundListener in interface ColumnSearchModel<K>
Parameters:
listener - a listener to be notified each time the upper bound changes

removeUpperBoundListener

public final void removeUpperBoundListener(ActionListener listener)

Specified by:
removeUpperBoundListener in interface ColumnSearchModel<K>
Parameters:
listener - the listener to remove

addLowerBoundListener

public final void addLowerBoundListener(ActionListener listener)

Specified by:
addLowerBoundListener in interface ColumnSearchModel<K>
Parameters:
listener - a listener to be notified each time the lower bound changes

removeLowerBoundListener

public final void removeLowerBoundListener(ActionListener listener)

Specified by:
removeLowerBoundListener in interface ColumnSearchModel<K>
Parameters:
listener - the listener to remove

addClearedListener

public final void addClearedListener(ActionListener listener)

Specified by:
addClearedListener in interface ColumnSearchModel<K>
Parameters:
listener - a listener to be notified each time the model is cleared

removeClearedListener

public final void removeClearedListener(ActionListener listener)

Specified by:
removeClearedListener in interface ColumnSearchModel<K>
Parameters:
listener - the listener to remove

addSearchStateListener

public final void addSearchStateListener(ActionListener listener)

Specified by:
addSearchStateListener in interface ColumnSearchModel<K>
Parameters:
listener - a listener to be notified each time the search state changes

removeSearchStateListener

public final void removeSearchStateListener(ActionListener listener)

Specified by:
removeSearchStateListener in interface ColumnSearchModel<K>
Parameters:
listener - the listener to remove

addSearchTypeListener

public final void addSearchTypeListener(ActionListener listener)

Specified by:
addSearchTypeListener in interface ColumnSearchModel<K>
Parameters:
listener - a listener to be notified each time the search type changes

removeSearchTypeListener

public final void removeSearchTypeListener(ActionListener listener)

Specified by:
removeSearchTypeListener in interface ColumnSearchModel<K>
Parameters:
listener - the listener to remove

getSearchTypeObserver

public final EventObserver getSearchTypeObserver()

Specified by:
getSearchTypeObserver in interface ColumnSearchModel<K>
Returns:
an observer for this model's search type

include

public final boolean include(Object object)

Specified by:
include in interface ColumnSearchModel<K>
Parameters:
object - the object
Returns:
true if the object should be included

include

public final boolean include(Comparable comparable)

Specified by:
include in interface ColumnSearchModel<K>
Parameters:
comparable - the value to check
Returns:
true if the given value should be included

getValueCount

public static int getValueCount(SearchType searchType)
Parameters:
searchType - the search type
Returns:
the number of input values required for the given search type

getComparable

protected Comparable getComparable(Object object)
Parameters:
object - the object
Returns:
a Comparable representing the given object