org.apache.commons.jexl3.internal.introspection
Class PropertySetExecutor

java.lang.Object
  extended by org.apache.commons.jexl3.internal.introspection.AbstractExecutor.Set
      extended by org.apache.commons.jexl3.internal.introspection.PropertySetExecutor
All Implemented Interfaces:
JexlPropertySet

public class PropertySetExecutor
extends AbstractExecutor.Set

Specialized executor to set a property in an object.

Since:
2.0

Nested Class Summary
static class AbstractExecutor.Get
          Abstract class that is used to execute an arbitrary 'get' method.
static class AbstractExecutor.Method
          Abstract class that is used to execute an arbitrary method.
static class AbstractExecutor.Set
          Abstract class that is used to execute an arbitrary 'set' method.
 
Field Summary
protected  Method method
          Method to be executed.
protected  Class<?> objectClass
          The class this executor applies to.
protected  String property
          The property.
static Object TRY_FAILED
          A marker for invocation failures in tryInvoke.
 
Constructor Summary
protected PropertySetExecutor(Class<?> clazz, Method method, String key)
          Creates an instance.
 
Method Summary
static PropertySetExecutor discover(Introspector is, Class<?> clazz, String property, Object arg)
          Discovers a PropertySetExecutor.
 boolean equals(org.apache.commons.jexl3.internal.introspection.AbstractExecutor arg)
          Indicates whether some other executor is equivalent to this one.
 boolean equals(Object obj)
           
 Method getMethod()
          Gets the method to be executed or used as a marker.
 String getMethodName()
          Gets the method name used.
 Class<?> getTargetClass()
          Gets the object class targeted by this executor.
 Object getTargetProperty()
          Gets the property targeted by this executor.
 int hashCode()
           
 Object invoke(Object o, Object arg)
          Method used to set the property value of an object.
 boolean isAlive()
          Tell whether the executor is alive by looking at the value of the method.
 boolean isCacheable()
          Specifies if this executor is cacheable and able to be reused for this class of object it was returned for.
 boolean tryFailed(Object exec)
          Checks whether a tryExecute failed or not.
 Object tryInvoke(Object o, Object identifier, Object arg)
          Attempts to reuse this JexlPropertySet, checking that it is compatible with the actual set of arguments.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.commons.jexl3.introspection.JexlPropertySet
isCacheable, tryFailed
 

Field Detail

property

protected final String property
The property.


TRY_FAILED

public static final Object TRY_FAILED
A marker for invocation failures in tryInvoke.


objectClass

protected final Class<?> objectClass
The class this executor applies to.


method

protected final Method method
Method to be executed.

Constructor Detail

PropertySetExecutor

protected PropertySetExecutor(Class<?> clazz,
                              Method method,
                              String key)
Creates an instance.

Parameters:
clazz - the class the set method applies to
method - the method called through this executor
key - the key to use as 1st argument to the set method
Method Detail

discover

public static PropertySetExecutor discover(Introspector is,
                                           Class<?> clazz,
                                           String property,
                                           Object arg)
Discovers a PropertySetExecutor.

The method to be found should be named "set{P,p}property.

Parameters:
is - the introspector
clazz - the class to find the get method from
property - the property name to find
arg - the value to assign to the property
Returns:
the executor if found, null otherwise

getTargetProperty

public Object getTargetProperty()
Gets the property targeted by this executor.

Returns:
the target property

invoke

public Object invoke(Object o,
                     Object arg)
              throws IllegalAccessException,
                     InvocationTargetException
Description copied from interface: JexlPropertySet
Method used to set the property value of an object.

Parameters:
o - Object on which the property setter will be called with the value
arg - value to be set
Returns:
the value returned from the set operation (impl specific)
Throws:
IllegalAccessException
InvocationTargetException

tryInvoke

public Object tryInvoke(Object o,
                        Object identifier,
                        Object arg)
Description copied from interface: JexlPropertySet
Attempts to reuse this JexlPropertySet, checking that it is compatible with the actual set of arguments.

Parameters:
o - the object to invoke the the get upon
identifier - the property key to get
arg - the property value to set
Returns:
the result of the method invocation that should be checked by tryFailed to determine if it succeeded or failed.

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(org.apache.commons.jexl3.internal.introspection.AbstractExecutor arg)
Indicates whether some other executor is equivalent to this one.

Parameters:
arg - the other executor to check
Returns:
true if both executors are equivalent, false otherwise

isAlive

public final boolean isAlive()
Tell whether the executor is alive by looking at the value of the method.

Returns:
boolean Whether the executor is alive.

isCacheable

public boolean isCacheable()
Specifies if this executor is cacheable and able to be reused for this class of object it was returned for.

Returns:
true if can be reused for this class, false if not

getMethod

public final Method getMethod()
Gets the method to be executed or used as a marker.

Returns:
Method The method used by execute in derived classes.

getTargetClass

public final Class<?> getTargetClass()
Gets the object class targeted by this executor.

Returns:
the target object class

getMethodName

public final String getMethodName()
Gets the method name used.

Returns:
method name

tryFailed

public final boolean tryFailed(Object exec)
Checks whether a tryExecute failed or not.

Parameters:
exec - the value returned by tryExecute
Returns:
true if tryExecute failed, false otherwise


Copyright © 2001–2017 The Apache Software Foundation. All rights reserved.