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.ognl
Class OgnlUtil

    java.lang.Object
      com.opensymphony.xwork2.ognl.OgnlUtil

    public class OgnlUtil

extends java.lang.Object

Utility class that provides common access to the Ognl APIs for setting and getting properties from objects (usually Actions).

Author:
  Jason Carreira

Constructor Summary
`OgnlUtil()`

Method Summary
`java.lang.Object` | `compile(java.lang.String expression)`
`void` | `copy(java.lang.Object from, java.lang.Object to, java.util.Map<java.lang.String,java.lang.Object> context)` Copies the properties in the object "from" and sets them in the object "to" using specified type converter, or `XWorkConverter` if none is specified.
`void` | `copy(java.lang.Object from, java.lang.Object to, java.util.Map<java.lang.String,java.lang.Object> context, java.util.Collection<java.lang.String> exclusions, java.util.Collection<java.lang.String> inclusions)` Copies the properties in the object "from" and sets them in the object "to" using specified type converter, or `XWorkConverter` if none is specified.
`java.beans.BeanInfo` | `getBeanInfo(java.lang.Class clazz)` Get's the java bean info for the given source.
`java.beans.BeanInfo` | `getBeanInfo(java.lang.Object from)` Get's the java bean info for the given source object.
`java.util.Map` | `getBeanMap(java.lang.Object source)` Creates a Map with read properties for the given source object.
`java.beans.PropertyDescriptor[]` | `getPropertyDescriptors(java.lang.Class clazz)` Get's the java beans property descriptors for the given class.
`java.beans.PropertyDescriptor[]` | `getPropertyDescriptors(java.lang.Object source)` Get's the java beans property descriptors for the given source.
`java.lang.Object` | `getRealTarget(java.lang.String property, java.util.Map<java.lang.String,java.lang.Object> context, java.lang.Object root)` Looks for the real target with the specified property given a root Object which may be a CompoundRoot.
`java.lang.Object` | `getValue(java.lang.String name, java.util.Map<java.lang.String,java.lang.Object> context, java.lang.Object root)`
`java.lang.Object` | `getValue(java.lang.String name, java.util.Map<java.lang.String,java.lang.Object> context, java.lang.Object root, java.lang.Class resultType)`
`static void` | `setDevMode(java.lang.String mode)`
`static void` | `setEnableExpressionCache(java.lang.String cache)`
`void` | `setProperties(java.util.Map<java.lang.String,?> properties, java.lang.Object o)` Sets the properties on the object using the default context, defaulting to not throwing exceptions for problems setting the properties.
`void` | `setProperties(java.util.Map<java.lang.String,?> properties, java.lang.Object o, boolean throwPropertyExceptions)` Sets the properties on the object using the default context.
`void` | `setProperties(java.util.Map<java.lang.String,?> props, java.lang.Object o, java.util.Map<java.lang.String,java.lang.Object> context)` Sets the object's properties using the default type converter, defaulting to not throw exceptions for problems setting the properties.
`void` | `setProperties(java.util.Map<java.lang.String,?> props, java.lang.Object o, java.util.Map<java.lang.String,java.lang.Object> context, boolean throwPropertyExceptions)` Sets the object's properties using the default type converter.
`void` | `setProperty(java.lang.String name, java.lang.Object value, java.lang.Object o, java.util.Map<java.lang.String,java.lang.Object> context)` Sets the named property to the supplied value on the Object, defaults to not throwing property exceptions.
`void` | `setProperty(java.lang.String name, java.lang.Object value, java.lang.Object o, java.util.Map<java.lang.String,java.lang.Object> context, boolean throwPropertyExceptions)` Sets the named property to the supplied value on the Object.
`void` | `setValue(java.lang.String name, java.util.Map<java.lang.String,java.lang.Object> context, java.lang.Object root, java.lang.Object value)` Wrapper around Ognl.setValue() to handle type conversion for collection elements.
`void` | `setXWorkConverter(XWorkConverter conv)`

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

Constructor Detail

### OgnlUtil

    public OgnlUtil()

Method Detail

### setXWorkConverter

    public void setXWorkConverter(XWorkConverter conv)

### setDevMode

    public static void setDevMode(java.lang.String mode)

### setEnableExpressionCache

    public static void setEnableExpressionCache(java.lang.String cache)

### setProperties

    public void setProperties(java.util.Map<java.lang.String,?> props,
                              java.lang.Object o,
                              java.util.Map<java.lang.String,java.lang.Object> context)

  Sets the object's properties using the default type converter, defaulting to not throw exceptions for problems setting the properties.

  Parameters:
    `props` - the properties being set
    `o` - the object
    `context` - the action context

### setProperties

    public void setProperties(java.util.Map<java.lang.String,?> props,
                              java.lang.Object o,
                              java.util.Map<java.lang.String,java.lang.Object> context,
                              boolean throwPropertyExceptions)
                       throws ReflectionException

  Sets the object's properties using the default type converter.

  Parameters:
    `props` - the properties being set
    `o` - the object
    `context` - the action context
    `throwPropertyExceptions` - boolean which tells whether it should throw exceptions for problems setting the properties
  Throws:
    `ReflectionException`

### setProperties

    public void setProperties(java.util.Map<java.lang.String,?> properties,
                              java.lang.Object o)

  Sets the properties on the object using the default context, defaulting to not throwing exceptions for problems setting the properties.

  Parameters:
    `properties` -
    `o` -

### setProperties

    public void setProperties(java.util.Map<java.lang.String,?> properties,
                              java.lang.Object o,
                              boolean throwPropertyExceptions)

  Sets the properties on the object using the default context.

  Parameters:
    `properties` - the property map to set on the object
    `o` - the object to set the properties into
    `throwPropertyExceptions` - boolean which tells whether it should throw exceptions for problems setting the properties

### setProperty

    public void setProperty(java.lang.String name,
                            java.lang.Object value,
                            java.lang.Object o,
                            java.util.Map<java.lang.String,java.lang.Object> context)

  Sets the named property to the supplied value on the Object, defaults to not throwing property exceptions.

  Parameters:
    `name` - the name of the property to be set
    `value` - the value to set into the named property
    `o` - the object upon which to set the property
    `context` - the context which may include the TypeConverter

### setProperty

    public void setProperty(java.lang.String name,
                            java.lang.Object value,
                            java.lang.Object o,
                            java.util.Map<java.lang.String,java.lang.Object> context,
                            boolean throwPropertyExceptions)

  Sets the named property to the supplied value on the Object.

  Parameters:
    `name` - the name of the property to be set
    `value` - the value to set into the named property
    `o` - the object upon which to set the property
    `context` - the context which may include the TypeConverter
    `throwPropertyExceptions` - boolean which tells whether it should throw exceptions for problems setting the property

### getRealTarget

    public java.lang.Object getRealTarget(java.lang.String property,
                                          java.util.Map<java.lang.String,java.lang.Object> context,
                                          java.lang.Object root)
                                   throws ognl.OgnlException

  Looks for the real target with the specified property given a root Object which may be a CompoundRoot.

  Returns:
    the real target or null if no object can be found with the specified property
  Throws:
    `ognl.OgnlException`

### setValue

    public void setValue(java.lang.String name,
                         java.util.Map<java.lang.String,java.lang.Object> context,
                         java.lang.Object root,
                         java.lang.Object value)
                  throws ognl.OgnlException

  Wrapper around Ognl.setValue() to handle type conversion for collection elements. Ideally, this should be handled by OGNL directly.

  Throws:
    `ognl.OgnlException`

### getValue

    public java.lang.Object getValue(java.lang.String name,
                                     java.util.Map<java.lang.String,java.lang.Object> context,
                                     java.lang.Object root)
                              throws ognl.OgnlException

  Throws:
    `ognl.OgnlException`

### getValue

    public java.lang.Object getValue(java.lang.String name,
                                     java.util.Map<java.lang.String,java.lang.Object> context,
                                     java.lang.Object root,
                                     java.lang.Class resultType)
                              throws ognl.OgnlException

  Throws:
    `ognl.OgnlException`

### compile

    public java.lang.Object compile(java.lang.String expression)
                             throws ognl.OgnlException

  Throws:
    `ognl.OgnlException`

### copy

    public void copy(java.lang.Object from,
                     java.lang.Object to,
                     java.util.Map<java.lang.String,java.lang.Object> context,
                     java.util.Collection<java.lang.String> exclusions,
                     java.util.Collection<java.lang.String> inclusions)

  Copies the properties in the object "from" and sets them in the object "to" using specified type converter, or `XWorkConverter` if none is specified.

  Parameters:
    `from` - the source object
    `to` - the target object
    `context` - the action context we're running under
    `exclusions` - collection of method names to excluded from copying ( can be null)
    `inclusions` - collection of method names to included copying (can be null) note if exclusions AND inclusions are supplied and not null nothing will get copied.

### copy

    public void copy(java.lang.Object from,
                     java.lang.Object to,
                     java.util.Map<java.lang.String,java.lang.Object> context)

  Copies the properties in the object "from" and sets them in the object "to" using specified type converter, or `XWorkConverter` if none is specified.

  Parameters:
    `from` - the source object
    `to` - the target object
    `context` - the action context we're running under

### getPropertyDescriptors

    public java.beans.PropertyDescriptor[] getPropertyDescriptors(java.lang.Object source)
                                                           throws java.beans.IntrospectionException

  Get's the java beans property descriptors for the given source.

  Parameters:
    `source` - the source object.
  Returns:
    property descriptors.
  Throws:
    `java.beans.IntrospectionException` - is thrown if an exception occurs during introspection.

### getPropertyDescriptors

    public java.beans.PropertyDescriptor[] getPropertyDescriptors(java.lang.Class clazz)
                                                           throws java.beans.IntrospectionException

  Get's the java beans property descriptors for the given class.

  Parameters:
    `clazz` - the source object.
  Returns:
    property descriptors.
  Throws:
    `java.beans.IntrospectionException` - is thrown if an exception occurs during introspection.

### getBeanMap

    public java.util.Map getBeanMap(java.lang.Object source)
                             throws java.beans.IntrospectionException,
                                    ognl.OgnlException

  Creates a Map with read properties for the given source object.

  If the source object does not have a read property (i.e. write-only) then the property is added to the map with the value `here is no read method for property-name`.

  Parameters:
    `source` - the source object.
  Returns:
    a Map with (key = read property name, value = value of read property).
  Throws:
    `java.beans.IntrospectionException` - is thrown if an exception occurs during introspection.
    `ognl.OgnlException` - is thrown by OGNL if the property value could not be retrieved

### getBeanInfo

    public java.beans.BeanInfo getBeanInfo(java.lang.Object from)
                                    throws java.beans.IntrospectionException

  Get's the java bean info for the given source object. Calls getBeanInfo(Class c).

  Parameters:
    `from` - the source object.
  Returns:
    java bean info.
  Throws:
    `java.beans.IntrospectionException` - is thrown if an exception occurs during introspection.

### getBeanInfo

    public java.beans.BeanInfo getBeanInfo(java.lang.Class clazz)
                                    throws java.beans.IntrospectionException

  Get's the java bean info for the given source.

  Parameters:
    `clazz` - the source class.
  Returns:
    java bean info.
  Throws:
    `java.beans.IntrospectionException` - is thrown if an exception occurs during introspection.

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-2011 Apache Software Foundation. All Rights Reserved.