Package org.marc4j

Examples of org.marc4j.MarcReader


    public static void convertToMARCXML( File inputFile, File outputFile, Charset inputEncoding, Charset outputEncoding ) throws Exception {
        InputStream in = new FileInputStream(inputFile);
        OutputStream out = new FileOutputStream(outputFile);

        //MarcReader reader = new MarcStreamReader(in, inputEncoding );
        MarcReader reader = new MarcPermissiveStreamReader(in,true,true,"IS05426");
        System.err.println("Using IS05426 for conversion");
        MarcXmlWriter writer = new MarcXmlWriter(out, outputEncoding, true);

        while (reader.hasNext()) {
            Record record = reader.next();

            writer.write(record);
        }
        writer.close();
    }
View Full Code Here


   * create the canonica XML for this object
   */
  public Document getCanonicalXML(Object native_object) throws RecordBuilderException {
    org.w3c.dom.Document retval = null;
    try {
      MarcReader reader = new MarcStreamReader(new ByteArrayInputStream((byte[])native_object));
      javax.xml.transform.dom.DOMResult result = new javax.xml.transform.dom.DOMResult();
      MarcXmlWriter writer = new MarcXmlWriter(result);
      writer.setConverter(new org.marc4j.converter.impl.AnselToUnicode());
      if (reader.hasNext()) {
        Record record = (Record) reader.next();
        writer.write(record);
      }
      writer.close();

      retval = (Document) result.getNode();
View Full Code Here

  }

  public String toString() {
    StringWriter sw = new StringWriter();
    try {
      MarcReader reader = new MarcReader();
      TaggedWriter handler = new TaggedWriter(sw);
      MarcSource source = new MarcSource(reader, new ByteArrayInputStream(this.source_record));
      MarcResult result = new MarcResult();
      result.setHandler(handler);
      Converter converter = new Converter();
View Full Code Here

                TransformerHandler handler = saxTFactory
                        .newTransformerHandler(templates);

                // parse the input
                MarcReader reader = new MarcXmlReader(input, handler);
                while (reader.hasNext()) {
                    Record record = reader.next();
                    System.out.println(record.toString());
                }
            }
        }
    }
View Full Code Here

    public static void main(String args[]) throws Exception {

        InputStream input = ReadSingleRecordExample.class
                .getResourceAsStream("resources/summerland.mrc");

        MarcReader reader = new MarcStreamReader(input);
        Record record = reader.next();
        System.out.println(record.toString());
    }
View Full Code Here

            System.arraycopy(args, 1, newArgs, 0, args.length-1);
            args = newArgs;
        }
        String fileStr = args[0];
        File file = new File(fileStr);
        MarcReader readerNormal = null;
        MarcReader readerPermissive = null;
        boolean to_utf_8 = true;
      
        InputStream inNorm;
        InputStream inPerm;
        OutputStream patchedRecStream = null;
        MarcWriter patchedRecs = null;
        ErrorHandler errorHandler = new ErrorHandler();
        try
        {
            inNorm = new FileInputStream(file);
            readerNormal = new MarcPermissiveStreamReader(inNorm, false, to_utf_8);
            inPerm = new FileInputStream(file);
            readerPermissive = new MarcPermissiveStreamReader(inPerm, errorHandler, to_utf_8, "BESTGUESS");
        }
        catch (FileNotFoundException e)
        {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        if (args.length > 1)
        {
            try
            {
                patchedRecStream = new FileOutputStream(new File(args[1]));
                patchedRecs = new MarcStreamWriter(patchedRecStream);
            }
            catch (FileNotFoundException e)
            {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
        while (readerNormal.hasNext() && readerPermissive.hasNext())
        {
            Record recNorm;
            Record recPerm;
            recPerm = readerPermissive.next();
            String strPerm = recPerm.toString();
            try {
                recNorm = readerNormal.next();
            }
            catch (MarcException me)
View Full Code Here

    public static void main(String args[]) throws Exception {

        InputStream input = ReadMarcExample.class
                .getResourceAsStream("resources/summerland.mrc");

        MarcReader reader = new MarcStreamReader(input);
        MarcWriter writer = new MarcStreamWriter(System.out);
        while (reader.hasNext()) {
            Record record = reader.next();
            writer.write(record);
        }
        writer.close();
    }
View Full Code Here

    Record record = null;

    public void setUp() throws Exception {
        InputStream input = getClass().getResourceAsStream(
                "resources/summerland.mrc");
        MarcReader reader = new MarcStreamReader(input);
        while (reader.hasNext()) {
            record = reader.next();
        }
        input.close();
    }
View Full Code Here

    public static void main(String args[]) throws Exception {

        InputStream input = ReadMarcExample.class
                .getResourceAsStream("resources/summerland.xml");

        MarcReader reader = new MarcXmlReader(input);
        while (reader.hasNext()) {
            Record record = reader.next();
            System.out.println(record.toString());
        }

    }
View Full Code Here

        Result result = new StreamResult(System.out);

        InputStream input = ReadMarcExample.class
                .getResourceAsStream("resources/summerland.mrc");
        MarcReader reader = new MarcStreamReader(input);

        MarcXmlWriter writer = new MarcXmlWriter(result, stylesheet);
        writer.setConverter(new AnselToUnicode());
        while (reader.hasNext()) {
            Record record = (Record) reader.next();
            writer.write(record);
        }
        writer.close();
    }
View Full Code Here

TOP

Related Classes of org.marc4j.MarcReader

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.