org.marc4j.marc.impl
Class DataFieldImpl

java.lang.Object
  extended by org.marc4j.marc.impl.VariableFieldImpl
      extended by org.marc4j.marc.impl.DataFieldImpl
All Implemented Interfaces:
Serializable, Comparable, DataField, VariableField

public class DataFieldImpl
extends VariableFieldImpl
implements DataField

Represents a data field in a MARC record.

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

Constructor Summary
DataFieldImpl()
          Creates a new DataField.
DataFieldImpl(String tag, char ind1, char ind2)
          Creates a new DataField and sets the tag name and the first and second indicator.
 
Method Summary
 void addSubfield(int index, Subfield subfield)
          Inserts a Subfield at the specified position.
 void addSubfield(Subfield subfield)
          Adds a Subfield.
 boolean find(String pattern)
          Returns true if the given regular expression matches a subsequence of a data element within the variable field.
 Long getId()
          Returns the identifier.
 char getIndicator1()
          Returns the first indicator
 char getIndicator2()
          Returns the second indicator
 Subfield getSubfield(char code)
          Returns the first Subfield with the given code.
 List getSubfields()
          Returns the list of Subfield objects.
 List getSubfields(char code)
          Returns the list of Subfield objects for the goven subfield code.
 void removeSubfield(Subfield subfield)
          Removes a Subfield.
 void setId(Long id)
          Sets the identifier.
 void setIndicator1(char ind1)
          Sets the first indicator.
 void setIndicator2(char ind2)
          Sets the second indicator.
 String toString()
          Returns a string representation of this data field.
 
Methods inherited from class org.marc4j.marc.impl.VariableFieldImpl
compareTo, getTag, setTag
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.marc4j.marc.VariableField
getTag, setTag
 
Methods inherited from interface java.lang.Comparable
compareTo
 

Constructor Detail

DataFieldImpl

public DataFieldImpl()
Creates a new DataField.


DataFieldImpl

public DataFieldImpl(String tag,
                     char ind1,
                     char ind2)
Creates a new DataField and sets the tag name and the first and second indicator.

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

setIndicator1

public void setIndicator1(char ind1)
Sets the first indicator.

Specified by:
setIndicator1 in interface DataField
Parameters:
ind1 - the first indicator

getIndicator1

public char getIndicator1()
Returns the first indicator

Specified by:
getIndicator1 in interface DataField
Returns:
char - the first indicator

setIndicator2

public void setIndicator2(char ind2)
Sets the second indicator.

Specified by:
setIndicator2 in interface DataField
Parameters:
ind2 - the second indicator

getIndicator2

public char getIndicator2()
Returns the second indicator

Specified by:
getIndicator2 in interface DataField
Returns:
char - the second indicator

addSubfield

public void addSubfield(Subfield subfield)
Adds a Subfield.

Specified by:
addSubfield in interface DataField
Parameters:
subfield - the Subfield object
Throws:
IllegalAddException - when the parameter is not a Subfield instance

addSubfield

public void addSubfield(int index,
                        Subfield subfield)
Inserts a Subfield at the specified position.

Specified by:
addSubfield in interface DataField
Parameters:
index - the position within the list
subfield - the Subfield object
Throws:
IllegalAddException - when the parameter is not a Subfield instance

removeSubfield

public void removeSubfield(Subfield subfield)
Removes a Subfield.

Specified by:
removeSubfield in interface DataField

getSubfields

public List getSubfields()
Returns the list of Subfield objects.

Specified by:
getSubfields in interface DataField
Returns:
List - the list of Subfield objects

getSubfields

public List getSubfields(char code)
Description copied from interface: DataField
Returns the list of Subfield objects for the goven subfield code.

Specified by:
getSubfields in interface DataField
Parameters:
code - the subfield code
Returns:
List - the list of Subfield objects

getSubfield

public Subfield getSubfield(char code)
Description copied from interface: DataField
Returns the first Subfield with the given code.

Specified by:
getSubfield in interface DataField
Parameters:
code - the subfield code
Returns:
Subfield - the subfield object or null if no subfield is found

find

public boolean find(String pattern)
Description copied from interface: VariableField
Returns true if the given regular expression matches a subsequence of a data element within the variable field.

See Pattern for more information about Java regular expressions.

Specified by:
find in interface VariableField
Parameters:
pattern - the regular expression
Returns:
true if the pattern matches, false othewise

toString

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

Example:

    245 10$aSummerland /$cMichael Chabon.
 

Overrides:
toString in class VariableFieldImpl
Returns:
String - a string representation of this data field

setId

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

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

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

getId

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

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


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