public final class DataForm extends java.lang.Object implements java.lang.Comparable<DataForm>
The implementation of the <x/>
element in the jabber:x:data
namespace, which represents data forms.
This specification defines an XMPP protocol extension for data forms that can be used in workflows such as service configuration as well as for application-specific data description and reporting. The protocol includes lightweight semantics for forms processing (such as request, response, submit, and cancel), defines several common field types (boolean, list options with single or multiple choice, text with single line or multiple lines, single or multiple JabberIDs, hidden fields, etc.), provides extensibility for future data types, and can be embedded in a wide range of applications. The protocol is not intended to provide complete forms-processing functionality as is provided in the W3C XForms technology, but instead provides a basic subset of such functionality for use by XMPP entities.
This class is immutable.
Modifier and Type | Class and Description |
---|---|
static class |
DataForm.Builder<T extends DataForm.Builder<T>>
An abstract builder to build simple data forms.
|
static class |
DataForm.Field
A data form field.
|
static class |
DataForm.Item
An item which can be understood as a table row.
|
static class |
DataForm.Option
Defines an option in a field of type
DataForm.Field.Type.LIST_SINGLE or DataForm.Field.Type.LIST_MULTI . |
static class |
DataForm.Type
The form type.
|
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
FORM_TYPE
The name of the hidden field, which determines the form type, “FORM_TYPE”.
|
static java.lang.String |
NAMESPACE
jabber:x:data
|
Constructor and Description |
---|
DataForm(DataForm.Builder<? extends DataForm.Builder> builder) |
DataForm(DataForm.Type type)
Creates a data form.
|
DataForm(DataForm.Type type,
java.util.Collection<DataForm.Field> fields)
Creates a data form.
|
DataForm(DataForm.Type type,
java.lang.String title,
java.util.Collection<DataForm.Field> fields,
java.util.Collection<DataForm.Field> reportedFields,
java.util.Collection<DataForm.Item> items,
java.util.Collection<java.lang.String> instructions,
java.util.Collection<Page> pages) |
Modifier and Type | Method and Description |
---|---|
int |
compareTo(DataForm o)
Compares this data form with another data form.
|
DataForm.Field |
findField(java.lang.String name)
Finds a field by its name (‘ver’ attribute).
|
java.lang.String |
findValue(java.lang.String var)
Gets the value for a specific field.
|
boolean |
findValueAsBoolean(java.lang.String var)
Finds the field and gets the value as boolean.
|
java.time.Instant |
findValueAsInstant(java.lang.String var)
Finds the field and gets its value as instant.
|
java.lang.Integer |
findValueAsInteger(java.lang.String var)
Finds the field and gets its value as integer.
|
Jid |
findValueAsJid(java.lang.String var)
Finds the field and gets the value as JID.
|
java.util.List<java.lang.String> |
findValues(java.lang.String var)
Gets the values for a specific field.
|
java.util.List<Jid> |
findValuesAsJid(java.lang.String var)
Finds the field and gets its values as JID list.
|
java.util.List<DataForm.Field> |
getFields()
Gets the fields of the form.
|
java.lang.String |
getFormType()
Gets the form type of this form, i.e. the value of the “FORM_TYPE” field.
|
java.util.List<java.lang.String> |
getInstructions()
Gets the instructions of the form.
|
java.util.List<DataForm.Item> |
getItems()
Gets the items, which can be understood as “table rows” containing data (if any) that matches the request.
|
java.util.List<Page> |
getPages()
Gets the layout pages for this data form.
|
java.util.List<DataForm.Field> |
getReportedFields()
Gets the reported fields, which can be understood as “table headers” describing the data to follow.
|
java.lang.String |
getTitle()
Gets the title of the form.
|
DataForm.Type |
getType()
Gets the type of the form.
|
public static final java.lang.String NAMESPACE
jabber:x:data
public static final java.lang.String FORM_TYPE
The name of the hidden field, which determines the form type, “FORM_TYPE”.
public DataForm(DataForm.Type type)
Creates a data form.
type
- The form type.public DataForm(DataForm.Type type, java.util.Collection<DataForm.Field> fields)
Creates a data form.
type
- The form type.fields
- The fields.public DataForm(DataForm.Builder<? extends DataForm.Builder> builder)
public DataForm(DataForm.Type type, java.lang.String title, java.util.Collection<DataForm.Field> fields, java.util.Collection<DataForm.Field> reportedFields, java.util.Collection<DataForm.Item> items, java.util.Collection<java.lang.String> instructions, java.util.Collection<Page> pages)
public final java.lang.String findValue(java.lang.String var)
Gets the value for a specific field.
var
- The field name.public final java.util.List<java.lang.String> findValues(java.lang.String var)
Gets the values for a specific field.
var
- The field name.public final boolean findValueAsBoolean(java.lang.String var)
Finds the field and gets the value as boolean.
var
- The field name.public final java.lang.Integer findValueAsInteger(java.lang.String var)
Finds the field and gets its value as integer.
var
- The field name.public final java.time.Instant findValueAsInstant(java.lang.String var)
Finds the field and gets its value as instant.
var
- The field name.public final Jid findValueAsJid(java.lang.String var)
Finds the field and gets the value as JID.
var
- The field name.public final java.util.List<Jid> findValuesAsJid(java.lang.String var)
Finds the field and gets its values as JID list. If the field could not be found, an empty list is returned.
var
- The field name.public final java.lang.String getFormType()
Gets the form type of this form, i.e. the value of the “FORM_TYPE” field.
public final java.lang.String getTitle()
Gets the title of the form.
The OPTIONAL
<title/>
and<instructions/>
elements enable the form-processing entity to label the form as a whole and specify natural-language instructions to be followed by the form-submitting entity. The XML character data for these elements SHOULD NOT contain newlines (the \n and \r characters), and any handling of newlines (e.g., presentation in a user interface) is unspecified herein; however, multiple instances of the<instructions/>
element MAY be included.
public final java.util.List<DataForm.Field> getFields()
Gets the fields of the form.
public final java.util.List<java.lang.String> getInstructions()
Gets the instructions of the form.
The OPTIONAL
<title/>
and<instructions/>
elements enable the form-processing entity to label the form as a whole and specify natural-language instructions to be followed by the form-submitting entity. The XML character data for these elements SHOULD NOT contain newlines (the \n and \r characters), and any handling of newlines (e.g., presentation in a user interface) is unspecified herein; however, multiple instances of the<instructions/>
element MAY be included.
public final DataForm.Type getType()
Gets the type of the form.
public final java.util.List<DataForm.Field> getReportedFields()
Gets the reported fields, which can be understood as “table headers” describing the data to follow.
public final java.util.List<DataForm.Item> getItems()
Gets the items, which can be understood as “table rows” containing data (if any) that matches the request.
public final java.util.List<Page> getPages()
Gets the layout pages for this data form.
public final DataForm.Field findField(java.lang.String name)
Finds a field by its name (‘ver’ attribute).
name
- The name.public final int compareTo(DataForm o)
Compares this data form with another data form. Data forms which have a “FORM_TYPE” field are are listed first in a collection.
compareTo
in interface java.lang.Comparable<DataForm>
o
- The other data form.Copyright © 2014–2019 XMPP.rocks. All rights reserved.