Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.opensymphony.xwork2.util
Class DefaultObjectTypeDeterminer

    java.lang.Object
      com.opensymphony.xwork2.util.DefaultObjectTypeDeterminer

All Implemented Interfaces:
  ObjectTypeDeterminer

Direct Known Subclasses:
  GenericsObjectTypeDeterminer

    public class DefaultObjectTypeDeterminer

extends Object
implements ObjectTypeDeterminer

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.

From WebWork 2.1.x, the Collection_xxx format is still supported and honored, although it is deprecated and will be removed eventually.

Author:
  Gabriel Zimmerman
See Also:
  `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
`Class` | `getElementClass(Class parentClass, String property, Object key)` Determines the key class by looking for the value of Element_${property} in the properties file for the given class.
`Class` | `getKeyClass(Class parentClass, String property)` Determines the key class by looking for the value of Key_${property} in the properties file for the given class.
`String` | `getKeyProperty(Class parentClass, String property)` Determines the String key property for a Collection by getting it from the conversion properties file using the KeyProperty_ prefix.
`boolean` | `shouldCreateIfNew(Class parentClass, String property, Object target, String keyProperty, boolean isIndexAccessed)` Determines the boolean CreateIfNull property for a Collection or Map by getting it from the conversion properties file using the CreateIfNull_ prefix.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### LOG

    protected static final Log LOG

### KEY_PREFIX

    public static final String KEY_PREFIX

See Also:
  Constant Field Values

### ELEMENT_PREFIX

    public static final String ELEMENT_PREFIX

See Also:
  Constant Field Values

### KEY_PROPERTY_PREFIX

    public static final String KEY_PROPERTY_PREFIX

See Also:
  Constant Field Values

### CREATE_IF_NULL_PREFIX

    public static final String CREATE_IF_NULL_PREFIX

See Also:
  Constant Field Values

### DEPRECATED_ELEMENT_PREFIX

    public static final String DEPRECATED_ELEMENT_PREFIX

See Also:
  Constant Field Values

Constructor Detail

### DefaultObjectTypeDeterminer

    public DefaultObjectTypeDeterminer()

Method Detail

### getKeyClass

    public Class getKeyClass(Class parentClass,
                             String property)

  Determines the key class by looking for the value of Key_${property} in the properties file for the given class.

  Specified by:
    `getKeyClass` in interface `ObjectTypeDeterminer`
  Parameters:
    `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 class
  See Also:
    `ObjectTypeDeterminer.getKeyClass(Class, String)`

### getElementClass

    public Class getElementClass(Class parentClass,
                                 String property,
                                 Object key)

  Determines the key class by looking for the value of Element_${property} in the properties file for the given class. Also looks for the deprecated Collection_${property}

  Specified by:
    `getElementClass` in interface `ObjectTypeDeterminer`
  Parameters:
    `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 class
  See Also:
    `ObjectTypeDeterminer.getElementClass(Class, String, Object)`

### getKeyProperty

    public String getKeyProperty(Class parentClass,
                                 String property)

  Determines the String key property for a Collection by getting it from the conversion properties file using the KeyProperty_ prefix. KeyProperty_${property}=somePropertyOfBeansInTheSet

  Specified by:
    `getKeyProperty` in interface `ObjectTypeDeterminer`
  Parameters:
    `parentClass` - the Class which contains as a property the Map or Collection we are finding the KeyProperty for.
    `property` - the property of the Map or Collection for the given parent class

### shouldCreateIfNew

    public boolean shouldCreateIfNew(Class parentClass,
                                     String property,
                                     Object target,
                                     String keyProperty,
                                     boolean isIndexAccessed)

  Determines the boolean CreateIfNull property for a Collection or Map by getting it from the conversion properties file using the CreateIfNull_ prefix. CreateIfNull_${property}=true|false

  Specified by:
    `shouldCreateIfNew` in interface `ObjectTypeDeterminer`
  Parameters:
    `parentClass` - the Class which contains as a property the Map or Collection we are finding the CreateIfNull for.
    `property` - the property of the Map or Collection for the given parent class
    `target` -
    `keyProperty` -
    `isIndexAccessed` -
  Returns:
    `true`, if the Collection or Map should be created, `false` otherwise.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2000-2007 Apache Software Foundation. All Rights Reserved.