org.apache.tuscany.sca.databinding.impl
Class SimpleType2JavaTransformer<T>

java.lang.Object
  extended by org.apache.tuscany.sca.databinding.impl.BaseTransformer<T,java.lang.Object>
      extended by org.apache.tuscany.sca.databinding.impl.SimpleType2JavaTransformer<T>
All Implemented Interfaces:
PullTransformer<T,java.lang.Object>, Transformer
Direct Known Subclasses:
Node2SimpleJavaType, OMElement2Object

public abstract class SimpleType2JavaTransformer<T>
extends BaseTransformer<T,java.lang.Object>
implements PullTransformer<T,java.lang.Object>

Transformer to convert data from a databinding's representation of simple types to Java Objects


Field Summary
protected  SimpleTypeMapper mapper
           
 
Constructor Summary
SimpleType2JavaTransformer()
           
SimpleType2JavaTransformer(SimpleTypeMapper mapper)
           
 
Method Summary
protected  void close(T source)
          To be overrided by the subclass
 java.lang.String getTargetDataBinding()
          Get the target type that this transformer transforms data into.
protected  java.lang.Class<java.lang.Object> getTargetType()
           
protected abstract  java.lang.String getText(T source)
          Get the string value from the source
 int getWeight()
          Get the cost of the transformation.
 java.lang.Object transform(T source, TransformationContext context)
          Transform source data into the result type.
 
Methods inherited from class org.apache.tuscany.sca.databinding.impl.BaseTransformer
getSourceDataBinding, getSourceType
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.tuscany.sca.databinding.Transformer
getSourceDataBinding
 

Field Detail

mapper

protected SimpleTypeMapper mapper
Constructor Detail

SimpleType2JavaTransformer

public SimpleType2JavaTransformer()

SimpleType2JavaTransformer

public SimpleType2JavaTransformer(SimpleTypeMapper mapper)
Method Detail

transform

public java.lang.Object transform(T source,
                                  TransformationContext context)
Description copied from interface: PullTransformer
Transform source data into the result type.

Specified by:
transform in interface PullTransformer<T,java.lang.Object>
Parameters:
source - The source data
context - The context for the transformation
Returns:
The transformed result

getTargetType

protected java.lang.Class<java.lang.Object> getTargetType()
Specified by:
getTargetType in class BaseTransformer<T,java.lang.Object>

getWeight

public int getWeight()
Description copied from interface: Transformer
Get the cost of the transformation. The weight can be used to choose the most efficient path if there are more than one available from the source to the target.

Specified by:
getWeight in interface Transformer
Overrides:
getWeight in class BaseTransformer<T,java.lang.Object>
Returns:
An integer representing the cost of the transformation

getText

protected abstract java.lang.String getText(T source)
Get the string value from the source

Parameters:
source -
Returns:
A string

close

protected void close(T source)
To be overrided by the subclass

Parameters:
source -

getTargetDataBinding

public java.lang.String getTargetDataBinding()
Description copied from interface: Transformer
Get the target type that this transformer transforms data into. The type is used as the key when the transformer is registered with TransformerRegistry.

Specified by:
getTargetDataBinding in interface Transformer
Overrides:
getTargetDataBinding in class BaseTransformer<T,java.lang.Object>
Returns:
A key identifying the target type