It’s been a lot of years since I used SAX so I wrote my handler method the way I remember it looking:
1 2 3 4 5 6 7 8 9 10 | 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:
1 2 3 4 5 6 7 | 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.