com.jgoodies.bookfinder.domain
Class BookFilter

java.lang.Object
  extended by com.jgoodies.binding.beans.Model
      extended by com.jgoodies.bookfinder.domain.BookFilter
All Implemented Interfaces:
com.jgoodies.binding.beans.Observable, Serializable

public final class BookFilter
extends com.jgoodies.binding.beans.Model

Used to filter books in a list of books as done in the SearchResultModel. The filtering is performed by the #accept(Book) and #filter(Collection) methods.

The FilterDialog presents and edits this class' properties.

Version:
$Revision: 1.5 $
Author:
Karsten Lentzsch
See Also:
SearchResultModel, FilterDialog, Serialized Form

Field Summary
 int limit
           
 boolean limitEnabled
           
 int price
           
 boolean priceEnabled
           
static String PROPERTYNAME_LIMIT
           
static String PROPERTYNAME_LIMIT_ENABLED
           
static String PROPERTYNAME_PRICE
           
static String PROPERTYNAME_PRICE_ENABLED
           
static String PROPERTYNAME_YEAR
           
static String PROPERTYNAME_YEAR_ENABLED
           
 int year
           
 boolean yearEnabled
           
 
Constructor Summary
BookFilter()
           
 
Method Summary
 boolean accept(Book details)
          Tests and answers if the specified details should be displayed in the overview.
 List filter(Collection allElements)
          Filters the given elements and returns a list of elements that are accepted by this filter.
 int getLimit()
          Returns this filter's limit.
 int getPrice()
          Returns this filter's price limit.
 int getYear()
          Returns this filter's year limit.
 boolean isLimitEnabled()
          Returns whether this filter takes the limit into account.
 boolean isPriceEnabled()
          Returns whether the price filter is enabled.
 boolean isYearEnabled()
          Returns whether the year filter is enabled.
 void restoreFrom(Preferences prefs)
          Restores the persistent data from the specified Preferences.
 void setLimit(int limit)
          Sets a new limit.
 void setLimitEnabled(boolean limitEnabled)
          Enables or disables the limit filter.
 void setPrice(int price)
          Sets a new price limit.
 void setPriceEnabled(boolean priceEnabled)
          Enables or disables the price limit filter.
 void setYear(int year)
          Sets a new year limit.
 void setYearEnabled(boolean yearEnabled)
          Enables or disables the year filter.
 void storeIn(Preferences prefs)
          Stores the persistent data in the specified Preferences.
 
Methods inherited from class com.jgoodies.binding.beans.Model
addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, addVetoableChangeListener, equals, fireIndexedPropertyChange, fireIndexedPropertyChange, fireIndexedPropertyChange, fireMultiplePropertiesChanged, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, getPropertyChangeListeners, getPropertyChangeListeners, getVetoableChangeListeners, getVetoableChangeListeners, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, removeVetoableChangeListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROPERTYNAME_LIMIT

public static final String PROPERTYNAME_LIMIT
See Also:
Constant Field Values

PROPERTYNAME_LIMIT_ENABLED

public static final String PROPERTYNAME_LIMIT_ENABLED
See Also:
Constant Field Values

PROPERTYNAME_PRICE

public static final String PROPERTYNAME_PRICE
See Also:
Constant Field Values

PROPERTYNAME_PRICE_ENABLED

public static final String PROPERTYNAME_PRICE_ENABLED
See Also:
Constant Field Values

PROPERTYNAME_YEAR

public static final String PROPERTYNAME_YEAR
See Also:
Constant Field Values

PROPERTYNAME_YEAR_ENABLED

public static final String PROPERTYNAME_YEAR_ENABLED
See Also:
Constant Field Values

limitEnabled

public boolean limitEnabled

priceEnabled

public boolean priceEnabled

yearEnabled

public boolean yearEnabled

limit

public int limit

price

public int price

year

public int year
Constructor Detail

BookFilter

public BookFilter()
Method Detail

accept

public boolean accept(Book details)
Tests and answers if the specified details should be displayed in the overview.

Parameters:
details - the details to check
Returns:
true if accepted, false if rejected

filter

public List filter(Collection allElements)
Filters the given elements and returns a list of elements that are accepted by this filter. The size of the filtered list is bound by this filter's limit.

Parameters:
allElements - the element list to be filtered
Returns:
a list of accepted elements

getLimit

public int getLimit()
Returns this filter's limit.

Returns:
the limit

setLimit

public void setLimit(int limit)
Sets a new limit.

Parameters:
limit - The limit to set.

isLimitEnabled

public boolean isLimitEnabled()
Returns whether this filter takes the limit into account.

Returns:
true if the limit is used to filter, false otherwise

setLimitEnabled

public void setLimitEnabled(boolean limitEnabled)
Enables or disables the limit filter.

Parameters:
limitEnabled - true to enable the limit filter

getPrice

public int getPrice()
Returns this filter's price limit.

Returns:
the price limit used to filter elements

setPrice

public void setPrice(int price)
Sets a new price limit.

Parameters:
price - The price limit to set.

isPriceEnabled

public boolean isPriceEnabled()
Returns whether the price filter is enabled.

Returns:
true if prices are used to filter

setPriceEnabled

public void setPriceEnabled(boolean priceEnabled)
Enables or disables the price limit filter.

Parameters:
priceEnabled - true to filter prices

getYear

public int getYear()
Returns this filter's year limit.

Returns:
this filter's year limit

setYear

public void setYear(int year)
Sets a new year limit.

Parameters:
year - The year limit to set.

isYearEnabled

public boolean isYearEnabled()
Returns whether the year filter is enabled.

Returns:
true if elements are filted by the year

setYearEnabled

public void setYearEnabled(boolean yearEnabled)
Enables or disables the year filter.

Parameters:
yearEnabled - true to enable the year filter

restoreFrom

public void restoreFrom(Preferences prefs)
Restores the persistent data from the specified Preferences.


storeIn

public void storeIn(Preferences prefs)
Stores the persistent data in the specified Preferences.



Copyright © 2002-2008 JGoodies Karsten Lentzsch. All Rights Reserved.