org.apache.hivemind.schema
Interface Translator

All Known Implementing Classes:
BooleanTranslator, ClassTranslator, ConfigurationTranslator, DoubleTranslator, EnumerationTranslator, IdListTranslator, InstanceTranslator, IntTranslator, LongTranslator, NullTranslator, ObjectTranslator, QualifiedIdTranslator, ResourceTranslator, ServicePointTranslator, ServiceTranslator, SmartTranslator

public interface Translator

Object which can translate a string into an object value. This is used to translate attribute values (or element content) from strings into numbers, booleans or other constructs before assigning the final value to a propery. Translation occurs after symbol substitution.

Translator classes should have a public constructor that takes no arguments. They may optionally have a second constructor that takes a single string as a parameter. When the DescriptorParser encounters a translator of the form "translator-id,initialization-string" (example: "int,min=0") it will use the second constructor, passing the initialization string.

Generally, initializion strings are of the form key=value[,key=value]*. Each initializer has a set of keys it recognizes, other keys are simply ignored.

Author:
Howard Lewis Ship

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.
 

Method Detail

translate

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. Substitution symbols will already have been expanded before this method is invoked.

Parameters:
contributingModule - the module from which the input value originates
propertyType - the type of the property to be assigned by this translator; smart translators may be able to automatically convert from string to the correct type
inputValue - the value to be translated, either an attribute value or the content of the element
location - the location of the inputValue; used to set the location of created objects, or when reporting errors