org.marc4j.marc
Class Record

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

public class Record
extends Object
implements Serializable

Record defines behaviour for a record.

The structure of a record according to the MARC standard is as follows:

 LEADER  DIRECTORY  FT  CONTROL_NUMBER_FIELD  FT
   CONTROL_FIELD_1  FT   ...   CONTROL_FIELD_n  FT
     DATA_FIELD_1  FT   ...   DATA_FIELD_n  FT  RT
 

This structure is returned by the marshal() method.

Note: the control number field (tag 001) is an instance of a ControlField. The method add(ControlField field) throws an IllegalAddException when more than one control number field is supplied.

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

Constructor Summary
Record()
          Default constructor.
Record(Leader leader)
          Creates a new instance for a record and registers the leader.
 
Method Summary
 void add(ControlField field)
          Adds a new ControlField instance to the collection of variable fields.
 void add(DataField field)
          Adds a new DataField instance to the collection of variable fields.
 void add(Leader leader)
          Registers the leader.
 ControlField getControlField(String tag)
          Returns the control field for the given tag.
 List getControlFieldList()
          Returns the collection of control fields.
 String getControlNumber()
          Returns the control number (contents for tag 001).
 ControlField getControlNumberField()
          Returns the control number field (tag 001).
 DataField getDataField(String tag)
          Returns the data field for the given tag.
 List getDataFieldList()
          Returns the collection of data fields.
 Leader getLeader()
          Returns the leader.
 List getVariableFieldList()
          Returns the collection of variable fields.
 boolean hasControlNumberField()
          Returns true if the collection of variable fields contains a control number field.
 boolean hasVariableField(String tag)
          Returns true if there is a variable field with the given tag.
 String marshal()
          Returns a String representation for a record following the structure of a MARC record (tape format).
 void setControlFieldList(List newList)
          Sets the collection of control fields.
 void setDataFieldList(List newList)
          Sets the collection of data fields.
 void setVariableFieldList(List newList)
          Sets the collection of variable fields.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Record

public Record()

Default constructor.


Record

public Record(Leader leader)

Creates a new instance for a record and registers the leader.

Parameters:
leader - the Leader object
Method Detail

getLeader

public Leader getLeader()

Returns the leader.

Returns:
Leader - the leader

add

public void add(Leader leader)

Registers the leader.

Parameters:
leader - the Leader object

add

public void add(ControlField field)

Adds a new ControlField instance to the collection of variable fields.

Checks if the variable field is a control number field (tag 001). If the field is a control number field an IllegalAddException is thrown when there is already a control number field in the field collection.

Parameters:
field - the control field
Throws:
IllegalAddException - when there is already a control number field on the field map

add

public void add(DataField field)

Adds a new DataField instance to the collection of variable fields.

Parameters:
field - the data field

getControlNumberField

public ControlField getControlNumberField()

Returns the control number field (tag 001).

Returns:
ControlField - the control number field

getControlNumber

public String getControlNumber()

Returns the control number (contents for tag 001).

Returns:
String - the control number value

getControlField

public ControlField getControlField(String tag)

Returns the control field for the given tag.

Parameters:
tag - the tag name
Returns:
ControlField - the control field object

hasVariableField

public boolean hasVariableField(String tag)

Returns true if there is a variable field with the given tag.

Parameters:
tag - the tag name
Returns:
true if the variable field exists, false if not

getDataField

public DataField getDataField(String tag)

Returns the data field for the given tag.

Parameters:
tag - the tag name
Returns:
DataField - the control number value

hasControlNumberField

public boolean hasControlNumberField()

Returns true if the collection of variable fields contains a control number field.

Returns:
boolean - true if there is a control number field, false if there is no control number field

getControlFieldList

public List getControlFieldList()

Returns the collection of control fields.

The collection of control fields contains:

Returns:
List - the control field collection
See Also:
ControlField

setControlFieldList

public void setControlFieldList(List newList)

Sets the collection of control fields.

A collection of control fields is a List object with null or more ControlField objects.

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

Parameters:
newList - the new control field collection

getDataFieldList

public List getDataFieldList()

Returns the collection of data fields.

Returns:
List - the data field collection
See Also:
DataField

setDataFieldList

public void setDataFieldList(List newList)

Sets the collection of data fields.

A collection of data fields is a List object with null or more DataField objects.

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

Parameters:
newList - the new data field collection

getVariableFieldList

public List getVariableFieldList()

Returns the collection of variable fields.

The collection of variable fields contains:

Returns:
List - the variable field collection
See Also:
ControlField, DataField

setVariableFieldList

public void setVariableFieldList(List newList)

Sets the collection of variable fields.

A collection of variable fields is a List object with null or more ControlField or DataField objects.

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

Parameters:
newList - the new variable field collection

marshal

public String marshal()
               throws MarcException

Returns a String representation for a record following the structure of a MARC record (tape format).

Variable fields are sorted by tag name.

Returns:
String - the MARC record
Throws:
MarcException - if the record contains no leader or no control number field


Copyright 2001-2003 Bas Peters. All Rights Reserved.