|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectcom.arsdigita.util.parameter.AbstractParameter
Subject to change.
A base implementation of the Parameter interface. It
offers subclasses use of the Apache BeanUtils framework, should
they opt to use it.
Methods of the form doXXX are extension points for
subclasses. The isRequired() and
getDefaultValue() methods may also be overriden.
Parameter| Field Summary | |
static String |
versionId
|
| Fields inherited from interface com.arsdigita.util.parameter.Parameter |
OPTIONAL, REQUIRED |
| Constructor Summary | |
protected |
AbstractParameter(String name,
Class type)
Constructs a new parameter using the beanutils converter for type type. |
protected |
AbstractParameter(String name,
int multiplicity,
Object defaalt)
Constructs a new parameter with the default value defaalt. |
protected |
AbstractParameter(String name,
int multiplicity,
Object defaalt,
Class type)
Constructs a new parameter with the default value defaalt and using the beanutils converter
registered for type. |
| Method Summary | |
protected Object |
doRead(ParameterReader reader,
ErrorList errors)
Reads the value of the parameter from reader,
unmarshals it, and returns it. |
protected void |
doValidate(Object value,
ErrorList errors)
Validates value, placing any validation errors in
errors. |
protected void |
doWrite(ParameterWriter writer,
Object value)
Marshals and writes value to writer. |
Object |
getDefaultValue()
Parameter users may override this method to achieve dynamic defaulting. |
ParameterInfo |
getInfo()
Gets metadata associated with the parameter if it is available. |
String |
getName()
Gets the name of the parameter. |
boolean |
isRequired()
Parameter users may override this method to make the multiplicity of the parameter dependent on the multiplicity of related parameters. |
protected String |
marshal(Object value)
Converts value to a representative
String, which is returned. |
Object |
read(ParameterReader reader,
ErrorList errors)
Calls doRead(ParameterReader,ErrorList). |
void |
setInfo(ParameterInfo info)
Sets the optional parameter metadata to info. |
String |
toString()
Returns a String representation of this object. |
protected Object |
unmarshal(String value,
ErrorList errors)
Converts a literal String value,
value, to a Java object, which is returned. |
void |
validate(Object value,
ErrorList errors)
Calls doValidate(Object,ErrorList) if
value is not null. |
void |
write(ParameterWriter writer,
Object value)
Calls doWrite(ParameterWriter,Object). |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
public static final String versionId
| Constructor Detail |
protected AbstractParameter(String name,
int multiplicity,
Object defaalt,
Class type)
defaalt and using the beanutils converter
registered for type.
name - The name of the parameter; it cannot be nullmultiplicity - The multiplicity type of the parameterdefaalt - The default value to use if the value is unset
or is nulltype - The Class whose beanutils converter
will be used to unmarshal literal values
protected AbstractParameter(String name,
int multiplicity,
Object defaalt)
defaalt.
name - The name of the parameter; it cannot be nullmultiplicity - The multiplicity type of the parameterdefaalt - The default value to use if the value is unset
or is null
protected AbstractParameter(String name,
Class type)
type. By default, the parameter is required
and has no default.
name - The name of the parameter; it cannot be nulltype - The Class whose beanutils converter
will be used to unmarshal literal values| Method Detail |
public boolean isRequired()
isRequired in interface ParameterParameter.isRequired()public final String getName()
Parameter
getName in interface ParameterString parameter name; it cannot be
nullParameter.getName()public Object getDefaultValue()
getDefaultValue in interface ParameterParameter.getDefaultValue()public final ParameterInfo getInfo()
Parameter
getInfo in interface ParameterParameterInfo object; it may be nullParameter.getInfo()public final void setInfo(ParameterInfo info)
Parameterinfo.
setInfo in interface Parameterinfo - The ParameterInfo to associate; it may
be nullParameter.setInfo(ParameterInfo)
public final Object read(ParameterReader reader,
ErrorList errors)
doRead(ParameterReader,ErrorList).
read in interface Parameterreader - The ParameterReader from which to
recover a string literal value; it cannot be nullerrors - The ErrorList in which to collect
any errors encountered; it cannot be null
Parameter.read(ParameterReader,ErrorList)
protected Object doRead(ParameterReader reader,
ErrorList errors)
reader,
unmarshals it, and returns it. If any errors are encountered,
they are added to errors.
If the literal string value from reader is not
null, this method delegates to unmarshal(String,ErrorList).
This implementation is suited to a parameter with a singular
scalar value. Subclasses that are compound parameters should
override this method to delegate to child parameters.
reader - The ParameterReader that will supply
the literal stored value for this parameter; it cannot be nullerrors - The ErrorList that will trap any
errors encountered; it cannot be null
protected Object unmarshal(String value,
ErrorList errors)
String value,
value, to a Java object, which is returned.
value - The String value to convert from; it
cannot be nullerrors - An ErrorList that holds any errors
encountered during unmarshaling; it cannot be null
public final void validate(Object value,
ErrorList errors)
doValidate(Object,ErrorList) if
value is not null. Otherwise, if the value is
required and null, an error is added to
errors and doValidate is not called.
validate in interface Parametervalue - The value to validate; this is typically the value
returned by Parameter.read(com.arsdigita.util.parameter.ParameterReader, com.arsdigita.util.parameter.ErrorList); it may be nullerrors - The ErrorList in which to collect
any errors encountered; it cannot be nullParameter.validate(Object,ErrorList)
protected void doValidate(Object value,
ErrorList errors)
value, placing any validation errors in
errors. This particular implementation does
nothing. Subclasses are expected to add specific validation
behaviors.
value - The value to validate; it cannot be nullerrors - The ErrorList that traps validation
errors; it cannot be null
public final void write(ParameterWriter writer,
Object value)
doWrite(ParameterWriter,Object).
write in interface Parameterwriter - The ParameterWriter that will take
the marshaled value and store it; it cannot be nullvalue - The Java object value of the parameterParameter.write(ParameterWriter,Object)
protected void doWrite(ParameterWriter writer,
Object value)
value to writer.
This implementation is suited to a parameter with a singular
scalar value. Subclasses that are compound parameters should
override this method to delegate to child parameters.
writer - The ParameterWriter we write to; it
cannot be nullvalue - The value to write; it may be nullprotected String marshal(Object value)
value to a representative
String, which is returned.
value - The value to marshal; it may be null
String literal representation of
value; it may be nullpublic String toString()
String representation of this object.
super.toString() + "," + getName() + "," +
isRequired()
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||