nl.tudelft.goal.EIS2Java.translation
Class Translator

Package class diagram package Translator
java.lang.Object
  extended by nl.tudelft.goal.EIS2Java.translation.Translator

public class Translator
extends Object

Singleton class that supports translation from Object to Parameter and vice versa.

Author:
Lennard de Rijk

Method Summary
static Translator getInstance()
           
 void registerJava2ParameterTranslator(Java2Parameter<?> translator)
          Registers a translator for Java to Parameter.
 void registerParameter2JavaTranslator(Parameter2Java<?> translator)
          Registers a translator for Parameter to Java.
<T> T
translate2Java(eis.iilang.Parameter parameter, Class<T> parameterClass)
          Translates the given parameter into an object of type T.
<T> eis.iilang.Parameter[]
translate2Parameter(T o)
          Translates the given object into a Parameter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static Translator getInstance()
Returns:
Creates or gets the singleton instance of the Translator.

registerJava2ParameterTranslator

public void registerJava2ParameterTranslator(Java2Parameter<?> translator)
Registers a translator for Java to Parameter.

Parameters:
translator - the translator to register.

registerParameter2JavaTranslator

public void registerParameter2JavaTranslator(Parameter2Java<?> translator)
Registers a translator for Parameter to Java.

Parameters:
translator - the translator to register.

translate2Parameter

public <T> eis.iilang.Parameter[] translate2Parameter(T o)
                                           throws TranslationException
Translates the given object into a Parameter. The Translator must contain a translator for the type T or of a superclass of T. Otherwise no translation can be made.

Type Parameters:
T - The type of the object to translate.
Parameters:
o - the object to translate.
Returns:
The object translated into the parameter.
Throws:
TranslationException - If the translation could not be made.

translate2Java

public <T> T translate2Java(eis.iilang.Parameter parameter,
                            Class<T> parameterClass)
                 throws TranslationException,
                        NoTranslatorException
Translates the given parameter into an object of type T. The Translator must contain a translator to type T otherwise no translation can be made.

Type Parameters:
T - The type to translate to.
Parameters:
parameter - The parameter to translate.
parameterClass - The class to which the parameter should be translated.
Returns:
The parameter translated into the object of class T.
Throws:
TranslationException - if the translation could not be made.
NoTranslatorException


Copyright © 2012 AMIS research group, Faculty of Mathematics and Physics, Charles University in Prague, Czech Republic. All Rights Reserved.