Use switch-case in startElement to increase readability
@@ -85,17 +85,20 @@ public class QtTranslationSaxParser extends DefaultHandler {
elementTypeStack.push(key);
- if (CONTEXT_NAME.equals(key) && !contextName.isEmpty()) {
+ switch (key) {
+ case CONTEXT_NAME:
+ if (!contextName.isEmpty()) {
throw new ParsingException("Element type \"%s\" can be only used once within element type \"%s\" (Line %d).", CONTEXT_NAME, CONTEXT, this.documentLocator
.getLineNumber());
}
-
- if (SOURCE.equals(key) && !sourceValue.isEmpty()) {
+ break;
+ case SOURCE:
+ if (!sourceValue.isEmpty()) {
throw new ParsingException("Element type \"%s\" can be only used once within element type \"%s\" (Line %d).", SOURCE, MESSAGE, this.documentLocator
.getLineNumber());
}
-
- if (TRANSLATION.equals(key)) {
+ break;
+ case TRANSLATION:
if (translationTagFound) {
throw new ParsingException("Element type \"%s\" can be only used once within element type \"%s\" (Line %d).", TRANSLATION, MESSAGE, this.documentLocator
.getLineNumber());
@@ -107,11 +110,11 @@ public class QtTranslationSaxParser extends DefaultHandler {
applyTranslationType(translationType);
emitIssue = true;
}
- }
-
- if (MESSAGE.equals(key)) {
+ break;
+ case MESSAGE:
builder.setLineStart(this.documentLocator.getLineNumber());
builder.setColumnStart(lastColumnNumber);
+ break;
}
lastColumnNumber = this.documentLocator.getColumnNumber();
