Tabnine Logo
Form.getField
Code IndexAdd Tabnine to your IDE (free)

How to use
getField
method
in
org.jivesoftware.smackx.xdata.Form

Best Java code snippets using org.jivesoftware.smackx.xdata.Form.getField (Showing top 16 results out of 315)

origin: igniterealtime/Smack

/**
 * 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".
 * @throws IllegalArgumentException if the form does not include the specified variable or
 *      if the answer type does not correspond with the field type.
 */
public void setAnswer(String variable, boolean value) {
  FormField field = getField(variable);
  if (field == null) {
    throw new IllegalArgumentException("Field not found for the specified variable name.");
  }
  if (field.getType() != FormField.Type.bool) {
    throw new IllegalArgumentException("This field is not of type boolean.");
  }
  setAnswer(field, Boolean.toString(value));
}
origin: igniterealtime/Smack

List<CharSequence> ownerStrings = answerForm.getField(MUC_ROOMCONFIG_ROOMOWNERS).getValues();
owners = new ArrayList<>(ownerStrings.size());
JidUtil.jidsFrom(ownerStrings, owners, null);
origin: igniterealtime/Smack

/**
 * 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".
 * @throws IllegalArgumentException if the form does not include the specified variable or
 *      if the answer type does not correspond with the field type.
 */
public void setAnswer(String variable, int value) {
  FormField field = getField(variable);
  if (field == null) {
    throw new IllegalArgumentException("Field not found for the specified variable name.");
  }
  validateThatFieldIsText(field);
  setAnswer(field, value);
}
origin: igniterealtime/Smack

/**
 * 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".
 * @throws IllegalArgumentException if the form does not include the specified variable or
 *      if the answer type does not correspond with the field type.
 */
public void setAnswer(String variable, long value) {
  FormField field = getField(variable);
  if (field == null) {
    throw new IllegalArgumentException("Field not found for the specified variable name.");
  }
  validateThatFieldIsText(field);
  setAnswer(field, value);
}
origin: igniterealtime/Smack

/**
 * 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".
 * @throws IllegalArgumentException if the form does not include the specified variable or
 *      if the answer type does not correspond with the field type.
 */
public void setAnswer(String variable, float value) {
  FormField field = getField(variable);
  if (field == null) {
    throw new IllegalArgumentException("Field not found for the specified variable name.");
  }
  validateThatFieldIsText(field);
  setAnswer(field, value);
}
origin: igniterealtime/Smack

/**
 * 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".
 * @throws IllegalArgumentException if the form does not include the specified variable or
 *      if the answer type does not correspond with the field type.
 */
public void setAnswer(String variable, double value) {
  FormField field = getField(variable);
  if (field == null) {
    throw new IllegalArgumentException("Field not found for the specified variable name.");
  }
  validateThatFieldIsText(field);
  setAnswer(field, value);
}
origin: igniterealtime/Smack

FormField field = getField(variable);
if (field == null) {
  throw new IllegalArgumentException("Field not found for the specified variable name.");
origin: igniterealtime/Smack

public void addUser(final EntityBareJid userJid, final String password)
        throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
  RemoteCommand command = addUser();
  command.execute();
  Form answerForm = command.getForm().createAnswerForm();
  FormField accountJidField = answerForm.getField("accountjid");
  accountJidField.addValue(userJid.toString());
  FormField passwordField = answerForm.getField("password");
  passwordField.addValue(password);
  FormField passwordVerifyField = answerForm.getField("password-verify");
  passwordVerifyField.addValue(password);
  command.execute(answerForm);
  assert (command.isCompleted());
}
origin: igniterealtime/Smack

/**
 * Sets the default value as the value of a given form's field. The field whose variable matches
 * the requested variable will be completed with its default value. If no field could be found
 * for the specified variable then an exception will be raised.
 *
 * @param variable the variable to complete with its default value.
 * @throws IllegalStateException if the form is not of type "submit".
 * @throws IllegalArgumentException if the form does not include the specified variable.
 */
public void setDefaultAnswer(String variable) {
  if (!isSubmitType()) {
    throw new IllegalStateException("Cannot set an answer if the form is not of type " +
    "\"submit\"");
  }
  FormField field = getField(variable);
  if (field != null) {
    // Clear the old values
    field.resetValues();
    // Set the default value
    for (CharSequence value : field.getValues()) {
      field.addValue(value);
    }
  }
  else {
    throw new IllegalArgumentException("Couldn't find a field for the specified variable.");
  }
}
origin: igniterealtime/Smack

  "\"submit\"");
FormField field = getField(variable);
if (field != null) {
origin: igniterealtime/Smack

/**
 * Returns the number of offline messages for the user of the connection.
 *
 * @return the number of offline messages for the user of the connection.
 * @throws XMPPErrorException If the user is not allowed to make this request or the server does
 *                       not support offline message retrieval.
 * @throws NoResponseException if there was no response from the server.
 * @throws NotConnectedException
 * @throws InterruptedException
 */
public int getMessageCount() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
  DiscoverInfo info = ServiceDiscoveryManager.getInstanceFor(connection).discoverInfo(null,
      namespace);
  Form extendedInfo = Form.getFormFrom(info);
  if (extendedInfo != null) {
    String value = extendedInfo.getField("number_of_messages").getFirstValue();
    return Integer.parseInt(value);
  }
  return 0;
}
origin: igniterealtime/Smack

FormField descField = form.getField("muc#roominfo_description");
if (descField != null && !descField.getValues().isEmpty()) {
FormField subjField = form.getField("muc#roominfo_subject");
if (subjField != null && !subjField.getValues().isEmpty()) {
  subject = subjField.getFirstValue();
FormField occCountField = form.getField("muc#roominfo_occupants");
if (occCountField != null && !occCountField.getValues().isEmpty()) {
  occupantsCount = Integer.parseInt(occCountField.getFirstValue());
FormField maxhistoryfetchField = form.getField("muc#maxhistoryfetch");
if (maxhistoryfetchField != null && !maxhistoryfetchField.getValues().isEmpty()) {
  maxhistoryfetch = Integer.parseInt(maxhistoryfetchField.getFirstValue());
FormField contactJidField = form.getField("muc#roominfo_contactjid");
if (contactJidField != null && !contactJidField.getValues().isEmpty()) {
  List<CharSequence> contactJidValues = contactJidField.getValues();
FormField langField = form.getField("muc#roominfo_lang");
if (langField != null && !langField.getValues().isEmpty()) {
  lang = langField.getFirstValue();
FormField ldapgroupField = form.getField("muc#roominfo_ldapgroup");
if (ldapgroupField != null && !ldapgroupField.getValues().isEmpty()) {
  ldapgroup = ldapgroupField.getFirstValue();
FormField subjectmodField = form.getField("muc#roominfo_subjectmod");
if (subjectmodField != null && !subjectmodField.getValues().isEmpty()) {
origin: igniterealtime/Smack

/**
 * Creates a node with specified configuration.
 *
 * Note: This is the only way to create a collection node.
 *
 * @param nodeId The name of the node, which must be unique within the
 * pubsub service
 * @param config The configuration for the node
 * @return The node that was created
 * @throws XMPPErrorException
 * @throws NoResponseException
 * @throws NotConnectedException
 * @throws InterruptedException
 */
public Node createNode(String nodeId, Form config) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
  PubSub request = PubSub.createPubsubPacket(pubSubService, Type.set, new NodeExtension(PubSubElementType.CREATE, nodeId));
  boolean isLeafNode = true;
  if (config != null) {
    request.addExtension(new FormNode(FormNodeType.CONFIGURE, config));
    FormField nodeTypeField = config.getField(ConfigureNodeFields.node_type.getFieldName());
    if (nodeTypeField != null)
      isLeafNode = nodeTypeField.getValues().get(0).toString().equals(NodeType.leaf.toString());
  }
  // Errors will cause exceptions in getReply, so it only returns
  // on success.
  sendPubsubPacket(request);
  Node newNode = isLeafNode ? new LeafNode(this, nodeId) : new CollectionNode(this, nodeId);
  nodeMap.put(newNode.getId(), newNode);
  return newNode;
}
origin: igniterealtime/Smack

  public void deleteUser(Set<EntityBareJid> jidsToDelete)
          throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
    RemoteCommand command = deleteUser();
    command.execute();

    Form answerForm = command.getForm().createAnswerForm();

    FormField accountJids = answerForm.getField("accountjids");
    accountJids.addValues(JidUtil.toStringList(jidsToDelete));

    command.execute(answerForm);
    assert (command.isCompleted());
  }
}
origin: igniterealtime/Smack

assertNotNull(formToRespond.getField("name"));
assertNotNull(formToRespond.getField("description"));
assertNotNull(completedForm.getField("hidden_var"));
assertNotNull(completedForm.getField("name"));
assertNotNull(completedForm.getField("description"));
assertEquals(
   completedForm.getField("name").getValues().get(0).toString(),
  "Credit card number invalid");
assertNotNull(completedForm.getField("time"));
assertNotNull(completedForm.getField("age"));
assertEquals("The age is bad", "20", completedForm.getField("age").getValues().get(0).toString());
origin: jitsi/jicofo

FormField whois = answer.getField(whoisFieldName);
if (whois == null)
org.jivesoftware.smackx.xdataFormgetField

Javadoc

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.

Popular methods of Form

  • createAnswerForm
    Returns a new Form to submit the completed values. The new Form will include all the fields of the o
  • setAnswer
    Sets a new Object value to a given form's field. In fact, the object representation (i.e. #toString)
  • <init>
    Creates a new Form that will wrap an existing DataForm. The wrapped DataForm must be used for gather
  • addField
    Adds a new field to complete as part of the form.
  • getDataFormToSend
    Returns a DataForm that serves to send this Form to the server. If the form is of type submit, it ma
  • getFields
    Returns a List of the fields that are part of the form.
  • getFormFrom
    Returns a new ReportedData if the stanza is used for gathering data and includes an extension that m
  • setDefaultAnswer
    Sets the default value as the value of a given form's field. The field whose variable matches the re
  • getInstructions
    Returns the instructions that explain how to fill out the form and what the form is about.
  • getType
    Returns the meaning of the data within the context. The data could be part of a form to fill out, a
  • hasField
    Check if a field with the given variable exists.
  • isFormType
    Returns true if the form is a form to fill out.
  • hasField,
  • isFormType,
  • isSubmitType,
  • setInstructions,
  • setTitle,
  • validateThatFieldIsText

Popular in Java

  • Creating JSON documents from java classes using gson
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • findViewById (Activity)
  • requestLocationUpdates (LocationManager)
  • Collections (java.util)
    This class consists exclusively of static methods that operate on or return collections. It contains
  • Hashtable (java.util)
    A plug-in replacement for JDK1.5 java.util.Hashtable. This version is based on org.cliffc.high_scale
  • Executors (java.util.concurrent)
    Factory and utility methods for Executor, ExecutorService, ScheduledExecutorService, ThreadFactory,
  • Pattern (java.util.regex)
    Patterns are compiled regular expressions. In many cases, convenience methods such as String#matches
  • JTable (javax.swing)
  • Reflections (org.reflections)
    Reflections one-stop-shop objectReflections scans your classpath, indexes the metadata, allows you t
  • Top 12 Jupyter Notebook extensions
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now