Package org.marc4j.marc

Examples of org.marc4j.marc.ControlField


        MarcReader reader = new MarcStreamReader(input);
        while (reader.hasNext()) {
            Record record = reader.next();
           
            // get control field with tag 008
            ControlField controlField = (ControlField) record
                    .getVariableField("008");
           
            String data = controlField.getData();

            // the three-character MARC language code takes character
            // positions 35-37
            String lang = data.substring(35, 38);
            System.out.println("Language code (008 35-37): " + lang);
View Full Code Here


                    if (inputrec.read() != Constants.FT)
                    {
                        throw new MarcException("expected field terminator at end of field");
                    }
   
                    ControlField field = factory.newControlField();
                    field.setTag(tags[i]);
                    field.setData(getDataAsString(byteArray));
                    record.addVariableField(field);
                }
                else
                {
                    byteArray = new byte[lengths[i]];
View Full Code Here

  public void setUp() throws Exception {
    factory = MarcFactory.newInstance();
  }

  public void testConstructor() throws Exception {
      ControlField cf = factory.newControlField("001");
      assertEquals("001", cf.getTag());
  }
View Full Code Here

      ControlField cf = factory.newControlField("001");
      assertEquals("001", cf.getTag());
  }

  public void testSetData() throws Exception {
      ControlField cf = factory.newControlField("001");
      cf.setData("12883376");
      assertEquals("12883376", cf.getData());
  }
View Full Code Here

      cf.setData("12883376");
      assertEquals("12883376", cf.getData());
  }
   
    public void testComparable() throws Exception {
        ControlField cf1 = factory.newControlField("008", "12345");
        ControlField cf2 = factory.newControlField("008", "12345");
        assertEquals(0, cf1.compareTo(cf2));
        cf2.setTag("009");
        assertEquals(-1, cf1.compareTo(cf2));
        cf2.setTag("007");
        assertEquals(1, cf1.compareTo(cf2));
    }
View Full Code Here

           
            // control fields
            List fields = record.getControlFields();
            Iterator i = fields.iterator();
            while (i.hasNext()) {
                ControlField cf = (ControlField) i.next();

                data.write(getDataElement(cf.getData()));
                data.write(Constants.FT);
                dir.write(getEntry(cf.getTag(), data.size() - previous,
                        previous));
                previous = data.size();
            }

            // data fields
View Full Code Here

            fields.add(i.next());
        return fields;
    }

    public String getControlNumber() {
        ControlField f = getControlNumberField();
        String result = (f == null || f.getData() == null) ? null : new String(f.getData());
        return(result);
    }
View Full Code Here

   *          the collection of <code>ControlField</code> objects.
   */
  public static boolean hasControlNumberField(Collection col) {
    Iterator i = col.iterator();
    while (i.hasNext()) {
      ControlField field = (ControlField) i.next();
      String tag = field.getTag();
      if (isControlNumberField(tag))
        return true;
    }
    return false;
  }
View Full Code Here

TOP

Related Classes of org.marc4j.marc.ControlField

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.