Package org.apache.velocity.app.event
Interface InvalidReferenceEventHandler
-
- All Superinterfaces:
EventHandler
- All Known Implementing Classes:
EventExample
,ReportInvalidReferences
public interface InvalidReferenceEventHandler extends EventHandler
Event handler called when an invalid reference is encountered. Allows the application to report errors or substitute return values. May be chained in sequence; the behavior will differ per method.This feature should be regarded as experimental.
- Since:
- 1.5
- Version:
- $Id$
- Author:
- Will Glass-Husain
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Object
invalidGetMethod(Context context, String reference, Object object, String property, Info info)
Called when object is null or there is no getter for the given property.Object
invalidMethod(Context context, String reference, Object object, String method, Info info)
Called when object is null or the given method does not exist.boolean
invalidSetMethod(Context context, String leftreference, String rightreference, Info info)
Called when object is null or there is no setter for the given property.
-
-
-
Method Detail
-
invalidGetMethod
Object invalidGetMethod(Context context, String reference, Object object, String property, Info info)
Called when object is null or there is no getter for the given property. Also called for invalid references without properties. invalidGetMethod() will be called in sequence for each link in the chain until the first non-null value is returned.- Parameters:
context
- the context when the reference was found invalidreference
- string with complete invalid referenceobject
- the object referred to, or null if not foundproperty
- the property name from the referenceinfo
- contains template, line, column details- Returns:
- substitute return value for missing reference, or null if no substitute
-
invalidSetMethod
boolean invalidSetMethod(Context context, String leftreference, String rightreference, Info info)
Called when object is null or there is no setter for the given property. invalidSetMethod() will be called in sequence for each link in the chain until a true value is returned. It's recommended that false be returned as a default to allow for easy chaining.- Parameters:
context
- the context when the reference was found invalidleftreference
- left reference being assigned torightreference
- invalid reference on the rightinfo
- contains info on template, line, col- Returns:
- if true then stop calling invalidSetMethod along the chain.
-
invalidMethod
Object invalidMethod(Context context, String reference, Object object, String method, Info info)
Called when object is null or the given method does not exist. invalidMethod() will be called in sequence for each link in the chain until the first non-null value is returned.- Parameters:
context
- the context when the reference was found invalidreference
- string with complete invalid referenceobject
- the object referred to, or null if not foundmethod
- the name of the (non-existent) methodinfo
- contains template, line, column details- Returns:
- substitute return value for missing reference, or null if no substitute
-
-