/** * 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 (!FormField.TYPE_BOOLEAN.equals(field.getType())) { throw new IllegalArgumentException("This field is not of type boolean."); } setAnswer(field, (value ? "1" : "0")); }
/** * 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. * @throws IllegalArgumentException 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 (!FormField.TYPE_BOOLEAN.equals(field.getType())) { throw new IllegalArgumentException("This field is not of type boolean."); } setAnswer(field, (value ? "1" : "0")); }
/** * 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 (!FormField.TYPE_BOOLEAN.equals(field.getType())) { throw new IllegalArgumentException("This field is not of type boolean."); } setAnswer(field, (value ? "1" : "0")); }
/** * 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 (!FormField.TYPE_BOOLEAN.equals(field.getType())) { throw new IllegalArgumentException("This field is not of type boolean."); } setAnswer(field, (value ? "1" : "0")); }
/** * 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. * @throws IllegalArgumentException 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."); } if (!FormField.TYPE_TEXT_MULTI.equals(field.getType()) && !FormField.TYPE_TEXT_PRIVATE.equals(field.getType()) && !FormField.TYPE_TEXT_SINGLE.equals(field.getType())) { throw new IllegalArgumentException("This field is not of type int."); } setAnswer(field, new Integer(value)); }
/** * 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. * @throws IllegalArgumentException 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."); } if (!FormField.TYPE_TEXT_MULTI.equals(field.getType()) && !FormField.TYPE_TEXT_PRIVATE.equals(field.getType()) && !FormField.TYPE_TEXT_SINGLE.equals(field.getType())) { throw new IllegalArgumentException("This field is not of type long."); } setAnswer(field, new Long(value)); }
/** * 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. * @throws IllegalArgumentException 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."); } if (!FormField.TYPE_TEXT_MULTI.equals(field.getType()) && !FormField.TYPE_TEXT_PRIVATE.equals(field.getType()) && !FormField.TYPE_TEXT_SINGLE.equals(field.getType())) { throw new IllegalArgumentException("This field is not of type double."); } setAnswer(field, new Double(value)); }
/** * 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."); } if (!FormField.TYPE_TEXT_MULTI.equals(field.getType()) && !FormField.TYPE_TEXT_PRIVATE.equals(field.getType()) && !FormField.TYPE_TEXT_SINGLE.equals(field.getType())) { throw new IllegalArgumentException("This field is not of type double."); } setAnswer(field, value); }
/** * 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."); } if (!FormField.TYPE_TEXT_MULTI.equals(field.getType()) && !FormField.TYPE_TEXT_PRIVATE.equals(field.getType()) && !FormField.TYPE_TEXT_SINGLE.equals(field.getType())) { throw new IllegalArgumentException("This field is not of type int."); } setAnswer(field, value); }
/** * 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."); } if (!FormField.TYPE_TEXT_MULTI.equals(field.getType()) && !FormField.TYPE_TEXT_PRIVATE.equals(field.getType()) && !FormField.TYPE_TEXT_SINGLE.equals(field.getType())) { throw new IllegalArgumentException("This field is not of type long."); } setAnswer(field, value); }
/** * 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."); } if (!FormField.TYPE_TEXT_MULTI.equals(field.getType()) && !FormField.TYPE_TEXT_PRIVATE.equals(field.getType()) && !FormField.TYPE_TEXT_SINGLE.equals(field.getType())) { throw new IllegalArgumentException("This field is not of type float."); } setAnswer(field, value); }
/** * 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."); } if (!FormField.TYPE_TEXT_MULTI.equals(field.getType()) && !FormField.TYPE_TEXT_PRIVATE.equals(field.getType()) && !FormField.TYPE_TEXT_SINGLE.equals(field.getType())) { throw new IllegalArgumentException("This field is not of type long."); } setAnswer(field, value); }
/** * 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 XMPPException If the user is not allowed to make this request or the server does * not support offline message retrieval. */ public int getMessageCount() throws XMPPException { DiscoverInfo info = ServiceDiscoveryManager.getInstanceFor(connection).discoverInfo(null, namespace); Form extendedInfo = Form.getFormFrom(info); if (extendedInfo != null) { String value = extendedInfo.getField("number_of_messages").getValues().next(); return Integer.parseInt(value); } return 0; }
/** * 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 XMPPException If the user is not allowed to make this request or the server does * not support offline message retrieval. */ public int getMessageCount() throws XMPPException { DiscoverInfo info = ServiceDiscoveryManager.getInstanceFor(connection).discoverInfo(null, namespace); Form extendedInfo = Form.getFormFrom(info); if (extendedInfo != null) { String value = (String) extendedInfo.getField("number_of_messages").getValues().next(); return Integer.parseInt(value); } return 0; }
/** * 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 XMPPException If the user is not allowed to make this request or the server does * not support offline message retrieval. */ public int getMessageCount() throws XMPPException { DiscoverInfo info = ServiceDiscoveryManager.getInstanceFor(connection).discoverInfo(null, namespace); Form extendedInfo = Form.getFormFrom(info); if (extendedInfo != null) { String value = extendedInfo.getField("number_of_messages").getValues().next(); return Integer.parseInt(value); } return 0; }
/** * 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 XMPPException If the user is not allowed to make this request or the server does * not support offline message retrieval. */ public int getMessageCount() throws XMPPException { DiscoverInfo info = ServiceDiscoveryManager.getInstanceFor(connection).discoverInfo(null, namespace); Form extendedInfo = Form.getFormFrom(info); if (extendedInfo != null) { String value = extendedInfo.getField("number_of_messages").getValues().next(); return Integer.parseInt(value); } return 0; }
RoomInfo(DiscoverInfo info) { super(); this.room = info.getFrom(); // Get the information based on the discovered features this.membersOnly = info.containsFeature("muc_membersonly"); this.moderated = info.containsFeature("muc_moderated"); this.nonanonymous = info.containsFeature("muc_nonanonymous"); this.passwordProtected = info.containsFeature("muc_passwordprotected"); this.persistent = info.containsFeature("muc_persistent"); // Get the information based on the discovered extended information Form form = Form.getFormFrom(info); if (form != null) { this.description = (String) form.getField("muc#roominfo_description").getValues().next(); this.subject = (String) form.getField("muc#roominfo_subject").getValues().next(); this.occupantsCount = Integer.parseInt((String) form.getField("muc#roominfo_occupants").getValues() .next()); } }
RoomInfo(DiscoverInfo info) { super(); this.room = info.getFrom(); // Get the information based on the discovered features this.membersOnly = info.containsFeature("muc_membersonly"); this.moderated = info.containsFeature("muc_moderated"); this.nonanonymous = info.containsFeature("muc_nonanonymous"); this.passwordProtected = info.containsFeature("muc_passwordprotected"); this.persistent = info.containsFeature("muc_persistent"); // Get the information based on the discovered extended information Form form = Form.getFormFrom(info); if (form != null) { FormField descField = form.getField("muc#roominfo_description"); this.description = descField == null ? "" : descField.getValues().next(); FormField subjField = form.getField("muc#roominfo_subject"); this.subject = subjField == null ? "" : subjField.getValues().next(); FormField occCountField = form.getField("muc#roominfo_occupants"); this.occupantsCount = occCountField == null ? -1 : Integer.parseInt(occCountField.getValues() .next()); } }
RoomInfo(DiscoverInfo info) { super(); this.room = info.getFrom(); // Get the information based on the discovered features this.membersOnly = info.containsFeature("muc_membersonly"); this.moderated = info.containsFeature("muc_moderated"); this.nonanonymous = info.containsFeature("muc_nonanonymous"); this.passwordProtected = info.containsFeature("muc_passwordprotected"); this.persistent = info.containsFeature("muc_persistent"); // Get the information based on the discovered extended information Form form = Form.getFormFrom(info); if (form != null) { FormField descField = form.getField("muc#roominfo_description"); this.description = ( descField == null || !(descField.getValues().hasNext()) )? "" : descField.getValues().next(); FormField subjField = form.getField("muc#roominfo_subject"); this.subject = ( subjField == null || !(subjField.getValues().hasNext()) ) ? "" : subjField.getValues().next(); FormField occCountField = form.getField("muc#roominfo_occupants"); this.occupantsCount = occCountField == null ? -1 : Integer.parseInt(occCountField.getValues() .next()); } }
RoomInfo(DiscoverInfo info) { super(); this.room = info.getFrom(); // Get the information based on the discovered features this.membersOnly = info.containsFeature("muc_membersonly"); this.moderated = info.containsFeature("muc_moderated"); this.nonanonymous = info.containsFeature("muc_nonanonymous"); this.passwordProtected = info.containsFeature("muc_passwordprotected"); this.persistent = info.containsFeature("muc_persistent"); // Get the information based on the discovered extended information Form form = Form.getFormFrom(info); if (form != null) { FormField descField = form.getField("muc#roominfo_description"); this.description = ( descField == null || !(descField.getValues().hasNext()) )? "" : descField.getValues().next(); FormField subjField = form.getField("muc#roominfo_subject"); this.subject = ( subjField == null || !(subjField.getValues().hasNext()) ) ? "" : subjField.getValues().next(); FormField occCountField = form.getField("muc#roominfo_occupants"); this.occupantsCount = occCountField == null ? -1 : Integer.parseInt(occCountField.getValues() .next()); } }