Package org.marc4j.marc

Examples of org.marc4j.marc.Record


        InputStream input = getClass().getResourceAsStream(
                "resources/summerland.xml");
        MarcStreamWriter writer = new MarcStreamWriter(System.out);
        MarcXmlReader reader = new MarcXmlReader(input);
        while (reader.hasNext()) {
            Record record = reader.next();
            writer.write(record);
        }
        input.close();
        writer.close();
    }
View Full Code Here


        InputStream input = getClass().getResourceAsStream(
                "resources/summerland.mrc");
        MarcXmlWriter writer = new MarcXmlWriter(System.out, true);
        MarcStreamReader reader = new MarcStreamReader(input);
        while (reader.hasNext()) {
            Record record = reader.next();
            writer.write(record);
        }
        input.close();
        writer.close();
    }
View Full Code Here

                "resources/summerland.xml");
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        MarcStreamWriter writer = new MarcStreamWriter(out);
        MarcXmlReader reader = new MarcXmlReader(input);
        while (reader.hasNext()) {
            Record record = reader.next();
            writer.write(record);
        }
        input.close();
        writer.close();
       
        ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
        MarcStreamReader marcReader = new MarcStreamReader(in);
        MarcStreamWriter marcWriter = new MarcStreamWriter(System.out);
        while (marcReader.hasNext()) {
            Record record = marcReader.next();
            marcWriter.write(record);
        }
        in.close();
        marcWriter.close();
       
View Full Code Here

       
    }
   
    public void testCreateRecord() throws Exception {
        MarcFactory factory = MarcFactory.newInstance();
        Record record = factory.newRecord("00000cam a2200000 a 4500");
        assertEquals("00000cam a2200000 a 4500", record.getLeader().marshal());

        record.addVariableField(factory.newControlField("001", "12883376"));
       
        DataField df = factory.newDataField("245", '1', '0');
        df.addSubfield(factory.newSubfield('a', "Summerland /"));
        df.addSubfield(factory.newSubfield('c', "Michael Chabon."));
        record.addVariableField(df);
    }
View Full Code Here

                        .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

            }
            writer.setConverter(charconv);
        }

        while (reader.hasNext()) {
            Record record = reader.next();
            if (Constants.MARC_8_ENCODING.equals(convert))
                record.getLeader().setCharCodingScheme(' ');
            writer.write(record);
        }
        writer.close();

        System.err.println("Total time: "
View Full Code Here

        MarcStreamReader reader = new MarcStreamReader(input);
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        MarcStreamWriter writer = new MarcStreamWriter(out);
        while (reader.hasNext()) {
            Record record = reader.next();
            writer.write(record);
            counter++;
        }
        input.close();
        writer.close();

        assertEquals(1, counter);

        counter = 0;

        input = new ByteArrayInputStream(out.toByteArray());

        reader = new MarcStreamReader(input);
        while (reader.hasNext()) {
            Record record = reader.next();
            counter++;
        }
        input.close();

        assertEquals(1, counter);
View Full Code Here

        MarcStreamReader reader = new MarcStreamReader(input);
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        MarcStreamWriter writer = new MarcStreamWriter(out, "UTF8");
        writer.setConverter(new AnselToUnicode());
        while (reader.hasNext()) {
            Record record = reader.next();
            writer.write(record);
            counter++;
        }
        input.close();
        writer.close();

        assertEquals(8, counter);

        counter = 0;

        input = new ByteArrayInputStream(out.toByteArray());

        reader = new MarcStreamReader(input, "UTF8");

        while (reader.hasNext()) {
            Record record = reader.next();
            counter++;
        }
        input.close();

        assertEquals(8, counter);
View Full Code Here

        wait();
      } catch (Exception e) {
      }
    }
    if (re != null) throw(re);
    Record record = null;
    if (list.size() > 0)
      record = (Record) list.remove(0);
    notifyAll();
    return record;
View Full Code Here

       // This marc file has three records, but the first one
       // is too long for a marc binary record. Can we still read
       // the next two?
       MarcReader reader = new MarcPermissiveStreamReader(input, true, true);
             
       Record bad_record = reader.next();
      
       // Bad record is a total loss, don't even bother trying to read
       // it, but do we get the good records next?
       Record good_record1 = reader.next();
       ControlField good001 = good_record1.getControlNumberField();
       assertEquals(good001.getData(), "360945");
      
      
       Record good_record2 = reader.next();
       good001 = good_record2.getControlNumberField();
       assertEquals(good001.getData(), "360946");
      
    }
View Full Code Here

TOP

Related Classes of org.marc4j.marc.Record

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.