mirror of
https://github.com/vanitasvitae/Smack.git
synced 2025-12-15 15:31:08 +01:00
Enable trailing whitespace checkstyle check
for all source code regions, including javadoc.
This commit is contained in:
parent
9d61a6de7d
commit
e8923b9d16
545 changed files with 3713 additions and 3715 deletions
|
|
@ -29,17 +29,17 @@ import org.jivesoftware.smackx.xdata.packet.DataForm;
|
|||
* Represents a Form for gathering data. The form could be of the following types:
|
||||
* <ul>
|
||||
* <li>form → Indicates a form to fill out.</li>
|
||||
* <li>submit → The form is filled out, and this is the data that is being returned from
|
||||
* <li>submit → The form is filled out, and this is the data that is being returned from
|
||||
* the form.</li>
|
||||
* <li>cancel → The form was cancelled. Tell the asker that piece of information.</li>
|
||||
* <li>result → Data results being returned from a search, or some other query.</li>
|
||||
* </ul>
|
||||
*
|
||||
*
|
||||
* Depending of the form's type different operations are available. For example, it's only possible
|
||||
* to set answers if the form is of type "submit".
|
||||
*
|
||||
*
|
||||
* @see <a href="http://xmpp.org/extensions/xep-0004.html">XEP-0004 Data Forms</a>
|
||||
*
|
||||
*
|
||||
* @author Gaston Dombiak
|
||||
*/
|
||||
public class Form {
|
||||
|
|
@ -47,9 +47,9 @@ public class Form {
|
|||
private DataForm dataForm;
|
||||
|
||||
/**
|
||||
* Returns a new ReportedData if the stanza is used for gathering data and includes an
|
||||
* extension that matches the elementName and namespace "x","jabber:x:data".
|
||||
*
|
||||
* Returns a new ReportedData if the stanza is used for gathering data and includes an
|
||||
* extension that matches the elementName and namespace "x","jabber:x:data".
|
||||
*
|
||||
* @param packet the stanza used for gathering data.
|
||||
* @return the data form parsed from the stanza or <tt>null</tt> if there was not
|
||||
* a form in the packet.
|
||||
|
|
@ -67,9 +67,9 @@ public class Form {
|
|||
|
||||
/**
|
||||
* Creates a new Form that will wrap an existing DataForm. The wrapped DataForm must be
|
||||
* used for gathering data.
|
||||
*
|
||||
* @param dataForm the data form used for gathering data.
|
||||
* used for gathering data.
|
||||
*
|
||||
* @param dataForm the data form used for gathering data.
|
||||
*/
|
||||
public Form(DataForm dataForm) {
|
||||
this.dataForm = dataForm;
|
||||
|
|
@ -86,7 +86,7 @@ public class Form {
|
|||
|
||||
/**
|
||||
* Adds a new field to complete as part of the form.
|
||||
*
|
||||
*
|
||||
* @param field the field to complete.
|
||||
*/
|
||||
public void addField(FormField field) {
|
||||
|
|
@ -94,13 +94,13 @@ public class Form {
|
|||
}
|
||||
|
||||
/**
|
||||
* Sets a new String value to a given form's field. The field whose variable matches the
|
||||
* requested variable will be completed with the specified value. If no field could be found
|
||||
* Sets a new String value to a given form's field. The field whose variable matches the
|
||||
* requested variable will be completed with the specified value. If no field could be found
|
||||
* for the specified variable then an exception will be raised.<p>
|
||||
*
|
||||
*
|
||||
* If the value to set to the field is not a basic type (e.g. String, boolean, int, etc.) you
|
||||
* can use this message where the String value is the String representation of the object.
|
||||
*
|
||||
* can use this message where the String value is the String representation of the object.
|
||||
*
|
||||
* @param variable the variable name that was completed.
|
||||
* @param value the String value that was answered.
|
||||
* @throws IllegalStateException if the form is not of type "submit".
|
||||
|
|
@ -126,10 +126,10 @@ public class Form {
|
|||
}
|
||||
|
||||
/**
|
||||
* Sets a new int value to a given form's field. The field whose variable matches the
|
||||
* requested variable will be completed with the specified value. If no field could be found
|
||||
* Sets a new int value to a given form's field. The field whose variable matches the
|
||||
* requested variable will be completed with the specified value. If no field could be found
|
||||
* for the specified variable then an exception will be raised.
|
||||
*
|
||||
*
|
||||
* @param variable the variable name that was completed.
|
||||
* @param value the int value that was answered.
|
||||
* @throws IllegalStateException if the form is not of type "submit".
|
||||
|
|
@ -146,10 +146,10 @@ public class Form {
|
|||
}
|
||||
|
||||
/**
|
||||
* Sets a new long value to a given form's field. The field whose variable matches the
|
||||
* requested variable will be completed with the specified value. If no field could be found
|
||||
* Sets a new long value to a given form's field. The field whose variable matches the
|
||||
* requested variable will be completed with the specified value. If no field could be found
|
||||
* for the specified variable then an exception will be raised.
|
||||
*
|
||||
*
|
||||
* @param variable the variable name that was completed.
|
||||
* @param value the long value that was answered.
|
||||
* @throws IllegalStateException if the form is not of type "submit".
|
||||
|
|
@ -166,10 +166,10 @@ public class Form {
|
|||
}
|
||||
|
||||
/**
|
||||
* Sets a new float value to a given form's field. The field whose variable matches the
|
||||
* requested variable will be completed with the specified value. If no field could be found
|
||||
* Sets a new float value to a given form's field. The field whose variable matches the
|
||||
* requested variable will be completed with the specified value. If no field could be found
|
||||
* for the specified variable then an exception will be raised.
|
||||
*
|
||||
*
|
||||
* @param variable the variable name that was completed.
|
||||
* @param value the float value that was answered.
|
||||
* @throws IllegalStateException if the form is not of type "submit".
|
||||
|
|
@ -186,10 +186,10 @@ public class Form {
|
|||
}
|
||||
|
||||
/**
|
||||
* Sets a new double value to a given form's field. The field whose variable matches the
|
||||
* requested variable will be completed with the specified value. If no field could be found
|
||||
* Sets a new double value to a given form's field. The field whose variable matches the
|
||||
* requested variable will be completed with the specified value. If no field could be found
|
||||
* for the specified variable then an exception will be raised.
|
||||
*
|
||||
*
|
||||
* @param variable the variable name that was completed.
|
||||
* @param value the double value that was answered.
|
||||
* @throws IllegalStateException if the form is not of type "submit".
|
||||
|
|
@ -217,10 +217,10 @@ public class Form {
|
|||
}
|
||||
|
||||
/**
|
||||
* Sets a new boolean value to a given form's field. The field whose variable matches the
|
||||
* requested variable will be completed with the specified value. If no field could be found
|
||||
* Sets a new boolean value to a given form's field. The field whose variable matches the
|
||||
* requested variable will be completed with the specified value. If no field could be found
|
||||
* for the specified variable then an exception will be raised.
|
||||
*
|
||||
*
|
||||
* @param variable the variable name that was completed.
|
||||
* @param value the boolean value that was answered.
|
||||
* @throws IllegalStateException if the form is not of type "submit".
|
||||
|
|
@ -239,19 +239,19 @@ public class Form {
|
|||
}
|
||||
|
||||
/**
|
||||
* Sets a new Object value to a given form's field. In fact, the object representation
|
||||
* Sets a new Object value to a given form's field. In fact, the object representation
|
||||
* (i.e. #toString) will be the actual value of the field.<p>
|
||||
*
|
||||
*
|
||||
* If the value to set to the field is not a basic type (e.g. String, boolean, int, etc.) you
|
||||
* will need to use {@link #setAnswer(String, String)} where the String value is the
|
||||
* String representation of the object.<p>
|
||||
*
|
||||
* Before setting the new value to the field we will check if the form is of type submit. If
|
||||
* the form isn't of type submit means that it's not possible to complete the form and an
|
||||
* will need to use {@link #setAnswer(String, String)} where the String value is the
|
||||
* String representation of the object.<p>
|
||||
*
|
||||
* Before setting the new value to the field we will check if the form is of type submit. If
|
||||
* the form isn't of type submit means that it's not possible to complete the form and an
|
||||
* exception will be thrown.
|
||||
*
|
||||
*
|
||||
* @param field the form field that was completed.
|
||||
* @param value the Object value that was answered. The object representation will be the
|
||||
* @param value the Object value that was answered. The object representation will be the
|
||||
* actual value.
|
||||
* @throws IllegalStateException if the form is not of type "submit".
|
||||
*/
|
||||
|
|
@ -265,13 +265,13 @@ public class Form {
|
|||
}
|
||||
|
||||
/**
|
||||
* Sets a new values to a given form's field. The field whose variable matches the requested
|
||||
* variable will be completed with the specified values. If no field could be found for
|
||||
* Sets a new values to a given form's field. The field whose variable matches the requested
|
||||
* variable will be completed with the specified values. If no field could be found for
|
||||
* the specified variable then an exception will be raised.<p>
|
||||
*
|
||||
*
|
||||
* The Objects contained in the List could be of any type. The String representation of them
|
||||
* (i.e. #toString) will be actually used when sending the answer to the server.
|
||||
*
|
||||
*
|
||||
* @param variable the variable that was completed.
|
||||
* @param values the values that were answered.
|
||||
* @throws IllegalStateException if the form is not of type "submit".
|
||||
|
|
@ -295,7 +295,7 @@ public class Form {
|
|||
default:
|
||||
throw new IllegalArgumentException("This field only accept list of values.");
|
||||
}
|
||||
// Clear the old values
|
||||
// Clear the old values
|
||||
field.resetValues();
|
||||
// Set the new values. The string representation of each value will be actually used.
|
||||
field.addValues(values);
|
||||
|
|
@ -344,10 +344,10 @@ public class Form {
|
|||
|
||||
/**
|
||||
* Returns the field of the form whose variable matches the specified variable.
|
||||
* The fields of type FIXED will never be returned since they do not specify a
|
||||
* variable.
|
||||
*
|
||||
* @param variable the variable to look for in the form fields.
|
||||
* The fields of type FIXED will never be returned since they do not specify a
|
||||
* variable.
|
||||
*
|
||||
* @param variable the variable to look for in the form fields.
|
||||
* @return the field of the form whose variable matches the specified variable.
|
||||
*/
|
||||
public FormField getField(String variable) {
|
||||
|
|
@ -367,7 +367,7 @@ public class Form {
|
|||
|
||||
/**
|
||||
* Returns the instructions that explain how to fill out the form and what the form is about.
|
||||
*
|
||||
*
|
||||
* @return instructions that explain how to fill out the form.
|
||||
*/
|
||||
public String getInstructions() {
|
||||
|
|
@ -385,9 +385,9 @@ public class Form {
|
|||
|
||||
|
||||
/**
|
||||
* Returns the description of the data. It is similar to the title on a web page or an X
|
||||
* Returns the description of the data. It is similar to the title on a web page or an X
|
||||
* window. You can put a title on either a form to fill out, or a set of data results.
|
||||
*
|
||||
*
|
||||
* @return description of the data.
|
||||
*/
|
||||
public String getTitle() {
|
||||
|
|
@ -398,17 +398,17 @@ public class Form {
|
|||
/**
|
||||
* Returns the meaning of the data within the context. The data could be part of a form
|
||||
* to fill out, a form submission or data results.
|
||||
*
|
||||
*
|
||||
* @return the form's type.
|
||||
*/
|
||||
public DataForm.Type getType() {
|
||||
return dataForm.getType();
|
||||
return dataForm.getType();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets instructions that explain how to fill out the form and what the form is about.
|
||||
*
|
||||
*
|
||||
* @param instructions instructions that explain how to fill out the form.
|
||||
*/
|
||||
public void setInstructions(String instructions) {
|
||||
|
|
@ -427,7 +427,7 @@ public class Form {
|
|||
/**
|
||||
* Sets the description of the data. It is similar to the title on a web page or an X window.
|
||||
* You can put a title on either a form to fill out, or a set of data results.
|
||||
*
|
||||
*
|
||||
* @param title description of the data.
|
||||
*/
|
||||
public void setTitle(String title) {
|
||||
|
|
@ -435,15 +435,15 @@ public class Form {
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns a DataForm that serves to send this Form to the server. If the form is of type
|
||||
* submit, it may contain fields with no value. These fields will be removed since they only
|
||||
* exist to assist the user while editing/completing the form in a UI.
|
||||
*
|
||||
* Returns a DataForm that serves to send this Form to the server. If the form is of type
|
||||
* submit, it may contain fields with no value. These fields will be removed since they only
|
||||
* exist to assist the user while editing/completing the form in a UI.
|
||||
*
|
||||
* @return the wrapped DataForm.
|
||||
*/
|
||||
public DataForm getDataFormToSend() {
|
||||
if (isSubmitType()) {
|
||||
// Create a new DataForm that contains only the answered fields
|
||||
// Create a new DataForm that contains only the answered fields
|
||||
DataForm dataFormToSend = new DataForm(getType());
|
||||
for (FormField field : getFields()) {
|
||||
if (!field.getValues().isEmpty()) {
|
||||
|
|
@ -457,7 +457,7 @@ public class Form {
|
|||
|
||||
/**
|
||||
* Returns true if the form is a form to fill out.
|
||||
*
|
||||
*
|
||||
* @return if the form is a form to fill out.
|
||||
*/
|
||||
private boolean isFormType() {
|
||||
|
|
@ -466,7 +466,7 @@ public class Form {
|
|||
|
||||
/**
|
||||
* Returns true if the form is a form to submit.
|
||||
*
|
||||
*
|
||||
* @return if the form is a form to submit.
|
||||
*/
|
||||
private boolean isSubmitType() {
|
||||
|
|
@ -475,16 +475,16 @@ public class Form {
|
|||
|
||||
/**
|
||||
* Returns a new Form to submit the completed values. The new Form will include all the fields
|
||||
* of the original form except for the fields of type FIXED. Only the HIDDEN fields will
|
||||
* include the same value of the original form. The other fields of the new form MUST be
|
||||
* completed. If a field remains with no answer when sending the completed form, then it won't
|
||||
* of the original form except for the fields of type FIXED. Only the HIDDEN fields will
|
||||
* include the same value of the original form. The other fields of the new form MUST be
|
||||
* completed. If a field remains with no answer when sending the completed form, then it won't
|
||||
* be included as part of the completed form.<p>
|
||||
*
|
||||
* The reason why the fields with variables are included in the new form is to provide a model
|
||||
* for binding with any UI. This means that the UIs will use the original form (of type
|
||||
*
|
||||
* The reason why the fields with variables are included in the new form is to provide a model
|
||||
* for binding with any UI. This means that the UIs will use the original form (of type
|
||||
* "form") to learn how to render the form, but the UIs will bind the fields to the form of
|
||||
* type submit.
|
||||
*
|
||||
*
|
||||
* @return a Form to submit the completed values.
|
||||
*/
|
||||
public Form createAnswerForm() {
|
||||
|
|
@ -500,9 +500,9 @@ public class Form {
|
|||
FormField newField = new FormField(field.getVariable());
|
||||
newField.setType(field.getType());
|
||||
form.addField(newField);
|
||||
// Set the answer ONLY to the hidden fields
|
||||
// Set the answer ONLY to the hidden fields
|
||||
if (field.getType() == FormField.Type.hidden) {
|
||||
// Since a hidden field could have many values we need to collect them
|
||||
// Since a hidden field could have many values we need to collect them
|
||||
// in a list
|
||||
List<CharSequence> values = new ArrayList<>();
|
||||
values.addAll(field.getValues());
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ public class FormField implements NamedElement {
|
|||
|
||||
/**
|
||||
* Form Field Types as defined in XEP-4 § 3.3.
|
||||
*
|
||||
*
|
||||
* @see <a href="http://xmpp.org/extensions/xep-0004.html#protocol-fieldtypes">XEP-4 § 3.3 Field Types</a>
|
||||
*/
|
||||
public enum Type {
|
||||
|
|
@ -273,7 +273,7 @@ public class FormField implements NamedElement {
|
|||
* "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")
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @return the variable name of the question.
|
||||
*/
|
||||
public String getVariable() {
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ public final class XDataManager extends Manager {
|
|||
* @throws NoResponseException
|
||||
* @throws XMPPErrorException
|
||||
* @throws NotConnectedException
|
||||
* @throws InterruptedException
|
||||
* @throws InterruptedException
|
||||
* @see <a href="http://xmpp.org/extensions/xep-0004.html#disco">XEP-0004: Data Forms § 6. Service Discovery</a>
|
||||
* @since 4.1
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -84,17 +84,17 @@ public class DataForm implements ExtensionElement {
|
|||
/**
|
||||
* Returns the meaning of the data within the context. The data could be part of a form
|
||||
* to fill out, a form submission or data results.
|
||||
*
|
||||
*
|
||||
* @return the form's type.
|
||||
*/
|
||||
public Type getType() {
|
||||
return type;
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the description of the data. It is similar to the title on a web page or an X
|
||||
* Returns the description of the data. It is similar to the title on a web page or an X
|
||||
* window. You can put a <title/> on either a form to fill out, or a set of data results.
|
||||
*
|
||||
*
|
||||
* @return description of the data.
|
||||
*/
|
||||
public String getTitle() {
|
||||
|
|
@ -102,11 +102,11 @@ public class DataForm implements ExtensionElement {
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns a List of 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. Join the instructions together in order
|
||||
* Returns a List of 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. Join the instructions together in order
|
||||
* to show them to the user.
|
||||
*
|
||||
*
|
||||
* @return a List of the list of instructions that explain how to fill out the form.
|
||||
*/
|
||||
public List<String> getInstructions() {
|
||||
|
|
@ -117,7 +117,7 @@ public class DataForm implements ExtensionElement {
|
|||
|
||||
/**
|
||||
* Returns the fields that will be returned from a search.
|
||||
*
|
||||
*
|
||||
* @return fields that will be returned from a search.
|
||||
*/
|
||||
public ReportedData getReportedData() {
|
||||
|
|
@ -185,7 +185,7 @@ public class DataForm implements ExtensionElement {
|
|||
/**
|
||||
* Sets the description of the data. It is similar to the title on a web page or an X window.
|
||||
* You can put a <title/> on either a form to fill out, or a set of data results.
|
||||
*
|
||||
*
|
||||
* @param title description of the data.
|
||||
*/
|
||||
public void setTitle(String title) {
|
||||
|
|
@ -193,10 +193,10 @@ public class DataForm implements ExtensionElement {
|
|||
}
|
||||
|
||||
/**
|
||||
* Sets 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.
|
||||
*
|
||||
* Sets 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.
|
||||
*
|
||||
* @param instructions list of instructions that explain how to fill out the form.
|
||||
*/
|
||||
public void setInstructions(List<String> instructions) {
|
||||
|
|
@ -208,7 +208,7 @@ public class DataForm implements ExtensionElement {
|
|||
|
||||
/**
|
||||
* Sets the fields that will be returned from a search.
|
||||
*
|
||||
*
|
||||
* @param reportedData the fields that will be returned from a search.
|
||||
*/
|
||||
public void setReportedData(ReportedData reportedData) {
|
||||
|
|
@ -217,7 +217,7 @@ public class DataForm implements ExtensionElement {
|
|||
|
||||
/**
|
||||
* Adds a new field as part of the form.
|
||||
*
|
||||
*
|
||||
* @param field the field to add to the form.
|
||||
*/
|
||||
public void addField(FormField field) {
|
||||
|
|
@ -235,10 +235,10 @@ public class DataForm implements ExtensionElement {
|
|||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @param instruction the new instruction that explain how to fill out the form.
|
||||
*/
|
||||
public void addInstruction(String instruction) {
|
||||
|
|
@ -249,7 +249,7 @@ public class DataForm implements ExtensionElement {
|
|||
|
||||
/**
|
||||
* Adds a new item returned from a search.
|
||||
*
|
||||
*
|
||||
* @param item the item returned from a search.
|
||||
*/
|
||||
public void addItem(Item item) {
|
||||
|
|
@ -329,8 +329,8 @@ public class DataForm implements ExtensionElement {
|
|||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Represents the fields that will be returned from a search. This information is useful when
|
||||
*
|
||||
* Represents the fields that will be returned from a search. This information is useful when
|
||||
* you try to use the jabber:iq:search namespace to return dynamic form information.
|
||||
*
|
||||
* @author Gaston Dombiak
|
||||
|
|
@ -346,7 +346,7 @@ public class DataForm implements ExtensionElement {
|
|||
|
||||
/**
|
||||
* Returns the fields returned from a search.
|
||||
*
|
||||
*
|
||||
* @return the fields returned from a search.
|
||||
*/
|
||||
public List<FormField> getFields() {
|
||||
|
|
@ -366,7 +366,7 @@ public class DataForm implements ExtensionElement {
|
|||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* Represents items of reported data.
|
||||
*
|
||||
* @author Gaston Dombiak
|
||||
|
|
@ -382,7 +382,7 @@ public class DataForm implements ExtensionElement {
|
|||
|
||||
/**
|
||||
* Returns the fields that define the data that goes with the item.
|
||||
*
|
||||
*
|
||||
* @return the fields that define the data that goes with the item.
|
||||
*/
|
||||
public List<FormField> getFields() {
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ import org.xmlpull.v1.XmlPullParserException;
|
|||
|
||||
/**
|
||||
* The DataFormProvider parses DataForm packets.
|
||||
*
|
||||
*
|
||||
* @author Gaston Dombiak
|
||||
*/
|
||||
public class DataFormProvider extends ExtensionElementProvider<DataForm> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue