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
Nested ClassesModifier and TypeClassDescriptionstatic classFormField.Builder<F extends FormField,B extends FormField.Builder<?, ?>> static classstatic final classRepresents the available options of aListSingleFormFieldandListMultiFormField.static final classstatic enumForm Field Types as defined in XEP-4 § 3.3.static class -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic BooleanFormField.BuilderbooleanBuilder(String fieldName) static TextSingleFormField.Builderstatic TextSingleFormFieldbuildHiddenFormType(String formType) booleanstatic TextSingleFormField.Builderstatic TextSingleFormField.BuilderfixedBuilder(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.inthashCode()booleanstatic TextSingleFormField.BuilderhiddenBuilder(String fieldName) <F extends FormField>
FifPossibleAs(Class<F> formFieldClass) <F extends FormField>
FifPossibleAsOrThrow(Class<F> formFieldClass) booleanReturns true if the question must be answered in order to complete the questionnaire.static JidMultiFormField.BuilderjidMultiBuilder(String fieldName) static JidSingleFormField.BuilderjidSingleBuilder(String fieldName) static ListMultiFormField.BuilderlistMultiBuilder(String fieldName) static ListSingleFormField.BuilderlistSingleBuilder(String fieldName) protected voidPopulateextraXmlChildElements.static TextMultiFormField.BuildertextMultiBuilder(String fieldName) static TextSingleFormField.BuildertextPrivateBuilder(String fieldName) static TextSingleFormField.BuildertextSingleBuilder(String fieldName) final XmlStringBuildertoXML(XmlEnvironment enclosingNamespace) final XmlStringBuildertoXML(XmlEnvironment enclosingNamespace, boolean includeType) Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods 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:NamedElementReturns the root element name.- Specified by:
getElementNamein interfaceNamedElement- Returns:
- the element name.
-
getNamespace
Description copied from interface:XmlElementReturns the root element XML namespace.- Specified by:
getNamespacein interfaceXmlElement- Returns:
- the namespace.
-
getQName
- Specified by:
getQNamein 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
-