RepoXMLHandler: tag handling simplification
* Don't have both curel and localName * Check for empty content only once * Don't convert curchars (StringBuilder) to String and trim unless necessary
This commit is contained in:
parent
c06c115f4d
commit
d1d81d85fa
@ -89,11 +89,8 @@ public class RepoXMLHandler extends DefaultHandler {
|
|||||||
throws SAXException {
|
throws SAXException {
|
||||||
|
|
||||||
super.endElement(uri, localName, qName);
|
super.endElement(uri, localName, qName);
|
||||||
final String curel = localName;
|
|
||||||
final String str = curchars.toString().trim();
|
|
||||||
final boolean empty = TextUtils.isEmpty(str);
|
|
||||||
|
|
||||||
if (curel.equals("application") && curapp != null) {
|
if (localName.equals("application") && curapp != null) {
|
||||||
apps.add(curapp);
|
apps.add(curapp);
|
||||||
curapp = null;
|
curapp = null;
|
||||||
// If the app id is already present in this apps list, then it
|
// If the app id is already present in this apps list, then it
|
||||||
@ -104,11 +101,16 @@ public class RepoXMLHandler extends DefaultHandler {
|
|||||||
// happen, and I don't *think* it will crash the client, because
|
// happen, and I don't *think* it will crash the client, because
|
||||||
// the first app will insert, the second one will update the newly
|
// the first app will insert, the second one will update the newly
|
||||||
// inserted one.
|
// inserted one.
|
||||||
} else if (curel.equals("package") && curapk != null && curapp != null) {
|
} else if (localName.equals("package") && curapk != null && curapp != null) {
|
||||||
apksList.add(curapk);
|
apksList.add(curapk);
|
||||||
curapk = null;
|
curapk = null;
|
||||||
} else if (!empty && curapk != null) {
|
} else if (curchars.length() == 0) {
|
||||||
switch (curel) {
|
// All options below require non-empty content
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final String str = curchars.toString().trim();
|
||||||
|
if (curapk != null) {
|
||||||
|
switch (localName) {
|
||||||
case "version":
|
case "version":
|
||||||
curapk.version = str;
|
curapk.version = str;
|
||||||
break;
|
break;
|
||||||
@ -157,8 +159,8 @@ public class RepoXMLHandler extends DefaultHandler {
|
|||||||
curapk.nativecode = Utils.CommaSeparatedList.make(str);
|
curapk.nativecode = Utils.CommaSeparatedList.make(str);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else if (!empty && curapp != null) {
|
} else if (curapp != null) {
|
||||||
switch (curel) {
|
switch (localName) {
|
||||||
case "name":
|
case "name":
|
||||||
curapp.name = str;
|
curapp.name = str;
|
||||||
break;
|
break;
|
||||||
@ -227,7 +229,7 @@ public class RepoXMLHandler extends DefaultHandler {
|
|||||||
curapp.requirements = Utils.CommaSeparatedList.make(str);
|
curapp.requirements = Utils.CommaSeparatedList.make(str);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else if (!empty && curel.equals("description")) {
|
} else if (localName.equals("description")) {
|
||||||
description = cleanWhiteSpace(str);
|
description = cleanWhiteSpace(str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user