public class KanjiDic extends Object implements Dictionary
Modifier and Type | Class and Description |
---|---|
class |
KanjiDic.Entry
Represents a single entry in the kanji dictionary file.
|
protected class |
KanjiDic.EntryListIterator |
Modifier and Type | Field and Description |
---|---|
protected String |
dicfile
Pathname to the dictionary file.
|
protected Map<Object,List<String>> |
entries
Map from a word to an entry of list of entries.
|
static DictionaryImplementation<KanjiDic> |
IMPLEMENTATION
Object describing this implementation of the
Dictionary interface. |
protected String |
name
Name of the dictionary file without path component.
|
Constructor and Description |
---|
KanjiDic(String dicfile)
Creates a new dictionary for a file in KANJIDIC format.
|
Modifier and Type | Method and Description |
---|---|
protected void |
addEntry(Object key,
String entry)
Adds an entry to the map of entries.
|
protected void |
addReadings(String line,
KanjiDic.Entry e,
String[] readings)
Adds the entry to the map of entries for all readings given as parameter.
|
void |
dispose()
Called when the dictionary is no longer needed.
|
boolean |
equals(Object o) |
<T extends AttributeValue> |
getAttributeValues(Attribute<T> att)
Return the set of known attribute values for an attribute.
|
String |
getDictionaryFile()
Returns the path to the dictionary file.
|
String |
getName()
Returns the name of this dictionary.
|
Set<Attribute<?>> |
getSupportedAttributes()
Get a set of all attributes used by this dictionary.
|
SearchFieldSelection |
getSupportedFields(SearchMode searchmode)
Return the search fields for which a search of the given mode is supported for
this dictionary implementation.
|
KanjiDic.Entry |
lookup(char kanji)
Returns the entry for the given kanji.
|
List<KanjiDic.Entry> |
lookup(String key)
Returns a list of
KanjiDic.Entry objects for the given key. |
Iterator<DictionaryEntry> |
search(SearchMode mode,
Object[] parameters)
Searches for an entry matching expression.
|
Iterator<DictionaryEntry> |
searchExpression(ExpressionSearchModes mode,
String expression,
SearchFieldSelection fields) |
boolean |
supports(SearchMode searchmode,
boolean fully)
Test if this dictionary supports searches of a certain type.
|
String |
toString()
Returns a string representation of this dictionary.
|
protected String dicfile
protected String name
protected Map<Object,List<String>> entries
public static final DictionaryImplementation<KanjiDic> IMPLEMENTATION
Dictionary
interface. The
Object can be used to register this class with the DictionaryFactory
, or
test if a descriptor matches this class.DictionaryFactory
public KanjiDic(String dicfile) throws IOException
IOException
- when the dictionary file cannot be read.protected void addEntry(Object key, String entry)
key
- The key under which to store the entry.entry
- The entry which will be stored.protected void addReadings(String line, KanjiDic.Entry e, String[] readings)
e
- The entry to add.readings
- List of readings. This can be normal or nanori readings.public KanjiDic.Entry lookup(char kanji)
null
will be returned.public List<KanjiDic.Entry> lookup(String key)
KanjiDic.Entry
objects for the given key.
The key can be a kanji, a reading or a
translation. If no match is found, the empty list will be returned.public Iterator<DictionaryEntry> search(SearchMode mode, Object[] parameters) throws SearchException
search
in interface Dictionary
mode
- The requested search mode. The search mode must be supported by this
dictionary.parameters
- Search parameters as required by the searchmode
.
The parameters must be valid for the selected search mode according to
List.isValid
.SearchException
- if the search mode is not supported or there was an error
during the search.public Iterator<DictionaryEntry> searchExpression(ExpressionSearchModes mode, String expression, SearchFieldSelection fields)
public boolean supports(SearchMode searchmode, boolean fully)
Dictionary
search
with this search mode will throw an exception.supports
in interface Dictionary
searchmode
- The search mode to test.fully
- If true
, test if the search mode is fully supported, if
false
, test if it is partially supported.public Set<Attribute<?>> getSupportedAttributes()
Dictionary
getSupportedAttributes
in interface Dictionary
public <T extends AttributeValue> Set<T> getAttributeValues(Attribute<T> att)
Dictionary
PartOfSpeech
attributes.
An example for non-constant values,
which will not be returned by this method, are
InformationAttributeValues
.
In this case, an empty set is returned. For unsupported attributes,
null
will be returned.getAttributeValues
in interface Dictionary
public SearchFieldSelection getSupportedFields(SearchMode searchmode)
Dictionary
SearchFieldSelection
parameter, at least one search field must be
selected in the SearchFieldSelection
object returned.getSupportedFields
in interface Dictionary
public String getDictionaryFile()
public String getName()
getName
in interface Dictionary
public String toString()
public void dispose()
Dictionary
dispose
in interface Dictionary
Copyright © 2001-2013 the JGloss developers. All Rights Reserved.