mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-26 05:52:06 +01:00
Merge branch '4.4'
This also fixes a errornous merge where the same branch with different commit was merged into master and 4.4 The conflicting commits are 4.4:8f760eaeb3
getRawValueCharSequencese626580f68
master:b47225c2c1
getRawValues097d245358
This commit is contained in:
commit
001985647a
13 changed files with 119 additions and 84 deletions
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Copyright 2003-2007 Jive Software, 2016-2020 Florian Schmaus.
|
* Copyright 2003-2007 Jive Software, 2016-2021 Florian Schmaus.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -20,6 +20,7 @@ package org.jivesoftware.smack.util;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.CharBuffer;
|
import java.nio.CharBuffer;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
@ -605,4 +606,13 @@ public class StringUtils {
|
||||||
String[] lines = input.split(PORTABLE_NEWLINE_REGEX);
|
String[] lines = input.split(PORTABLE_NEWLINE_REGEX);
|
||||||
return Arrays.asList(lines);
|
return Arrays.asList(lines);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static List<String> toStrings(Collection<? extends CharSequence> charSequences) {
|
||||||
|
List<String> res = new ArrayList<>(charSequences.size());
|
||||||
|
for (CharSequence cs : charSequences) {
|
||||||
|
String string = cs.toString();
|
||||||
|
res.add(string);
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -700,7 +700,7 @@ public final class EntityCapsManager extends Manager {
|
||||||
for (FormField f : fs) {
|
for (FormField f : fs) {
|
||||||
sb.append(f.getFieldName());
|
sb.append(f.getFieldName());
|
||||||
sb.append('<');
|
sb.append('<');
|
||||||
formFieldValuesToCaps(f.getRawValues(), sb);
|
formFieldValuesToCaps(f.getRawValueCharSequences(), sb);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,11 +38,7 @@ public class FormNode extends NodeExtension {
|
||||||
* @param submitForm The form
|
* @param submitForm The form
|
||||||
*/
|
*/
|
||||||
public FormNode(FormNodeType formType, DataForm submitForm) {
|
public FormNode(FormNodeType formType, DataForm submitForm) {
|
||||||
super(formType.getNodeElement());
|
this(formType, null, submitForm);
|
||||||
|
|
||||||
if (submitForm == null)
|
|
||||||
throw new IllegalArgumentException("Submit form cannot be null");
|
|
||||||
configForm = submitForm;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -55,9 +51,6 @@ public class FormNode extends NodeExtension {
|
||||||
*/
|
*/
|
||||||
public FormNode(FormNodeType formType, String nodeId, DataForm submitForm) {
|
public FormNode(FormNodeType formType, String nodeId, DataForm submitForm) {
|
||||||
super(formType.getNodeElement(), nodeId);
|
super(formType.getNodeElement(), nodeId);
|
||||||
|
|
||||||
if (submitForm == null)
|
|
||||||
throw new IllegalArgumentException("Submit form cannot be null");
|
|
||||||
configForm = submitForm;
|
configForm = submitForm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,11 @@ import org.jivesoftware.smackx.xdata.packet.DataForm;
|
||||||
public class FormNodeProvider extends EmbeddedExtensionProvider<FormNode> {
|
public class FormNodeProvider extends EmbeddedExtensionProvider<FormNode> {
|
||||||
@Override
|
@Override
|
||||||
protected FormNode createReturnExtension(String currentElement, String currentNamespace, Map<String, String> attributeMap, List<? extends XmlElement> content) {
|
protected FormNode createReturnExtension(String currentElement, String currentNamespace, Map<String, String> attributeMap, List<? extends XmlElement> content) {
|
||||||
return new FormNode(FormNodeType.valueOfFromElementName(currentElement, currentNamespace), attributeMap.get("node"), (DataForm) content.iterator().next());
|
DataForm dataForm = null;
|
||||||
|
if (!content.isEmpty()) {
|
||||||
|
dataForm = (DataForm) content.get(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new FormNode(FormNodeType.valueOfFromElementName(currentElement, currentNamespace), attributeMap.get("node"), dataForm);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,35 +27,26 @@ import org.jxmpp.util.XmppDateTime;
|
||||||
|
|
||||||
public class AbstractMultiFormField extends FormField {
|
public class AbstractMultiFormField extends FormField {
|
||||||
|
|
||||||
private final List<String> values;
|
private final List<Value> values;
|
||||||
|
|
||||||
private final List<String> rawValues;
|
|
||||||
|
|
||||||
protected AbstractMultiFormField(Builder<?, ?> builder) {
|
protected AbstractMultiFormField(Builder<?, ?> builder) {
|
||||||
super(builder);
|
super(builder);
|
||||||
values = CollectionUtil.cloneAndSeal(builder.values);
|
values = CollectionUtil.cloneAndSeal(builder.values);
|
||||||
rawValues = CollectionUtil.cloneAndSeal(builder.rawValues);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final List<String> getValues() {
|
public final List<Value> getRawValues() {
|
||||||
return values;
|
return values;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public final List<String> getRawValues() {
|
|
||||||
return rawValues;
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract static class Builder<F extends AbstractMultiFormField, B extends FormField.Builder<F, B>>
|
public abstract static class Builder<F extends AbstractMultiFormField, B extends FormField.Builder<F, B>>
|
||||||
extends FormField.Builder<F, B> {
|
extends FormField.Builder<F, B> {
|
||||||
|
|
||||||
private List<String> values;
|
private List<Value> values;
|
||||||
private List<String> rawValues;
|
|
||||||
|
|
||||||
protected Builder(AbstractMultiFormField formField) {
|
protected Builder(AbstractMultiFormField formField) {
|
||||||
super(formField);
|
super(formField);
|
||||||
values = CollectionUtil.newListWith(formField.getValues());
|
values = CollectionUtil.newListWith(formField.getRawValues());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Builder(String fieldName, FormField.Type type) {
|
protected Builder(String fieldName, FormField.Type type) {
|
||||||
|
@ -65,7 +56,6 @@ public class AbstractMultiFormField extends FormField {
|
||||||
private void ensureValuesAreInitialized() {
|
private void ensureValuesAreInitialized() {
|
||||||
if (values == null) {
|
if (values == null) {
|
||||||
values = new ArrayList<>();
|
values = new ArrayList<>();
|
||||||
rawValues = new ArrayList<>();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,11 +67,13 @@ public class AbstractMultiFormField extends FormField {
|
||||||
public abstract B addValue(CharSequence value);
|
public abstract B addValue(CharSequence value);
|
||||||
|
|
||||||
public B addValueVerbatim(CharSequence value) {
|
public B addValueVerbatim(CharSequence value) {
|
||||||
|
return addValueVerbatim(new Value(value));
|
||||||
|
}
|
||||||
|
|
||||||
|
public B addValueVerbatim(Value value) {
|
||||||
ensureValuesAreInitialized();
|
ensureValuesAreInitialized();
|
||||||
|
|
||||||
String valueString = value.toString();
|
values.add(value);
|
||||||
values.add(valueString);
|
|
||||||
rawValues.add(valueString);
|
|
||||||
return getThis();
|
return getThis();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -74,8 +74,15 @@ public class AbstractSingleStringValueFormField extends SingleValueFormField {
|
||||||
return setValue(value);
|
return setValue(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public B setValue(Value value) {
|
||||||
|
this.value = value.getValue().toString();
|
||||||
|
this.rawValue = value;
|
||||||
|
return getThis();
|
||||||
|
}
|
||||||
|
|
||||||
public B setValue(CharSequence value) {
|
public B setValue(CharSequence value) {
|
||||||
this.rawValue = this.value = value.toString();
|
this.value = value.toString();
|
||||||
|
rawValue = new Value(this.value);
|
||||||
return getThis();
|
return getThis();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -71,17 +71,21 @@ public class BooleanFormField extends SingleValueFormField {
|
||||||
@Deprecated
|
@Deprecated
|
||||||
// TODO: Remove in Smack 4.6.
|
// TODO: Remove in Smack 4.6.
|
||||||
public Builder addValue(CharSequence value) {
|
public Builder addValue(CharSequence value) {
|
||||||
return setValue(value);
|
return setValue(new Value(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder setValue(CharSequence value) {
|
public Builder setValue(CharSequence value) {
|
||||||
rawValue = value.toString();
|
return setValue(new Value(value));
|
||||||
boolean valueBoolean = ParserUtils.parseXmlBoolean(rawValue);
|
}
|
||||||
return setValue(valueBoolean);
|
|
||||||
|
public Builder setValue(Value value) {
|
||||||
|
this.value = ParserUtils.parseXmlBoolean(value.getValue().toString());
|
||||||
|
rawValue = value;
|
||||||
|
return getThis();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder setValue(boolean value) {
|
public Builder setValue(boolean value) {
|
||||||
rawValue = Boolean.toString(value);
|
rawValue = new Value(Boolean.toString(value));
|
||||||
this.value = value;
|
this.value = value;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
|
@ -269,9 +269,25 @@ public abstract class FormField implements XmlElement {
|
||||||
*
|
*
|
||||||
* @return a List of the default values or answered values of the question.
|
* @return a List of the default values or answered values of the question.
|
||||||
*/
|
*/
|
||||||
public abstract List<? extends CharSequence> getValues();
|
public List<? extends CharSequence> getValues() {
|
||||||
|
return getRawValueCharSequences();
|
||||||
|
}
|
||||||
|
|
||||||
public abstract List<String> getRawValues();
|
public abstract List<Value> getRawValues();
|
||||||
|
|
||||||
|
private transient List<CharSequence> rawValueCharSequences;
|
||||||
|
|
||||||
|
public final List<CharSequence> getRawValueCharSequences() {
|
||||||
|
if (rawValueCharSequences == null) {
|
||||||
|
List<Value> rawValues = getRawValues();
|
||||||
|
rawValueCharSequences = new ArrayList<>(rawValues.size());
|
||||||
|
for (Value value : rawValues) {
|
||||||
|
rawValueCharSequences.add(value.value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return rawValueCharSequences;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean hasValueSet() {
|
public boolean hasValueSet() {
|
||||||
List<?> values = getValues();
|
List<?> values = getValues();
|
||||||
|
@ -385,12 +401,15 @@ public abstract class FormField implements XmlElement {
|
||||||
|
|
||||||
protected transient List<XmlElement> extraXmlChildElements;
|
protected transient List<XmlElement> extraXmlChildElements;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Populate @{link {@link #extraXmlChildElements}}. Note that this method may be overridden by subclasses.
|
||||||
|
*/
|
||||||
protected void populateExtraXmlChildElements() {
|
protected void populateExtraXmlChildElements() {
|
||||||
List<? extends CharSequence> values = getValues();
|
List<Value> values = getRawValues();
|
||||||
|
// Note that we need to create a new ArrayList here, since subclasses may add to it by overriding
|
||||||
|
// populateExtraXmlChildElements.
|
||||||
extraXmlChildElements = new ArrayList<>(values.size());
|
extraXmlChildElements = new ArrayList<>(values.size());
|
||||||
for (CharSequence value : values) {
|
extraXmlChildElements.addAll(values);
|
||||||
extraXmlChildElements.add(new Value(value));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -414,7 +433,8 @@ public abstract class FormField implements XmlElement {
|
||||||
populateExtraXmlChildElements();
|
populateExtraXmlChildElements();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (formFieldChildElements.isEmpty() && extraXmlChildElements == null) {
|
if (formFieldChildElements.isEmpty()
|
||||||
|
&& (extraXmlChildElements == null || extraXmlChildElements.isEmpty())) {
|
||||||
buf.closeEmptyElement();
|
buf.closeEmptyElement();
|
||||||
} else {
|
} else {
|
||||||
buf.rightAngleBracket();
|
buf.rightAngleBracket();
|
||||||
|
|
|
@ -23,13 +23,14 @@ import java.util.List;
|
||||||
import org.jivesoftware.smack.util.CollectionUtil;
|
import org.jivesoftware.smack.util.CollectionUtil;
|
||||||
|
|
||||||
import org.jxmpp.jid.Jid;
|
import org.jxmpp.jid.Jid;
|
||||||
import org.jxmpp.jid.util.JidUtil;
|
import org.jxmpp.jid.impl.JidCreate;
|
||||||
|
import org.jxmpp.stringprep.XmppStringprepException;
|
||||||
|
|
||||||
public final class JidMultiFormField extends FormField {
|
public final class JidMultiFormField extends FormField {
|
||||||
|
|
||||||
private final List<Jid> values;
|
private final List<Jid> values;
|
||||||
|
|
||||||
private final List<String> rawValues;
|
private final List<Value> rawValues;
|
||||||
|
|
||||||
JidMultiFormField(Builder builder) {
|
JidMultiFormField(Builder builder) {
|
||||||
super(builder);
|
super(builder);
|
||||||
|
@ -43,7 +44,7 @@ public final class JidMultiFormField extends FormField {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> getRawValues() {
|
public List<Value> getRawValues() {
|
||||||
return rawValues;
|
return rawValues;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,7 +55,7 @@ public final class JidMultiFormField extends FormField {
|
||||||
public static final class Builder extends FormField.Builder<JidMultiFormField, JidMultiFormField.Builder> {
|
public static final class Builder extends FormField.Builder<JidMultiFormField, JidMultiFormField.Builder> {
|
||||||
private List<Jid> values;
|
private List<Jid> values;
|
||||||
|
|
||||||
private List<String> rawValues;
|
private List<Value> rawValues;
|
||||||
|
|
||||||
private Builder(JidMultiFormField jidMultiFormField) {
|
private Builder(JidMultiFormField jidMultiFormField) {
|
||||||
super(jidMultiFormField);
|
super(jidMultiFormField);
|
||||||
|
@ -79,27 +80,29 @@ public final class JidMultiFormField extends FormField {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder addValue(Jid jid) {
|
public Builder addValue(Jid jid) {
|
||||||
return addValue(jid, null);
|
Value value = new Value(jid);
|
||||||
}
|
|
||||||
|
|
||||||
public Builder addValue(Jid jid, String rawValue) {
|
|
||||||
if (rawValue == null) {
|
|
||||||
rawValue = jid.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
ensureValuesAreInitialized();
|
ensureValuesAreInitialized();
|
||||||
|
|
||||||
values.add(jid);
|
values.add(jid);
|
||||||
rawValues.add(rawValue);
|
rawValues.add(value);
|
||||||
|
|
||||||
|
return getThis();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder addValue(Value value) throws XmppStringprepException {
|
||||||
|
Jid jid = JidCreate.from(value.getValue());
|
||||||
|
|
||||||
|
ensureValuesAreInitialized();
|
||||||
|
values.add(jid);
|
||||||
|
rawValues.add(value);
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder addValues(Collection<? extends Jid> jids) {
|
public Builder addValues(Collection<? extends Jid> jids) {
|
||||||
ensureValuesAreInitialized();
|
for (Jid jid : jids) {
|
||||||
|
addValue(jid);
|
||||||
values.addAll(jids);
|
}
|
||||||
rawValues.addAll(JidUtil.toStringList(jids));
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,8 @@
|
||||||
package org.jivesoftware.smackx.xdata;
|
package org.jivesoftware.smackx.xdata;
|
||||||
|
|
||||||
import org.jxmpp.jid.Jid;
|
import org.jxmpp.jid.Jid;
|
||||||
|
import org.jxmpp.jid.impl.JidCreate;
|
||||||
|
import org.jxmpp.stringprep.XmppStringprepException;
|
||||||
|
|
||||||
public class JidSingleFormField extends SingleValueFormField {
|
public class JidSingleFormField extends SingleValueFormField {
|
||||||
|
|
||||||
|
@ -60,11 +62,13 @@ public class JidSingleFormField extends SingleValueFormField {
|
||||||
|
|
||||||
public Builder setValue(Jid value, String rawValue) {
|
public Builder setValue(Jid value, String rawValue) {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
if (rawValue != null) {
|
this.rawValue = new Value(value);
|
||||||
this.rawValue = rawValue;
|
return getThis();
|
||||||
} else {
|
|
||||||
this.rawValue = value.toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Builder setValue(Value value) throws XmppStringprepException {
|
||||||
|
this.value = JidCreate.from(value.getValue());
|
||||||
|
this.rawValue = value;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ import org.jivesoftware.smack.util.CollectionUtil;
|
||||||
|
|
||||||
public abstract class SingleValueFormField extends FormField {
|
public abstract class SingleValueFormField extends FormField {
|
||||||
|
|
||||||
private final String rawValue;
|
private final Value rawValue;
|
||||||
|
|
||||||
protected SingleValueFormField(Builder<?, ?> builder) {
|
protected SingleValueFormField(Builder<?, ?> builder) {
|
||||||
super(builder);
|
super(builder);
|
||||||
|
@ -38,24 +38,23 @@ public abstract class SingleValueFormField extends FormField {
|
||||||
|
|
||||||
public abstract CharSequence getValue();
|
public abstract CharSequence getValue();
|
||||||
|
|
||||||
public final String getRawValue() {
|
public final Value getRawValue() {
|
||||||
return rawValue;
|
return rawValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final List<String> getRawValues() {
|
public final List<Value> getRawValues() {
|
||||||
String rawValue = getRawValue();
|
Value rawValue = getRawValue();
|
||||||
return CollectionUtil.emptyOrSingletonListFrom(rawValue);
|
return CollectionUtil.emptyOrSingletonListFrom(rawValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void populateExtraXmlChildElements() {
|
protected void populateExtraXmlChildElements() {
|
||||||
CharSequence value = getValue();
|
if (rawValue == null) {
|
||||||
if (value == null) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
extraXmlChildElements = Collections.singletonList(new Value(value));
|
extraXmlChildElements = Collections.singletonList(rawValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract static class Builder<F extends SingleValueFormField, B extends Builder<F, B>>
|
public abstract static class Builder<F extends SingleValueFormField, B extends Builder<F, B>>
|
||||||
|
@ -65,11 +64,12 @@ public abstract class SingleValueFormField extends FormField {
|
||||||
super(fieldName, type);
|
super(fieldName, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Builder(FormField formField) {
|
protected Builder(SingleValueFormField formField) {
|
||||||
super(formField);
|
super(formField);
|
||||||
|
rawValue = formField.getRawValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String rawValue;
|
protected Value rawValue;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void resetInternal() {
|
protected void resetInternal() {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Copyright 2020 Florian Schmaus
|
* Copyright 2020-2021 Florian Schmaus
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -21,6 +21,8 @@ import java.util.Collections;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.jivesoftware.smack.util.StringUtils;
|
||||||
|
|
||||||
import org.jivesoftware.smackx.xdata.AbstractMultiFormField;
|
import org.jivesoftware.smackx.xdata.AbstractMultiFormField;
|
||||||
import org.jivesoftware.smackx.xdata.AbstractSingleStringValueFormField;
|
import org.jivesoftware.smackx.xdata.AbstractSingleStringValueFormField;
|
||||||
import org.jivesoftware.smackx.xdata.BooleanFormField;
|
import org.jivesoftware.smackx.xdata.BooleanFormField;
|
||||||
|
@ -54,7 +56,8 @@ public interface FormReader {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
AbstractMultiFormField multiFormField = formField.ifPossibleAs(AbstractMultiFormField.class);
|
AbstractMultiFormField multiFormField = formField.ifPossibleAs(AbstractMultiFormField.class);
|
||||||
return multiFormField.getValues();
|
List<? extends CharSequence> charSequences = multiFormField.getValues();
|
||||||
|
return StringUtils.toStrings(charSequences);
|
||||||
}
|
}
|
||||||
|
|
||||||
default Boolean readBoolean(String fieldName) {
|
default Boolean readBoolean(String fieldName) {
|
||||||
|
|
|
@ -49,9 +49,6 @@ import org.jivesoftware.smackx.xdata.packet.DataForm;
|
||||||
import org.jivesoftware.smackx.xdatalayout.packet.DataLayout;
|
import org.jivesoftware.smackx.xdatalayout.packet.DataLayout;
|
||||||
import org.jivesoftware.smackx.xdatalayout.provider.DataLayoutProvider;
|
import org.jivesoftware.smackx.xdatalayout.provider.DataLayoutProvider;
|
||||||
|
|
||||||
import org.jxmpp.jid.Jid;
|
|
||||||
import org.jxmpp.jid.impl.JidCreate;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The DataFormProvider parses DataForm packets.
|
* The DataFormProvider parses DataForm packets.
|
||||||
*
|
*
|
||||||
|
@ -237,9 +234,7 @@ public class DataFormProvider extends ExtensionElementProvider<DataForm> {
|
||||||
case jid_multi:
|
case jid_multi:
|
||||||
JidMultiFormField.Builder jidMultiBuilder = FormField.jidMultiBuilder(fieldName);
|
JidMultiFormField.Builder jidMultiBuilder = FormField.jidMultiBuilder(fieldName);
|
||||||
for (FormField.Value value : values) {
|
for (FormField.Value value : values) {
|
||||||
String rawValue = value.getValue().toString();
|
jidMultiBuilder.addValue(value);
|
||||||
Jid jid = JidCreate.from(rawValue);
|
|
||||||
jidMultiBuilder.addValue(jid, rawValue);
|
|
||||||
}
|
}
|
||||||
builder = jidMultiBuilder;
|
builder = jidMultiBuilder;
|
||||||
break;
|
break;
|
||||||
|
@ -247,9 +242,8 @@ public class DataFormProvider extends ExtensionElementProvider<DataForm> {
|
||||||
ensureAtMostSingleValue(type, values);
|
ensureAtMostSingleValue(type, values);
|
||||||
JidSingleFormField.Builder jidSingleBuilder = FormField.jidSingleBuilder(fieldName);
|
JidSingleFormField.Builder jidSingleBuilder = FormField.jidSingleBuilder(fieldName);
|
||||||
if (!values.isEmpty()) {
|
if (!values.isEmpty()) {
|
||||||
String rawValue = values.get(0).getValue().toString();
|
FormField.Value value = values.get(0);
|
||||||
Jid jid = JidCreate.from(rawValue);
|
jidSingleBuilder.setValue(value);
|
||||||
jidSingleBuilder.setValue(jid, rawValue);
|
|
||||||
}
|
}
|
||||||
builder = jidSingleBuilder;
|
builder = jidSingleBuilder;
|
||||||
break;
|
break;
|
||||||
|
@ -303,7 +297,7 @@ public class DataFormProvider extends ExtensionElementProvider<DataForm> {
|
||||||
BooleanFormField.Builder builder = FormField.booleanBuilder(fieldName);
|
BooleanFormField.Builder builder = FormField.booleanBuilder(fieldName);
|
||||||
ensureAtMostSingleValue(builder.getType(), values);
|
ensureAtMostSingleValue(builder.getType(), values);
|
||||||
if (values.size() == 1) {
|
if (values.size() == 1) {
|
||||||
String value = values.get(0).getValue().toString();
|
FormField.Value value = values.get(0);
|
||||||
builder.setValue(value);
|
builder.setValue(value);
|
||||||
}
|
}
|
||||||
return builder;
|
return builder;
|
||||||
|
|
Loading…
Reference in a new issue