org.marc4j.marc
Class DataField

java.lang.Object
  |
  +--org.marc4j.marc.VariableField
        |
        +--org.marc4j.marc.DataField
All Implemented Interfaces:
Serializable

public class DataField
extends VariableField
implements Serializable

DataField defines behaviour for a data field (tag 010-999).

Data fields are variable fields identified by tags beginning with ASCII numeric values other than two zero's. Data fields contain indicators, subfield codes, data and a field terminator. The structure of a data field according to the MARC standard is as follows:

 INDICATOR_1  INDICATOR_2  DELIMITER  DATA_ELEMENT_IDENTIFIER_1
   DATA_ELEMENT_1  ...  DELIMITER  DATA_ELEMENT_IDENTIFIER_n
     DATA_ELEMENT_n  FT
 

This structure is returned by the marshal() method.

Version:
$Revision: 1.6 $
Author:
Bas Peters
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.marc4j.marc.VariableField
FT
 
Constructor Summary
DataField()
          Default constructor.
DataField(String tag)
          Creates a new DataField instance and registers the tag name.
DataField(String tag, char ind1, char ind2)
          Creates a new DataField instance and registers the tag name and the indicator values.
 
Method Summary
 void add(Subfield subfield)
          Adds a new subfield instance to the collection of data elements.
 char getIndicator1()
          Returns the first indicator.
 char getIndicator2()
          Returns the second indicator.
 int getLength()
          Returns the length of the serialized form of the current data field.
 Subfield getSubfield(char code)
          Returns the subfield for a given data element identifier.
 List getSubfieldList()
          Returns the collection of data elements.
 String getTag()
          Returns the tag name.
 boolean hasSubfield(char code)
          Returns true if there is a subfield with the given identifier.
 String marshal()
          Returns a String representation for a data field following the structure of a MARC data field.
 void setIndicator1(char ind1)
          Registers the first indicator value.
 void setIndicator2(char ind2)
          Registers the second indicator value.
 void setSubfieldList(List newList)
          Sets the collection of data elements.
 void setTag(String tag)
          Registers the tag.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DataField

public DataField()

Default constructor.


DataField

public DataField(String tag)

Creates a new DataField instance and registers the tag name.

Parameters:
tag - the tag name

DataField

public DataField(String tag,
                 char ind1,
                 char ind2)

Creates a new DataField instance and registers the tag name and the indicator values.

Parameters:
tag - the tag name
ind1 - the first indicator
ind2 - the second indicator
Method Detail

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 data field identifier

getTag

public String getTag()

Returns the tag name.

Overrides:
getTag in class VariableField
Returns:
String - the tag name

setIndicator1

public void setIndicator1(char ind1)

Registers the first indicator value.

Parameters:
ind1 - the first indicator
Throws:
IllegalIndicatorException - when the indicator value is invalid

setIndicator2

public void setIndicator2(char ind2)

Registers the second indicator value.

Parameters:
ind2 - the second indicator
Throws:
IllegalIndicatorException - when the indicator value is invalid

add

public void add(Subfield subfield)

Adds a new subfield instance to the collection of data elements.

Parameters:
subfield - the data element
See Also:
Subfield

getIndicator1

public char getIndicator1()

Returns the first indicator.

Returns:
char - the first indicator

getIndicator2

public char getIndicator2()

Returns the second indicator.

Returns:
char - the second indicator

getSubfieldList

public List getSubfieldList()

Returns the collection of data elements.

Returns:
List - the data element collection
See Also:
Subfield

getSubfield

public Subfield getSubfield(char code)

Returns the subfield for a given data element identifier.

Parameters:
code - the data element identifier
Returns:
Subfield the data element
See Also:
Subfield

hasSubfield

public boolean hasSubfield(char code)

Returns true if there is a subfield with the given identifier.

Parameters:
code - the data element identifier
Returns:
true if the data element exists, false if not

setSubfieldList

public void setSubfieldList(List newList)

Sets the collection of data elements.

A collection of data elements is a List object with null or more Subfield objects.

Note: this method replaces the current List of subfields with the subfields in the new List.

Parameters:
newList - the new data element collection

marshal

public String marshal()

Returns a String representation for a data field following the structure of a MARC data field.

Returns:
String - the data field

getLength

public int getLength()

Returns the length of the serialized form of the current data field.

Returns:
int - the data field length


Copyright 2001-2003 Bas Peters. All Rights Reserved.