public abstract class IlpAbstractAttributeBinding extends Object
This class defines a binding between a TGO attribute
(IlpAttribute
) of a given IlpClass
and a SDM model
property (IlvSDMModel
).
An attribute binding is defined by a source TGO attribute and a target
SDM Model property and their corresponding types. It can be defined as
READ_ONLY
(the SDM model property is only readable) or
READ_WRITE
(the SDM model property can be modified, which will
update the TGO attribute value accordingly).
The binding is also responsible for converting from TGO attribute to SDM model property and vice-versa, the default behavior is to just cast one type to another (which may throw casting exceptions). Subclasses can customize the conversion behavior as needed.
When converting from a SDM model property to a TGO attribute, the binding will also validate the converted value, to ensure that it is a valid TGO attribute value.
Note: The binding conversion methods are automatically
accessed by the IlpAbstractSDMAdapter
holding the binding.
Directly invoking these methods may result in unpredictable behavior.
Modifier and Type | Class and Description |
---|---|
static class |
IlpAbstractAttributeBinding.ConversionFailedException
This exception indicates that an attribute or property conversion failed.
|
static class |
IlpAbstractAttributeBinding.PropertyAlreadySetException
This exception indicates that a binding property has been already set
and cannot be updated.
|
static class |
IlpAbstractAttributeBinding.Type
Enumeration defining the different types of binding, which are:
READ_ONLY The SDM model property can only be read
READ_WRITE The SDM model property can be updated
|
Modifier and Type | Field and Description |
---|---|
protected String |
_attributeName
The TGO attribute name property
|
protected Class<?> |
_attributeType
The TGO attribute type property
|
protected IlpAttributeBindingContext |
_bindingContext
Reference to the attribute binding support
|
protected String |
_propertyName
The SDM model property name
|
protected Class<?> |
_propertyType
The SDM model property type
|
protected IlpAbstractAttributeBinding.Type |
_type
The binding type
|
Constructor and Description |
---|
IlpAbstractAttributeBinding(IlpAbstractAttributeBinding.Type bindingType,
String attrName,
Class<?> attrType,
String propName,
Class<?> propType)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
abstract Object |
convertToAttribute(Object newPropVal)
Converts a value from the SDM model property target type to the
TGO attribute source type.
|
abstract Object |
convertToProperty(Object newAttrVal)
Converts a value from the TGO attribute source type to the
SDM model property target type.
|
boolean |
equals(Object obj)
Two attribute bindings are considered equal if:
this.getAttributeName().equals(other.getAttributeName())
&&
this.getPropertyName().equals(other.getPropertyName())
Other parameters are not considered.
|
String |
getAttributeName()
Access the TGO attribute name of this binding.
|
Class<?> |
getAttributeType()
Access the TGO attribute type of this binding.
|
protected IlpAttributeBindingContext |
getBindingContext()
Access the binding context.
|
String |
getPropertyName()
Access the SDM model property name of this binding.
|
Class<?> |
getPropertyType()
Access the SDM model property type of this binding.
|
IlpAbstractAttributeBinding.Type |
getType()
Access the binding type.
|
void |
setAttributeName(String name)
Sets the TGO attribute name of this binding.
|
void |
setAttributeType(Class<?> type)
Sets the TGO attribute type of this binding.
|
void |
setBindingContext(IlpAttributeBindingContext bindingContext)
Method invoked internally by
IlpAbstractSDMAdapter to set
the binding context into this binding. |
void |
setPropertyName(String name)
Sets the SDM model property name of this binding.
|
void |
setPropertyType(Class<?> type)
Sets the SDM model property type of this binding.
|
void |
setType(IlpAbstractAttributeBinding.Type type)
Sets the binding type.
|
boolean |
validate(Object value)
Validates a given TGO attribute value.
|
protected IlpAttributeBindingContext _bindingContext
protected String _attributeName
protected Class<?> _attributeType
protected String _propertyName
protected Class<?> _propertyType
protected IlpAbstractAttributeBinding.Type _type
public IlpAbstractAttributeBinding(IlpAbstractAttributeBinding.Type bindingType, String attrName, Class<?> attrType, String propName, Class<?> propType)
bindingType
- The binding typeattrName
- The TGO attribute nameattrType
- The TGO attribute value typepropName
- The SDM model property namepropType
- The SDM model property value typepublic String getAttributeName()
public void setAttributeName(String name) throws IlpAbstractAttributeBinding.PropertyAlreadySetException
Sets the TGO attribute name of this binding.
Note that this method can only be invoked once, when the binding has been constructed as a bean.
name
- The TGO attribute nameIlpAbstractAttributeBinding.PropertyAlreadySetException
- If the property has already been setpublic Class<?> getAttributeType()
public void setAttributeType(Class<?> type)
Sets the TGO attribute type of this binding.
Note that this method can only be invoked once, when the binding has been constructed as a bean.
type
- The TGO attribute typeIlpAbstractAttributeBinding.PropertyAlreadySetException
- If the property has already been setpublic String getPropertyName()
public void setPropertyName(String name)
Sets the SDM model property name of this binding.
Note that this method can only be invoked once, when the binding has been constructed as a bean.
name
- The SDM model property nameIlpAbstractAttributeBinding.PropertyAlreadySetException
- If the property has already been setpublic Class<?> getPropertyType()
public void setPropertyType(Class<?> type)
Sets the SDM model property type of this binding.
Note that this method can only be invoked once, when the binding has been constructed as a bean.
type
- The SDM model property typeIlpAbstractAttributeBinding.PropertyAlreadySetException
- If the property has already been setpublic IlpAbstractAttributeBinding.Type getType()
public void setType(IlpAbstractAttributeBinding.Type type)
Sets the binding type.
Note that this method can only be invoked once, when the binding has been constructed as a bean.
type
- The binding typeIlpAbstractAttributeBinding.PropertyAlreadySetException
- If the property has already been setprotected IlpAttributeBindingContext getBindingContext()
public final void setBindingContext(IlpAttributeBindingContext bindingContext)
Method invoked internally by IlpAbstractSDMAdapter
to set
the binding context into this binding.
This method cannot be extended.
bindingContext
- The binding context to be setpublic abstract Object convertToProperty(Object newAttrVal)
Converts a value from the TGO attribute source type to the SDM model property target type.
It can throw RuntimeException
if the conversion fails.
newAttrVal
- The TGO attribute valuepublic abstract Object convertToAttribute(Object newPropVal)
Converts a value from the SDM model property target type to the TGO attribute source type.
It can throw RuntimeException
if the conversion fails.
newPropVal
- The target valuepublic boolean validate(Object value)
Validates a given TGO attribute value.
This method may throw IllegalArgumentException
or
IlpAbstractAttributeBinding.ConversionFailedException
with descriptive detail of the
error. The attribute binding mechanism will log the exception.
value
- The attribute value to be validated.true
for valid values;
false
otherwise© Copyright 2024 Rogue Wave Software, Inc., a Perforce company.. All Rights Reserved.