org.apache.velocity.util.introspection
Class VelArrayMethod

java.lang.Object
  extended by org.apache.velocity.util.introspection.VelArrayMethod
All Implemented Interfaces:
VelMethod

public class VelArrayMethod
extends Object
implements VelMethod

Implementation of VelMethod to provide introspective "methods" for arrays that match those that would work on a fixed-size List. Currently only size(), isEmpty(), get(int), and set(int,Object) are supported. Later, support may be added for other read-only methods such as contains(Object) or subList(int,int). Patches are welcome! :)

Version:
$Id: VelArrayMethod.java 440740 2006-09-06 15:37:44Z nbubna $
Author:
Nathan Bubna

Field Summary
static String GET
           
static String IS_EMPTY
           
static String SET
           
static String SIZE
           
 
Constructor Summary
VelArrayMethod(Class arrayClass, String methodName, Object[] params)
           
 
Method Summary
 String getMethodName()
          returns the method name used
 Class getReturnType()
          returns the return type of the method invoked
 Object invoke(Object array, Object[] params)
          invocation method - called when the method invocation should be performed and a value returned
 boolean isCacheable()
          specifies if this VelMethod is cacheable and able to be reused for this class of object it was returned for
protected static boolean isNumeric(Object param)
           
static boolean supports(String methodName, Object[] params)
           
protected  int toInt(Object param)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SIZE

public static String SIZE

IS_EMPTY

public static String IS_EMPTY

GET

public static String GET

SET

public static String SET
Constructor Detail

VelArrayMethod

public VelArrayMethod(Class arrayClass,
                      String methodName,
                      Object[] params)
Method Detail

supports

public static boolean supports(String methodName,
                               Object[] params)

isNumeric

protected static boolean isNumeric(Object param)

toInt

protected int toInt(Object param)

invoke

public Object invoke(Object array,
                     Object[] params)
              throws Exception
Description copied from interface: VelMethod
invocation method - called when the method invocation should be performed and a value returned

Specified by:
invoke in interface VelMethod
Returns:
The resulting object.
Throws:
Exception

isCacheable

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

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

getMethodName

public String getMethodName()
Description copied from interface: VelMethod
returns the method name used

Specified by:
getMethodName in interface VelMethod
Returns:
The method name used

getReturnType

public Class getReturnType()
Description copied from interface: VelMethod
returns the return type of the method invoked

Specified by:
getReturnType in interface VelMethod
Returns:
The return type of the method invoked


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