com.intersys.objects.reflect
Interface CacheMethod


public interface CacheMethod

A CacheMethod provides information about, and access to, a single method on a Cache class. The reflected method may be a class method or an instance method


Method Summary
 Iterator getArgumentIterator()
          Returns iterator over method argument types.
 CacheArgument[] getArgumentTypes()
          Returns an array containing method argument types.
 CacheClass getDeclaringClass()
          Returns the class in which method is declared.
 Class getJavaReturnType()
          Returns the return type of the method when it is run from Java client.
 String getJavaReturnTypeName()
          Returns the Java name of the return type of the method when it is run from Java client.
 int getModifiers()
          Returns Cache modifiers for the CacheMethod.
 String getName()
          Returns the name of the method.
 CacheClass getReturnType()
          Returns the return type of the method when it is run in Cache.
 String getSignature()
          Returns signature of the method as it appears in CacheObject Script.
 Object invoke(int oref, Object[] args)
          Runs the method in Cache.
 Object invoke(RegisteredObject obj, Object[] args)
          Runs the method in Cache.
 

Method Detail

getName

public String getName()
Returns the name of the method.

Returns:
the name of the method represented by this CacheMethod object, as a String

getReturnType

public CacheClass getReturnType()
                         throws CacheException
Returns the return type of the method when it is run in Cache.

Returns:
CacheClass object that represents the formal return type of the method represented by this CacheMethod object.
Throws:
CacheException

getJavaReturnType

public Class getJavaReturnType()
                        throws CacheException
Returns the return type of the method when it is run from Java client.

Returns:
java.lang.Class object that represents the formal return type of the method represented by this CacheMethod object.
Throws:
CacheException

getJavaReturnTypeName

public String getJavaReturnTypeName()
                             throws CacheException
Returns the Java name of the return type of the method when it is run from Java client. Does not attempt to load corresponding Java class, so this method can be called even if there is no such class in the classpath.

Returns:
java.lang.Class object that represents the formal return type of the method represented by this CacheMethod object.
Throws:
CacheException

getArgumentTypes

public CacheArgument[] getArgumentTypes()
                                 throws CacheException
Returns an array containing method argument types.

Returns:
an array of CacheArgument objects that represent the formal argument types, in declaration order, of the method represented by this CacheMethod object. Returns an array of length 0 if the underlying method takes no arguments. Method getType of CacheArgument class can be used to obtain argument types as CacheClass.
Throws:
CacheException
See Also:
CacheDescription.getType()

getDeclaringClass

public CacheClass getDeclaringClass()
                             throws CacheException
Returns the class in which method is declared.

Returns:
the CacheClass object representing the class that declares the method represented by this CacheMethod object.
Throws:
CacheException

getArgumentIterator

public Iterator getArgumentIterator()
                             throws CacheException
Returns iterator over method argument types.

Returns:
Iterator of CacheArgument elements
Throws:
CacheException

getModifiers

public int getModifiers()
Returns Cache modifiers for the CacheMethod.

Possible modifiers: CacheModifier.STATIC, CacheModifier.RETURNS_VALUE, CacheModifier.LITERAL

Returns:
modifiers for the CacheMethod represented as an int. The CacheModifier class should be used to decode the modifiers.
See Also:
CacheModifier

getSignature

public String getSignature()
                    throws CacheException
Returns signature of the method as it appears in CacheObject Script. This signature can be used by CacheClass.getMethod(String signature) method.

Returns:
Signature of the method represented as a String.
Throws:
CacheException
See Also:
CacheClass.getMethod(java.lang.String)

invoke

public Object invoke(RegisteredObject obj,
                     Object[] args)
              throws CacheException,
                     IllegalArgumentException
Runs the method in Cache.

Parameters:
obj - Instance for which the method will be run. If the underlying method is static, then the specified obj argument is ignored. It may be null.
args - Array of parameters passed to the method. Parameters may be represented as natural Java objects. For instance, if parameter is of type %Library.Integer corresponding element in array may be java.lang.Integer.

If parameter is passed by reference, then it can also be of corresponding Holder class, e.g. com.intersys.objects.IntegerHolder. In any case the value returned by reference is placed in the corresponding element of the array after method is completed. If original parameter was java.lang.Integer then returned value would be java.lang.Integer as well. If it was com.intersys.objects.IntegerHolder then it will be the same com.intersys.objects.IntegerHolder instance with replaced value.

Returns:
Return value of method represented as appropriate Java object.
Throws:
CacheException
IllegalArgumentException

invoke

public Object invoke(int oref,
                     Object[] args)
              throws CacheException,
                     IllegalArgumentException
Runs the method in Cache.

Unless there is a specific reason to use this form using method it is reommended to use invoke(RegisteredObject obj, Object[] args).

Parameters:
oref - Integer value corresponding to object reference of the object, for which the method will be run. If the underlying method is static, then the specified oref argument is ignored.
args - Array of parameters passed to the method. Parameters may be represented as natural Java objects. For instance, if parameter is of type %Library.Integer corresponding element in array may be java.lang.Integer.

If parameter is passed by reference, then it can also be of corresponding Holder class, e.g. com.intersys.objects.IntegerHolder. In any case the value returned by reference is placed in the corresponding element of the array after method is completed. If original parameter was java.lang.Integer then returned value would be java.lang.Integer as well. If it was com.intersys.objects.IntegerHolder then it will be the same com.intersys.objects.IntegerHolder instance with replaced value.

Returns:
Return value of method represented as appropriate Java object.
Throws:
CacheException
IllegalArgumentException
See Also:
invoke(com.intersys.classes.RegisteredObject,Object[])