org.marc4j.marc.impl
Class RecordImpl

java.lang.Object
  extended by org.marc4j.marc.impl.RecordImpl
All Implemented Interfaces:
Serializable, Record

public class RecordImpl
extends Object
implements Record

Represents a MARC record.

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

Constructor Summary
RecordImpl()
          Creates a new Record.
 
Method Summary
 void addVariableField(VariableField field)
          Adds a VariableField being a ControlField or DataField.
 List find(String pattern)
          Returns a List of VariableField objects that have a data element that matches the given regular expression.
 List find(String[] tag, String pattern)
          Returns a List of VariableField objects with the given tags that have a data element that matches the given regular expression.
 List find(String tag, String pattern)
          Returns a List of VariableField objects with the given tag that have a data element that matches the given regular expression.
 List getControlFields()
          Returns a list of control fields
 String getControlNumber()
          Returns the control number or null if no control number is available.
 ControlField getControlNumberField()
          Returns the control number field or null if no control number field is available.
 List getDataFields()
          Returns a list of data fields
 Long getId()
          Returns the identifier.
 Leader getLeader()
          Returns the Leader.
 String getType()
          Returns the type of record.
 VariableField getVariableField(String tag)
          Returns the first instance of the variable field with the given tag.
 List getVariableFields()
          Returns a list of variable fields
 List getVariableFields(String tag)
          Returns a list of variable fields with the given tag.
 List getVariableFields(String[] tags)
          Returns a list of variable fields for the given tags.
 void removeVariableField(VariableField field)
          Removes a variable field from the collection.
 void setId(Long id)
          Sets the identifier.
 void setLeader(Leader leader)
          Sets the Leader.
 void setType(String type)
          Sets the type of record.
 String toString()
          Returns a string representation of this record.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RecordImpl

public RecordImpl()
Creates a new Record.

Method Detail

setType

public void setType(String type)
Description copied from interface: Record
Sets the type of record.

Specified by:
setType in interface Record
Parameters:
type - the type of record

getType

public String getType()
Description copied from interface: Record
Returns the type of record.

Specified by:
getType in interface Record
Returns:
String - the type of record

setLeader

public void setLeader(Leader leader)
Description copied from interface: Record
Sets the Leader.

Specified by:
setLeader in interface Record
Parameters:
leader - the Leader

getLeader

public Leader getLeader()
Description copied from interface: Record
Returns the Leader.

Specified by:
getLeader in interface Record
Returns:
Leader - the Leader

addVariableField

public void addVariableField(VariableField field)
Adds a VariableField being a ControlField or DataField. If the VariableField is a control number field (001) and the record already has a control number field, the field is replaced with the new instance.

Specified by:
addVariableField in interface Record
Parameters:
field - the VariableField
Throws:
IllegalAddException - when the parameter is not a VariableField instance

removeVariableField

public void removeVariableField(VariableField field)
Description copied from interface: Record
Removes a variable field from the collection.

Specified by:
removeVariableField in interface Record
Parameters:
field - the variable field

getControlNumberField

public ControlField getControlNumberField()
Returns the control number field or null if no control number field is available.

Specified by:
getControlNumberField in interface Record
Returns:
ControlField - the control number field

getControlFields

public List getControlFields()
Description copied from interface: Record
Returns a list of control fields

Specified by:
getControlFields in interface Record
Returns:
List - the control fields

getDataFields

public List getDataFields()
Description copied from interface: Record
Returns a list of data fields

Specified by:
getDataFields in interface Record
Returns:
List - the data fields

getVariableField

public VariableField getVariableField(String tag)
Description copied from interface: Record
Returns the first instance of the variable field with the given tag.

Specified by:
getVariableField in interface Record
Returns:
VariableField - the variable field

getVariableFields

public List getVariableFields(String tag)
Description copied from interface: Record
Returns a list of variable fields with the given tag.

Specified by:
getVariableFields in interface Record
Returns:
List - the variable fields

getVariableFields

public List getVariableFields()
Description copied from interface: Record
Returns a list of variable fields

Specified by:
getVariableFields in interface Record
Returns:
List - the variable fields

getControlNumber

public String getControlNumber()
Description copied from interface: Record
Returns the control number or null if no control number is available. This method returns the data for a ControlField with tag 001.

Specified by:
getControlNumber in interface Record
Returns:
String - the control number

getVariableFields

public List getVariableFields(String[] tags)
Description copied from interface: Record
Returns a list of variable fields for the given tags.

For example:

 String tags = { "100", "245", "260", "300" };
 
 List fields = record.getVariableFields(tags);
 

Specified by:
getVariableFields in interface Record
Returns:
List - the variable fields

toString

public String toString()
Returns a string representation of this record.

Example:

     
      LEADER 00714cam a2200205 a 4500 
      001 12883376 
      005 20030616111422.0
      008 020805s2002 nyu j 000 1 eng 
      020   $a0786808772 
      020   $a0786816155 (pbk.) 
      040   $aDLC$cDLC$dDLC 
      100 1 $aChabon, Michael. 
      245 10$aSummerland /$cMichael Chabon. 
      250   $a1st ed. 
      260   $aNew York :$bMiramax Books/Hyperion Books for Children,$cc2002. 
      300   $a500 p. ;$c22 cm. 
      650  1$aFantasy. 
      650  1$aBaseball$vFiction. 
      650  1$aMagic$vFiction.
      
 

Overrides:
toString in class Object
Returns:
String - a string representation of this record

find

public List find(String pattern)
Description copied from interface: Record
Returns a List of VariableField objects that have a data element that matches the given regular expression.

See Pattern for more information about Java regular expressions.

Specified by:
find in interface Record
Parameters:
pattern - the regular expression
Returns:
List - the result list

find

public List find(String tag,
                 String pattern)
Description copied from interface: Record
Returns a List of VariableField objects with the given tag that have a data element that matches the given regular expression.

See Pattern for more information about Java regular expressions.

Specified by:
find in interface Record
Parameters:
tag - the tag value
pattern - the regular expression
Returns:
List - the result list

find

public List find(String[] tag,
                 String pattern)
Description copied from interface: Record
Returns a List of VariableField objects with the given tags that have a data element that matches the given regular expression.

See Pattern for more information about Java regular expressions.

Specified by:
find in interface Record
Parameters:
tag - the tag values
pattern - the regular expression
Returns:
List - the result list

setId

public void setId(Long id)
Description copied from interface: Record
Sets the identifier.

The purpose of this identifier is to provide an identifier for persistency.

Specified by:
setId in interface Record
Parameters:
id - the identifier

getId

public Long getId()
Description copied from interface: Record
Returns the identifier.

Specified by:
getId in interface Record
Returns:
Long - the identifier


Copyright © 2002-2006 Bas Peters. All Rights Reserved.