com.sas.dataselectors.filters
Class AbstractFilterableListModel

com.sas.dataselectors.filters.AbstractFilterableListModel
All Implemented Interfaces:
FilterableListModelInterface
Direct Known Subclasses:
BusinessModelToFilterableListModelAdapter, BusinessQueryToFilterableListModelAdapter

public abstract class AbstractFilterableListModel
implements FilterableListModelInterface

This class takes a model as input, decides what filterable items it contains, and constructs a list of FilterableItemInterface instances that define those filterable items and their individual filter models.


Field Summary
protected  java.lang.Object _dataSource
          The data source for the model.
protected  java.util.List _filterableItems
          The list of filterable items in the model.
protected  java.lang.Object _initialFilter
          An initial filter object in the native filter to focus the model on.
protected  boolean _initialized
          A flag to indicate whether the model has been initialized or not.
protected  java.util.Locale _locale
          The locale the model should use when generating UI elements.
protected  int environment
          The operating environment (e.g.
 
Constructor Summary
AbstractFilterableListModel()
          Construct a new AbstractFilterableListModel.
AbstractFilterableListModel(java.lang.Object dataSource)
          Constructs a new model from the given source.
AbstractFilterableListModel(java.lang.Object dataSource, int environment)
          Constructs a new model from the given source and initial filter.
AbstractFilterableListModel(java.lang.Object dataSource, java.lang.Object initialFilter)
          Constructs a new model from the given source and initial filter.
 
Method Summary
 void cancel()
          Cancels any changes to the filter model.
 void clearAll()
          Removes the filters from all filterable items.
 void clearFilter(int index)
          Removes the filter from the filterable item at the specified index.
 boolean commitChanges()
          Commits any changes made in the filter model to the native model.
protected abstract  FilterableItemInterface createFilterableItem(java.lang.Object filterable)
          Creates an instance of FilterableItemInterface for the given object from the native filter model.
protected  void createFilterableItemList()
          Creates the list of filterable items based on the underlying native model.
 int getEnvironment()
          Gets the current operating environment.
 FilterableItemInterface getFilterableItem(java.lang.Object filterable)
          Creates and returns the filterable item object for the given object from the native filter model.
 java.util.List getFilterableItems()
          Returns the list of filterable items from the source model.
protected abstract  java.util.List getFilterableObjects()
          Returns the list of native filter model objects that should be used for filterable items in the filter model.
 java.lang.Object getInitialFilter()
          Returns the initial filter for the model.
 java.util.Locale getLocale()
          Returns the Locale currently assigned to the model.
 java.lang.Object getModel()
          Returns the source native model for this adapter.
 void setEnvironment(int environment)
          Sets the operating environment to the specified value.
 void setInitialFilter(java.lang.Object initialFilter)
          Sets the initial filter for the model.
 void setLocale(java.util.Locale locale)
          Sets the locale assigned to this model and all the filterable items.
 void setModel(java.lang.Object model)
          Sets the source native model for this adapter.
 

Field Detail

_locale

protected java.util.Locale _locale
The locale the model should use when generating UI elements.


_dataSource

protected java.lang.Object _dataSource
The data source for the model. This should be either a BusinessModel or a BusinessQuery object.


_initialFilter

protected java.lang.Object _initialFilter
An initial filter object in the native filter to focus the model on. If omitted, all filterable items from the data source will be examined.


_initialized

protected boolean _initialized
A flag to indicate whether the model has been initialized or not. The model is considered initialized when the list of filterable items has been constructed.


_filterableItems

protected java.util.List _filterableItems
The list of filterable items in the model.


environment

protected int environment
The operating environment (e.g. Swing/JSP)

Constructor Detail

AbstractFilterableListModel

public AbstractFilterableListModel()
Construct a new AbstractFilterableListModel. Because the class is abstract, it cannot be instantiated directly.


AbstractFilterableListModel

public AbstractFilterableListModel(java.lang.Object dataSource)
Constructs a new model from the given source.

Parameters:
dataSource - the source model

AbstractFilterableListModel

public AbstractFilterableListModel(java.lang.Object dataSource,
                                   java.lang.Object initialFilter)
Constructs a new model from the given source and initial filter.

Parameters:
dataSource - the source model
initialFilter - the initial filter object from the native model

AbstractFilterableListModel

public AbstractFilterableListModel(java.lang.Object dataSource,
                                   int environment)
Constructs a new model from the given source and initial filter.

Parameters:
dataSource - the source model
initialFilter - the initial filter object from the native model
environment - the current operating environment
Method Detail

setInitialFilter

public void setInitialFilter(java.lang.Object initialFilter)
Sets the initial filter for the model.

Parameters:
initialFilter - the initial filter object from the native model

getInitialFilter

public java.lang.Object getInitialFilter()
Returns the initial filter for the model.

Specified by:
getInitialFilter in interface FilterableListModelInterface
Returns:
the initial filter object from the native model

getModel

public java.lang.Object getModel()
Returns the source native model for this adapter.

Specified by:
getModel in interface FilterableListModelInterface
Returns:
the source native model

setModel

public void setModel(java.lang.Object model)
Sets the source native model for this adapter.

Parameters:
model - the source native model

getFilterableItems

public java.util.List getFilterableItems()
Returns the list of filterable items from the source model.

Specified by:
getFilterableItems in interface FilterableListModelInterface
Returns:
the list of filterable items

getFilterableItem

public FilterableItemInterface getFilterableItem(java.lang.Object filterable)
Creates and returns the filterable item object for the given object from the native filter model.

Specified by:
getFilterableItem in interface FilterableListModelInterface
Parameters:
filterable - the object to process from the native filter model
Returns:
the filterable item based on the given native filter object

createFilterableItemList

protected void createFilterableItemList()
Creates the list of filterable items based on the underlying native model.


getFilterableObjects

protected abstract java.util.List getFilterableObjects()
Returns the list of native filter model objects that should be used for filterable items in the filter model.

Returns:
the list of native filter model objects to process

createFilterableItem

protected abstract FilterableItemInterface createFilterableItem(java.lang.Object filterable)
Creates an instance of FilterableItemInterface for the given object from the native filter model.

Parameters:
filterable - the native model object to process
Returns:
the FilterableItemInterface instance representing the given object

commitChanges

public boolean commitChanges()
Commits any changes made in the filter model to the native model. If the commit succeeds, TRUE is returned, FALSE otherwise.

Specified by:
commitChanges in interface FilterableListModelInterface
Returns:
TRUE if everything succeeds, FALSE otherwise

cancel

public void cancel()
Cancels any changes to the filter model.

Specified by:
cancel in interface FilterableListModelInterface

clearAll

public void clearAll()
Removes the filters from all filterable items.

Specified by:
clearAll in interface FilterableListModelInterface

clearFilter

public void clearFilter(int index)
Removes the filter from the filterable item at the specified index.

Specified by:
clearFilter in interface FilterableListModelInterface
Parameters:
index - the index in the list of filterable items of the filter to clear

getLocale

public java.util.Locale getLocale()
Returns the Locale currently assigned to the model.

Specified by:
getLocale in interface FilterableListModelInterface
Returns:
the model's current locale

setLocale

public void setLocale(java.util.Locale locale)
Sets the locale assigned to this model and all the filterable items.

Specified by:
setLocale in interface FilterableListModelInterface
Parameters:
locale - the locale to assign to all filterable items in this model

setEnvironment

public void setEnvironment(int environment)
Sets the operating environment to the specified value.

Parameters:
environment - The environment to set. Valid values are defined in com.sas.util.OperatingEnvironmentInterface.

getEnvironment

public int getEnvironment()
Gets the current operating environment.

Returns:
The operating environment. Valid values are defined in com.sas.util.OperatingEnvironmentInterface.



Copyright © 2009 SAS Institute Inc. All Rights Reserved.