|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
ObjectCharMap
public class CharMap
Maintains an in-memory, one-to-one mapping from characters in one set to characters in another. The list is read from a disk file, which may be sorted or unsorted. The format of file entries should be one pair per line, separated by a bar ("|") character. The first word is considered the "key", the second is the "value". Each should be a four-digit hex number representing a Unicode code point. For speed, an in-memory cache of recently mapped words is maintained.
| Field Summary | |
|---|---|
private FastCache |
cache
Keep a cache of lookups performed to-date |
private static int |
CACHE_SIZE
How many recent mappings to maintain |
private char[] |
map
The mapping of chars. |
private static char |
NULL_CHAR
Special character to denote null list |
private static int |
SUPP_HASH_SIZE
Size of supplimental mapping of chars... typically there are few |
private IntHash |
supplementalCharsMap
Supplemental mapping of characters after the first |
| Constructor Summary | |
|---|---|
CharMap(File f)
Construct a char map by reading in a file. |
|
CharMap(InputStream s)
Construct a char map by reading from an InputStream. |
|
| Method Summary | |
|---|---|
String |
mapWord(String word)
Map the characters in a word and return the mapped resulting word, or null if no mappings found. |
private void |
readFile(BufferedReader reader)
Read in the contents of a char file. |
| Methods inherited from class Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private char[] map
private static final char NULL_CHAR
private static final int SUPP_HASH_SIZE
private IntHash supplementalCharsMap
private static final int CACHE_SIZE
private FastCache cache
| Constructor Detail |
|---|
public CharMap(File f)
throws IOException
IOException
public CharMap(InputStream s)
throws IOException
IOException| Method Detail |
|---|
public String mapWord(String word)
private void readFile(BufferedReader reader)
throws IOException
reader - Reader to get the data from
IOException
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||