Package org.marc4j.marc

Examples of org.marc4j.marc.Record


        "resources/bad_too_long_plus_2.mrc");
      
       MarcReader reader = new MarcPermissiveStreamReader(input, true, true);
      
       //First record is the long one.
       Record weird_record = reader.next();
      
       //is it's marshal'd leader okay?
       String strLeader = weird_record.getLeader().marshal();

       // Make sure only five digits for length is used in the leader,
       // even though it's not big enough to hold the leader, we need to
       // make sure byte offsets in the rest of the leader are okay.
       assertEquals("nas", strLeader.substring(5,8) );
View Full Code Here


                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

                .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

    }

    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

        String[] tokens = line.trim().split("\t");
       
        if (tokens.length != 3)
            throw new MarcException("Index out of bounds");

        Record record = factory.newRecord("00000nz  a2200000o  4500");

        ControlField cf = factory.newControlField("001", tokens[0]);
        record.addVariableField(cf);

        DataField df = factory.newDataField("100", '1', ' ');
        df.addSubfield(factory.newSubfield('a', tokens[1]));
        df.addSubfield(factory.newSubfield('d', tokens[2]));
        record.addVariableField(df);

        return record;
    }
View Full Code Here

        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

        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

            // parse the input
            MarcReader reader = new MarcStreamReader(input);
            MarcWriter writer = new MarcXmlWriter(result);
            while (reader.hasNext()) {
                Record record = reader.next();
                writer.write(record);
            }
            writer.close();
           
            out.close();
View Full Code Here

        // Result result = new SAXResult(serializer.asContentHandler());

        // MarcXmlWriter writer = new MarcXmlWriter(result);
        // writer.setConverter(new AnselToUnicode());
        while (reader.hasNext()) {
            Record record = reader.next();
            // writer.write(record);
        }
        // writer.close();

    }
View Full Code Here

        URL url = new URL(
                "http://www.loc.gov/standards/marcxml/Sandburg/sandburg.mrc");

        MarcReader reader = new MarcStreamReader(url.openStream());
        while (reader.hasNext()) {
            Record record = reader.next();
            System.out.println(record.toString());
        }

    }
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.