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.
-
catForm
-
-
charEncoding
-
-
controlType
-
-
debug
- Just used for debugging.
-
encLvl
-
-
field_separator
- The field separator of USMARC record in tape format.
-
fixFields
- The fixed fields of this object as a Vector of Strings.
-
isInstantiated
- Has this been properly instantiated (e.g., from a valid tape format or
XML string)?
-
level
-
-
linkedRecRqrd
-
-
record_end
- The record end symbol of a USMARC record in tape format.
-
status
-
-
type
-
-
varFields
- The variable fields of this object as a Vector of MarcVarFields.
-
xmlMap
- Device for mapping ANSEL (and some ASCII) characters to XML entities.
-
MarcRecord(Debug)
- Create a null MarcRecord, with a minimal xmlMap (one with only & and < in it).
-
MarcRecord(EntityMap, Debug)
- Create a MarcRecord object using an explicit EntityMap.
-
anselToCanonicalAscii(String, BufferedWriter)
- Convert data into the closest possible version that uses only ASCII
characters.
-
getBiblioLevel()
-
-
getCatalogingForm()
-
-
getCharEncoding()
-
-
getControlType()
-
-
getEncodingLevel()
-
-
getFixFieldById(int)
- Return the fixed field of this object with the specified id.
-
getFixFieldByIndex(int)
- Return the indexth fixed field of this object.
-
getLinkedRecordRq()
-
-
getNumberFixFields()
- Return the number of fixed fields contained in this object.
-
getNumberVarFields()
- Return the number of variable fields contained in this object.
-
getStatus()
- Return the indexth char in the header of this object.
-
getType()
-
-
getVarFieldByIndex(int)
- Return the indexth variable field of this object.
-
getVarFieldsById(int)
- Return all the variable fields of this object with the specified id.
-
init()
- Set instance variables to default values.
-
isValid()
- Is this object a valid MARC record?
-
newVarField(int)
- Create the correct sort of field object.
-
presentAsTapeFormat(BufferedWriter)
- Send this MarcRecord to an output stream in tape format.
-
presentAsXml(BufferedWriter)
- Send this MarcRecord to an output stream in the form of OAI XML.
-
setFromTapeFormat(BufferedReader)
-
-
setFromTapeFormat(String)
- Instantiate this MarcRecord object from a raw (tape format) record.
-
setFromXml(BufferedReader)
- Instantiate this MarcRecord object from an XML stream.
status
protected char status
type
protected char type
level
protected char level
controlType
protected char controlType
charEncoding
protected char charEncoding
encLvl
protected char encLvl
catForm
protected char catForm
linkedRecRqrd
protected char linkedRecRqrd
fixFields
protected Vector fixFields
- The fixed fields of this object as a Vector of Strings.
varFields
protected Vector varFields
- The variable fields of this object as a Vector of MarcVarFields.
field_separator
protected static final char field_separator
- The field separator of USMARC record in tape format.
record_end
protected static final char record_end
- The record end symbol of a USMARC record in tape format.
debug
protected Debug debug
- Just used for debugging.
xmlMap
protected EntityMap xmlMap
- Device for mapping ANSEL (and some ASCII) characters to XML entities.
isInstantiated
protected boolean isInstantiated
- Has this been properly instantiated (e.g., from a valid tape format or
XML string)?
MarcRecord
public MarcRecord(Debug dbg)
- Create a null MarcRecord, with a minimal xmlMap (one with only & and < in it).
- Parameters:
- debug - -- used for debugging
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
init
protected void init()
- Set instance variables to default values.
NOTE: Called in constructors and in setFrom*(). Added to
(not overridden) in MarcDocument class.
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?
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 ...
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.
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.
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
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.
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.
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.
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
getType
public char getType()
getBiblioLevel
public char getBiblioLevel()
getControlType
public char getControlType()
getCharEncoding
public char getCharEncoding()
getEncodingLevel
public char getEncodingLevel()
getCatalogingForm
public char getCatalogingForm()
getLinkedRecordRq
public char getLinkedRecordRq()
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.
setFromTapeFormat
public int setFromTapeFormat(BufferedReader in) throws IOException
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.
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.
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.
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