org.alfresco.repo.forms
Class FormData

java.lang.Object
  extended by org.alfresco.repo.forms.FormData
All Implemented Interfaces:
java.lang.Iterable

public class FormData
extends java.lang.Object
implements java.lang.Iterable

Represents the data going to or coming from a Form.


Nested Class Summary
 class FormData.FieldData
          Inner class to represent the value of a field on a form
 
Field Summary
protected  java.util.Map data
           
 
Constructor Summary
FormData()
          Default constructor
 
Method Summary
 void addFieldData(org.springframework.extensions.webscripts.servlet.FormData.FormField field)
          Adds the given webscript FormField object to the form.
 void addFieldData(java.lang.String fieldName, java.lang.Object fieldValue)
          Adds the given data to the form.
 void addFieldData(java.lang.String fieldName, java.lang.Object fieldValue, boolean overwrite)
          Adds the given data to the form.
 FormData.FieldData getFieldData(java.lang.String fieldName)
          Returns the data for the given field.
 java.util.Set getFieldNames()
          Returns a list of the names of the fields held by this object.
 int getNumberOfFields()
          Returns the number of fields data is being held for.
 boolean hasFieldData(java.lang.String fieldName)
          Determines whether field data for the given item exists.
 java.util.Iterator iterator()
          Returns an Iterator over the FieldData objects held by this object.
 void removeFieldData(java.lang.String fieldName)
          Removes the data associated with the given field if it exists.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

data

protected java.util.Map data
Constructor Detail

FormData

public FormData()
Default constructor

Method Detail

hasFieldData

public boolean hasFieldData(java.lang.String fieldName)
Determines whether field data for the given item exists.

Parameters:
fieldName - Name of field to look for
Returns:
true if the field exists, false otherwise

getFieldData

public FormData.FieldData getFieldData(java.lang.String fieldName)
Returns the data for the given field.

Parameters:
fieldName - Name of field to look for
Returns:
FieldData object representing the data for the field or null if it doesn't exist

addFieldData

public void addFieldData(java.lang.String fieldName,
                         java.lang.Object fieldValue)
Adds the given data to the form.

NOTE: Adding the same named data will append the value and thereafter return a List containing all added values.

Parameters:
fieldName - The name of the field
fieldValue - The value of the data

addFieldData

public void addFieldData(org.springframework.extensions.webscripts.servlet.FormData.FormField field)
Adds the given webscript FormField object to the form.

Parameters:
field - A WebScript FormField object

addFieldData

public void addFieldData(java.lang.String fieldName,
                         java.lang.Object fieldValue,
                         boolean overwrite)
Adds the given data to the form. If data for the field is already present the behaviour is controlled by the overwrite property.

If overwrite is true the provided value replaces the existing value whereas false will force the creation of a List (if necessary) and the provided value will be added to the List.

Parameters:
fieldName - The name of the field
fieldValue - The value of the data
overwrite -

removeFieldData

public void removeFieldData(java.lang.String fieldName)
Removes the data associated with the given field if it exists.

Parameters:
fieldName - Name of the field to remove

getFieldNames

public java.util.Set getFieldNames()
Returns a list of the names of the fields held by this object.

Returns:
List of String objects

getNumberOfFields

public int getNumberOfFields()
Returns the number of fields data is being held for.

Returns:
Number of fields

iterator

public java.util.Iterator iterator()
Returns an Iterator over the FieldData objects held by this object.

Specified by:
iterator in interface java.lang.Iterable
Returns:
Iterator of FieldData

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright © 2005 - 2010 Alfresco Software, Inc. All Rights Reserved.