Package org.jivesoftware.smackx.xdata
Class FormField
java.lang.Object
org.jivesoftware.smackx.xdata.FormField
- All Implemented Interfaces:
Element
,NamedElement
,XmlElement
,XmlLangElement
- Direct Known Subclasses:
AbstractMultiFormField
,JidMultiFormField
,SingleValueFormField
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.
Fields have a name, which is stored in the 'var' attribute of the field's XML representation. Field instances of all types, except of type "fixed" must have a name.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
FormField.Builder<F extends FormField,
B extends FormField.Builder<?, ?>> static class
static final class
Represents the available options of aListSingleFormField
andListMultiFormField
.static final class
static enum
Form Field Types as defined in XEP-4 § 3.3.static class
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic BooleanFormField.Builder
booleanBuilder
(String fieldName) static TextSingleFormField.Builder
static TextSingleFormField
buildHiddenFormType
(String formType) boolean
static TextSingleFormField.Builder
static TextSingleFormField.Builder
fixedBuilder
(String fieldName) Returns a description that provides extra clarification about the question.Returns the root element name.Returns the field's name, also known as the variable name in case this is an filled out answer form.Returns the first value of this form field ornull
.Parses the first value of this form field as XEP-0082 date/time format and returns a date instance ornull
.getFormFieldChildElement
(QName qname) getFormFieldChildElements
(QName qname) getLabel()
Returns the label of the question which should give enough information to the user to fill out the form.Returns the root element XML namespace.getQName()
final List<CharSequence>
abstract List<FormField.Value>
getType()
Returns an indicative of the format for the data to answer.List<? extends CharSequence>
Returns a List of the default values of the question if the question is part of a form to fill out.Returns the values a String.int
hashCode()
boolean
static TextSingleFormField.Builder
hiddenBuilder
(String fieldName) <F extends FormField>
FifPossibleAs
(Class<F> formFieldClass) <F extends FormField>
FifPossibleAsOrThrow
(Class<F> formFieldClass) boolean
Returns true if the question must be answered in order to complete the questionnaire.static JidMultiFormField.Builder
jidMultiBuilder
(String fieldName) static JidSingleFormField.Builder
jidSingleBuilder
(String fieldName) static ListMultiFormField.Builder
listMultiBuilder
(String fieldName) static ListSingleFormField.Builder
listSingleBuilder
(String fieldName) protected void
PopulateextraXmlChildElements
.static TextMultiFormField.Builder
textMultiBuilder
(String fieldName) static TextSingleFormField.Builder
textPrivateBuilder
(String fieldName) static TextSingleFormField.Builder
textSingleBuilder
(String fieldName) final XmlStringBuilder
toXML
(XmlEnvironment enclosingNamespace) final XmlStringBuilder
toXML
(XmlEnvironment enclosingNamespace, boolean includeType) Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.jivesoftware.smack.packet.XmlElement
getLanguage
-
Field Details
-
ELEMENT
- See Also:
-
NAMESPACE
- See Also:
-
QNAME
-
FORM_TYPE
The constant String "FORM_TYPE".- See Also:
-
extraXmlChildElements
-
-
Constructor Details
-
FormField
-
-
Method Details
-
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
Returns the label of the question which should give enough information to the user to fill out the form.- Returns:
- label of the question.
-
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
Returns an indicative of the format for the data to answer.- Returns:
- format for the data to answer.
- See Also:
-
getValues
Returns a List of the default values of the question if the question is part of a form to fill out. Otherwise, returns a List of the answered values of the question.- Returns:
- a List of the default values or answered values of the question.
-
getRawValues
-
getRawValueCharSequences
-
hasValueSet
-
getValuesAsString
Returns the values a String. Note that you should usegetValues()
whenever possible instead of this method.- Returns:
- a list of Strings representing the values
- Since:
- 4.3
- See Also:
-
getFirstValue
Returns the first value of this form field ornull
.- Returns:
- the first value or
null
- Since:
- 4.3
-
getFirstValueAsDate
Parses the first value of this form field as XEP-0082 date/time format and returns a date instance ornull
.- Returns:
- a Date instance representing the date/time information of the first value of this field.
- Throws:
ParseException
- if parsing fails.- Since:
- 4.3.0
-
getFieldName
Returns the field's name, also known as the variable name in case this is an filled out answer form.According to XEP-4 § 3.2 the variable name (the 'var' attribute) "uniquely identifies the field in the context of the form" (if the field is not of type 'fixed', in which case the field "MAY possess a 'var' attribute")
- Returns:
- the field's name.
-
getFormFieldChildElement
-
getFormFieldChildElements
-
getFormFieldChildElements
-
getElementName
Description copied from interface:NamedElement
Returns the root element name.- Specified by:
getElementName
in interfaceNamedElement
- Returns:
- the element name.
-
getNamespace
Description copied from interface:XmlElement
Returns the root element XML namespace.- Specified by:
getNamespace
in interfaceXmlElement
- Returns:
- the namespace.
-
getQName
- Specified by:
getQName
in interfaceXmlElement
-
populateExtraXmlChildElements
PopulateextraXmlChildElements
. Note that this method may be overridden by subclasses. -
toXML
-
toXML
-
equals
-
hashCode
-
booleanBuilder
-
fixedBuilder
-
fixedBuilder
-
jidMultiBuilder
-
jidSingleBuilder
-
listMultiBuilder
-
listSingleBuilder
-
textMultiBuilder
-
textPrivateBuilder
-
textSingleBuilder
-
builder
-
buildHiddenFormType
-
ifPossibleAs
-
ifPossibleAsOrThrow
-
asHiddenFormTypeFieldIfPossible
-