net.sf.extjwnl.dictionary
Class AbstractCachingDictionary

java.lang.Object
  extended by net.sf.extjwnl.dictionary.Dictionary
      extended by net.sf.extjwnl.dictionary.AbstractCachingDictionary
Direct Known Subclasses:
DatabaseBackedDictionary, FileBackedDictionary

public abstract class AbstractCachingDictionary
extends Dictionary

Extends Dictionary to provide caching of elements.

Author:
John Didion , Aliaksandr Autayeu

Nested Class Summary
 
Nested classes/interfaces inherited from class net.sf.extjwnl.dictionary.Dictionary
Dictionary.Version
 
Field Summary
protected  boolean isCachingEnabled
           
 
Fields inherited from class net.sf.extjwnl.dictionary.Dictionary
CHECK_LEX_IDS_KEY, maxOffset, params
 
Constructor Summary
protected AbstractCachingDictionary(Document doc)
           
 
Method Summary
 void addException(Exc exc)
          Adds exception to the dictionary.
 void addIndexWord(IndexWord indexWord)
          Adds index word to the dictionary.
 void addSynset(Synset synset)
          Adds synset to the dictionary.
protected  void cacheAll()
           
protected  void cacheException(POSKey key, Exc exception)
           
protected  void cacheIndexWord(POSKey key, IndexWord word)
           
protected  void cachePOS(POS pos)
           
 void cacheSynset(POSKey key, Synset synset)
           
 void clearCache()
           
 void clearCache(DictionaryElementType elementType)
           
protected  void clearException(POSKey key)
           
protected  void clearIndexWord(POSKey key)
           
 void clearSynset(POSKey key)
           
 void edit()
          Puts the dictionary into edit mode.
 int getCacheCapacity(DictionaryElementType type)
           
protected  Exc getCachedException(POSKey key)
           
protected  IndexWord getCachedIndexWord(POSKey key)
           
protected  Synset getCachedSynset(POSKey key)
           
 int getCacheSizes(DictionaryElementType type)
           
 Iterator<Exc> getExceptionIterator(POS pos)
          Return an Iterator over all the Exceptions in the database.
 Iterator<IndexWord> getIndexWordIterator(POS pos)
          Return an Iterator over all the IndexWords of part-of-speech pos in the database.
 Iterator<IndexWord> getIndexWordIterator(POS pos, String substring)
          Return an Iterator over all the IndexWords of part-of-speech pos whose lemmas contain substring as a substring.
 Iterator<Synset> getSynsetIterator(POS pos)
          Return an Iterator over all the Synsets of part-of-speech pos in the database.
 boolean isCachingEnabled()
           
 void removeException(Exc exc)
          Removes the exc from the dictionary.
 void removeIndexWord(IndexWord indexWord)
          Removes indexWord from the dictionary.
 void removeSynset(Synset synset)
          Removes synset from the dictionary.
 void setCacheCapacity(DictionaryElementType type, int size)
           
 void setCacheCapacity(int size)
           
 void setCachingEnabled(boolean cachingEnabled)
           
 
Methods inherited from class net.sf.extjwnl.dictionary.Dictionary
addElement, close, createException, createIndexWord, createSynset, delete, getDatabaseBackedInstance, getException, getFileBackedInstance, getIndexWord, getInstance, getInstance, getInstance, getMapBackedInstance, getMorphologicalProcessor, getRandomIndexWord, getRestoreDictionary, getSynsetAt, getVersion, isEditable, lookupAllIndexWords, lookupIndexWord, prepareQueryString, removeElement, save, setInstance, setMorphologicalProcessor, setRestoreDictionary, uninstall
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

isCachingEnabled

protected boolean isCachingEnabled
Constructor Detail

AbstractCachingDictionary

protected AbstractCachingDictionary(Document doc)
                             throws JWNLException
Throws:
JWNLException
Method Detail

isCachingEnabled

public boolean isCachingEnabled()

setCachingEnabled

public void setCachingEnabled(boolean cachingEnabled)

getCacheSizes

public int getCacheSizes(DictionaryElementType type)

getCacheCapacity

public int getCacheCapacity(DictionaryElementType type)

setCacheCapacity

public void setCacheCapacity(int size)

setCacheCapacity

public void setCacheCapacity(DictionaryElementType type,
                             int size)

clearCache

public void clearCache()

clearCache

public void clearCache(DictionaryElementType elementType)

cacheIndexWord

protected void cacheIndexWord(POSKey key,
                              IndexWord word)

clearIndexWord

protected void clearIndexWord(POSKey key)

getCachedIndexWord

protected IndexWord getCachedIndexWord(POSKey key)

cacheSynset

public void cacheSynset(POSKey key,
                        Synset synset)

clearSynset

public void clearSynset(POSKey key)

getCachedSynset

protected Synset getCachedSynset(POSKey key)

cacheException

protected void cacheException(POSKey key,
                              Exc exception)

clearException

protected void clearException(POSKey key)

getCachedException

protected Exc getCachedException(POSKey key)

getExceptionIterator

public Iterator<Exc> getExceptionIterator(POS pos)
                                   throws JWNLException
Description copied from class: Dictionary
Return an Iterator over all the Exceptions in the database.

Specified by:
getExceptionIterator in class Dictionary
Parameters:
pos - the part-of-speech
Returns:
Iterator An iterator over Excs
Throws:
JWNLException - JWNLException

getSynsetIterator

public Iterator<Synset> getSynsetIterator(POS pos)
                                   throws JWNLException
Description copied from class: Dictionary
Return an Iterator over all the Synsets of part-of-speech pos in the database.

Specified by:
getSynsetIterator in class Dictionary
Parameters:
pos - The part-of-speech.
Returns:
An iterator over Synsets.
Throws:
JWNLException - JWNLException

getIndexWordIterator

public Iterator<IndexWord> getIndexWordIterator(POS pos)
                                         throws JWNLException
Description copied from class: Dictionary
Return an Iterator over all the IndexWords of part-of-speech pos in the database.

Specified by:
getIndexWordIterator in class Dictionary
Parameters:
pos - The part-of-speech
Returns:
An iterator over IndexWords
Throws:
JWNLException - JWNLException

getIndexWordIterator

public Iterator<IndexWord> getIndexWordIterator(POS pos,
                                                String substring)
                                         throws JWNLException
Description copied from class: Dictionary
Return an Iterator over all the IndexWords of part-of-speech pos whose lemmas contain substring as a substring.

Specified by:
getIndexWordIterator in class Dictionary
Parameters:
pos - The part-of-speech.
substring - substring
Returns:
An iterator over IndexWords.
Throws:
JWNLException - JWNLException

edit

public void edit()
          throws JWNLException
Description copied from class: Dictionary
Puts the dictionary into edit mode.

Overrides:
edit in class Dictionary
Throws:
JWNLException - JWNLException

addSynset

public void addSynset(Synset synset)
               throws JWNLException
Description copied from class: Dictionary
Adds synset to the dictionary.

Overrides:
addSynset in class Dictionary
Parameters:
synset - synset to add
Throws:
JWNLException - JWNLException

removeSynset

public void removeSynset(Synset synset)
                  throws JWNLException
Description copied from class: Dictionary
Removes synset from the dictionary.

Overrides:
removeSynset in class Dictionary
Parameters:
synset - synset to remove
Throws:
JWNLException - JWNLException

addException

public void addException(Exc exc)
                  throws JWNLException
Description copied from class: Dictionary
Adds exception to the dictionary.

Overrides:
addException in class Dictionary
Parameters:
exc - exception to add
Throws:
JWNLException - JWNLException

removeException

public void removeException(Exc exc)
                     throws JWNLException
Description copied from class: Dictionary
Removes the exc from the dictionary.

Overrides:
removeException in class Dictionary
Parameters:
exc - exc to be removed
Throws:
JWNLException - JWNLException

addIndexWord

public void addIndexWord(IndexWord indexWord)
                  throws JWNLException
Description copied from class: Dictionary
Adds index word to the dictionary.

Overrides:
addIndexWord in class Dictionary
Parameters:
indexWord - index word to add
Throws:
JWNLException - JWNLException

removeIndexWord

public void removeIndexWord(IndexWord indexWord)
                     throws JWNLException
Description copied from class: Dictionary
Removes indexWord from the dictionary.

Overrides:
removeIndexWord in class Dictionary
Parameters:
indexWord - index word to remove
Throws:
JWNLException - JWNLException

cacheAll

protected void cacheAll()
                 throws JWNLException
Throws:
JWNLException

cachePOS

protected void cachePOS(POS pos)
                 throws JWNLException
Throws:
JWNLException


Copyright © 2011. All Rights Reserved.