thinkmap.datasource.relational
Class Binding<T>

java.lang.Object
  extended by thinkmap.datasource.relational.Binding<T>
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
AttributeBinding, ConstantBinding, EntityIdBinding, EntityPropertyBinding, OutBinding, SQLBinding

public abstract class Binding<T>
extends Object
implements Serializable

Binding binds a value between a datasource and its input or output.

See Also:
Serialized Form

Constructor Summary
Binding()
           
 
Method Summary
abstract  T bind(Message message, SourceEntity entity, EntityId id, Object context)
           
protected  T convertType(Object obj)
           
 Class<T> getOutputType()
          Get the type of object this binding will return, or null if no conversion will be performed.
 String getProperty()
          Get the name of the property for this binding.
 String getProperty(Message message, SourceEntity entity, EntityId id, Object context)
          Get the name of the property for this binding.
 void setOutputType(Class<T> outputType)
          Set the type of object this binding will return.
 void setProperty(String name)
          Set the name of the property for this binding.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Binding

public Binding()
Method Detail

bind

public abstract T bind(Message message,
                       SourceEntity entity,
                       EntityId id,
                       Object context)
                throws BindingException
Parameters:
message - incoming message
entity - the entity being bound (may be null)
id - the id of the entity being bound
context - context object; datasource-specific
Returns:
value
Throws:
BindingException

getProperty

public String getProperty(Message message,
                          SourceEntity entity,
                          EntityId id,
                          Object context)
                   throws BindingException
Get the name of the property for this binding. By default, simply returns getProperty. Override this to change the property name based on the results object.

Parameters:
message - incoming message
entity - the entity being bound (may be null)
id - the id of the entity being bound
context - context object; datasource-specific
Returns:
property name
Throws:
BindingException

getProperty

public String getProperty()
Get the name of the property for this binding.

Returns:
property name

setProperty

public void setProperty(String name)
Set the name of the property for this binding.

Parameters:
name - property name

getOutputType

public Class<T> getOutputType()
Get the type of object this binding will return, or null if no conversion will be performed.

Returns:
output type

setOutputType

public void setOutputType(Class<T> outputType)
Set the type of object this binding will return.

Parameters:
outputType - output type
Throws:
IllegalArgumentException - if outputType is unsupported

convertType

protected T convertType(Object obj)
                 throws BindingException
Throws:
BindingException


Copyright © 2013 Thinkmap, Inc. All Rights Reserved.