com.arsdigita.bebop.parameters
Class ParameterData

java.lang.Object
  extended bycom.arsdigita.bebop.parameters.ParameterData
All Implemented Interfaces:
Cloneable, Map.Entry

public final class ParameterData
extends Object
implements Map.Entry, Cloneable

This class is used to manage the data associated with a single parameter. A ParameterData object contains errors and values associated with a given parameter.

Version:
$Id: //core-platform/dev/src/com/arsdigita/bebop/parameters/ParameterData.java#9 $
Author:
Uday Mathur

Field Summary
static String versionId
           
 
Constructor Summary
ParameterData(ParameterModel model, Object value)
          Construct a new ParameterData object with the specified name and value.
 
Method Summary
 void addError(GlobalizedMessage message)
           Adds an error to this parameter.
 void addError(String message)
          Adds a an error to this parameter.
 Object clone()
          Clones this object making a new reference to the errors list.
 Iterator getErrors()
          Gets the errors in this particular parameter.
 Object getKey()
          Return the name of this parameter.
 ParameterModel getModel()
          Return the ParameterModel underlying this parameter.
 Object getName()
          Return the name of this parameter.
 Object getValue()
          Return the value of this parameter.
 void invalidate()
          Mark this ParameterData as invalid.
 boolean isArray()
          Return true if the value is an array of values.
 boolean isTransformed()
           
 boolean isValid()
           
 String marshal()
          Produce a string representation of the current value.
 void setInvalid()
          Deprecated. Use invalidate().
 void setUntransformed()
          Mark this ParameterData as untransformed.
 Object setValue(Object value)
          Sets the value of this parameter.
 String toString()
          Convert to a String.
 void unmarshal(String encoded)
          Set the value to the unmarshalled object represented by encoded.
 void validate()
          Revalidate this ParameterData.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map.Entry
equals, hashCode
 

Field Detail

versionId

public static final String versionId
See Also:
Constant Field Values
Constructor Detail

ParameterData

public ParameterData(ParameterModel model,
                     Object value)
Construct a new ParameterData object with the specified name and value.

Parameters:
value - value of this parameter.
Method Detail

clone

public Object clone()
             throws CloneNotSupportedException
Clones this object making a new reference to the errors list.

Throws:
CloneNotSupportedException

getValue

public final Object getValue()
Return the value of this parameter.

Specified by:
getValue in interface Map.Entry
Returns:
the value of this parameter. If isArray() is true, then the return value is an array

getModel

public final ParameterModel getModel()
Return the ParameterModel underlying this parameter.


getName

public Object getName()
Return the name of this parameter.

Returns:
the name of this parameter. This should be the same name as the ParameterModel

getKey

public Object getKey()
Return the name of this parameter.

Specified by:
getKey in interface Map.Entry
Returns:
getName()

setValue

public final Object setValue(Object value)
Sets the value of this parameter. Marks this parameterData as transformed. Does NOT write through to any underlying Map, as specified in the Map.Entry interface.

Specified by:
setValue in interface Map.Entry
Parameters:
value - the value of this parameter
Returns:
the previous value of this parameter

marshal

public final String marshal()
Produce a string representation of the current value. The underlying parameter model has to be able to read the resulting string back into the right object o so that getValue().equals(o).

Returns:
the value as a readable string
See Also:
ParameterModel.marshal(java.lang.Object)

unmarshal

public final void unmarshal(String encoded)
Set the value to the unmarshalled object represented by encoded.

Parameters:
encoded - the marshalled version of a parameter value.
See Also:
ParameterModel.unmarshal(java.lang.String)

addError

public void addError(String message)
Adds a an error to this parameter. This method is called by FormData.addError and by ParameterListeners.

Parameters:
message - The error message to add to this parameter

addError

public void addError(GlobalizedMessage message)

Adds an error to this parameter. This method is called by FormData.addError and by ParameterListeners.

Parameters:
message - GlobalizedMessage representing the error to add to this parameter.

getErrors

public Iterator getErrors()
Gets the errors in this particular parameter.

Returns:
in Iterator of error message strings for this parameter

validate

public void validate()
              throws FormProcessException
Revalidate this ParameterData. If transformation failed, and the value has not been reset, this will be a no-op.

Throws:
FormProcessException

isArray

public boolean isArray()
Return true if the value is an array of values.

Returns:
boolean value depending on whether the value of this parameter is a single value or an array

isValid

public final boolean isValid()
Returns:
true if this ParameterData has no errors

isTransformed

public final boolean isTransformed()
Returns:
true if this ParameterData tranformed without error, or the value was manually set with setValue()

setInvalid

public final void setInvalid()
Deprecated. Use invalidate().

Mark this ParameterData as invalid.


invalidate

public final void invalidate()
Mark this ParameterData as invalid.


setUntransformed

public final void setUntransformed()
Mark this ParameterData as untransformed.


toString

public String toString()
Convert to a String.

Returns:
a human-readable representation of this.


Copyright (c) 2004 Red Hat, Inc. Corporation. All Rights Reserved. Generated at July 20 2004:2337 UTC