use of org.jivesoftware.smackx.mam.element.MamPrefsIQ.DefaultBehavior in project Smack by igniterealtime.
the class MamPrefsIQProvider method parse.
@Override
public MamPrefsIQ parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException {
String iqType = parser.getAttributeValue("", "type");
String defaultBehaviorString = parser.getAttributeValue("", "default");
DefaultBehavior defaultBehavior = null;
if (defaultBehaviorString != null) {
defaultBehavior = DefaultBehavior.valueOf(defaultBehaviorString);
}
if (iqType == null) {
iqType = "result";
}
List<Jid> alwaysJids = null;
List<Jid> neverJids = null;
outerloop: while (true) {
final int eventType = parser.next();
final String name = parser.getName();
switch(eventType) {
case XmlPullParser.START_TAG:
switch(name) {
case "always":
alwaysJids = iterateJids(parser);
break;
case "never":
neverJids = iterateJids(parser);
break;
}
break;
case XmlPullParser.END_TAG:
if (parser.getDepth() == initialDepth) {
break outerloop;
}
break;
}
}
return new MamPrefsIQ(alwaysJids, neverJids, defaultBehavior);
}
use of org.jivesoftware.smackx.mam.element.MamPrefsIQ.DefaultBehavior in project Smack by igniterealtime.
the class MamPrefsIQProvider method parse.
@Override
public MamPrefsIQ parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) throws XmlPullParserException, IOException {
MamElementFactory elementFactory = MamElementFactory.forParser(parser);
String defaultBehaviorString = parser.getAttributeValue("", "default");
DefaultBehavior defaultBehavior = null;
if (defaultBehaviorString != null) {
defaultBehavior = DefaultBehavior.valueOf(defaultBehaviorString);
}
List<Jid> alwaysJids = null;
List<Jid> neverJids = null;
outerloop: while (true) {
final XmlPullParser.Event eventType = parser.next();
switch(eventType) {
case START_ELEMENT:
final String name = parser.getName();
switch(name) {
case "always":
alwaysJids = iterateJids(parser);
break;
case "never":
neverJids = iterateJids(parser);
break;
}
break;
case END_ELEMENT:
if (parser.getDepth() == initialDepth) {
break outerloop;
}
break;
default:
// Catch all for incomplete switch (MissingCasesInEnumSwitch) statement.
break;
}
}
return elementFactory.newPrefsIQ(alwaysJids, neverJids, defaultBehavior);
}
Aggregations