de.keepondreaming.xml
Class ClassNameMappingObjectStrategy

java.lang.Object
  extended by de.keepondreaming.xml.ClassNameMappingObjectStrategy
All Implemented Interfaces:
ObjectStrategy

public class ClassNameMappingObjectStrategy
extends java.lang.Object
implements ObjectStrategy

Resolves interfaces and attributes via a Properties mapping.

If the mapping does not resolve the strategy can be configured via the constructor ClassNameMappingObjectStrategy(Properties, boolean) to use a backup strategy, usually ProxyObjectStrategy

Property mappings are as follows:

Note that the mappings of XML tagnames to setter/getter methods is only needed if the methods can not get obtained via reflection

$Author: wintermond $ $Date: 2005/07/10 18:38:43 $ $Log: ClassNameMappingObjectStrategy.java,v $ Revision 1.1 2005/07/10 18:38:43 wintermond Renamed ImplObjectStrategy to ClassNameMappingStrategy Performance improvements Revision 1.2 2005/07/09 09:56:38 wintermond Javadoc and implemented ProxyClassCreator. Backupstrategy now more generic


Constructor Summary
ClassNameMappingObjectStrategy(java.util.Properties mappings)
          Default constructor
ClassNameMappingObjectStrategy(java.util.Properties mappings, boolean useProxyMapping)
          Constructor, specifying if in case of insufficient mapping information the call should get passed to the backup strategy
 
Method Summary
 java.lang.Object createInstance(java.lang.Class clazz)
          Creates an instance of the type clazz.
 java.lang.String getMethodName(java.lang.Class clazz, java.lang.String attribute, boolean set)
          Returns the get/set method name for an attribute read by the parser
 void init()
          Restore initial state
 java.lang.Class resolveInterface(java.lang.Object object)
          Determines the interfaces this object was created upon.
 void setAttribute(java.lang.Object target, java.lang.String attribute, java.lang.Object value)
          Sets the attribute on an instance returned via ObjectStrategy.createInstance(Class) target and attribute are guaranteed to be not null.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClassNameMappingObjectStrategy

public ClassNameMappingObjectStrategy(java.util.Properties mappings)
Default constructor

Parameters:
mappings - Must not be null;

ClassNameMappingObjectStrategy

public ClassNameMappingObjectStrategy(java.util.Properties mappings,
                                      boolean useProxyMapping)
Constructor, specifying if in case of insufficient mapping information the call should get passed to the backup strategy

Parameters:
mappings -
useProxyMapping -
Method Detail

createInstance

public java.lang.Object createInstance(java.lang.Class clazz)
Description copied from interface: ObjectStrategy
Creates an instance of the type clazz.

clazz is never null

Specified by:
createInstance in interface ObjectStrategy
Returns:
An instance of the type clazz.

setAttribute

public void setAttribute(java.lang.Object target,
                         java.lang.String attribute,
                         java.lang.Object value)
Description copied from interface: ObjectStrategy
Sets the attribute on an instance returned via ObjectStrategy.createInstance(Class)

target and attribute are guaranteed to be not null.

value is guaranteed to be not null if called by the parser

Specified by:
setAttribute in interface ObjectStrategy
Parameters:
target - Object to set the attribute to
attribute - Attribute name
value - value to set

init

public void init()
Description copied from interface: ObjectStrategy
Restore initial state

Specified by:
init in interface ObjectStrategy

resolveInterface

public java.lang.Class resolveInterface(java.lang.Object object)
Description copied from interface: ObjectStrategy
Determines the interfaces this object was created upon.

Specified by:
resolveInterface in interface ObjectStrategy
Parameters:
object - Object created by ObjectStrategy.createInstance(Class) of this object
Returns:
Target The interfaces this object was created upon.

getMethodName

public java.lang.String getMethodName(java.lang.Class clazz,
                                      java.lang.String attribute,
                                      boolean set)
Description copied from interface: ObjectStrategy
Returns the get/set method name for an attribute read by the parser

Specified by:
getMethodName in interface ObjectStrategy
set - true if set method is requested, false if get
Returns:
Null if attribute can not be handled or strategy does not support the operation, name of method otherwise


Copyright © -2005 . All Rights Reserved.