Skip to content

Instantly share code, notes, and snippets.

@dmj
Last active December 26, 2015 07:39
Show Gist options
  • Save dmj/7116314 to your computer and use it in GitHub Desktop.
Save dmj/7116314 to your computer and use it in GitHub Desktop.

001A 02012:18-04-12
001B 02012:04-05-12t16:13:28.000
001D 02012:31-08-98
001U 0utf8
001X 00
002@ 0Tuv1
003@ 0034034986
003U ahttp://d-nb.info/gnd/4510065-2
004B awit
007K agnd04510065-2
007N aswd04510065-2vzg
008A as
022@ aPraelectio in priora Aristotelis analyticavNUC pre 56
022@ aPraelectio in priora Aristotelis analytica, titulus LamiavNUC pre 56
022@ aPraelectio in analytica Aristotelis quae dicitur Lamia
022@ aPraelectio in Aristotelem, cui titulus est Lamia
022@ aIn priora analytica praelectio cui titulus est Lamia
022A aLamia
028R 90793881328Politianus, Angelus ; ID: gnd/1185955124aut1
042A a12.2pa6.1p
042B aXA-IT
050E aLUI, -GBV-AK gegen NUC pre 56
050H aPhilosophische Vorlesung, gehalten im November 1492

001A 02012:18-04-12
001B 02012:04-05-12t16:13:29.000
001D 02012:03-08-98
001U 0utf8
001X 00
002@ 0Tuv1
003@ 0034041737
003U ahttp://d-nb.info/gnd/4509532-2
004B awit
007K agnd04509532-2
007N aswd04509532-2vzg
008A as
022@ aSpeyrer Zeitungv1814-1816
022A aNeue Speyerer Zeitung
041R 91061088328Zeitung ; ID: gnd/4067510-54obin
042A a2.3
042B aXA-DE
050E aZDB
050H a1816-1853
065R 91047048618Deutschland ; ID: gnd/4011882-44geoa
/*
* This file is part of de.hab.diglib.
*
* de.hab.diglib is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* de.hab.diglib is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with de.hab.diglib. If not, see <http://www.gnu.org/licenses/>.
*/
package de.hab.diglib.batch.reader;
import org.springframework.batch.item.ItemReader;
import java.io.Reader;
import java.io.IOException;
import java.io.BufferedReader;
/**
* Read PICA+ records from a VZG export file.
*
* In contrast to the common dumpfile format the VZG's format uses one
* line per field and indicates records with a preceeding sequence of
* 0x0A 0x1D.
*
* @author David Maus <[email protected]>
*/
public class PicaVzgDumpReader implements ItemReader<String>
{
/**
* Reader
*/
private BufferedReader reader;
/**
* Constructor.
*/
public PicaVzgDumpReader (Reader reader)
{
this.reader = new BufferedReader(reader);
}
@Override
public String read () throws IOException
{
if (this.next()) {
String field;
StringBuilder record = new StringBuilder();
do {
field = this.reader.readLine();
if (field != null) {
record.append(field);
}
} while (field != null && !field.isEmpty());
return record.toString();
}
return null;
}
/**
* Advance reader to next record.
*
* Returns TRUE if there is a next record, otherwise FALSE.
*
* Moves cursor until the reader is exhausted or the record
* separator character (ASCII 0x1D) is found.
*/
private boolean next () throws IOException
{
int octet;
do {
octet = this.reader.read();
} while (octet != -1 && octet != 29);
if (octet == 29) {
this.reader.skip(1);
return true;
}
return false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment