public abstract class ReverseCodeTable extends Object
ReverseCodeTable is a set of methods to facilitate Unicode to MARC-8 character conversion, it tracks the
current charset encodings that are in use, and defines abstract methods isCombining() and getCharTable()which must be
overridden in a sub-class to actually implement the Unicode to MARC8 character conversion. There are two defined
subclasses: ReverseCodeTableHash which reads in and parses a large XML file at runtime, and ReverseCodeTableGenerated
which consists of a couple of switch statements that implement the same two methods. The code for the second of these
two sub-classes, ReverseCodeTableGenerated, is generated when the marc4j jar file is created using the same XML file
that ReverseCodeTableHash uses.
| Modifier and Type | Field and Description |
|---|---|
protected String |
charsetsUsed |
protected byte[] |
g |
protected Character |
lastLookupKey |
protected Hashtable<Integer,char[]> |
lastLookupValue |
| Constructor and Description |
|---|
ReverseCodeTable()
Default constructor for the abstract class, allocates and initializes the structures that are used to track the
current character sets in use.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
charHasMatch(Character c)
Checks whether a MARC8 translation of a given Unicode character exists.
|
Hashtable<Integer,char[]> |
codeTableHash(Character c)
Performs a lookup of the MARC8 translation of a given Unicode character.
|
static char[] |
deHexify(String str)
Utility function for translating a String consisting of one or more two character hex string of the character
values into a character array containing those characters
|
char |
getBestCharSet(Character c)
Lookups up the MARC8 translation of a given Unicode character and determines which of the MARC-8 character sets
that have a translation for that Unicode character is the best one to use.
|
char[] |
getCharEntry(Character c,
int charset)
Returns the MARC8 translation of a given Unicode character from the character set currently loaded as either the
G0 or the G1 character set, as specified by the second parameter.
|
abstract Hashtable<Integer,char[]> |
getCharTable(Character c)
Abstract method that must be defined in a sub-class, used in the conversion of Unicode to MARC-8.
|
char[] |
getCurrentG0CharEntry(Character c)
Returns the MARC8 translation of a given Unicode character from the character set currently loaded as the G0
character set.
|
char[] |
getCurrentG1CharEntry(Character c)
Returns the MARC8 translation of a given Unicode character from the character set currently loaded as the G0
character set.
|
byte |
getPreviousG0()
Routine used for tracking which character set is currently in use for characters less than 0x80
|
byte |
getPreviousG1()
Routine used for tracking which character set is currently in use for characters greater than 0x80
|
void |
init()
Initializes the ReverseCodeTable state to the default value for encoding a field.
|
boolean |
inPreviousG0CharEntry(Character c)
Checks whether a MARC8 translation of a given Unicode character exists in the character set currently loaded as
the G0 character set.
|
boolean |
inPreviousG1CharEntry(Character c)
Checks whether a MARC8 translation of a given Unicode character exists in the character set currently loaded as
the G1 character set.
|
abstract boolean |
isCombining(Character c)
Abstract method that must be defined in a sub-class, used in the conversion of Unicode to MARC-8.
|
void |
setPreviousG0(int table)
Routine used for changing which character set is currently in use for characters less than 0x80
|
void |
setPreviousG1(int table)
Routine used for changing which character set is currently in use for characters greater than 0x80
|
protected Character lastLookupKey
protected byte[] g
protected String charsetsUsed
public ReverseCodeTable()
public abstract boolean isCombining(Character c)
c - - the UCS/Unicode character to look uppublic abstract Hashtable<Integer,char[]> getCharTable(Character c)
c - - the UCS/Unicode character to look uppublic void init()
public byte getPreviousG0()
public byte getPreviousG1()
public void setPreviousG0(int table)
table - - the current G0 character set to be used.public void setPreviousG1(int table)
table - - the current G1 character set to be used.public Hashtable<Integer,char[]> codeTableHash(Character c)
c - - the UCS/Unicode character to look uppublic boolean charHasMatch(Character c)
c - - the UCS/Unicode character to look uppublic boolean inPreviousG0CharEntry(Character c)
c - - the UCS/Unicode character to look uppublic boolean inPreviousG1CharEntry(Character c)
c - - the UCS/Unicode character to look uppublic char[] getCurrentG0CharEntry(Character c)
c - - the UCS/Unicode character to look uppublic char[] getCurrentG1CharEntry(Character c)
c - - the UCS/Unicode character to look uppublic char[] getCharEntry(Character c, int charset)
c - - the UCS/Unicode character to look upcharset - - whether to use the current G0 charset of the current G1 charset to perform the lookuppublic char getBestCharSet(Character c)
c - - the UCS/Unicode character to look uppublic static char[] deHexify(String str)
str - - A string containing the two-character hex strings of characters to decodeCopyright © 2014 FreeLibrary. All Rights Reserved.