Package org.marc4j.marc
Class ControlField
- java.lang.Object
-
- org.marc4j.marc.VariableField
-
- org.marc4j.marc.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
-
-
Field Summary
-
Fields inherited from class org.marc4j.marc.VariableField
EMPTY_ID
-
-
Constructor Summary
Constructors Constructor Description ControlField()
Default constructor.ControlField(String tag, char[] data)
Creates a new control field instance and registers the tag and the control field data.ControlField(String tag, char[] data, Long id)
Creates a new control field instance and registers the tag and the control field data.ControlField(String tag, String data)
Creates a new control field instance and registers the tag and the control field data.ControlField(String tag, String data, Long id)
Creates a new control field instance and registers the tag and the control field data.ControlField(ControlField other)
Copy constructor Copy id attribute, so if you don't want has the same, usecopy(ControlField)
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description Object
clone()
Deprecated.static ControlField
copy(ControlField original)
Creates a copy of the original instance without copy the id attribute.boolean
equals(Object obj)
boolean
find(Pattern pattern)
char[]
getData()
Returns the control field data.int
getLength()
Returns the length of the serialized form of the control field.int
hashCode()
String
marshal()
Returns aString
representation for a control field following the structure of a MARC control field.void
setData(char[] data)
Registers the control field data.void
setData(String data)
Registers the control field data.void
setTag(String tag)
Registers the tag.String
toString()
-
Methods inherited from class org.marc4j.marc.VariableField
getId, getTag, setId
-
-
-
-
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 namedata
- 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 namedata
- 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 namedata
- the control field dataid
- 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 namedata
- the control field dataid
- the field id if exists.
-
ControlField
public ControlField(ControlField other)
Copy constructor Copy id attribute, so if you don't want has the same, usecopy(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)
- Specified by:
find
in classVariableField
- Parameters:
pattern
- An instance of a compiled Pattern to use as matcher
-
setTag
public void setTag(String tag)
Registers the tag.- Overrides:
setTag
in classVariableField
- 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 aString
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
-
clone
@Deprecated public Object clone()
Deprecated.- Specified by:
clone
in classVariableField
-
equals
public boolean equals(Object obj)
- Specified by:
equals
in classVariableField
-
hashCode
public int hashCode()
- Specified by:
hashCode
in classVariableField
-
-