It’s been a lot of years since I used SAX so I wrote my handler method the way I remember it looking:
if (qualifiedName.equals("edition") || qualifiedName.equals("author")) {
inTagWithText = true;
}
if (qualifiedName.equals("book")) {
System.out.println(attributes.getValue("title"));
} else if (qualifiedName.equals("paperback")) {
paperback = true;
} else if (qualifiedName.equals("authors")) {
System.out.println("Paperback? " + paperback);
}
IntelliJ suggested that this would be better with a switch. It was right. The new code is:
switch (qualifiedName) {
case "edition", "author" -> inTagWithText = true;
case "paperback" -> paperback = true;
case "authors" -> System.out.println("Paperback? " + paperback);
case "book" -> System.out.println(attributes.getValue("title"));
}
}
Thank you IntelliJ. That looks much better.