C - the type of entries in the dictionarypublic abstract class AbstractDictionary<C> extends AbstractSet<DictionaryEntry<C>> implements Dictionary<C>, Compilable
AbstractDictionary is a dictionary with convenience
implementations of most methods. Like the AbstractSet
class it extends, the AbstractCollection.iterator() method must be defined by
concrete implementations to return an iterator over dictionary
entries. Unlike AbstractSet, even the size()
method is implemented in terms of the iterator.
The implementation of the mutable methods in this class all
throw unsupported operation exceptions. This includes the method
addEntry(DictionaryEntry entry) in the dictionary
interface, and the methods AbstractCollection.remove(Object) and AbstractCollection.add(Object) and their relatives in the set interface. Subclasses
may override any or all of these methods.
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractDictionary()
Construct an abstract dictionary.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addEntry(DictionaryEntry<C> entry)
Adds the specified dictionary entry to the dictionary.
|
Iterator<DictionaryEntry<C>> |
categoryEntryIt(C category)
Returns an iterator over the dictionary entries with the
specified category.
|
List<DictionaryEntry<C>> |
categoryEntryList(C category)
Returns the dictionary entries with the specified category.
|
void |
compileTo(ObjectOutput out)
Compiles this dictionary to the specified object output.
|
List<DictionaryEntry<C>> |
entryList()
Returns all of the dictionary entries for this dictionary.
|
Iterator<DictionaryEntry<C>> |
phraseEntryIt(String phrase)
Returns an iterator over the dictionary entries with the
specified phrase.
|
List<DictionaryEntry<C>> |
phraseEntryList(String phrase)
Returns the dictionary entries with the specified phrase.
|
int |
size()
Returns the size of this dictionary as measured by number
of dictionary entries.
|
equals, hashCode, removeAlladd, addAll, clear, contains, containsAll, isEmpty, iterator, remove, retainAll, toArray, toArray, toStringprotected AbstractDictionary()
public Iterator<DictionaryEntry<C>> phraseEntryIt(String phrase)
Implementation Note: This implementation filters the
result of AbstractCollection.iterator() for entries with a matching
phrase.
phraseEntryIt in interface Dictionary<C>phrase - The phrase to look up.public List<DictionaryEntry<C>> phraseEntryList(String phrase)
Implementation Note: This implementation buffers the
results of phraseEntryIt(String) in a list.
phraseEntryList in interface Dictionary<C>phrase - The phrase to look up.public Iterator<DictionaryEntry<C>> categoryEntryIt(C category)
Implementation Note: This implementation filters the
result of AbstractCollection.iterator() for entries with a matching
category.
categoryEntryIt in interface Dictionary<C>category - Category of entries.public List<DictionaryEntry<C>> categoryEntryList(C category)
Implementation Note: This implementation buffers the
results of categoryEntryIt(Object) in a list.
categoryEntryList in interface Dictionary<C>category - Category of entries.public int size()
Implementation Note: The implementation here just
takes the length of entries(). Subclasses may
override this method for greater efficiency.
size in interface Dictionary<C>size in interface Collection<DictionaryEntry<C>>size in interface Set<DictionaryEntry<C>>size in class AbstractCollection<DictionaryEntry<C>>public List<DictionaryEntry<C>> entryList()
Implementation Note: This implementation buffers the
results of categoryEntryIt(Object) in a list.
entryList in interface Dictionary<C>public void addEntry(DictionaryEntry<C> entry)
addEntry in interface Dictionary<C>entry - Dictionary entry to add.UnsupportedOperationException - If this operation is not
supported by a subclass implementation.public void compileTo(ObjectOutput out) throws IOException
compileTo in interface Compilableout - Object output to which this dictionary is compiled.UnsupportedOperationException - If this operation is not
supported by a subclass implementation.IOException - If there is an I/O error writing the
object.Copyright © 2016 Alias-i, Inc.. All rights reserved.