mirror of
https://github.com/vanitasvitae/Smack.git
synced 2025-09-09 17:19:39 +02:00
Add Support for XEP-80: User Location
SMACK-610
This commit is contained in:
parent
e126469003
commit
0d8f3185e5
8 changed files with 1021 additions and 0 deletions
|
@ -17,6 +17,10 @@
|
|||
package org.jivesoftware.smack.util;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.text.ParseException;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
|
||||
import org.jxmpp.jid.BareJid;
|
||||
|
@ -24,6 +28,7 @@ import org.jxmpp.jid.Jid;
|
|||
import org.jxmpp.jid.impl.JidCreate;
|
||||
import org.jxmpp.jid.parts.Resourcepart;
|
||||
import org.jxmpp.stringprep.XmppStringprepException;
|
||||
import org.jxmpp.util.XmppDateTime;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
|
@ -150,4 +155,38 @@ public class ParserUtils {
|
|||
return l;
|
||||
}
|
||||
}
|
||||
|
||||
public static double getDoubleFromNextText(XmlPullParser parser) throws XmlPullParserException, IOException {
|
||||
String doubleString = parser.nextText();
|
||||
return Double.valueOf(doubleString);
|
||||
}
|
||||
|
||||
public static Double getDoubleAttribute(XmlPullParser parser, String name) {
|
||||
String valueString = parser.getAttributeValue("", name);
|
||||
if (valueString == null)
|
||||
return null;
|
||||
return Double.valueOf(valueString);
|
||||
}
|
||||
|
||||
public static double getDoubleAttribute(XmlPullParser parser, String name, long defaultValue) {
|
||||
Double d = getDoubleAttribute(parser, name);
|
||||
if (d == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
else {
|
||||
return d;
|
||||
}
|
||||
}
|
||||
|
||||
public static Date getDateFromNextText(XmlPullParser parser) throws XmlPullParserException, IOException, ParseException {
|
||||
String dateString = parser.nextText();
|
||||
return XmppDateTime.parseDate(dateString);
|
||||
}
|
||||
|
||||
public static URI getUriFromNextText(XmlPullParser parser) throws XmlPullParserException, IOException, URISyntaxException {
|
||||
String uriString = parser.nextText();
|
||||
URI uri = new URI(uriString);
|
||||
return uri;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -111,6 +111,13 @@ public class XmlStringBuilder implements Appendable, CharSequence {
|
|||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public XmlStringBuilder optElement(String name, Object object) {
|
||||
if (object != null) {
|
||||
element(name, object.toString());
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public XmlStringBuilder optIntElement(String name, int value) {
|
||||
if (value >= 0) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue