@Override public void endElement(String namespaceURI, String localName, String qName) throws SAXException { if (qName.equalsIgnoreCase("title") && sect) { section.setTitle(ch_str.toString()); ch_str = new StringBuilder(64); } else if (qName.equalsIgnoreCase("section")) { section.setDescription(ch_str.toString()); book.add(new Chapter(section.getTitle(), section.getDescription())); ch_str = new StringBuilder(64); } else if (descript) { if (qName.equalsIgnoreCase("annotation")) { book.setAnnotation(ch_str.toString() + ""); ch_str = new StringBuilder(64); } if (qName.equalsIgnoreCase("author")) { book.authors.add(authors); authors = new Author(); } } ElementName = ""; }
@Override public void characters(char[] ch, int start, int length) throws SAXException { if (descript) { if (ElementName.equalsIgnoreCase("p") || ElementName.equalsIgnoreCase("i")) ch_str.append(new String(ch, start, length) + "\n"); else if (ElementName.equalsIgnoreCase("genre")) book.genres.add(new String(ch, start, length)); else if (ElementName.equalsIgnoreCase("first-name")) authors.setFirst_name(new String(ch, start, length)); else if (ElementName.equalsIgnoreCase("last-name")) authors.setLast_name(new String(ch, start, length)); else if (ElementName.equalsIgnoreCase("book-title")) book.setBook_title(new String(ch, start, length)); } else if ((!descript) && sect) { // if (ElementName.equalsIgnoreCase("title")) if (ElementName.equalsIgnoreCase("p") || ElementName.equalsIgnoreCase("i")) { ch_str.append(ch, start, length); ch_str.append("\n"); } } }