com.penguinwerks.jodene.data
Class Translator

java.lang.Object
  extended bycom.penguinwerks.jodene.data.Translator
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
KClassTranslator, NMinusOneClassTranslator

public abstract class Translator
extends java.lang.Object
implements java.io.Serializable

The translator takes a string and returns a set of values, which are a function of the input. Normally this is used with non-numeric inputs, such as color, that are encoded using N-1 or K classes. See KClassTranslator and NMinusOneClassTranslator as concrete examples.

Author:
Paul Hoehne
See Also:
Serialized Form

Constructor Summary
Translator()
           
 
Method Summary
 void addKey(java.lang.String keyName)
          Adds a new key to translate - note that all necessary keys must be defined in the translator.
abstract  int getOutputSize()
          Abstract method that returns the size of an encoded class.
abstract  double[] translate(java.lang.String values)
          The abstract translation function.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Translator

public Translator()
Method Detail

translate

public abstract double[] translate(java.lang.String values)
                            throws TranslatorException
The abstract translation function. Subclasses will take a string value and translate it into some combination of double values, returned as an array.

Parameters:
values - The raw string
Returns:
The values.
Throws:
TranslatorException - Thrown if there is an error in translation.

addKey

public void addKey(java.lang.String keyName)
Adds a new key to translate - note that all necessary keys must be defined in the translator. Any values that are not defined, will generate a TranslatorException. The order in which the keys are added is important, but dependant on the type of translation accomplished.

Parameters:
keyName - The name of the class to translate.

getOutputSize

public abstract int getOutputSize()
Abstract method that returns the size of an encoded class.

Returns:
The size of the return tags.