Class Subfield

  • All Implemented Interfaces:
    Serializable, Cloneable

    public class Subfield
    extends Object
    implements Serializable, Cloneable

    Subfield defines behaviour for a subfield (a data element within a data field).

    A subfield consists of a delimiter followed by a data element identifier (together the subfield code) and a data element. The structure of a data element according to the MARC standard is as follows:

     DELIMITER DATA_ELEMENT_IDENTIFIER DATA_ELEMENT
     

    This structure is returned by the marshal() method.

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

      • EMPTY_LINK_CODE

        public static final String EMPTY_LINK_CODE
        Empty value for the link code
    • Constructor Detail

      • Subfield

        public Subfield()
        Default constructor
      • Subfield

        public Subfield​(char code,
                        char[] data)

        Creates a new Subfield instance and registers the data element identifier and the data element.

        Parameters:
        code - the data element identifier
        data - the data element
      • Subfield

        public Subfield​(char code,
                        String data)

        Creates a new Subfield instance and registers the data element identifier and the data element.

        Parameters:
        code - the data element identifier
        data - the data element
      • Subfield

        public Subfield​(char code,
                        char[] data,
                        String linkCode)

        Creates a new Subfield instance and registers the data element identifier and the data element.

        Parameters:
        code - the data element identifier
        data - the data element
        linkCode - A code if the subfield has a link with another Record.
      • Subfield

        public Subfield​(char code,
                        String data,
                        String linkCode)

        Creates a new Subfield instance and registers the data element identifier and the data element.

        Parameters:
        code - the data element identifier
        data - the data element
        linkCode - A code if the subfield has a link with another Record.
      • Subfield

        public Subfield​(Subfield other)
        Copy constructor
        Parameters:
        other - Another instance of Subfield
    • Method Detail

      • find

        public boolean find​(Pattern pattern)
        Returns true is the supplied regular expression pattern matches the Subfield data; else, false.
        Parameters:
        pattern - An instance of a compiled Pattern to use as matcher
      • setCode

        public void setCode​(char code)
        Sets the Subfield code.
        Parameters:
        code - The code identifier
      • getCode

        public char getCode()
        Gets the Subfield code.
        Returns:
        char The code identifier
      • setData

        public void setData​(char[] data)
        Sets the Subfield data.
        Parameters:
        data - The data element
      • setData

        public void setData​(String data)
        Sets the Subfield data.
        Parameters:
        data - The data element
      • getData

        public char[] getData()
        Gets the Subfield data.
        Returns:
        char[] The data element
      • setLinkCode

        public void setLinkCode​(String linkCode)
        Sets the Subfield link code.
      • getLinkCode

        public String getLinkCode()
        Gets the Subfield link code.
      • marshal

        public String marshal()
        Returns a String representation for a data element following the structure of a MARC data element.
        Returns:
        String The marshaled representation of this Subfield
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object