|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.arsdigita.bebop.parameters.ParameterModel
com.arsdigita.bebop.parameters.ArrayParameter
Reads an array of values
and converts them to a Java object array. The values in the array can be
any parameter type, for example strings, big decimals etc. The values
are read from a request either as multiple repeated values with the same
parameter name, i.e. from a URL like
http://foo.com/page?array=one&array=two or from an encoded
string that was previously produced by unmarshal
.
Either way, the transformed value of the parameters is an array of the
type of getElementParameter().getValueClass()[]
, so if the
element parameter is a StringParameter
, the transformed
value will be of type String[]
, and if it is a
BigDecimalParameter
, it will be of type
BigDecimal[]
.
Warning: The array parameter does currently no checking related to the size of the array, no matter what you set min and max value counts to.
Field Summary | |
protected int |
maxCount
|
protected int |
minCount
|
static String |
versionId
|
Fields inherited from class com.arsdigita.bebop.parameters.ParameterModel |
m_defaultValue, m_locked, m_name, m_parameterListeners |
Constructor Summary | |
ArrayParameter(ParameterModel element)
Create a new array parameter. |
|
ArrayParameter(String name)
Creates a new array parameter. |
Method Summary | |
ParameterModel |
getElementParameter()
Return the parameter model that transforms and validates individual entries in the array. |
int |
getMaxValueCount()
Gets the maximum number of values for this parameter that may be submitted for the request to be valid. |
int |
getMinValueCount()
Gets the minimum number of values for this parameter that may be submitted for the request to be valid. |
Class |
getValueClass()
Return the class that all values produced by the model will have. |
void |
lock()
Lock the model, blocking any further modifications. |
String |
marshal(Object value)
Encode the value which must be an array of objects into one string. |
String |
marshalElement(Object value)
Encode the given value into a string. |
void |
setElementParameter(ParameterModel v)
Set the parameter model that transforms and validates individual entries in the array. |
void |
setMaxValueCount(int count)
Sets the maximum number of values for this parameter that may be submitted for the request to be valid. |
void |
setMinValueCount(int count)
Sets the minimum number of values for this parameter that may be submitted for the request to be valid. |
Object |
transformValue(javax.servlet.http.HttpServletRequest request)
Extract an array of values from the request. |
Object |
unmarshal(String value)
Decode the string representation of an array into an array of objects. |
Object |
unmarshalElement(String encoded)
Decode one array element from its string representation. |
protected void |
validate(ParameterData data)
Validate the array extracted from the request by running the validation listeners of this parameter, and by running thte validation for the element parameter for each entry in the array separately. |
Methods inherited from class com.arsdigita.bebop.parameters.ParameterModel |
addParameterListener, createParameterData, createParameterData, createParameterData, getDefaultOverridesNull, getDefaultValue, getName, isLocked, isPassIn, setDefaultOverridesNull, setDefaultValue, setName, setPassIn, transformSingleValue |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final String versionId
protected int maxCount
protected int minCount
Constructor Detail |
public ArrayParameter(String name)
String
.
name
- the name of the array parameter in URIs.public ArrayParameter(ParameterModel element)
element
. Validation listeners on the
element
are run for each array entry.
element
- the parameter model for entries in the array.Method Detail |
public final ParameterModel getElementParameter()
public final void setElementParameter(ParameterModel v)
v
- the parameter model for entries in the array.public final String marshalElement(Object value)
value
by unmarshalElement(java.lang.String)
. Uses the marshalling of the element parameter
model.
value
- an object with the type of array elements
ParameterModel.marshal(java.lang.Object)
,
unmarshalElement(java.lang.String)
public final Object unmarshalElement(String encoded)
encoded
must have been produced through the marshalling
of the element parameter.
encoded
- the marshalled representation of an array element
encoded
ParameterModel.unmarshal(java.lang.String)
,
marshalElement(java.lang.Object)
public Object transformValue(javax.servlet.http.HttpServletRequest request)
marshal(java.lang.Object)
.
transformValue
in class ParameterModel
request
- a HttpServletRequest
value
Object
valuepublic String marshal(Object value)
element
parameter
. The unmarshal(java.lang.String)
method can read this format and
reconstruct the array from that string again.
marshal
in class ParameterModel
value
- an array of values
public Object unmarshal(String value)
Object[]
. The
type of the entries in the array depends on the element parameter
.
unmarshal
in class ParameterModel
value
- the marshalled version of an array.
Object[]
reconstructed from
value
.public final void setMinValueCount(int count)
public final void setMaxValueCount(int count)
public final int getMinValueCount()
public final int getMaxValueCount()
protected void validate(ParameterData data) throws FormProcessException
validate
in class ParameterModel
data
- the parameter data to validate.
FormProcessException
- if the data can not be validated.public void lock()
ParameterModel
lock
in interface Lockable
lock
in class ParameterModel
public Class getValueClass()
ParameterModel
Object.class
getValueClass
in class ParameterModel
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |