org.chwf.filter
Class PropertyFilter

java.lang.Object
  |
  +--org.chwf.filter.PropertyFilter

public abstract class PropertyFilter
extends java.lang.Object

An abstract superclass of property filters.

Author:
Paul Strack

Constructor Summary
PropertyFilter(java.lang.Class beanClass, java.lang.String name, java.lang.Class type)
          Constructor.
 
Method Summary
 java.util.Iterator attributeNames()
          Get all attribute names.
abstract  java.lang.String get(java.lang.Object object)
          Get the specified property of the target object, as a string.
 java.lang.Object getAttribute(java.lang.String name)
          Get the named attribute value.
 java.lang.Class getBeanClass()
          The bean class for the filter.
 java.lang.String getLocalizedAttribute(java.lang.String name, java.util.Locale locale)
          Get the localized value of the named attribute.
 java.lang.String getName()
          Get the property name.
abstract  java.lang.Object getPropertyAsObject(java.lang.Object object)
          Get the specified property of the target object, as an object.
 java.lang.Class getType()
          Get the property's Java type.
protected  Validator getValidator()
          Return the validator for this class, or null if the filter should not perform external validation.
 boolean isReadable()
          Whether the property is readable.
 boolean isWriteable()
          Whether the property is writeable.
abstract  void set(java.lang.Object object, java.lang.String value)
          Set the specified property of the target object, using a string.
protected  void setAttribute(java.lang.String name, java.lang.Object value)
          Set the named attribute.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PropertyFilter

public PropertyFilter(java.lang.Class beanClass,
                      java.lang.String name,
                      java.lang.Class type)
               throws InitializationException
Constructor.

Parameters:
beanClass - The bean class.
name - The property name.
type - The property type.
Throws:
InitializationException - If filter initialization fails.
Method Detail

getBeanClass

public java.lang.Class getBeanClass()
The bean class for the filter.

Returns:
The bean class for the filter.

get

public abstract java.lang.String get(java.lang.Object object)
                              throws FilterException
Get the specified property of the target object, as a string.

Parameters:
object - The object whose property is being retrieved.
Returns:
The property value.
Throws:
FilterException - For read failure.

getPropertyAsObject

public abstract java.lang.Object getPropertyAsObject(java.lang.Object object)
                                              throws FilterException
Get the specified property of the target object, as an object.

Parameters:
object - The object whose property is being retrieved.
Returns:
The property value.
Throws:
FilterException - For read failure.

set

public abstract void set(java.lang.Object object,
                         java.lang.String value)
                  throws ConversionException,
                         FilterException
Set the specified property of the target object, using a string.

Parameters:
object - The object whose property is being updated.
value - The new property value.
Throws:
ConversionException - If the value cannot be converted to the correct type.
FilterException - For write failure.

getName

public java.lang.String getName()
Get the property name.

Returns:
The property name.

getType

public java.lang.Class getType()
Get the property's Java type.

Returns:
The property's Java type.

getAttribute

public java.lang.Object getAttribute(java.lang.String name)
Get the named attribute value.

Parameters:
name - The attribute name.
Returns:
The attribute value.

getLocalizedAttribute

public java.lang.String getLocalizedAttribute(java.lang.String name,
                                              java.util.Locale locale)
Get the localized value of the named attribute.

Parameters:
name - The attribute name.
locale - The locale.
Returns:
The attribute value.

attributeNames

public java.util.Iterator attributeNames()
Get all attribute names.

Returns:
An iterator for all the attribute names.

isReadable

public boolean isReadable()
Whether the property is readable. For dynamically generated property filters, this value is determined by whether the property has a getter method. For custom filters that extend this class, this value defaults to true. Custom filters must override this method if they are not readable

Returns:
true if readable.

isWriteable

public boolean isWriteable()
Whether the property is writeable. For dynamically generated property filters, this value is determined by whether the property has a setter method and a converter from the org.chwf.converter package. For custom filters that extend this class, this value defaults to true. Custom filters must override this method if they are not writeable.

Returns:
true if writeable.

setAttribute

protected void setAttribute(java.lang.String name,
                            java.lang.Object value)
Set the named attribute.

Parameters:
name - The attribute name.
value - The attribute value.

getValidator

protected Validator getValidator()
Return the validator for this class, or null if the filter should not perform external validation.

Returns:
The validator or null


Copyright © 2002-2004, Paul Strack. All Rights Reserved.