Class IPADictionary

java.lang.Object
ca.phon.ipadictionary.IPADictionary
All Implemented Interfaces:
IExtendable

public final class IPADictionary extends Object implements IExtendable
API for the IPA dictionary. This class is final. To implement custom IPADictionaries, implement the IPADictionarySPI interface and pass the constructed object as an argument to the constructor for this class. Dictionaries are only required to provide the method lookup(String). All other functionality is optional, but it is recommended to at least implement the actions AddEntry, RemoveEntry, and OrthoKeyIterator.
  • Constructor Details

    • IPADictionary

      public IPADictionary(IPADictionarySPI impl)
      Constructor
      Parameters:
      dictionary - implementation
  • Method Details

    • lookup

      public String[] lookup(String orthography)
      Perform a lookup for the given orthographic transcription.
      Parameters:
      orthography -
      Returns:
      the ipa transcriptions found or generated by this dictionary
    • addEntry

      public void addEntry(String orthography, String ipa) throws IPADictionaryExecption
      Add an entry to this dictionary (optional)
      Parameters:
      orthography -
      ipa -
      Throws:
      IPADictionaryExecption - if the dictionary is not capable of adding entries or the entry was not added because it was a duplicate.
    • removeEntry

      public void removeEntry(String orthography, String ipa) throws IPADictionaryExecption
      Remove an entry from this dictionary. (optional)
      Parameters:
      orthography -
      ipa -
      Throws:
      IPADictionaryException - if the dictionary is not capable of removing the entry.
      IPADictionaryExecption
    • keyIterator

      public Iterator<String> keyIterator() throws IPADictionaryExecption
      Return an iterator for the keys in this dictionary. (optional)
      Returns:
      the key iterator for the dictionary
      Throws:
      IPADictionaryExecption - if the dictionary is not capable of iterating it's keys
    • prefixSearch

      public String[] prefixSearch(String prefix) throws IPADictionaryExecption
      Return all keys which start with the given prefix. (optional)
      Parameters:
      prefix -
      Returns:
      the list of keys which have the given prefix
      Throws:
      IPADictionaryExecption - if the dictionary does not support this function
    • getLanguage

      public Language getLanguage()
      Returns the language handled by this dictionary.
      Returns:
      the LanguageEntry for this dictionary
    • getName

      public String getName()
      Returns a string identifier for this dictionary. While not required, the name should be unique to help users identify dictionaries which handle the same language.
      Returns:
      the dictionary name
    • getMetadataValue

      public String getMetadataValue(String key)
      Get value for a given metadata key.
      Parameters:
      key - the metadata key. Common keys are 'provider' and 'website'
      Returns:
      the value for the specified key or null if no data is available. See metadataKeyIterator()
    • metadataKeyIterator

      public Iterator<String> metadataKeyIterator()
      Get the iteator for metadata keys.
      Returns:
      an iterator for the metadata keys available
    • getExtensions

      public Set<Class<?>> getExtensions()
      Description copied from interface: IExtendable
      Return all extension types supported
      Specified by:
      getExtensions in interface IExtendable
    • getExtension

      public <T> T getExtension(Class<T> cap)
      Description copied from interface: IExtendable
      Get the requested extension if available.
      Specified by:
      getExtension in interface IExtendable
      Returns:
      the capability object or null if the cability is not available
    • putExtension

      public <T> T putExtension(Class<T> cap, T impl)
      Description copied from interface: IExtendable
      Add a new extension.
      Specified by:
      putExtension in interface IExtendable
      Parameters:
      cap - the extension to add
      Returns:
      the added extension implementation
    • removeExtension

      public <T> T removeExtension(Class<T> cap)
      Description copied from interface: IExtendable
      Remove a capability.
      Specified by:
      removeExtension in interface IExtendable
      Parameters:
      cap - the capability to remove