Class ReportInvalidReferences
java.lang.Object
org.apache.velocity.app.event.implement.ReportInvalidReferences
- All Implemented Interfaces:
EventHandler
,InvalidReferenceEventHandler
,RuntimeServicesAware
public class ReportInvalidReferences
extends Object
implements InvalidReferenceEventHandler, RuntimeServicesAware
Use this event handler to flag invalid references. Since this
is intended to be used for a specific request, this should be
used as a local event handler attached to a specific context
instead of being globally defined in the Velocity properties file.
Note that InvalidReferenceHandler can be used in two modes. If the Velocity properties file contains the following:
event_handler.invalid_references.exception = truethen the event handler will throw a ParseErrorRuntimeException upon hitting the first invalid reference. This stops processing and is passed through to the application code. The ParseErrorRuntimeException contain information about the template name, line number, column number, and invalid reference.
If this configuration setting is false or omitted then the page will be processed as normal, but all invalid references will be collected in a List of InvalidReferenceInfo objects.
This feature should be regarded as experimental.
- Since:
- 1.5
- Version:
- $Id$
- Author:
- Will Glass-Husain
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionAll invalid references during the processing of this page.Collect the error and/or throw an exception, depending on configuration.Collect the error and/or throw an exception, depending on configuration.boolean
invalidSetMethod
(Context context, String leftreference, String rightreference, Info info) Collect the error and/or throw an exception, depending on configuration.void
Called automatically when event cartridge is initialized.
-
Field Details
-
EVENTHANDLER_INVALIDREFERENCE_EXCEPTION
- See Also:
-
OLD_EVENTHANDLER_INVALIDREFERENCE_EXCEPTION
Deprecated.- See Also:
-
-
Constructor Details
-
ReportInvalidReferences
public ReportInvalidReferences()
-
-
Method Details
-
invalidGetMethod
public Object invalidGetMethod(Context context, String reference, Object object, String property, Info info) Collect the error and/or throw an exception, depending on configuration.- Specified by:
invalidGetMethod
in interfaceInvalidReferenceEventHandler
- 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:
- always returns null
- Throws:
ParseErrorException
-
invalidMethod
public Object invalidMethod(Context context, String reference, Object object, String method, Info info) Collect the error and/or throw an exception, depending on configuration.- Specified by:
invalidMethod
in interfaceInvalidReferenceEventHandler
- Parameters:
context
- the context when the reference was found invalidreference
- complete invalid referenceobject
- the object referred to, or null if not foundmethod
- the property name from the referenceinfo
- contains template, line, column details- Returns:
- always returns null
- Throws:
ParseErrorException
-
invalidSetMethod
public boolean invalidSetMethod(Context context, String leftreference, String rightreference, Info info) Collect the error and/or throw an exception, depending on configuration.- Specified by:
invalidSetMethod
in interfaceInvalidReferenceEventHandler
- 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:
- loop to end -- always returns false
-
getInvalidReferences
All invalid references during the processing of this page.- Returns:
- a List of InvalidReferenceInfo objects
-
setRuntimeServices
Called automatically when event cartridge is initialized.- Specified by:
setRuntimeServices
in interfaceRuntimeServicesAware
- Parameters:
rs
- RuntimeServices object assigned during initialization
-