1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-12-23 11:07:57 +01:00

Changes the way the properties are parsed.

git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@2346 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
Gaston Dombiak 2004-07-17 17:50:18 +00:00 committed by gdombiak
parent f7ccbe1421
commit 287c54a6ac

View file

@ -747,54 +747,62 @@ class PacketReader {
while (true) { while (true) {
int eventType = parser.next(); int eventType = parser.next();
if (eventType == XmlPullParser.START_TAG && parser.getName().equals("property")) { if (eventType == XmlPullParser.START_TAG && parser.getName().equals("property")) {
// Advance to name element. // Parse a property
parser.next(); boolean done = false;
// Depending on the server we may need to skip possible CRs String name = null;
eventType = parser.next(); String type = null;
String name; String valueText = null;
if (eventType == XmlPullParser.TEXT) {
name = parser.getText();
}
else {
name = parser.nextText();
}
parser.next();
// Skip CRs
parser.next();
String type = parser.getAttributeValue("", "type");
String valueText = parser.nextText();
Object value = null; Object value = null;
if ("integer".equals(type)) { while (!done) {
value = new Integer(valueText); eventType = parser.next();
} if (eventType == XmlPullParser.START_TAG) {
else if ("long".equals(type)) { String elementName = parser.getName();
value = new Long(valueText); String namespace = parser.getNamespace();
} if (elementName.equals("name")) {
else if ("float".equals(type)) { name = parser.nextText();
value = new Float(valueText); }
} else if (elementName.equals("value")) {
else if ("double".equals(type)) { type = parser.getAttributeValue("", "type");
value = new Double(valueText); valueText = parser.nextText();
} }
else if ("boolean".equals(type)) {
value = new Boolean(valueText);
}
else if ("string".equals(type)) {
value = valueText;
}
else if ("java-object".equals(type)) {
try {
byte [] bytes = StringUtils.decodeBase64(valueText);
ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(bytes));
value = in.readObject();
} }
catch (Exception e) { else if (eventType == XmlPullParser.END_TAG) {
e.printStackTrace(); if (parser.getName().equals("property")) {
if ("integer".equals(type)) {
value = new Integer(valueText);
}
else if ("long".equals(type)) {
value = new Long(valueText);
}
else if ("float".equals(type)) {
value = new Float(valueText);
}
else if ("double".equals(type)) {
value = new Double(valueText);
}
else if ("boolean".equals(type)) {
value = new Boolean(valueText);
}
else if ("string".equals(type)) {
value = valueText;
}
else if ("java-object".equals(type)) {
try {
byte [] bytes = StringUtils.decodeBase64(valueText);
ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(bytes));
value = in.readObject();
}
catch (Exception e) {
e.printStackTrace();
}
}
if (name != null && value != null) {
properties.put(name, value);
}
done = true;
}
} }
} }
if (name != null && value != null) {
properties.put(name, value);
}
} }
else if (eventType == XmlPullParser.END_TAG) { else if (eventType == XmlPullParser.END_TAG) {
if (parser.getName().equals("properties")) { if (parser.getName().equals("properties")) {