public class DirectAttributeHandler extends Object implements AttributeHandler
Constructor and Description |
---|
DirectAttributeHandler(String reposAttrName,
Class cls)
Constructor.
|
DirectAttributeHandler(String reposAttrName,
Class[] getFromClasses)
Constructor.
|
DirectAttributeHandler(String reposAttrName,
Class[] getFromClasses,
Map classMap)
Constructor.
|
DirectAttributeHandler(String reposAttrName,
Class cls,
Map classMap)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
boolean |
canHandle(AttributeHandlerContext context)
Returns
true if this handler can handle the attribute
request on the given object instance. |
boolean |
canUpdate(AttributeHandlerContext context)
Returns
true if this handler can update the attribute,
false if the attribute is not updateable. |
String |
getDefaultReposAttributeName()
Returns the default repository attribute name.
|
String |
getReposAttributeName(Class cls)
Returns the repository attribute name for the corresponding class
as mapped by this attribute handler.
|
Object |
getValue(AttributeHandlerContext context)
Returns the value of an attribute.
|
boolean |
isSimpleAttributeMap()
Returns true if the attribute map is null.
|
AttributeUpdater |
setValue(AttributeHandlerContext context,
Object value)
Updates the attribute with the given value.
|
public DirectAttributeHandler(String reposAttrName, Class cls)
reposAttrName
- The name of the attribute as defined on the
repository object.cls
- The top class type of the repository objects this
handler can handle. Ttypically this is the first
class in the hierarchy that defines the
reposAttrName. It cannot be null
.public DirectAttributeHandler(String reposAttrName, Class cls, Map classMap)
reposAttrName
- The name of the attribute as defined on the
repository object.cls
- The top class type of the repository objects this
handler can handle. Ttypically this is the first
class in the hierarchy that defines the
reposAttrName. It cannot be null
.classMap
- A map from .class to uppercased repository attribute
name that allows various classes to map to an
attribute other than the default
reposAttrName
.public DirectAttributeHandler(String reposAttrName, Class[] getFromClasses)
reposAttrName
- The name of the attribute as defined on the
repository object.getFromClasses
- List of classes this attribute can be retrieved
from. This is useful if the attribute needs
to be restricted to a subset of the class
hierarchy. It cannot be null
.public DirectAttributeHandler(String reposAttrName, Class[] getFromClasses, Map classMap)
reposAttrName
- The name of the attribute as defined on the
repository object.getFromClasses
- List of classes this attribute can be retrieved
from. This is useful if the attribute needs
to be restricted to a subset of the class
hierarchy. It cannot be null
.classMap
- A map from .class to uppercased repository attribute
name that allows various classes to map to an
attribute other than the default
reposAttrName
.public boolean canHandle(AttributeHandlerContext context)
AttributeHandler
true
if this handler can handle the attribute
request on the given object instance. The necessary information to
determine which attribute is requested and what the underlying repository
object is will be packaged in the context.canHandle
in interface AttributeHandler
context
- The context when this handler is called.public boolean canUpdate(AttributeHandlerContext context)
AttributeHandler
true
if this handler can update the attribute,
false
if the attribute is not updateable.
The necessary information to determine which
attribute is requested and what the underlying repository object is will
be packaged in the context.canUpdate
in interface AttributeHandler
context
- The context when this handler is called.public Object getValue(AttributeHandlerContext context) throws IfsException
AttributeHandler
RuntimeException
if canHandle()
returns
false
and this method is still being called.
Note that implementations which handle read-only attributes should
subclass ReadOnlyAttributeHandler
for convenience as they
would need to provide the read side methods only.
getValue
in interface AttributeHandler
context
- The context when this handler is called.IfsException
- If a repository exception occurs.public AttributeUpdater setValue(AttributeHandlerContext context, Object value) throws IfsException
AttributeHandler
RuntimeException
if canUpdate()
returns
false
and this method is still being called.
An implementation of this method has two choices:
AttributeUpdater
object filled in
with the repositoy object to update, the name of the attribute and
the value of the attribute (which may be a derived value from the
value passed in). The driving code that invokes it will then do the
actual update in an optimized way.
null
in order to notify
the caller the update was executed.
setValue
in interface AttributeHandler
context
- The context when this handler is called.value
- The value to set the attribute to.IfsException
- If a repository exception occurs.public boolean isSimpleAttributeMap()
public String getDefaultReposAttributeName()
Copyright © 2023. All rights reserved.