com.agfa.hap.sdo.mapper
Class JavaBeanMapper

java.lang.Object
  extended by com.agfa.hap.sdo.mapper.JavaBeanMapper
All Implemented Interfaces:
DataMapper<java.lang.Object>

public class JavaBeanMapper
extends java.lang.Object
implements DataMapper<java.lang.Object>

DataMapper that uses Java Bean conventions to access data on java classes. This mapper assumes that for each Property there are appropriately named accessors defined on the corresponding class. Each Type is mapped to the java class with the same name. It is also possible to register a class as corresponding to a type.

This DataMapper ensures that opposite properties are properly filled in. As such, objects will not be added multiple times to a many-valued property if that property has an opposite property.

Author:
AMOCZ

Constructor Summary
JavaBeanMapper(TypeMapper typeMapper)
           
 
Method Summary
 java.lang.Object create(Type type)
           
 Type getCorrespondingType(java.lang.Class clazz)
           
 java.util.Iterator<?> getObjects(java.lang.Object object, Property property)
           
 java.util.Collection<java.lang.Object> getProperties(java.util.Collection<java.lang.Object> objects, Property bulkProperty, SnapshotDefinition def)
          Return the corresponding values for this bulk property for the given object.
 java.lang.Object getProperty(java.lang.Object object, Property property)
           
 Type getType(java.lang.Object object)
           
 TypeMapper getTypeMapper()
           
 boolean isBulkProperty(java.lang.Class clazz, Property property)
           
 boolean isProxy(java.lang.Object instance)
           
 java.lang.Object newProxy(Type type, java.lang.Object identity)
          Create a new proxy.
protected  void setOpposite(java.lang.Object object, Property property, java.lang.Object value)
           
 void setProperty(java.lang.Object object, Property property, java.lang.Object value)
          Assigns the given value to the property of the object.
 void setUnavailable(java.lang.Object object, Property property)
          Marks a property as unavailable (PartialDataObject#isAvailable(Property)}.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JavaBeanMapper

public JavaBeanMapper(TypeMapper typeMapper)
Method Detail

getObjects

public java.util.Iterator<?> getObjects(java.lang.Object object,
                                        Property property)
Specified by:
getObjects in interface DataMapper<java.lang.Object>
Returns:
An iterator over all values of this property of the given Object. Property should be a many-valued property. returns an "empty" iterator in case the property is null (SDO doesn't have the concept of a many valued property that can be null)

getProperty

public java.lang.Object getProperty(java.lang.Object object,
                                    Property property)
Specified by:
getProperty in interface DataMapper<java.lang.Object>
Returns:
The value of the property for the given object.

setProperty

public void setProperty(java.lang.Object object,
                        Property property,
                        java.lang.Object value)
Description copied from interface: DataMapper
Assigns the given value to the property of the object. If the property is many-valued, adds the property to the collection of values.

Specified by:
setProperty in interface DataMapper<java.lang.Object>

setOpposite

protected void setOpposite(java.lang.Object object,
                           Property property,
                           java.lang.Object value)

setUnavailable

public void setUnavailable(java.lang.Object object,
                           Property property)
Description copied from interface: DataMapper
Marks a property as unavailable (PartialDataObject#isAvailable(Property)}.

Specified by:
setUnavailable in interface DataMapper<java.lang.Object>

getType

public Type getType(java.lang.Object object)
Specified by:
getType in interface DataMapper<java.lang.Object>
Returns:
The sdo type that corresponds with this object. It is assumed that for all properties of this type, appropriate values can be retrieved from the instance.

getCorrespondingType

public Type getCorrespondingType(java.lang.Class clazz)
Specified by:
getCorrespondingType in interface DataMapper<java.lang.Object>
Returns:
The sdo type that corresponds with this class. It is assumed that for all properties of this type, appropriate values can be retrieved from the instance.

getTypeMapper

public TypeMapper getTypeMapper()

create

public java.lang.Object create(Type type)
Specified by:
create in interface DataMapper<java.lang.Object>
Returns:
A newly created instance of which the class corresponds to the given type.
See Also:
DataMapper.getCorrespondingType(Class)

newProxy

public java.lang.Object newProxy(Type type,
                                 java.lang.Object identity)
Description copied from interface: DataMapper
Create a new proxy. The type is passed as parameter as this accessor might be usable for multiple types.

Specified by:
newProxy in interface DataMapper<java.lang.Object>
Returns:
null if the datamapper is unable to create a proxy for the given type

isProxy

public boolean isProxy(java.lang.Object instance)
Specified by:
isProxy in interface DataMapper<java.lang.Object>

getProperties

public java.util.Collection<java.lang.Object> getProperties(java.util.Collection<java.lang.Object> objects,
                                                            Property bulkProperty,
                                                            SnapshotDefinition def)
Description copied from interface: DataMapper
Return the corresponding values for this bulk property for the given object. A snapshotdefinition is passed as indication for which child objects are needed as well.

Specified by:
getProperties in interface DataMapper<java.lang.Object>

isBulkProperty

public boolean isBulkProperty(java.lang.Class clazz,
                              Property property)
Specified by:
isBulkProperty in interface DataMapper<java.lang.Object>
Returns:
if this property is a bulk property for the given implementation clazz. Bulk properties are accessed in bulk (@see DataMapper.getProperties(Collection, Property, SnapshotDefinition) to allow more efficient retrieval.


Copyright © 2007. All Rights Reserved.