コード例 #1
0
  public void processJournals(Reader reader) throws Exception {

    Iterator lineIter = FormattedTextParser.parseDelimitedReader(reader, '|');

    while (lineIter.hasNext()) {
      String[] line = (String[]) lineIter.next();

      if (line.length < 2) {
        throw new RuntimeException(
            "Journal line does not have enough elements: " + line.length + line[0]);
      }

      String primaryIdentifier = line[0];
      String name = line[1];
      String abbrev = line[2];
      String publisher = line[3];

      Item journal = getJournal(primaryIdentifier);

      if (!StringUtils.isEmpty(name)) {
        journal.setAttribute("name", name);
      }
      if (!StringUtils.isEmpty(abbrev)) {
        journal.setAttribute("abbrev", abbrev);
      }
      if (!StringUtils.isEmpty(publisher)) {
        journal.setAttribute("publisher", publisher);
      }

      if (journal.getAttribute("primaryIdentifier").getValue().equals("ZDB-JRNL-050621-1000")) {
        System.out.println("storing: ZDB-JRNL-050621-1000");
      }

      try {

        store(journal);
      } catch (ObjectStoreException e) {
        throw new SAXException(e);
      }
    }
  }