mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-10-05 05:59:32 +02:00
Merge branch '4.3'
This commit is contained in:
commit
62a0c6f26e
|
@ -89,6 +89,11 @@
|
|||
<property name="message" value="Usage of println"/>
|
||||
<property name="ignoreComments" value="true"/>
|
||||
</module>
|
||||
<module name="RegexpSinglelineJava">
|
||||
<property name="format" value="Boolean\.valueOf\("/>
|
||||
<property name="message" value="Usage Boolean.valueOf(), consider using ParserUtils.parseXmlBoolean() instead (if you want to parse xs:boolean values)"/>
|
||||
<property name="ignoreComments" value="true"/>
|
||||
</module>
|
||||
<module name="RegexpSinglelineJava">
|
||||
<property name="format" value="^\t+"/>
|
||||
<property name="message" value="Indent must not use tab characters. Use space instead."/>
|
||||
|
|
|
@ -123,7 +123,9 @@ public class IntrospectionProvider{
|
|||
case "java.lang.String":
|
||||
return value;
|
||||
case "boolean":
|
||||
// CHECKSTYLE:OFF
|
||||
return Boolean.valueOf(value);
|
||||
// CHECKSTYLE:ON
|
||||
case "int":
|
||||
return Integer.valueOf(value);
|
||||
case "long":
|
||||
|
|
|
@ -129,6 +129,27 @@ public class ParserUtils {
|
|||
return Resourcepart.from(resourcepartString);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prase a string to a boolean value as per "xs:boolean". Valid input strings are "true", "1" for true, and "false", "0" for false.
|
||||
*
|
||||
* @param booleanString the input string.
|
||||
* @return the boolean representation of the input string
|
||||
* @throws IllegalArgumentException if the input string is not valid.
|
||||
* @since 4.3.2
|
||||
*/
|
||||
public static boolean parseXmlBoolean(String booleanString) {
|
||||
switch (booleanString) {
|
||||
case "true":
|
||||
case "1":
|
||||
return true;
|
||||
case "false":
|
||||
case "0":
|
||||
return false;
|
||||
default:
|
||||
throw new IllegalArgumentException(booleanString + " is not a valid boolean string");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the boolean value of an argument.
|
||||
*
|
||||
|
@ -141,7 +162,7 @@ public class ParserUtils {
|
|||
if (valueString == null)
|
||||
return null;
|
||||
valueString = valueString.toLowerCase(Locale.US);
|
||||
return valueString.equals("true") || valueString.equals("0");
|
||||
return parseXmlBoolean(valueString);
|
||||
}
|
||||
|
||||
public static boolean getBooleanAttribute(XmlPullParser parser, String name,
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.hoxt.provider;
|
||||
|
||||
import org.jivesoftware.smack.util.ParserUtils;
|
||||
|
||||
import org.jivesoftware.smackx.hoxt.packet.HttpMethod;
|
||||
import org.jivesoftware.smackx.hoxt.packet.HttpOverXmppReq;
|
||||
|
||||
|
@ -47,13 +49,13 @@ public class HttpOverXmppReqProvider extends AbstractHttpOverXmppProvider<HttpOv
|
|||
String jingleStr = parser.getAttributeValue("", AbstractHttpOverXmppProvider.ELEMENT_JINGLE);
|
||||
|
||||
if (sipubStr != null) {
|
||||
builder.setSipub(Boolean.valueOf(sipubStr));
|
||||
builder.setSipub(ParserUtils.parseXmlBoolean(sipubStr));
|
||||
}
|
||||
if (ibbStr != null) {
|
||||
builder.setIbb(Boolean.valueOf(ibbStr));
|
||||
builder.setIbb(ParserUtils.parseXmlBoolean(ibbStr));
|
||||
}
|
||||
if (jingleStr != null) {
|
||||
builder.setJingle(Boolean.valueOf(jingleStr));
|
||||
builder.setJingle(ParserUtils.parseXmlBoolean(jingleStr));
|
||||
}
|
||||
|
||||
String maxChunkSize = parser.getAttributeValue("", ATTRIBUTE_MAX_CHUNK_SIZE);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright © 2016 Florian Schmaus
|
||||
* Copyright © 2016-2018 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -16,6 +16,8 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.iot.control.element;
|
||||
|
||||
import org.jivesoftware.smack.util.ParserUtils;
|
||||
|
||||
public class SetBoolData extends SetData {
|
||||
|
||||
public SetBoolData(String name, boolean value) {
|
||||
|
@ -31,7 +33,7 @@ public class SetBoolData extends SetData {
|
|||
|
||||
public Boolean getBooleanValue() {
|
||||
if (booleanCache != null) {
|
||||
booleanCache = Boolean.valueOf(getValue());
|
||||
booleanCache = ParserUtils.parseXmlBoolean(getValue());
|
||||
}
|
||||
return booleanCache;
|
||||
}
|
||||
|
|
|
@ -269,12 +269,12 @@ public class Bookmarks implements PrivateData {
|
|||
|
||||
private static BookmarkedConference getConferenceStorage(XmlPullParser parser) throws XmlPullParserException, IOException {
|
||||
String name = parser.getAttributeValue("", "name");
|
||||
String autojoin = parser.getAttributeValue("", "autojoin");
|
||||
boolean autojoin = ParserUtils.getBooleanAttribute(parser, "autojoin", false);
|
||||
EntityBareJid jid = ParserUtils.getBareJidAttribute(parser);
|
||||
|
||||
BookmarkedConference conf = new BookmarkedConference(jid);
|
||||
conf.setName(name);
|
||||
conf.setAutoJoin(Boolean.valueOf(autojoin));
|
||||
conf.setAutoJoin(autojoin);
|
||||
|
||||
// Check for nickname
|
||||
boolean done = false;
|
||||
|
|
|
@ -92,7 +92,9 @@ public class JivePropertiesExtensionProvider extends ExtensionElementProvider<Ji
|
|||
value = Double.valueOf(valueText);
|
||||
}
|
||||
else if ("boolean".equals(type)) {
|
||||
// CHECKSTYLE:OFF
|
||||
value = Boolean.valueOf(valueText);
|
||||
// CHECKSTYLE:ON
|
||||
}
|
||||
else if ("string".equals(type)) {
|
||||
value = valueText;
|
||||
|
|
|
@ -207,7 +207,8 @@ public class RoomInfo {
|
|||
|
||||
FormField subjectmodField = form.getField("muc#roominfo_subjectmod");
|
||||
if (subjectmodField != null && !subjectmodField.getValues().isEmpty()) {
|
||||
subjectmod = Boolean.valueOf(subjectmodField.getFirstValue());
|
||||
String firstValue = subjectmodField.getFirstValue();
|
||||
subjectmod = ("true".equals(firstValue) || "1".equals(firstValue));
|
||||
}
|
||||
|
||||
FormField urlField = form.getField("muc#roominfo_logs");
|
||||
|
|
|
@ -104,7 +104,9 @@ public class WorkgroupProperties extends IQ {
|
|||
while (!done) {
|
||||
int eventType = parser.next();
|
||||
if (eventType == XmlPullParser.START_TAG && "authRequired".equals(parser.getName())) {
|
||||
// CHECKSTYLE:OFF
|
||||
props.setAuthRequired(Boolean.valueOf(parser.nextText()).booleanValue());
|
||||
// CHECKSTYLE:ON
|
||||
}
|
||||
else if (eventType == XmlPullParser.START_TAG && "email".equals(parser.getName())) {
|
||||
props.setEmail(parser.nextText());
|
||||
|
|
Loading…
Reference in a new issue