cdx.scorebot.util.translator
Class TypeTranslator<TYPE1,TYPE2>

java.lang.Object
  extended by cdx.scorebot.util.translator.TypeTranslator<TYPE1,TYPE2>
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
SelfTranslator, TestItemNameTranslator, TranslatorBooleanString, TranslatorDoubleString, TranslatorIdentifierString, TranslatorInstanceString, TranslatorIntegerString, TranslatorMulti, TranslatorObjectClassName, TranslatorTimeString

public abstract class TypeTranslator<TYPE1,TYPE2>
extends java.lang.Object
implements java.io.Serializable

Declares translation methods a parameter must have so it can be translated between a one type and another type.

Author:
David Underhill
See Also:
Serialized Form

Constructor Summary
TypeTranslator()
          Instantiates a translator
 
Method Summary
 boolean canTranslate1(TYPE1 valueToTranslate)
          whether or not the specified value can be translated to TYPE2
 boolean canTranslate2(TYPE2 valueToTranslate)
          whether or not the specified value can be translated to TYPE1
 TranslationFailedException getLastException()
          gets the last exception thrown when the translation was attempted (null if none have been thown)
abstract  TYPE2 translate1(TYPE1 valueToTranslate)
          gets the TYPE2 representation of the item
abstract  TYPE1 translate2(TYPE2 valueToTranslate)
          gets the TYPE1 representation of the item
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TypeTranslator

public TypeTranslator()
Instantiates a translator

Method Detail

canTranslate1

public boolean canTranslate1(TYPE1 valueToTranslate)
whether or not the specified value can be translated to TYPE2

Parameters:
valueToTranslate - some value
Returns:
true if the translation is possible

translate1

public abstract TYPE2 translate1(TYPE1 valueToTranslate)
                          throws TranslationFailedException
gets the TYPE2 representation of the item

Parameters:
valueToTranslate - some value
Returns:
the TYPE2 representation of the valueToTranslate
Throws:
TranslationFailedException - thrown if the value cannot be translated

canTranslate2

public boolean canTranslate2(TYPE2 valueToTranslate)
whether or not the specified value can be translated to TYPE1

Parameters:
valueToTranslate - some value
Returns:
true if the translation is possible

translate2

public abstract TYPE1 translate2(TYPE2 valueToTranslate)
                          throws TranslationFailedException
gets the TYPE1 representation of the item

Parameters:
valueToTranslate - some value
Returns:
the TYPE1 representation of the valueToTranslate
Throws:
TranslationFailedException - thrown if the value cannot be translated

getLastException

public TranslationFailedException getLastException()
gets the last exception thrown when the translation was attempted (null if none have been thown)