|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--net.sourceforge.wohenchan.convert.AbstractConverterTable
This is an abstract base class for ConverterTableInterface. It contains convenience methods for firing events and initializing in a separate thread.
Field Summary | |
private java.util.Hashtable |
m_callersWaiting
Map from Thread into Vector (a list of messages waiting to be delivered) |
private java.lang.Thread |
m_initThread
|
private boolean |
m_isInitDone
|
private ConverterListener |
m_passthroughListener
|
Constructor Summary | |
AbstractConverterTable()
|
Method Summary | |
static java.lang.String |
bytesToUnicode(byte[] input,
java.lang.String encoding)
|
protected static void |
fireDone(ConverterListener listener)
|
protected static void |
fireEntryFound(ConverterListener listener,
ConverterEntryInterface entry)
|
protected void |
fireProgressChanged(ConverterListener listener,
java.lang.String whatInProgress,
int newProgress)
Updates the progress for a given task |
protected static void |
fireStatus(ConverterListener listener,
java.lang.String newStatus)
|
protected static void |
fireTaskChange(ConverterListener listener,
java.lang.String newTask)
|
protected abstract void |
init(ConverterListener listener)
Initialization method, to be overridden by subclasses. |
void |
initInOtherThread(ConverterListener listener)
Calls the init method in a separate thread. |
private void |
joinJustInCase()
|
void |
lookupByEnglishSubstring(java.lang.String str,
ConverterListener listener)
Locates ConverterEntryInterface objects corresponding to a given case insensitive English substring. |
void |
lookupByPinyin(java.lang.String pinyin,
ConverterListener listener)
Looks up a dictionary entry by pinyin. |
void |
lookupBySimplifiedChinese(java.lang.String chinese,
ConverterListener listener)
Looks up a converter table entry by simplified chinese characters. |
void |
lookupByTraditionalChinese(java.lang.String chinese,
ConverterListener listener)
Looks up a converter table entry by traditional chinese characters. |
private void |
passThroughConverterEvent(ConverterEvent evt)
Notifies any waiting threads of a new event genrated by init. |
private void |
passThroughMessages(ConverterListener listener)
|
protected abstract void |
postInitLookupByEnglishSubstring(java.lang.String str,
ConverterListener listener)
Locates ConverterEntryInterface objects corresponding to a given case insensitive English substring. |
protected abstract void |
postInitLookupByPinyin(java.lang.String pinyin,
ConverterListener listener)
Looks up a dictionary entry by pinyin. |
protected abstract void |
postInitLookupBySimplifiedChinese(java.lang.String chinese,
ConverterListener listener)
Looks up a converter table entry by simplified chinese. |
protected abstract void |
postInitLookupByTraditionalChinese(java.lang.String chinese,
ConverterListener listener)
Looks up a converter table entry by traditional chinese. |
protected abstract void |
postInitLookupByUnicode(java.lang.String unicode,
ConverterListener listener)
Looks up a ConverterEntry by Unicode character value. |
private void |
register()
|
static byte[] |
unicodeToBytes(java.lang.String input,
java.lang.String encoding)
|
private void |
waitForInit(ConverterListener listener)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private java.lang.Thread m_initThread
private volatile boolean m_isInitDone
private java.util.Hashtable m_callersWaiting
private ConverterListener m_passthroughListener
Constructor Detail |
public AbstractConverterTable()
Method Detail |
public final void initInOtherThread(ConverterListener listener)
private void passThroughConverterEvent(ConverterEvent evt)
protected static void fireDone(ConverterListener listener)
protected static void fireStatus(ConverterListener listener, java.lang.String newStatus) throws AbortSearchException
AbortSearchException
protected static void fireTaskChange(ConverterListener listener, java.lang.String newTask) throws AbortSearchException
AbortSearchException
protected static void fireEntryFound(ConverterListener listener, ConverterEntryInterface entry) throws AbortSearchException
AbortSearchException
protected void fireProgressChanged(ConverterListener listener, java.lang.String whatInProgress, int newProgress) throws AbortSearchException
whatInProgress
- a string describing the thing in progress.
AbortSearchException
private void register()
private void passThroughMessages(ConverterListener listener) throws AbortSearchException
AbortSearchException
private void joinJustInCase()
private void waitForInit(ConverterListener listener) throws AbortSearchException
AbortSearchException
public void lookupByPinyin(java.lang.String pinyin, ConverterListener listener)
ConverterTableInterface
lookupByPinyin
in interface ConverterTableInterface
pinyin
- The input string is specified in pinyin.
The string may be composed of the letters 'a'-'z' (lower case
only), the numbers '1'-'5' and space (' ').
The string is composed of at least 1 space-separated pinyin
syllables. Syllables are separated with exactly one space.
There is no leading or trailing space.
Each syllable is composed of at least two letters followed by
exactly one digit. The neutral tone is expicitly specified with
'5'.
u w/ umlaut (as in luu2 (donkey, palm tree), or luu3 (drizzle)
is specified with uu.listener
- the ConverterListener to which this object
should send its resultspublic void lookupBySimplifiedChinese(java.lang.String chinese, ConverterListener listener)
ConverterTableInterface
lookupBySimplifiedChinese
in interface ConverterTableInterface
public void lookupByTraditionalChinese(java.lang.String chinese, ConverterListener listener)
ConverterTableInterface
lookupByTraditionalChinese
in interface ConverterTableInterface
public void lookupByEnglishSubstring(java.lang.String str, ConverterListener listener)
ConverterTableInterface
lookupByEnglishSubstring
in interface ConverterTableInterface
public static java.lang.String bytesToUnicode(byte[] input, java.lang.String encoding)
public static byte[] unicodeToBytes(java.lang.String input, java.lang.String encoding)
protected abstract void postInitLookupByPinyin(java.lang.String pinyin, ConverterListener listener)
pinyin
- The input string is specified in pinyin.
The string may be composed of the letters 'a'-'z' (lower case
only), the numbers '1'-'5' and space (' ').
The string is composed of at least 1 space-separated pinyin
syllables. Syllables are separated with exactly one space.
There is no leading or trailing space.
Each syllable is composed of at least two letters followed by
exactly one digit. The neutral tone is expicitly specified with
'5'.
u w/ umlaut (as in luu2 (donkey, palm tree), or luu3 (drizzle)
is specified with uu.
protected abstract void postInitLookupBySimplifiedChinese(java.lang.String chinese, ConverterListener listener)
protected abstract void postInitLookupByTraditionalChinese(java.lang.String chinese, ConverterListener listener)
protected abstract void postInitLookupByUnicode(java.lang.String unicode, ConverterListener listener)
protected abstract void postInitLookupByEnglishSubstring(java.lang.String str, ConverterListener listener)
protected abstract void init(ConverterListener listener) throws java.io.IOException
java.io.IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |