public static final class DataForm.Field extends Object implements Comparable<DataForm.Field>
// <field type="boolean" var="test"><value>1</value></field>
DataForm.Field field = DataForm.Field.builder()
.var("test")
.value(true)
.build();
// <field type="jid-single" var="test"><value>domain</value></field>
DataForm.Field.builder()
.var("test")
.value(Jid.of("domain"))
.build();
// <field type="list-single" var="test"><option><value>option</value></option></field>
DataForm.Field field = DataForm.Field.builder()
.var("test")
.type(DataForm.Field.Type.LIST_SINGLE)
.options(Collections.singleton(new DataForm.Option("option")))
.build();
// Interprets the field value as integer, e.g. <value>123</value>
Integer intValue = field.getValueAsInteger();
// Interprets the field value as boolean, e.g. <value>1</value>
boolean boolValue = field.getValueAsBoolean();
This class is immutable.| Modifier and Type | Class and Description |
|---|---|
static class |
DataForm.Field.Builder
A builder class to build a data form field.
|
static class |
DataForm.Field.Type
Defines field types.
|
| Modifier and Type | Method and Description |
|---|---|
static DataForm.Field.Builder |
builder()
Creates the builder to build a data form field.
|
int |
compareTo(DataForm.Field o) |
String |
getDescription()
Gets a natural-language description of the field, intended for presentation in a user-agent (e.g., as a "tool-tip", help button, or explanatory text provided near the field).
|
String |
getLabel()
Gets the field label.
|
Media |
getMedia()
Gets the media element.
|
List<DataForm.Option> |
getOptions()
Gets the options if the field type is
DataForm.Field.Type.LIST_SINGLE or DataForm.Field.Type.LIST_MULTI. |
DataForm.Field.Type |
getType()
Gets the field type.
|
Validation |
getValidation()
Gets the validation for this field.
|
String |
getValue()
Gets the value of the field.
|
boolean |
getValueAsBoolean()
Gets the value as boolean.
|
Instant |
getValueAsInstant()
Returns the first value as date.
|
Integer |
getValueAsInteger()
Returns the first value as integer.
|
Jid |
getValueAsJid()
Returns the first value as JID, e.g. for the
DataForm.Field.Type.JID_SINGLE field type. |
List<String> |
getValues()
Gets the values of the field.
|
List<Jid> |
getValuesAsJid()
Returns a JID list for the
DataForm.Field.Type.JID_MULTI field type. |
String |
getVar()
Gets a unique identifier for the field in the context of the form.
|
boolean |
isRequired()
If the field as required in order for the form to be considered valid.
|
String |
toString() |
public static DataForm.Field.Builder builder()
public final DataForm.Field.Type getType()
public final String getVar()
public final String getLabel()
public final List<DataForm.Option> getOptions()
DataForm.Field.Type.LIST_SINGLE or DataForm.Field.Type.LIST_MULTI.public final List<String> getValues()
DataForm.Field.Type.LIST_MULTI, DataForm.Field.Type.JID_MULTI or DataForm.Field.Type.TEXT_MULTI may contain multiple values.public final String getValue()
public final boolean getValueAsBoolean()
public final Integer getValueAsInteger()
public final Instant getValueAsInstant()
public final List<Jid> getValuesAsJid()
DataForm.Field.Type.JID_MULTI field type.public final Jid getValueAsJid()
DataForm.Field.Type.JID_SINGLE field type.public final Media getMedia()
public final String getDescription()
public final Validation getValidation()
public final boolean isRequired()
public final int compareTo(DataForm.Field o)
compareTo in interface Comparable<DataForm.Field>Copyright © 2014–2018 XMPP.rocks. All rights reserved.