org.apache.jetspeed.util.parser
Class ValidationParameterParser

java.lang.Object
  extended byorg.apache.turbine.util.pool.RecyclableSupport
      extended byorg.apache.turbine.util.parser.BaseValueParser
          extended byorg.apache.turbine.util.parser.DefaultParameterParser
              extended byorg.apache.jetspeed.util.parser.DefaultJetspeedParameterParser
                  extended byorg.apache.jetspeed.util.parser.ValidationParameterParser
All Implemented Interfaces:
org.apache.turbine.util.ParameterParser, org.apache.turbine.util.pool.Recyclable, org.apache.turbine.util.ValueParser

public class ValidationParameterParser
extends DefaultJetspeedParameterParser
implements org.apache.turbine.util.ParameterParser, org.apache.turbine.util.pool.Recyclable

A Turbine parameter parser with Validation built in. Validates any bean with methods that begin with validate[AttributeName]. Works with Torque-generated beans. To use this class, override the TurbineResources.properties: services.RunDataService.default.parameter.parser=org.apache.turbine.util.parser.DefaultParameterParser

Version:
$Id: ValidationParameterParser.java,v 1.7 2005/04/27 14:08:24 raphael Exp $
Author:
David Sean Taylor

Field Summary
 
Fields inherited from class org.apache.turbine.util.parser.BaseValueParser
parameters
 
Fields inherited from interface org.apache.turbine.util.ValueParser
URL_CASE_FOLDING, URL_CASE_FOLDING_LOWER, URL_CASE_FOLDING_NONE, URL_CASE_FOLDING_UPPER
 
Constructor Summary
ValidationParameterParser()
           
ValidationParameterParser(java.lang.String characterEncoding)
           
 
Method Summary
protected  java.lang.String generalValidation(java.lang.Object bean)
          Validate a bean's property based on definition in the business object
protected  java.lang.Object[] getArguments(java.beans.PropertyDescriptor prop)
           
protected  void setMyProperty(java.lang.Object bean, java.beans.PropertyDescriptor prop)
          Set the property 'prop' in the bean to the value of the corresponding parameters.
 void setProperties(java.lang.Object bean)
          Uses bean introspection to set writable properties of bean from the parameters, where a (case-insensitive) name match between the bean property and the parameter is looked for.
protected  boolean validateObject(java.beans.PropertyDescriptor prop)
           
protected  boolean validateProperty(java.lang.Object bean, java.beans.PropertyDescriptor prop)
          Validate a bean's property based on definition in the business object
 
Methods inherited from class org.apache.jetspeed.util.parser.DefaultJetspeedParameterParser
getString, setRequest
 
Methods inherited from class org.apache.turbine.util.parser.DefaultParameterParser
append, dispose, getFileItem, getFileItems, getRequest, getUploadData, setUploadData
 
Methods inherited from class org.apache.turbine.util.parser.BaseValueParser
add, add, add, add, add, append, clear, containsDateSelectorKeys, containsKey, containsTimeSelectorKeys, convert, convertAndTrim, get, getBigDecimal, getBigDecimal, getBigDecimals, getBool, getBool, getBoolean, getBoolean, getByte, getByte, getBytes, getCharacterEncoding, getDate, getDate, getDate, getDouble, getDouble, getFloat, getFloat, getInt, getInt, getInteger, getInteger, getInteger, getIntegers, getInts, getKeys, getLong, getLong, getLongObjects, getLongs, getNumberKey, getObject, getObjects, getString, getStringKey, getStrings, getStrings, keys, recycle, recycle, remove, setCharacterEncoding, setProperty, setString, setStrings, toString
 
Methods inherited from class org.apache.turbine.util.pool.RecyclableSupport
doDispose, isDisposed, Recyclable
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.apache.turbine.util.ParameterParser
append, getFileItem, getFileItems, getRequest, getUploadData, setRequest, setUploadData
 
Methods inherited from interface org.apache.turbine.util.ValueParser
add, add, add, add, add, append, clear, containsDateSelectorKeys, containsKey, convert, get, getBigDecimal, getBigDecimal, getBigDecimals, getBool, getBool, getBoolean, getBoolean, getByte, getByte, getBytes, getCharacterEncoding, getDate, getDate, getDate, getDouble, getDouble, getFloat, getFloat, getInt, getInt, getInteger, getInteger, getInteger, getIntegers, getInts, getKeys, getLong, getLong, getLongObjects, getLongs, getNumberKey, getObject, getObjects, getString, getString, getStringKey, getStrings, getStrings, keys, remove, setCharacterEncoding, setString, setStrings, toString
 
Methods inherited from interface org.apache.turbine.util.pool.Recyclable
dispose, isDisposed, recycle
 

Constructor Detail

ValidationParameterParser

public ValidationParameterParser()

ValidationParameterParser

public ValidationParameterParser(java.lang.String characterEncoding)
Method Detail

setProperties

public void setProperties(java.lang.Object bean)
                   throws java.lang.Exception
Uses bean introspection to set writable properties of bean from the parameters, where a (case-insensitive) name match between the bean property and the parameter is looked for.

Specified by:
setProperties in interface org.apache.turbine.util.ValueParser
Parameters:
bean - An Object.
Throws:
Exception, - a generic exception.
java.lang.Exception

setMyProperty

protected void setMyProperty(java.lang.Object bean,
                             java.beans.PropertyDescriptor prop)
                      throws java.lang.Exception
Set the property 'prop' in the bean to the value of the corresponding parameters. Supports all types supported by getXXX methods plus a few more that come for free because primitives have to be wrapped before being passed to invoke anyway.

Parameters:
bean - An Object.
prop - A PropertyDescriptor.
Throws:
Exception, - a generic exception.
java.lang.Exception

getArguments

protected java.lang.Object[] getArguments(java.beans.PropertyDescriptor prop)
                                   throws java.lang.Exception
Throws:
java.lang.Exception

validateProperty

protected boolean validateProperty(java.lang.Object bean,
                                   java.beans.PropertyDescriptor prop)
                            throws java.lang.Exception
Validate a bean's property based on definition in the business object

Parameters:
bean - The bean to be validated.
prop - The bean's property descriptor
Returns:
true if validation was successful, false if validation failed
Throws:
java.lang.Exception

validateObject

protected boolean validateObject(java.beans.PropertyDescriptor prop)
                          throws java.lang.Exception
Throws:
java.lang.Exception

generalValidation

protected java.lang.String generalValidation(java.lang.Object bean)
                                      throws java.lang.Exception
Validate a bean's property based on definition in the business object

Parameters:
bean - The bean to be validated.
Returns:
null if validation was successful, an error message if validation failed
Throws:
java.lang.Exception


Copyright © 2000-2005 Apache Software Foundation. All Rights Reserved.