Class ControlField

  • All Implemented Interfaces:
    Serializable, Cloneable

    public class ControlField
    extends VariableField
    implements Serializable, Cloneable

    ControlField defines behavior for a control field (tag 001-009).

    Control fields are variable fields identified by tags beginning with two zero's. They are comprised of data and a field terminator and do not contain indicators or subfield codes. The structure of a control field according to the MARC standard is as follows:

     DATA_ELEMENT FIELD_TERMINATOR
     

    This structure is returned by the marshal() method.

    Author:
    Bas Peters
    See Also:
    Serialized Form
    • Constructor Detail

      • ControlField

        public ControlField()
        Default constructor.
      • ControlField

        public ControlField​(String tag,
                            char[] data)
        Creates a new control field instance and registers the tag and the control field data.
        Parameters:
        tag - the tag name
        data - the control field data
      • ControlField

        public ControlField​(String tag,
                            String data)
        Creates a new control field instance and registers the tag and the control field data.
        Parameters:
        tag - the tag name
        data - the control field data
      • ControlField

        public ControlField​(String tag,
                            char[] data,
                            Long id)
        Creates a new control field instance and registers the tag and the control field data.
        Parameters:
        tag - the tag name
        data - the control field data
        id - the field id if exists.
      • ControlField

        public ControlField​(String tag,
                            String data,
                            Long id)
        Creates a new control field instance and registers the tag and the control field data.
        Parameters:
        tag - the tag name
        data - the control field data
        id - the field id if exists.
      • ControlField

        public ControlField​(ControlField other)
        Copy constructor Copy id attribute, so if you don't want has the same, use copy(ControlField).
        Parameters:
        other - Another instance of ControlField
    • Method Detail

      • copy

        public static ControlField copy​(ControlField original)
        Creates a copy of the original instance without copy the id attribute.
        Parameters:
        original - Instance to copy.
        Returns:
        new copy of original instance without the id attribute.
      • find

        public boolean find​(Pattern pattern)
        Returns true is the supplied regular expression pattern matches the ControlField data; else, false.
        Specified by:
        find in class VariableField
        Parameters:
        pattern - An instance of a compiled Pattern to use as matcher
      • setTag

        public void setTag​(String tag)
        Registers the tag.
        Overrides:
        setTag in class VariableField
        Parameters:
        tag - the tag name
        Throws:
        IllegalTagException - when the tag is not a valid control field identifier
      • setData

        public void setData​(char[] data)
        Registers the control field data.
        Parameters:
        data - the control field data
        Throws:
        IllegalDataElementException - if the data element contains control characters
      • setData

        public void setData​(String data)
        Registers the control field data.
        Parameters:
        data - the control field data
        Throws:
        IllegalDataElementException - if the data element contains control characters
      • getData

        public char[] getData()
        Returns the control field data.
        Returns:
        char[] - control field as a character array
      • marshal

        public String marshal()
        Returns a String representation for a control field following the structure of a MARC control field.
        Returns:
        String - control field
      • getLength

        public int getLength()
        Returns the length of the serialized form of the control field.
        Returns:
        int - length of control field