Exemplo n.º 1
0
  private void readNext() throws XMLStreamException {
    Publication publication = new Publication();
    while (xmlEventReader.hasNext()) {
      XMLEvent xmlEvent = xmlEventReader.nextEvent();
      if (xmlEvent.isStartElement()) {
        StartElement startElement = xmlEvent.asStartElement();

        if (in_publication_types(startElement.getName().getLocalPart())) {
          publication = new Publication();
          publication.type = startElement.getName().getLocalPart();
          in_publication = true;
          continue;
        }

        if (in_publication && startElement.getName().getLocalPart().equals("title")) {
          xmlEvent = xmlEventReader.nextEvent();
          publication.title = xmlEvent.toString();
          continue;
        }
      }

      if (xmlEvent.isEndElement()) {
        if (in_publication_types(xmlEvent.asEndElement().getName().getLocalPart())) {
          if (publication.title != null && !publication.title.equals("")) {
            next_publications.add(publication);
          }
          publication = new Publication();
          in_publication = false;

          if (next_publications.size() >= BUFFER_SIZE) {
            break;
          }
        }
      }
    }
  }