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