org.apache.velocity.app.event
Interface InvalidReferenceEventHandler

All Superinterfaces:
EventHandler
All Known Implementing Classes:
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: InvalidReferenceEventHandler.java 685685 2008-08-13 21:43:27Z nbubna $
Author:
Will Glass-Husain

Nested Class Summary
static class InvalidReferenceEventHandler.InvalidGetMethodExecutor
          Defines the execution strategy for invalidGetMethod
static class InvalidReferenceEventHandler.InvalidMethodExecutor
          Defines the execution strategy for invalidGetMethod
static class InvalidReferenceEventHandler.InvalidSetMethodExecutor
          Defines the execution strategy for invalidGetMethod
 
Method Summary
 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 invalid
reference - string with complete invalid reference
object - the object referred to, or null if not found
property - the property name from the reference
info - 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 invalid
leftreference - left reference being assigned to
rightreference - invalid reference on the right
info - 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 invalid
reference - string with complete invalid reference
object - the object referred to, or null if not found
method - the name of the (non-existent) method
info - contains template, line, column details
Returns:
substitute return value for missing reference, or null if no substitute


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