All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class edu.vt.marian.Document.MarcRecord

java.lang.Object
   |
   +----edu.vt.marian.Document.MarcRecord

public class MarcRecord
extends Object
A USMARC record (see http://www.loc.gov/marc/).

The primary purpose of this root class is for methods for reading and writing MARC records in various formats (USMARC "tape" format, Open Archives Initiative XML MARC trasport format, and Atomic transport format. I've also provided a set of basic methods to get at parts of the record, most created originally by Jianxin Zhao. More sophisticated methods, e.g. for presentation to users or reflective self-description, are added in the child class MarcDocument.


Variable Index

 o catForm
 o charEncoding
 o controlType
 o debug
Just used for debugging.
 o encLvl
 o field_separator
The field separator of USMARC record in tape format.
 o fixFields
The fixed fields of this object as a Vector of Strings.
 o isInstantiated
Has this been properly instantiated (e.g., from a valid tape format or XML string)?
 o level
 o linkedRecRqrd
 o record_end
The record end symbol of a USMARC record in tape format.
 o status
 o type
 o varFields
The variable fields of this object as a Vector of MarcVarFields.
 o xmlMap
Device for mapping ANSEL (and some ASCII) characters to XML entities.

Constructor Index

 o MarcRecord(Debug)
Create a null MarcRecord, with a minimal xmlMap (one with only & and < in it).
 o MarcRecord(EntityMap, Debug)
Create a MarcRecord object using an explicit EntityMap.

Method Index

 o anselToCanonicalAscii(String, BufferedWriter)
Convert data into the closest possible version that uses only ASCII characters.
 o getBiblioLevel()
 o getCatalogingForm()
 o getCharEncoding()
 o getControlType()
 o getEncodingLevel()
 o getFixFieldById(int)
Return the fixed field of this object with the specified id.
 o getFixFieldByIndex(int)
Return the indexth fixed field of this object.
 o getLinkedRecordRq()
 o getNumberFixFields()
Return the number of fixed fields contained in this object.
 o getNumberVarFields()
Return the number of variable fields contained in this object.
 o getStatus()
Return the indexth char in the header of this object.
 o getType()
 o getVarFieldByIndex(int)
Return the indexth variable field of this object.
 o getVarFieldsById(int)
Return all the variable fields of this object with the specified id.
 o init()
Set instance variables to default values.
 o isValid()
Is this object a valid MARC record?
 o newVarField(int)
Create the correct sort of field object.
 o presentAsTapeFormat(BufferedWriter)
Send this MarcRecord to an output stream in tape format.
 o presentAsXml(BufferedWriter)
Send this MarcRecord to an output stream in the form of OAI XML.
 o setFromTapeFormat(BufferedReader)
 o setFromTapeFormat(String)
Instantiate this MarcRecord object from a raw (tape format) record.
 o setFromXml(BufferedReader)
Instantiate this MarcRecord object from an XML stream.

Variables

 o status
 protected char status
 o type
 protected char type
 o level
 protected char level
 o controlType
 protected char controlType
 o charEncoding
 protected char charEncoding
 o encLvl
 protected char encLvl
 o catForm
 protected char catForm
 o linkedRecRqrd
 protected char linkedRecRqrd
 o fixFields
 protected Vector fixFields
The fixed fields of this object as a Vector of Strings.

 o varFields
 protected Vector varFields
The variable fields of this object as a Vector of MarcVarFields.

 o field_separator
 protected static final char field_separator
The field separator of USMARC record in tape format.

 o record_end
 protected static final char record_end
The record end symbol of a USMARC record in tape format.

 o debug
 protected Debug debug
Just used for debugging.

 o xmlMap
 protected EntityMap xmlMap
Device for mapping ANSEL (and some ASCII) characters to XML entities.

 o isInstantiated
 protected boolean isInstantiated
Has this been properly instantiated (e.g., from a valid tape format or XML string)?

Constructors

 o MarcRecord
 public MarcRecord(Debug dbg)
Create a null MarcRecord, with a minimal xmlMap (one with only & and < in it).

Parameters:
debug - -- used for debugging
 o MarcRecord
 public MarcRecord(EntityMap xMap,
                   Debug dbg)
Create a MarcRecord object using an explicit EntityMap.

Parameters:
xMap - --- an EntityMap used when reading or writing the record in XML.
debug - -- used for debugging

Methods

 o init
 protected void init()
Set instance variables to default values.

NOTE: Called in constructors and in setFrom*(). Added to (not overridden) in MarcDocument class.

 o newVarField
 protected MarcVarField newVarField(int ID)
Create the correct sort of field object.

NOTE: This may not seem very sensible at this level, but in the MarcDocument subclass, where variable fields with different semantics get created as different subclasses of MarcVarField, it will become indispensable.
DEVEL: This is a method created to be replaced by a private method in the subclass. Should it be protected or private?

 o isValid
 public boolean isValid()
Is this object a valid MARC record?

Returns:
true / false

**DEVEL: At this point this method is incomplete and only checks if something has been read in. More checking would be reasonable when we figure out the right level ...

 o getNumberFixFields
 public int getNumberFixFields()
Return the number of fixed fields contained in this object.

Returns:
the number of the fixed fields of this object as an integer.
 o getNumberVarFields
 public int getNumberVarFields()
Return the number of variable fields contained in this object.

Returns:
the number of the variable fields of this object as an integer.
 o getFixFieldById
 public MarcFixField getFixFieldById(int id)
Return the fixed field of this object with the specified id.

Parameters:
id - -- the fixed field with this id will be returned
Returns:
a MarcFixField -- the fixed field in this object with the specified id
null -- the id is invalid or there is no such fixed field in this object with the specified id
 o getVarFieldsById
 public Vector getVarFieldsById(int id)
Return all the variable fields of this object with the specified id.

Parameters:
id - -- all the variable fields with this id will be returned
Returns:
a vector containing all the variable fields found with the specified id.
null -- the id is not valid
the empty vector -- everything was fine, but there are no fields with that id in this record. NOTE: Since a MARC record may have several variable variable fields with the same ID, one ID may return zero, one, or several fields.
 o getFixFieldByIndex
 public MarcFixField getFixFieldByIndex(int index)
Return the indexth fixed field of this object.

Parameters:
index - -- this will be used to search the fixed fields
Returns:
the fixed field at the specified index or
null if the index is not valid.
 o getVarFieldByIndex
 public MarcVarField getVarFieldByIndex(int index)
Return the indexth variable field of this object.

Parameters:
index - -- this will be used to search the variable fields
Returns:
the variable field at the specified index or
null if the index is not valid.
 o getStatus
 public char getStatus()
Return the indexth char in the header of this object.

Parameters:
index - -- specifies with char to return in the header
Returns:
a char other than '\0' -- the indexth char in the header
'\0' -- the index is not valid
 o getType
 public char getType()
 o getBiblioLevel
 public char getBiblioLevel()
 o getControlType
 public char getControlType()
 o getCharEncoding
 public char getCharEncoding()
 o getEncodingLevel
 public char getEncodingLevel()
 o getCatalogingForm
 public char getCatalogingForm()
 o getLinkedRecordRq
 public char getLinkedRecordRq()
 o setFromTapeFormat
 public int setFromTapeFormat(String inStr)
Instantiate this MarcRecord object from a raw (tape format) record.

Parameters:
rawMarcRecord - --- a string containing a USMARC record in tape format.
Returns:
OK -- everything jake.
IO_ERROR or PARSE_ERROR -- problems.
 o setFromTapeFormat
 public int setFromTapeFormat(BufferedReader in) throws IOException
 o setFromXml
 public int setFromXml(BufferedReader in) throws IOException
Instantiate this MarcRecord object from an XML stream.

Parameters:
in - -- a BufferedReader (String or InputStream, presumably) from which to read the next record in OAI MARC XML format.
Returns:
OK -- everything jake.
IO_ERROR or PARSE_ERROR -- problems.

NOTE: This routine checks the OIA XML for correctness as it is read. In particular, it checks for matched tags and required attributes, and for the presence of at least one fixed field. It does not check the incoming MARC record for correctness as a MARC record.

 o presentAsXml
 public int presentAsXml(BufferedWriter out) throws IOException
Send this MarcRecord to an output stream in the form of OAI XML.

Parameters:
out - -- a BufferedWriter (String or InputStream, presumably) to which to write the next record in OA_MARC XML format.
Returns:
OK -- everything jake.
IO_ERROR or PARSE_ERROR -- problems.
 o presentAsTapeFormat
 public int presentAsTapeFormat(BufferedWriter out) throws IOException
Send this MarcRecord to an output stream in tape format.

Parameters:
out - -- a BufferedWriter (String or InputStream, presumably) to which to write this.
Returns:
OK -- everything jake.
IO_ERROR or PARSE_ERROR -- problems.
 o anselToCanonicalAscii
 public static void anselToCanonicalAscii(String data,
                                          BufferedWriter out) throws IOException
Convert data into the closest possible version that uses only ASCII characters.

NOTE: At this point, this function leaves nonprintable characters unchanged. In the primary application, this is silly and probably wrong, but it is morally pure.


All Packages  Class Hierarchy  This Package  Previous  Next  Index