org.semwebcentral.sweetrules.infrastructure
Interface ISweetTranslatorRepository

All Known Implementing Classes:
SweetTranslatorRepository

public interface ISweetTranslatorRepository

This is generic interface for storing the known translators and composing translations

TODO: enhance this with 1) preferredTranslator - get / set - done, need to think about the case of composite translator 2) add with override 3) replace 4) remove

Author:
Shashidhara K Ganjugunte, Dr. Benjamin Grosof, Dr. Said Tabet, Chitravanu Neogy

Method Summary
 void addTranslator(ISweetTranslator translator)
          Add a translator to the repository
 ISweetCompositeTranslator getCompositeTranslator(ISweetKRDescriptor source, ISweetKRDescriptor target, ISweetInvocationDescriptor translatorOptions)
          Returns a composite (may involve multiple steps) translator by computing the transitive closure of the required translators.
 java.lang.String getMostPreferredTranslatorClassName(ISweetKRDescriptor source, ISweetKRDescriptor target, ISweetCanonicalVersionNumber translatorVersionNumber, ISweetInvocationDescriptor translatorOptions)
          Based on the source, target and the translatorOptions parameters this returns the current most preferred translator class name If no direct translator exists null is returned
 ISweetTranslator getSimpleTranslator(ISweetKRDescriptor source, ISweetKRDescriptor target, ISweetInvocationDescriptor translatorOptions)
          Returns a simple(i.e. direct one step) translator if one exists without bothering about transitive closure.
 ISweetCompositeTranslator[] searchCompositeTranslators(ISweetKRDescriptor source, ISweetKRDescriptor target, ISweetInvocationDescriptor translatorOptions)
          Searches for the repository for translators depending on source, target and options.
 ISweetTranslator[] searchSimpleTranslators(ISweetKRDescriptor source, ISweetKRDescriptor target, ISweetInvocationDescriptor translatorOptions)
          Searches for the repository for translators depending on source, target and options.
 void setMostPreferredTranslatorClassName(ISweetKRDescriptor source, ISweetKRDescriptor target, ISweetCanonicalVersionNumber translatorVersionNumber, ISweetInvocationDescriptor translatorOptions, java.lang.String className)
          Based on the source, target, translator version and the translatorOptions parameters this sets the current most preferred translator class name
 

Method Detail

addTranslator

public void addTranslator(ISweetTranslator translator)
                   throws SweetTranslatorException
Add a translator to the repository

Parameters:
translator - the translator to be stored in the repository as a "known" translator
Throws:
TranslatorException - if the translator already exists
SweetTranslatorException

getSimpleTranslator

public ISweetTranslator getSimpleTranslator(ISweetKRDescriptor source,
                                            ISweetKRDescriptor target,
                                            ISweetInvocationDescriptor translatorOptions)
                                     throws SweetTranslatorException
Returns a simple(i.e. direct one step) translator if one exists without bothering about transitive closure. If there is no such translator it returns null. If there are multiple translators available then most preferred translator is returned

Parameters:
source - the source KR format
target - the target KR format
translatorOptions - the options for "complete" translation, i.e. including options for all intermediate translations
Returns:
A translator(simple) instance.
Throws:
TranslatorException - if an error occurs
SweetTranslatorException

getCompositeTranslator

public ISweetCompositeTranslator getCompositeTranslator(ISweetKRDescriptor source,
                                                        ISweetKRDescriptor target,
                                                        ISweetInvocationDescriptor translatorOptions)
                                                 throws SweetTranslatorException
Returns a composite (may involve multiple steps) translator by computing the transitive closure of the required translators. If there is no such translator then null is returned

Parameters:
source - the source KR format
target - the target KR format
translatorOptions - the options for "complete" translation, i.e. including options for all intermediate translations
Returns:
A translator (composite) instance
Throws:
TranslatorException - if an error occurs
SweetTranslatorException

searchSimpleTranslators

public ISweetTranslator[] searchSimpleTranslators(ISweetKRDescriptor source,
                                                  ISweetKRDescriptor target,
                                                  ISweetInvocationDescriptor translatorOptions)
                                           throws SweetTranslatorException
Searches for the repository for translators depending on source, target and options. This returns only direct translators and does not consider transitivity

Parameters:
source - The source KR format, if it is null the target is matched
target - The target KR format, if it is null the source is matched Note: if both source and target are null then null is returned
translatorOptions - Options to the translator
Returns:
The translators which match the search criteria
Throws:
TranslatorException - if an error occurs
SweetTranslatorException

searchCompositeTranslators

public ISweetCompositeTranslator[] searchCompositeTranslators(ISweetKRDescriptor source,
                                                              ISweetKRDescriptor target,
                                                              ISweetInvocationDescriptor translatorOptions)
                                                       throws SweetTranslatorException
Searches for the repository for translators depending on source, target and options. This returns composite translators and considering transitivity and is **very** expensive operation

Parameters:
source - The source KR format, if it is null the target is matched
target - The target KR format, if it is null the source is matched Note: if both source and target are null then null is returned
translatorOptions - Options to the translator
Returns:
The translators which match the search criteria
Throws:
TranslatorException - if an error occurs
SweetTranslatorException

getMostPreferredTranslatorClassName

public java.lang.String getMostPreferredTranslatorClassName(ISweetKRDescriptor source,
                                                            ISweetKRDescriptor target,
                                                            ISweetCanonicalVersionNumber translatorVersionNumber,
                                                            ISweetInvocationDescriptor translatorOptions)
                                                     throws SweetTranslatorException
Based on the source, target and the translatorOptions parameters this returns the current most preferred translator class name If no direct translator exists null is returned

Parameters:
source - The source KR format
target - The target KR format
translatorVersionNumber - The version number of the translator
translatorOptions - Options to the translator
Returns:
The current most preferred direct translator or null if no such translator exists
Throws:
TranslatorException - if an error occurs
SweetTranslatorException

setMostPreferredTranslatorClassName

public void setMostPreferredTranslatorClassName(ISweetKRDescriptor source,
                                                ISweetKRDescriptor target,
                                                ISweetCanonicalVersionNumber translatorVersionNumber,
                                                ISweetInvocationDescriptor translatorOptions,
                                                java.lang.String className)
                                         throws SweetTranslatorException
Based on the source, target, translator version and the translatorOptions parameters this sets the current most preferred translator class name

Parameters:
source - The source KR format
target - The target KR format
translatorVersionNumber - The version number of the translator
translatorOptions - Options to the translator
className - The class name of the most preferred direct translator
Throws:
TranslatorException - if an error occurs
SweetTranslatorException