InvalidReferenceEventHandler (Velocity 1.7 API)
Keywords: org.apache.velocity.app.event.InvalidReferenceEventHandler interface

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## 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 832324 2009-11-03 07:33:03Z wglass $
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

    public 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. If silent reference, will start with $!
    `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

    public 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

    public 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. If silent reference, will start with $!
    `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

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2000-2010 Apache Software Foundation. All Rights Reserved.