org.apache.hivemind.schema.rules
Class EnumerationTranslator
java.lang.Object
org.apache.hivemind.schema.rules.EnumerationTranslator
- All Implemented Interfaces:
- Translator
public class EnumerationTranslator
- extends java.lang.Object
- implements Translator
Used to translate a set of strings to one of a number of constant values.
Each input string is matched against the name of a public static field
of a class. The name of the class, and the mappings, are provided
in the initializer.
- Author:
- Howard Lewis Ship
Constructor Summary |
EnumerationTranslator(java.lang.String initializer)
Initialized the translator; the intitializer is the name of the class, a comma,
and a series of key=value mappings from the input values to the names
of the public static fields of the class. |
Method Summary |
java.lang.Object |
translate(Module contributingModule,
java.lang.Class propertyType,
java.lang.String inputValue,
Location location)
Invoked by a Rule
to translate an inputValue into an appropriate object. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
EnumerationTranslator
public EnumerationTranslator(java.lang.String initializer)
- Initialized the translator; the intitializer is the name of the class, a comma,
and a series of key=value mappings from the input values to the names
of the public static fields of the class.
translate
public java.lang.Object translate(Module contributingModule,
java.lang.Class propertyType,
java.lang.String inputValue,
Location location)
- Description copied from interface:
Translator
- Invoked by a
Rule
to translate an inputValue into an appropriate object.
Substitution symbols will already have been expanded before this method is
invoked.
- Specified by:
translate
in interface Translator
- Parameters:
contributingModule
- the module from which the input value originatespropertyType
- the type of the property to be assigned by this translator; smart translators may
be able to automatically convert from string to the correct typeinputValue
- the value to be translated, either an attribute value or the content of the elementlocation
- the location of the inputValue; used to set the location of created objects,
or when reporting errors