1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-11-29 17:52:06 +01:00

Use switch-case in PacketParserUtils.parseContentDepthWithoutRoundtrip()

This commit is contained in:
Florian Schmaus 2014-12-10 12:28:08 +01:00
parent 77f0fdc156
commit c89d06861b

View file

@ -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();
} }