|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
Subject to change.
Describes a named property that can read, write, and validate its
own value. See the documentation on read(com.arsdigita.util.parameter.ParameterReader, com.arsdigita.util.parameter.ErrorList), write(com.arsdigita.util.parameter.ParameterWriter, java.lang.Object),
and validate(java.lang.Object, com.arsdigita.util.parameter.ErrorList) for details.
They have the following features as well:
ParameterContext manages a set of
parameters and keeps their values.
Here's what it typically looks like to use a parameter:
Properties props = System.getProperties();
ParameterReader reader = JavaPropertyReader(props);
ParameterWriter writer = JavaPropertyWriter(props);
ErrorList errors = new ErrorList();
Object value = param.read(reader, errors);
errors.check(); // If errors is not empty, fails
param.validate(value, errors);
errors.check(); // If errors is not empty, fails
// We now have a valid unmarshaled value, so code of actual use can
// go here.
param.write(writer, value);
AbstractParameter,
ParameterContext| Field Summary | |
static int |
OPTIONAL
Flag to indicate the parameter value is nullable. |
static int |
REQUIRED
Flag to indicate the parameter value cannot be null. |
static String |
versionId
|
| Method Summary | |
Object |
getDefaultValue()
Gets the default value of the parameter. |
ParameterInfo |
getInfo()
Gets metadata associated with the parameter if it is available. |
String |
getName()
Gets the name of the parameter. |
boolean |
isRequired()
Tells wether the parameter is nullable or not. |
Object |
read(ParameterReader reader,
ErrorList errors)
Gets the parameter value as a Java object. |
void |
setInfo(ParameterInfo info)
Sets the optional parameter metadata to info. |
void |
validate(Object value,
ErrorList errors)
Validates the parameter value, value. |
void |
write(ParameterWriter writer,
Object value)
Writes the parameter value as a string literal. |
| Field Detail |
public static final String versionId
public static final int OPTIONAL
public static final int REQUIRED
| Method Detail |
public boolean isRequired()
public String getName()
String parameter name; it cannot be
nullpublic Object getDefaultValue()
public ParameterInfo getInfo()
ParameterInfo object; it may be nullpublic void setInfo(ParameterInfo info)
info.
info - The ParameterInfo to associate; it may
be null
public Object read(ParameterReader reader,
ErrorList errors)
readererrors. Callers of this method will
typically construct an ErrorList in which to
collect errors.
reader - 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
public void validate(Object value,
ErrorList errors)
value. Any
validation errors encountered are added to errors.
value - The value to validate; this is typically the value
returned by 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 null
public void write(ParameterWriter writer,
Object value)
value to a string and sends it
to writer.
writer - The ParameterWriter that will take
the marshaled value and store it; it cannot be nullvalue - The Java object value of the parameter
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||