Smack

org.jivesoftware.smackx
Class FormField

java.lang.Object
  extended by org.jivesoftware.smackx.FormField

public class FormField
extends Object

Represents a field of a form. The field could be used to represent a question to complete, a completed question or a data returned from a search. The exact interpretation of the field depends on the context where the field is used.

Author:
Gaston Dombiak

Nested Class Summary
static class FormField.Option
          Represents the available option of a given FormField.
 
Field Summary
static String TYPE_BOOLEAN
           
static String TYPE_FIXED
           
static String TYPE_HIDDEN
           
static String TYPE_JID_MULTI
           
static String TYPE_JID_SINGLE
           
static String TYPE_LIST_MULTI
           
static String TYPE_LIST_SINGLE
           
static String TYPE_TEXT_MULTI
           
static String TYPE_TEXT_PRIVATE
           
static String TYPE_TEXT_SINGLE
           
 
Constructor Summary
FormField()
          Creates a new FormField of type FIXED.
FormField(String variable)
          Creates a new FormField with the variable name that uniquely identifies the field in the context of the form.
 
Method Summary
 void addOption(FormField.Option option)
          Adss an available options to the question that the user has in order to answer the question.
 void addValue(String value)
          Adds a default value to the question if the question is part of a form to fill out.
 void addValues(List<String> newValues)
          Adds a default values to the question if the question is part of a form to fill out.
 String getDescription()
          Returns a description that provides extra clarification about the question.
 String getLabel()
          Returns the label of the question which should give enough information to the user to fill out the form.
 Iterator<FormField.Option> getOptions()
          Returns an Iterator for the available options that the user has in order to answer the question.
 String getType()
          Returns an indicative of the format for the data to answer.
 Iterator<String> getValues()
          Returns an Iterator for the default values of the question if the question is part of a form to fill out.
 String getVariable()
          Returns the variable name that the question is filling out.
 boolean isRequired()
          Returns true if the question must be answered in order to complete the questionnaire.
protected  void resetValues()
          Removes all the values of the field.
 void setDescription(String description)
          Sets a description that provides extra clarification about the question.
 void setLabel(String label)
          Sets the label of the question which should give enough information to the user to fill out the form.
 void setRequired(boolean required)
          Sets if the question must be answered in order to complete the questionnaire.
 void setType(String type)
          Sets an indicative of the format for the data to answer.
 String toXML()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TYPE_BOOLEAN

public static final String TYPE_BOOLEAN
See Also:
Constant Field Values

TYPE_FIXED

public static final String TYPE_FIXED
See Also:
Constant Field Values

TYPE_HIDDEN

public static final String TYPE_HIDDEN
See Also:
Constant Field Values

TYPE_JID_MULTI

public static final String TYPE_JID_MULTI
See Also:
Constant Field Values

TYPE_JID_SINGLE

public static final String TYPE_JID_SINGLE
See Also:
Constant Field Values

TYPE_LIST_MULTI

public static final String TYPE_LIST_MULTI
See Also:
Constant Field Values

TYPE_LIST_SINGLE

public static final String TYPE_LIST_SINGLE
See Also:
Constant Field Values

TYPE_TEXT_MULTI

public static final String TYPE_TEXT_MULTI
See Also:
Constant Field Values

TYPE_TEXT_PRIVATE

public static final String TYPE_TEXT_PRIVATE
See Also:
Constant Field Values

TYPE_TEXT_SINGLE

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

FormField

public FormField(String variable)
Creates a new FormField with the variable name that uniquely identifies the field in the context of the form.

Parameters:
variable - the variable name of the question.

FormField

public FormField()
Creates a new FormField of type FIXED. The fields of type FIXED do not define a variable name.

Method Detail

getDescription

public String getDescription()
Returns a description that provides extra clarification about the question. This information could be presented to the user either in tool-tip, help button, or as a section of text before the question.

If the question is of type FIXED then the description should remain empty.

Returns:
description that provides extra clarification about the question.

getLabel

public String getLabel()
Returns the label of the question which should give enough information to the user to fill out the form.

Returns:
label of the question.

getOptions

public Iterator<FormField.Option> getOptions()
Returns an Iterator for the available options that the user has in order to answer the question.

Returns:
Iterator for the available options.

isRequired

public boolean isRequired()
Returns true if the question must be answered in order to complete the questionnaire.

Returns:
true if the question must be answered in order to complete the questionnaire.

getType

public String getType()
Returns an indicative of the format for the data to answer. Valid formats are:

Returns:
format for the data to answer.

getValues

public Iterator<String> getValues()
Returns an Iterator for the default values of the question if the question is part of a form to fill out. Otherwise, returns an Iterator for the answered values of the question.

Returns:
an Iterator for the default values or answered values of the question.

getVariable

public String getVariable()
Returns the variable name that the question is filling out.

Returns:
the variable name of the question.

setDescription

public void setDescription(String description)
Sets a description that provides extra clarification about the question. This information could be presented to the user either in tool-tip, help button, or as a section of text before the question.

If the question is of type FIXED then the description should remain empty.

Parameters:
description - provides extra clarification about the question.

setLabel

public void setLabel(String label)
Sets the label of the question which should give enough information to the user to fill out the form.

Parameters:
label - the label of the question.

setRequired

public void setRequired(boolean required)
Sets if the question must be answered in order to complete the questionnaire.

Parameters:
required - if the question must be answered in order to complete the questionnaire.

setType

public void setType(String type)
Sets an indicative of the format for the data to answer. Valid formats are:

Parameters:
type - an indicative of the format for the data to answer.

addValue

public void addValue(String value)
Adds a default value to the question if the question is part of a form to fill out. Otherwise, adds an answered value to the question.

Parameters:
value - a default value or an answered value of the question.

addValues

public void addValues(List<String> newValues)
Adds a default values to the question if the question is part of a form to fill out. Otherwise, adds an answered values to the question.

Parameters:
newValues - default values or an answered values of the question.

resetValues

protected void resetValues()
Removes all the values of the field.


addOption

public void addOption(FormField.Option option)
Adss an available options to the question that the user has in order to answer the question.

Parameters:
option - a new available option for the question.

toXML

public String toXML()

Smack

Copyright © 2003-2007 Jive Software.