DataFormField Class Reference

An abstraction of a single field in a JEP-0004 Data Form. More...

#include <dataformfield.h>

Inherited by DataFormItem [private], and DataFormReported [private].

Inheritance diagram for DataFormField:

Inheritance graph
[legend]
List of all members.

Public Types

enum  DataFormFieldType {
  FIELD_TYPE_BOOLEAN, FIELD_TYPE_FIXED, FIELD_TYPE_HIDDEN, FIELD_TYPE_JID_MULTI,
  FIELD_TYPE_JID_SINGLE, FIELD_TYPE_LIST_MULTI, FIELD_TYPE_LIST_SINGLE, FIELD_TYPE_TEXT_MULTI,
  FIELD_TYPE_TEXT_PRIVATE, FIELD_TYPE_TEXT_SINGLE, FIELD_TYPE_ITEM, FIELD_TYPE_REPORTED,
  FIELD_TYPE_INVALID
}

Public Member Functions

 DataFormField (DataFormFieldType type=FIELD_TYPE_TEXT_SINGLE)
 DataFormField (Tag *tag)
virtual ~DataFormField ()
StringMapoptions ()
virtual Tagtag () const
virtual const std::string & name () const
void setName (const std::string &name)
void setOptions (const StringMap &options)
bool required () const
void setRequired (bool required)
DataFormFieldType type () const
const std::string & label () const
void setLabel (const std::string &label)
const std::string & value () const
void setValue (const std::string &value)
const StringListvalues () const
void setValues (const StringList &values)

Detailed Description

An abstraction of a single field in a JEP-0004 Data Form.

Author:
Jakob Schroeter <js@camaya.net>
Since:
0.7

Definition at line 31 of file dataformfield.h.


Member Enumeration Documentation

enum DataFormFieldType
 

Describes the possible type of a Data Form Field.

Enumerator:
FIELD_TYPE_BOOLEAN  The field enables an entity to gather or provide an either-or choice between two options. The default value is "false".
FIELD_TYPE_FIXED  The field is intended for data description (e.g., human-readable text such as "section" headers) rather than data gathering or provision. The <value/> child SHOULD NOT contain newlines (the \n and \r characters); instead an application SHOULD generate multiple fixed fields, each with one <value/> child.
FIELD_TYPE_HIDDEN  The field is not shown to the entity providing information, but instead is returned with the form.
FIELD_TYPE_JID_MULTI  The field enables an entity to gather or provide multiple Jabber IDs.
FIELD_TYPE_JID_SINGLE  The field enables an entity to gather or provide a single Jabber ID.
FIELD_TYPE_LIST_MULTI  The field enables an entity to gather or provide one or more options from among many.
FIELD_TYPE_LIST_SINGLE  The field enables an entity to gather or provide one option from among many.
FIELD_TYPE_TEXT_MULTI  The field enables an entity to gather or provide multiple lines of text.
FIELD_TYPE_TEXT_PRIVATE  The field enables an entity to gather or provide a single line or word of text, which shall be obscured in an interface (e.g., *****).
FIELD_TYPE_TEXT_SINGLE  The field enables an entity to gather or provide a single line or word of text, which may be shown in an interface. This field type is the default and MUST be assumed if an entity receives a field type it does not understand.
FIELD_TYPE_ITEM  The field really is an element of type 'item' which allows for addition of sub-fields. See the explanantion in JEP-0004 (Data Forms) Section 3.4 for more information
FIELD_TYPE_REPORTED  The field really is an element of type 'reported' which allows for addition of sub-fields. See the explanantion in JEP-0004 (Data Forms) Section 3.4 for more information
FIELD_TYPE_INVALID  The field is invalid. Only possible if the field was created from a Tag not correctly describing a Data Form Field.

Definition at line 38 of file dataformfield.h.


Constructor & Destructor Documentation

DataFormField DataFormFieldType  type = FIELD_TYPE_TEXT_SINGLE  ) 
 

Constructs a new Data Form Field.

Parameters:
type The type of the field. Default: text-single.

Definition at line 19 of file dataformfield.cpp.

DataFormField Tag tag  ) 
 

Constructs a new Data Form Field from an existing tag that describes a field.

Parameters:
tag The tag to parse.

Definition at line 24 of file dataformfield.cpp.

References Tag::children(), DataFormField::FIELD_TYPE_BOOLEAN, DataFormField::FIELD_TYPE_FIXED, DataFormField::FIELD_TYPE_HIDDEN, DataFormField::FIELD_TYPE_JID_MULTI, DataFormField::FIELD_TYPE_JID_SINGLE, DataFormField::FIELD_TYPE_LIST_MULTI, DataFormField::FIELD_TYPE_LIST_SINGLE, DataFormField::FIELD_TYPE_TEXT_MULTI, DataFormField::FIELD_TYPE_TEXT_PRIVATE, DataFormField::FIELD_TYPE_TEXT_SINGLE, Tag::hasAttribute(), and DataFormField::tag().

~DataFormField  )  [virtual]
 

Virtual destructor.

Definition at line 74 of file dataformfield.cpp.


Member Function Documentation

const std::string& label  )  const [inline]
 

Use this function to retrieve the describing label of this field.

Returns:
The describing label of this field.

Definition at line 148 of file dataformfield.h.

virtual const std::string& name  )  const [inline, virtual]
 

Use this function to retrieve the name of the field (the content of the 'var' attribute).

Returns:
The name of the field.

Definition at line 110 of file dataformfield.h.

StringMap& options  )  [inline]
 

Use this function to retrieve the optional values of a field.

Returns:
The options of a field.

Definition at line 96 of file dataformfield.h.

bool required  )  const [inline]
 

Use this function to determine whether or not this field is required.

Returns:
Whether or not this field is required.

Definition at line 130 of file dataformfield.h.

void setLabel const std::string &  label  )  [inline]
 

Use this function to set the describing label of this field.

Parameters:
label The describing label of this field.

Definition at line 154 of file dataformfield.h.

void setName const std::string &  name  )  [inline]
 

Sets the name (the content of the 'var' attribute) of the field. The name identifies the field uniquely in the form.

Parameters:
name The new name of the field.
Note:
Fields of type other than 'fixed' MUST have a name, if it is 'fixed', it MAY.

Definition at line 118 of file dataformfield.h.

void setOptions const StringMap options  )  [inline]
 

Use this function to set the optional values of a field.

Parameters:
options The optional values of a list* or *multi type of field.

Definition at line 124 of file dataformfield.h.

void setRequired bool  required  )  [inline]
 

Use this field to set this field to be required.

Parameters:
required Whether or not this field is required.

Definition at line 136 of file dataformfield.h.

void setValue const std::string &  value  )  [inline]
 

Use this function to set the value of this field.

Parameters:
value The new value of this field.

Definition at line 166 of file dataformfield.h.

void setValues const StringList values  )  [inline]
 

Use this function to set multiple values of this field, if it is of type 'text-multi'. If its not, use setValue() instead.

Parameters:
value The new values of this field.

Definition at line 179 of file dataformfield.h.

Tag * tag  )  const [virtual]
 

Use this function to create a Tag representation of the form field. This is usually called by DataForm.

Returns:
A Tag hierarchically describing the form field, or NULL if the field is invalid (i.e. created from a Tag not correctly describing a Data Form Field).

Definition at line 78 of file dataformfield.cpp.

References Tag::addAttrib(), Tag::addChild(), DataFormField::FIELD_TYPE_BOOLEAN, DataFormField::FIELD_TYPE_FIXED, DataFormField::FIELD_TYPE_HIDDEN, DataFormField::FIELD_TYPE_INVALID, DataFormField::FIELD_TYPE_JID_MULTI, DataFormField::FIELD_TYPE_JID_SINGLE, DataFormField::FIELD_TYPE_LIST_MULTI, DataFormField::FIELD_TYPE_LIST_SINGLE, DataFormField::FIELD_TYPE_TEXT_MULTI, DataFormField::FIELD_TYPE_TEXT_PRIVATE, and DataFormField::FIELD_TYPE_TEXT_SINGLE.

Referenced by DataFormField::DataFormField().

DataFormFieldType type  )  const [inline]
 

Use this function to retrieve the type of this field.

Returns:
The type of this field.

Definition at line 142 of file dataformfield.h.

const std::string& value  )  const [inline]
 

Use this function to retrieve the value of this field.

Returns:
The value of this field.

Definition at line 160 of file dataformfield.h.

const StringList& values  )  const [inline]
 

Use this function to retrieve the values of this field, if its of type 'text-multi'.

Returns:
The value of this field.

Definition at line 172 of file dataformfield.h.


The documentation for this class was generated from the following files:
Generated on Mon Jan 16 16:19:57 2006 for gloox by  doxygen 1.4.6