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

java.lang.Object
  extended by org.apache.commons.jexl3.internal.introspection.ConstructorMethod
All Implemented Interfaces:
JexlMethod

public final class ConstructorMethod
extends Object
implements JexlMethod

A JexlMethod that wraps a constructor.


Method Summary
static ConstructorMethod discover(Introspector is, Object ctorHandle, Object... args)
          Discovers a class constructor and wrap it as a JexlMethod.
 Class<?> getReturnType()
          returns the return type of the method invoked.
 Object invoke(Object obj, Object... params)
          Invocation method, called when the method invocation should be performed and a value returned.
 boolean isCacheable()
          Specifies if this JexlMethod is cacheable and able to be reused for this class of object it was returned for.
 boolean tryFailed(Object rval)
          Checks whether a tryInvoke return value indicates a failure or not.
 Object tryInvoke(String name, Object obj, Object... params)
          Attempts to reuse this JexlMethod, checking that it is compatible with the actual set of arguments.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

discover

public static ConstructorMethod discover(Introspector is,
                                         Object ctorHandle,
                                         Object... args)
Discovers a class constructor and wrap it as a JexlMethod.

Parameters:
is - the introspector
ctorHandle - a class or class name
args - constructor arguments
Returns:
a JexlMethod

invoke

public Object invoke(Object obj,
                     Object... params)
              throws Exception
Description copied from interface: JexlMethod
Invocation method, called when the method invocation should be performed and a value returned.

Specified by:
invoke in interface JexlMethod
Parameters:
obj - the object
params - method parameters.
Returns:
the result
Throws:
Exception - on any error.

tryInvoke

public Object tryInvoke(String name,
                        Object obj,
                        Object... params)
Description copied from interface: JexlMethod
Attempts to reuse this JexlMethod, checking that it is compatible with the actual set of arguments. Related to isCacheable since this method is often used with cached JexlMethod instances.

Specified by:
tryInvoke in interface JexlMethod
Parameters:
name - the method name
obj - the object to invoke the method upon
params - the method arguments
Returns:
the result of the method invocation that should be checked by tryFailed to determine if it succeeded or failed.

tryFailed

public boolean tryFailed(Object rval)
Description copied from interface: JexlMethod
Checks whether a tryInvoke return value indicates a failure or not.

Usage is : Object r = tryInvoke(...); if (tryFailed(r) {...} else {...}

Specified by:
tryFailed in interface JexlMethod
Parameters:
rval - the value returned by tryInvoke
Returns:
true if tryInvoke failed, false otherwise

isCacheable

public boolean isCacheable()
Description copied from interface: JexlMethod
Specifies if this JexlMethod is cacheable and able to be reused for this class of object it was returned for.

Specified by:
isCacheable in interface JexlMethod
Returns:
true if can be reused for this class, false if not

getReturnType

public Class<?> getReturnType()
Description copied from interface: JexlMethod
returns the return type of the method invoked.

Specified by:
getReturnType in interface JexlMethod
Returns:
return type


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