de.keepondreaming.xml.annotations
Class JavaAnnotationsStrategy

java.lang.Object
  extended by de.keepondreaming.xml.annotations.JavaAnnotationsStrategy
All Implemented Interfaces:
AnnotationStrategy

public class JavaAnnotationsStrategy
extends java.lang.Object
implements AnnotationStrategy

Resolves annotations needed by the XmlConverter by using the Annotation mechanism, introduced with Java 1.5, eg. Java 5 or also called Tiger $Author: wintermond $ $Date: 2005/07/10 18:34:58 $ $Log: JavaAnnotationsStrategy.java,v $ Revision 1.1 2005/07/10 18:34:58 wintermond Renamed from AnnotationsParserStrategy javadoc


Constructor Summary
JavaAnnotationsStrategy()
          Default constructor
 
Method Summary
 java.lang.String getContentAttribute(java.lang.Class unused, java.lang.Object object)
          This method is called whenever the XmlConverter wants to set contents read by the ContentHandler.characters(char[], int, int)-method.
 java.lang.String getDateFormatPattern(java.lang.reflect.Method method)
          This method is called whenever the XmlConverter reads a String for a method returning a Date or one of its subclasses.
 java.lang.Class getGenericReturnType(java.lang.reflect.Method method)
          This method is called whenever the XmlConverter wants to set the contents of a Collection- or Map-return type.
 java.lang.String getKeyAttribute(java.lang.reflect.Method method)
          Called by the XmlConverter if an entry has to be set in a Map.
 void init()
          Restore initial state
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JavaAnnotationsStrategy

public JavaAnnotationsStrategy()
Default constructor

Method Detail

getContentAttribute

public java.lang.String getContentAttribute(java.lang.Class unused,
                                            java.lang.Object object)
Description copied from interface: AnnotationStrategy
This method is called whenever the XmlConverter wants to set contents read by the ContentHandler.characters(char[], int, int)-method. The XmlConverter needs the attribute name designated for the content to lookup the corresponding setter method.

clazz is guaranteed to be not null

Specified by:
getContentAttribute in interface AnnotationStrategy
Parameters:
unused - Name of the current class, never null
object - The current objct processed
Returns:
The name of the method set receives the untagged contents

getKeyAttribute

public java.lang.String getKeyAttribute(java.lang.reflect.Method method)
Description copied from interface: AnnotationStrategy
Called by the XmlConverter if an entry has to be set in a Map.

The name of the attribute containing the key identifier gets returned.

Note: At the moment the key attribute must be of type String and the attribute must be read as an attribute, not as a sub tag!

This means that

<myTag><myKeyAttribute>myKeyValue</myKeyAttribute></myTag> will not work, use instead

<myTag myKeyAttribute="myKeyValue">

Specified by:
getKeyAttribute in interface AnnotationStrategy
Parameters:
method - Method returning a Map
Returns:
The attribute name of the Class storing the key-value

getGenericReturnType

public java.lang.Class getGenericReturnType(java.lang.reflect.Method method)
Description copied from interface: AnnotationStrategy
This method is called whenever the XmlConverter wants to set the contents of a Collection- or Map-return type.

The method returns the base class all stored elements must be assignable to.

Note that the ProxyObjectStrategy requires the returned class types to be interfaces.

Specified by:
getGenericReturnType in interface AnnotationStrategy
Parameters:
method - Getter method returning aCollection or Map
Returns:
An class of the element classes stored within.

getDateFormatPattern

public java.lang.String getDateFormatPattern(java.lang.reflect.Method method)
Description copied from interface: AnnotationStrategy
This method is called whenever the XmlConverter reads a String for a method returning a Date or one of its subclasses. Values can be either longs or formatted strings, which have to be converted to longs.

This method returns the formatting string, or null if values are expected as longs

Specified by:
getDateFormatPattern in interface AnnotationStrategy
Parameters:
method - Getter method returning a Date or one of its subclasses
Returns:
A Date format string or null

init

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

Specified by:
init in interface AnnotationStrategy


Copyright © -2005 . All Rights Reserved.