|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.opensymphony.xwork2.util.DefaultObjectTypeDeterminer
public class DefaultObjectTypeDeterminer
This ObjectTypeDeterminer
looks at the Class-conversion.properties for entries that indicated what
objects are contained within Maps and Collections. For Collections, such as Lists, the element is specified using the
pattern Element_xxx, where xxx is the field name of the collection property in your action or object. For
Maps, both the key and the value may be specified by using the pattern Key_xxx and Element_xxx,
respectively.
XWorkListPropertyAccessor
,
XWorkCollectionPropertyAccessor
,
XWorkMapPropertyAccessor
Field Summary | |
---|---|
static String |
CREATE_IF_NULL_PREFIX
|
static String |
DEPRECATED_ELEMENT_PREFIX
|
static String |
ELEMENT_PREFIX
|
static String |
KEY_PREFIX
|
static String |
KEY_PROPERTY_PREFIX
|
protected static Log |
LOG
|
Constructor Summary | |
---|---|
DefaultObjectTypeDeterminer()
|
Method Summary | ||
---|---|---|
protected
|
getAnnotation(Class parentClass,
String property,
Class<T> annotationClass)
Retrieves an annotation for the specified property of field, setter or getter. |
|
private
|
getAnnotationFromGetter(Class parentClass,
String property,
Class<T> annotationClass)
Retrieves an annotation for the specified field of getter. |
|
private
|
getAnnotationFromSetter(Class parentClass,
String property,
Class<T> annotationClass)
Retrieves an annotation for the specified field of setter. |
|
private Class |
getClass(Class parentClass,
String property,
boolean element)
Returns the class for the given field via generic type check. |
|
Class |
getElementClass(Class parentClass,
String property,
Object key)
Determines the element class by looking for the value of @Element annotation for the given class. |
|
Class |
getKeyClass(Class parentClass,
String property)
Determines the key class by looking for the value of @Key annotation for the given class. |
|
String |
getKeyProperty(Class parentClass,
String property)
Determines the key property for a Collection by getting it from the @KeyProperty annotation. |
|
boolean |
shouldCreateIfNew(Class parentClass,
String property,
Object target,
String keyProperty,
boolean isIndexAccessed)
Determines the createIfNull property for a Collection or Map by getting it from the @CreateIfNull annotation. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final Log LOG
public static final String KEY_PREFIX
public static final String ELEMENT_PREFIX
public static final String KEY_PROPERTY_PREFIX
public static final String CREATE_IF_NULL_PREFIX
public static final String DEPRECATED_ELEMENT_PREFIX
Constructor Detail |
---|
public DefaultObjectTypeDeterminer()
Method Detail |
---|
public Class getKeyClass(Class parentClass, String property)
getKeyClass
in interface ObjectTypeDeterminer
parentClass
- the Class which contains as a property the Map or Collection we are finding the key for.property
- the property of the Map or Collection for the given parent classObjectTypeDeterminer.getKeyClass(Class, String)
public Class getElementClass(Class parentClass, String property, Object key)
getElementClass
in interface ObjectTypeDeterminer
parentClass
- the Class which contains as a property the Map or Collection we are finding the key for.property
- the property of the Map or Collection for the given parent classObjectTypeDeterminer.getElementClass(Class, String, Object)
public String getKeyProperty(Class parentClass, String property)
getKeyProperty
in interface ObjectTypeDeterminer
parentClass
- the Class which contains as a property the Map or Collection we are finding the key for.property
- the property of the Map or Collection for the given parent classObjectTypeDeterminer.getKeyProperty(Class, String)
public boolean shouldCreateIfNew(Class parentClass, String property, Object target, String keyProperty, boolean isIndexAccessed)
shouldCreateIfNew
in interface ObjectTypeDeterminer
parentClass
- the Class which contains as a property the Map or Collection we are finding the key for.property
- the property of the Map or Collection for the given parent classtarget
- keyProperty
- isIndexAccessed
- true, if the collection or map is accessed via index, false otherwise.
ObjectTypeDeterminer.getKeyProperty(Class, String)
protected <T extends Annotation> T getAnnotation(Class parentClass, String property, Class<T> annotationClass)
T
- the annotation type to be retrievedparentClass
- the classproperty
- the propertyannotationClass
- the annotation
null
if not foundprivate <T extends Annotation> T getAnnotationFromGetter(Class parentClass, String property, Class<T> annotationClass)
parentClass
- the Class which contains as a property the Map or Collection we are finding the key for.property
- the property of the Map or Collection for the given parent classannotationClass
- The annotation
private <T extends Annotation> T getAnnotationFromSetter(Class parentClass, String property, Class<T> annotationClass)
parentClass
- the Class which contains as a property the Map or Collection we are finding the key for.property
- the property of the Map or Collection for the given parent classannotationClass
- The annotation
private Class getClass(Class parentClass, String property, boolean element)
parentClass
- the Class which contains as a property the Map or Collection we are finding the key for.property
- the property of the Map or Collection for the given parent classelement
- true for indexed types and Maps.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |