1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-11-25 21:42:07 +01:00

Fix style issues in Workgroup Macros

This commit is contained in:
Florian Schmaus 2018-03-28 14:47:33 +02:00
parent 74e3d56ba2
commit 4c13ea4125

View file

@ -126,80 +126,74 @@ public class Macros extends IQ {
} }
public Macro parseMacro(XmlPullParser parser) throws XmlPullParserException, IOException { public Macro parseMacro(XmlPullParser parser) throws XmlPullParserException, IOException {
// CHECKSTYLE:OFF Macro macro = new Macro();
Macro macro = new Macro(); boolean done = false;
boolean done = false;
while (!done) { while (!done) {
int eventType = parser.next(); int eventType = parser.next();
if (eventType == XmlPullParser.START_TAG) { if (eventType == XmlPullParser.START_TAG) {
if (parser.getName().equals("title")) { if (parser.getName().equals("title")) {
parser.next(); parser.next();
macro.setTitle(parser.getText()); macro.setTitle(parser.getText());
} }
else if (parser.getName().equals("description")) { else if (parser.getName().equals("description")) {
macro.setDescription(parser.nextText()); macro.setDescription(parser.nextText());
} }
else if (parser.getName().equals("response")) { else if (parser.getName().equals("response")) {
macro.setResponse(parser.nextText()); macro.setResponse(parser.nextText());
} }
else if (parser.getName().equals("type")) { else if (parser.getName().equals("type")) {
macro.setType(Integer.valueOf(parser.nextText()).intValue()); macro.setType(Integer.valueOf(parser.nextText()).intValue());
} }
} }
else if (eventType == XmlPullParser.END_TAG) { else if (eventType == XmlPullParser.END_TAG) {
if (parser.getName().equals("macro")) { if (parser.getName().equals("macro")) {
done = true; done = true;
} }
} }
} }
return macro; return macro;
// CHECKSTYLE:ON
} }
public MacroGroup parseMacroGroup(XmlPullParser parser) throws XmlPullParserException, IOException { public MacroGroup parseMacroGroup(XmlPullParser parser) throws XmlPullParserException, IOException {
// CHECKSTYLE:OFF MacroGroup group = new MacroGroup();
MacroGroup group = new MacroGroup();
boolean done = false; boolean done = false;
while (!done) { while (!done) {
int eventType = parser.next(); int eventType = parser.next();
if (eventType == XmlPullParser.START_TAG) { if (eventType == XmlPullParser.START_TAG) {
if (parser.getName().equals("macrogroup")) { if (parser.getName().equals("macrogroup")) {
group.addMacroGroup(parseMacroGroup(parser)); group.addMacroGroup(parseMacroGroup(parser));
} }
if (parser.getName().equals("title")) { if (parser.getName().equals("title")) {
group.setTitle(parser.nextText()); group.setTitle(parser.nextText());
} }
if (parser.getName().equals("macro")) { if (parser.getName().equals("macro")) {
group.addMacro(parseMacro(parser)); group.addMacro(parseMacro(parser));
} }
} }
else if (eventType == XmlPullParser.END_TAG) { else if (eventType == XmlPullParser.END_TAG) {
if (parser.getName().equals("macrogroup")) { if (parser.getName().equals("macrogroup")) {
done = true; done = true;
} }
} }
} }
return group; return group;
// CHECKSTYLE:ON
} }
public MacroGroup parseMacroGroups(String macros) throws XmlPullParserException, IOException { public MacroGroup parseMacroGroups(String macros) throws XmlPullParserException, IOException {
// CHECKSTYLE:OFF MacroGroup group = null;
MacroGroup group = null; XmlPullParser parser = XmlPullParserFactory.newInstance().newPullParser();
XmlPullParser parser = XmlPullParserFactory.newInstance().newPullParser(); parser.setInput(new StringReader(macros));
parser.setInput(new StringReader(macros)); int eventType = parser.getEventType();
int eventType = parser.getEventType(); while (eventType != XmlPullParser.END_DOCUMENT) {
while (eventType != XmlPullParser.END_DOCUMENT) { eventType = parser.next();
eventType = parser.next(); if (eventType == XmlPullParser.START_TAG) {
if (eventType == XmlPullParser.START_TAG) { if (parser.getName().equals("macrogroup")) {
if (parser.getName().equals("macrogroup")) { group = parseMacroGroup(parser);
group = parseMacroGroup(parser); }
} }
} }
} return group;
return group;
// CHECKSTYLE:ON
} }
} }
} }