mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-26 05:52:06 +01:00
Use switch/case in MUCUserProvider
This commit is contained in:
parent
afd7c67bf9
commit
28c3554085
1 changed files with 22 additions and 19 deletions
|
@ -39,35 +39,38 @@ public class MUCUserProvider implements PacketExtensionProvider {
|
||||||
* @throws Exception if a parsing error occurs.
|
* @throws Exception if a parsing error occurs.
|
||||||
*/
|
*/
|
||||||
public PacketExtension parseExtension(XmlPullParser parser) throws Exception {
|
public PacketExtension parseExtension(XmlPullParser parser) throws Exception {
|
||||||
|
final int initialDepth = parser.getDepth();
|
||||||
MUCUser mucUser = new MUCUser();
|
MUCUser mucUser = new MUCUser();
|
||||||
boolean done = false;
|
outerloop: while (true) {
|
||||||
while (!done) {
|
switch (parser.next()) {
|
||||||
int eventType = parser.next();
|
case XmlPullParser.START_TAG:
|
||||||
if (eventType == XmlPullParser.START_TAG) {
|
switch (parser.getName()) {
|
||||||
if (parser.getName().equals("invite")) {
|
case "invite":
|
||||||
mucUser.setInvite(parseInvite(parser));
|
mucUser.setInvite(parseInvite(parser));
|
||||||
}
|
break;
|
||||||
if (parser.getName().equals("item")) {
|
case "item":
|
||||||
mucUser.setItem(MUCParserUtils.parseItem(parser));
|
mucUser.setItem(MUCParserUtils.parseItem(parser));
|
||||||
}
|
break;
|
||||||
if (parser.getName().equals("password")) {
|
case "password":
|
||||||
mucUser.setPassword(parser.nextText());
|
mucUser.setPassword(parser.nextText());
|
||||||
}
|
break;
|
||||||
if (parser.getName().equals("status")) {
|
case "status":
|
||||||
String statusString = parser.getAttributeValue("", "code");
|
String statusString = parser.getAttributeValue("", "code");
|
||||||
mucUser.addStatusCode(MUCUser.Status.create(statusString));
|
mucUser.addStatusCode(MUCUser.Status.create(statusString));
|
||||||
}
|
break;
|
||||||
if (parser.getName().equals("decline")) {
|
case "decline":
|
||||||
mucUser.setDecline(parseDecline(parser));
|
mucUser.setDecline(parseDecline(parser));
|
||||||
}
|
break;
|
||||||
if (parser.getName().equals("destroy")) {
|
case "destroy":
|
||||||
mucUser.setDestroy(MUCParserUtils.parseDestroy(parser));
|
mucUser.setDestroy(MUCParserUtils.parseDestroy(parser));
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
break;
|
||||||
else if (eventType == XmlPullParser.END_TAG) {
|
case XmlPullParser.END_TAG:
|
||||||
if (parser.getName().equals("x")) {
|
if (parser.getDepth() == initialDepth) {
|
||||||
done = true;
|
break outerloop;
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue