mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-27 14:32:06 +01:00
Use nextTag and switch in provider
This commit is contained in:
parent
0fc9822eaa
commit
fc253578d1
1 changed files with 41 additions and 39 deletions
|
@ -46,11 +46,11 @@ public class MetadataProvider extends ExtensionElementProvider<MetadataExtension
|
||||||
List<MetadataInfo> metadataInfos = null;
|
List<MetadataInfo> metadataInfos = null;
|
||||||
List<MetadataPointer> pointers = null;
|
List<MetadataPointer> pointers = null;
|
||||||
|
|
||||||
while (true) {
|
outerloop: while (true) {
|
||||||
XmlPullParser.Event eventType = parser.next();
|
XmlPullParser.TagEvent eventType = parser.nextTag();
|
||||||
|
|
||||||
if (eventType == XmlPullParser.Event.START_ELEMENT) {
|
|
||||||
|
|
||||||
|
switch (eventType) {
|
||||||
|
case START_ELEMENT:
|
||||||
if (parser.getName().equals("info")) {
|
if (parser.getName().equals("info")) {
|
||||||
if (metadataInfos == null) {
|
if (metadataInfos == null) {
|
||||||
metadataInfos = new ArrayList<>();
|
metadataInfos = new ArrayList<>();
|
||||||
|
@ -69,14 +69,13 @@ public class MetadataProvider extends ExtensionElementProvider<MetadataExtension
|
||||||
|
|
||||||
pointers.add(parsePointer(parser));
|
pointers.add(parsePointer(parser));
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (eventType == XmlPullParser.Event.END_ELEMENT) {
|
|
||||||
if (parser.getDepth() == initialDepth) {
|
|
||||||
break;
|
break;
|
||||||
|
case END_ELEMENT:
|
||||||
|
if (parser.getDepth() == initialDepth) {
|
||||||
|
break outerloop;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new MetadataExtension(metadataInfos, pointers);
|
return new MetadataExtension(metadataInfos, pointers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,10 +125,11 @@ public class MetadataProvider extends ExtensionElementProvider<MetadataExtension
|
||||||
String namespace = null;
|
String namespace = null;
|
||||||
HashMap<String, Object> fields = null;
|
HashMap<String, Object> fields = null;
|
||||||
|
|
||||||
while (true) {
|
outperloop: while (true) {
|
||||||
XmlPullParser.Event eventType2 = parser.next();
|
XmlPullParser.TagEvent tag = parser.nextTag();
|
||||||
|
|
||||||
if (eventType2 == XmlPullParser.Event.START_ELEMENT) {
|
switch (tag) {
|
||||||
|
case START_ELEMENT:
|
||||||
if (parser.getName().equals("x")) {
|
if (parser.getName().equals("x")) {
|
||||||
namespace = parser.getNamespace();
|
namespace = parser.getNamespace();
|
||||||
} else {
|
} else {
|
||||||
|
@ -141,9 +141,11 @@ public class MetadataProvider extends ExtensionElementProvider<MetadataExtension
|
||||||
Object value = parser.nextText();
|
Object value = parser.nextText();
|
||||||
fields.put(name, value);
|
fields.put(name, value);
|
||||||
}
|
}
|
||||||
} else if (eventType2 == XmlPullParser.Event.END_ELEMENT) {
|
|
||||||
if (parser.getDepth() == pointerDepth) {
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case END_ELEMENT:
|
||||||
|
if (parser.getDepth() == pointerDepth) {
|
||||||
|
break outperloop;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue