org.sovt.impl
Class PropertySelector

java.lang.Object
  extended byorg.sovt.impl.PropertySelector
All Implemented Interfaces:
java.lang.Cloneable, Inspector, Transformer, Validator

public class PropertySelector
extends java.lang.Object
implements Inspector, Transformer, Validator, java.lang.Cloneable

This class is used to validate properties of JavaBean objects. It extracts property of JavaBean, forwards it to sub-validators/transformers/inspectors and then sets this property again if necessary (only for transform/inspect).

Author:
Vilmantas Baranauskas (vilmantas_baranauskas@yahoo.com)

Constructor Summary
PropertySelector()
          Creates instance of PropertySelector.
 
Method Summary
 void addInspector(Inspector inspector)
          Adds inspector to the group.
 void addTransformer(Transformer transformer)
          Adds transformer to the group.
 void addValidator(Validator validator)
          Adds validator to the group.
 java.lang.Object clone()
          Performs a partly deep-cloning.
 java.lang.Object inspect(java.lang.Object object, ValidationResult result)
          Performs transformation and validation of given object.
 void setName(java.lang.String property)
          Set the name of the property to work on.
 java.lang.Object transform(java.lang.Object object)
          Transforms given object.
 void validate(java.lang.Object object, ValidationResult result)
          Implementation should validate given object and use result parameter to store stores validation result.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PropertySelector

public PropertySelector()
Creates instance of PropertySelector. The instance can be registered as any of: Inspector, Transformer, Validator.

Method Detail

addInspector

public void addInspector(Inspector inspector)
Adds inspector to the group.

Parameters:
inspector - Inspector to add.

addTransformer

public void addTransformer(Transformer transformer)
Adds transformer to the group.

Parameters:
transformer - Transformer to add.

addValidator

public void addValidator(Validator validator)
Adds validator to the group.

Parameters:
validator - Validator to add.

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Performs a partly deep-cloning. New list of contained elements is created but elements themselfs are not cloned.

Specified by:
clone in interface Inspector
Returns:
clone of itself.
Throws:
java.lang.CloneNotSupportedException - never.

inspect

public java.lang.Object inspect(java.lang.Object object,
                                ValidationResult result)
Performs transformation and validation of given object. Transformers, validators and inspectors are invoked in the order they are registered.

Specified by:
inspect in interface Inspector
Parameters:
object - Object to inspect.
result - Container for validation results.
Returns:
Transformed or completely new object which is also validated.

setName

public void setName(java.lang.String property)
Set the name of the property to work on. This can be specified as an attribute of a XML tag.

Parameters:
property - Name of the property to work on.

transform

public java.lang.Object transform(java.lang.Object object)
Transforms given object. Given object can be modified or new object can be returned.

Specified by:
transform in interface Transformer
Parameters:
object - Object to transform.
Returns:
Transformed or completely new object.

validate

public void validate(java.lang.Object object,
                     ValidationResult result)
Implementation should validate given object and use result parameter to store stores validation result.

Specified by:
validate in interface Validator
Parameters:
object - Object to validate
result - Container for validation results.


Copyright © 2003-2005 . All Rights Reserved.