Overview | Package | Class | Tree | Deprecated | Index | Help
| Openfire 3.4.4 Javadoc
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.xmpp.forms
Class DataForm

    java.lang.Object
      org.xmpp.packet.PacketExtension
          org.xmpp.forms.DataForm

    public class DataForm

extends PacketExtension

Represents a form that could be use for gathering data as well as for reporting data returned from a search.

The form could be of the following types:

- form -> Indicates a form to fill out.
- submit -> The form is filled out, and this is the data that is being returned from the form.
- cancel -> The form was cancelled. Tell the asker that piece of information.
- result -> Data results being returned from a search, or some other query.

In case the form represents a search, the report will be structured in columns and rows. Use `addReportedField(String,String,FormField.Type)` to set the columns of the report whilst the report's rows can be configured using `addItemFields(Map)`.

Author:
  Gaston Dombiak

Nested Class Summary
`static class` | `DataForm.Type` Type-safe enumeration to represent the type of the Data forms.

Field Summary
`static String` | `ELEMENT_NAME` Element name of the packet extension.
`static String` | `NAMESPACE` Namespace of the packet extension.

Fields inherited from class org.xmpp.packet.PacketExtension
`docFactory, element, registeredExtensions`

Constructor Summary
`DataForm(DataForm.Type type)`
`DataForm(org.dom4j.Element element)`

Method Summary
`FormField` | `addField()` Adds a new field as part of the form.
`void` | `addInstruction(String instruction)` Adds a new instruction to the list of instructions that explain how to fill out the form and what the form is about.
`void` | `addItemFields(Map<String,Object> fields)` Adds a new row of items of reported data.
`void` | `addReportedField(String variable, String label, FormField.Type type)` Adds a field to the list of fields that will be returned from a search.
`void` | `clearInstructions()` Clears all the stored instructions in this packet extension.
`DataForm` | `createCopy()` Creates a deep copy of this packet extension.
`FormField` | `getField(String variable)` Returns the field whose variable matches the specified variable.
`List<FormField>` | `getFields()` Returns the fields that are part of the form.
`List<String>` | `getInstructions()` Returns an unmodifiable list of instructions that explain how to fill out the form and what the form is about.
`String` | `getTitle()` Returns the description of the data form.
`DataForm.Type` | `getType()` Returns the type of this data form.
`static boolean` | `parseBoolean(String booleanString)`
`static Date` | `parseDate(String date)` Returns the Date obtained by parsing the specified date representation.
`boolean` | `removeField(String variable)` Removes the field whose variable matches the specified variable.
`void` | `setTitle(String title)` Sets the description of the data.

Methods inherited from class org.xmpp.packet.PacketExtension
`getElement, getExtensionClass`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### ELEMENT_NAME

    public static final String ELEMENT_NAME

  Element name of the packet extension.

  See Also:
    Constant Field Values

### NAMESPACE

    public static final String NAMESPACE

  Namespace of the packet extension.

  See Also:
    Constant Field Values

Constructor Detail

### DataForm

    public DataForm(DataForm.Type type)

### DataForm

    public DataForm(org.dom4j.Element element)

Method Detail

### parseDate

    public static Date parseDate(String date)
                          throws ParseException

  Returns the Date obtained by parsing the specified date representation. The date representation is expected to be in the UTC GMT+0 format.

  Parameters:
    `date` - date representation in the UTC GMT+0 format.
  Returns:
    the Date obtained by parsing the specified date representation.
  Throws:
    `ParseException` - if an error occurs while parsing the date representation.

### parseBoolean

    public static boolean parseBoolean(String booleanString)
                                throws ParseException

  Throws:
    `ParseException`

### getType

    public DataForm.Type getType()

  Returns the type of this data form.

  Returns:
    the data form type.
  See Also:
    `DataForm.Type`

### setTitle

    public void setTitle(String title)

  Sets the description of the data. It is similar to the title on a web page or an X window. You can put a on either a form to fill out, or a set of data results.

  Parameters:
    `title` - description of the data.

### getTitle

    public String getTitle()

  Returns the description of the data form. It is similar to the title on a web page or an X window. You can put a on either a form to fill out, or a set of data results.

  Returns:
    description of the data.

### getInstructions

    public List<String> getInstructions()

  Returns an unmodifiable list of instructions that explain how to fill out the form and what the form is about. The dataform could include multiple instructions since each instruction could not contain newlines characters.

  Returns:
    an unmodifiable list of instructions that explain how to fill out the form.

### addInstruction

    public void addInstruction(String instruction)

  Adds a new instruction to the list of instructions that explain how to fill out the form and what the form is about. The dataform could include multiple instructions since each instruction could not contain newlines characters.

  Parameters:
    `instruction` - the new instruction that explain how to fill out the form.

### clearInstructions

    public void clearInstructions()

  Clears all the stored instructions in this packet extension.

### addField

    public FormField addField()

  Adds a new field as part of the form.

  Returns:
    the newly created field.

### getFields

    public List<FormField> getFields()

  Returns the fields that are part of the form.

  Returns:
    fields that are part of the form.

### getField

    public FormField getField(String variable)

  Returns the field whose variable matches the specified variable.

  Parameters:
    `variable` - the variable name of the field to search.
  Returns:
    the field whose variable matches the specified variable

### removeField

    public boolean removeField(String variable)

  Removes the field whose variable matches the specified variable.

  Parameters:
    `variable` - the variable name of the field to remove.
  Returns:
    true if the field was removed.

### addReportedField

    public void addReportedField(String variable,
                                 String label,
                                 FormField.Type type)

  Adds a field to the list of fields that will be returned from a search. Each field represents a column in the report. The order of the columns in the report will honor the sequence in which they were added.

  Parameters:
    `variable` - variable name of the new column. This value will be used in `addItemFields(java.util.Map)` when adding reported items.
    `label` - label that corresponds to the new column. Optional parameter.
    `type` - indicates the type of field of the new column. Optional parameter.

### addItemFields

    public void addItemFields(Map<String,Object> fields)

  Adds a new row of items of reported data. For each entry in the `fields` parameter a `field` element will be added to the element. The variable of the new `field` will be the key of the entry. The new `field` will have several values if the entry's value is a `Collection`. Since the value is of type `Object` it is possible to include any type of object as a value. The actual value to include in the data form is the result of the `encode(Object)` method.

  Parameters:
    `fields` - list of to be added as a new item.

### createCopy

    public DataForm createCopy()

  Description copied from class: `PacketExtension`
  Creates a deep copy of this packet extension.

  Overrides:
    `createCopy` in class `PacketExtension`
  Returns:
    a deep copy of this packet extension.

Overview | Package | Class | Tree | Deprecated | Index | Help
| Openfire 3.4.4 Javadoc
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2003-2007 Jive Software.