mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-12-23 02:58:00 +01:00
Use switch-case in PacketParserUtils.parseContentDepthWithoutRoundtrip()
This commit is contained in:
parent
77f0fdc156
commit
c89d06861b
1 changed files with 9 additions and 7 deletions
|
@ -443,8 +443,9 @@ public class PacketParserUtils {
|
||||||
// it. This 'flag' ensures that when a namespace is set for an element, it won't be set again
|
// it. This 'flag' ensures that when a namespace is set for an element, it won't be set again
|
||||||
// in a nested element. It's an ugly workaround that has the potential to break things.
|
// in a nested element. It's an ugly workaround that has the potential to break things.
|
||||||
String namespaceElement = null;
|
String namespaceElement = null;
|
||||||
while (true) {
|
outerloop: while (true) {
|
||||||
if (event == XmlPullParser.START_TAG) {
|
switch (event) {
|
||||||
|
case XmlPullParser.START_TAG:
|
||||||
xml.halfOpenElement(parser.getName());
|
xml.halfOpenElement(parser.getName());
|
||||||
if (namespaceElement == null || fullNamespaces) {
|
if (namespaceElement == null || fullNamespaces) {
|
||||||
String namespace = parser.getNamespace();
|
String namespace = parser.getNamespace();
|
||||||
|
@ -463,8 +464,8 @@ public class PacketParserUtils {
|
||||||
else {
|
else {
|
||||||
xml.rightAngleBracket();
|
xml.rightAngleBracket();
|
||||||
}
|
}
|
||||||
}
|
break;
|
||||||
else if (event == XmlPullParser.END_TAG) {
|
case XmlPullParser.END_TAG:
|
||||||
if (isEmptyElement) {
|
if (isEmptyElement) {
|
||||||
// Do nothing as the element was already closed, just reset the flag
|
// Do nothing as the element was already closed, just reset the flag
|
||||||
isEmptyElement = false;
|
isEmptyElement = false;
|
||||||
|
@ -478,11 +479,12 @@ public class PacketParserUtils {
|
||||||
}
|
}
|
||||||
if (parser.getDepth() <= depth) {
|
if (parser.getDepth() <= depth) {
|
||||||
// Abort parsing, we are done
|
// Abort parsing, we are done
|
||||||
break;
|
break outerloop;
|
||||||
}
|
}
|
||||||
}
|
break;
|
||||||
else if (event == XmlPullParser.TEXT) {
|
case XmlPullParser.TEXT:
|
||||||
xml.append(parser.getText());
|
xml.append(parser.getText());
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
event = parser.next();
|
event = parser.next();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue