Java Code Examples for org.jivesoftware.smackx.xdata.FormField#ifPossibleAs()
The following examples show how to use
org.jivesoftware.smackx.xdata.FormField#ifPossibleAs() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ConfigureFormReader.java From Smack with Apache License 2.0 | 5 votes |
/** * List of JID's that are on the whitelist that determines who can associate child nodes * with the collection node. This is only relevant if {@link #getChildrenAssociationPolicy()} is set to * {@link ChildrenAssociationPolicy#whitelist}. * * @return List of the whitelist */ default List<Jid> getChildrenAssociationWhitelist() { FormField formField = getField(ConfigureNodeFields.children_association_whitelist.getFieldName()); if (formField == null) { Collections.emptyList(); } JidMultiFormField jidMultiFormField = formField.ifPossibleAs(JidMultiFormField.class); return jidMultiFormField.getValues(); }
Example 2
Source File: FormReader.java From Smack with Apache License 2.0 | 5 votes |
default List<String> readStringValues(String fieldName) { FormField formField = getField(fieldName); if (formField == null) { return Collections.emptyList(); } AbstractMultiFormField multiFormField = formField.ifPossibleAs(AbstractMultiFormField.class); return multiFormField.getValues(); }
Example 3
Source File: FormReader.java From Smack with Apache License 2.0 | 5 votes |
default Boolean readBoolean(String fieldName) { FormField formField = getField(fieldName); if (formField == null) { return null; } BooleanFormField booleanFormField = formField.ifPossibleAs(BooleanFormField.class); return booleanFormField.getValueAsBoolean(); }
Example 4
Source File: FormReader.java From Smack with Apache License 2.0 | 5 votes |
default Integer readInteger(String fieldName) { FormField formField = getField(fieldName); if (formField == null) { return null; } AbstractSingleStringValueFormField textSingleFormField = formField.ifPossibleAs(AbstractSingleStringValueFormField.class); return textSingleFormField.getValueAsInt(); }
Example 5
Source File: FormReader.java From Smack with Apache License 2.0 | 5 votes |
default Date readDate(String fieldName) throws ParseException { FormField formField = getField(fieldName); if (formField == null) { return null; } AbstractSingleStringValueFormField textSingleFormField = formField.ifPossibleAs(AbstractSingleStringValueFormField.class); String value = textSingleFormField.getValue(); if (value == null) { return null; } return XmppDateTime.parseDate(value); }
Example 6
Source File: ValidateElement.java From Smack with Apache License 2.0 | 5 votes |
@Override public void validate(FormField formField) { AbstractSingleStringValueFormField singleValueFormField = formField.ifPossibleAs(AbstractSingleStringValueFormField.class); if (singleValueFormField == null) { // We currently only implement validation for single value fields. return; } String valueString = singleValueFormField.getValue(); switch (getDatatype()) { case "xs:int": case "xs:integer": BigInteger value = new BigInteger(valueString); String minString = getMin(); if (minString != null) { BigInteger min = new BigInteger(minString); if (value.compareTo(min) < 0) { throw new IllegalArgumentException("The provided value " + valueString + " is lower than the allowed minimum of " + minString); } } String maxString = getMax(); if (maxString != null) { BigInteger max = new BigInteger(maxString); if (value.compareTo(max) > 0) { throw new IllegalArgumentException("The provided value " + valueString + " is higher than the allowed maximum of " + maxString); } } break; } }