下面列出了怎么用org.apache.velocity.util.introspection.VelMethod的API类实例代码及写法,或者点击链接到github查看源代码。
public VelMethod getMethod(Object obj, String methodName, Object[] args, Info i) throws Exception
{
if (obj == null)
{
if (beKindToNulls)
{
return null;
}
else
{
throw new VelocityParsingError("tried " + getMethodText("null", methodName, args), i);
}
}
Method m = introspector.getMethod(obj.getClass(), methodName, args);
if (m == null)
{
throw new VelocityParsingError(
"Method " + getMethodText(obj.getClass().getName(), methodName, args) + " does not exist.", i);
}
return new VelMethodImpl(m);
}
@Override
public VelMethod getMethod(Object obj, String methodName, Object[] args, Info info) throws Exception {
if( isRuntimeCheckEnabled()) {
checkRestrictedPackage( obj);
if( this.packageChecker.includePackage( obj.getClass().getPackage())) {
checkMethodAccess( obj, methodName, args, info);
}
}
return super.getMethod(obj, methodName, args, info);
}
public VelMethod getMethod(Object obj, String methodName, Object[] args, Info i)
{
VelMethod method = super.getMethod(obj, methodName, args, i);
if (method == null)
{
if (obj == null)
throw new UberspectTestException("Can't call method '" + methodName + "' on null object",i);
else
throw new UberspectTestException("Did not find method "+ obj.getClass().getName()+"."+methodName, i);
}
return method;
}
@Override
public VelMethod getMethod(Object obj, String method, Object[] args, Info info) throws Exception {
return uberspector.getMethod( obj, method, args, info);
}
public VelSetterImpl(VelMethod velmethod)
{
this.vm = velmethod;
}
public VelSetterImpl(VelMethod velmethod, String key)
{
this.vm = velmethod;
putKey = key;
}