org.apache.velocity.app.event
Class EventCartridge

java.lang.Object
  extended by org.apache.velocity.app.event.EventCartridge
All Implemented Interfaces:
EventHandler, MethodExceptionEventHandler, NullSetEventHandler, ReferenceInsertionEventHandler

public class EventCartridge
extends Object
implements ReferenceInsertionEventHandler, NullSetEventHandler, MethodExceptionEventHandler

'Package' of event handlers...

Version:
$Id: EventCartridge.java 191743 2005-06-21 23:22:20Z dlr $
Author:
Geir Magnusson Jr., Jose Alberto Fernandez

Constructor Summary
EventCartridge()
           
 
Method Summary
 boolean addEventHandler(EventHandler ev)
          Adds an event handler(s) to the Cartridge.
 boolean attachToContext(Context context)
          Attached the EventCartridge to the context Final because not something one should mess with lightly :)
 Object methodException(Class claz, String method, Exception e)
          Implementation of MethodExceptionEventHandler method methodException().
 Object referenceInsert(String reference, Object value)
          Implementation of ReferenceInsertionEventHandler method referenceInsert().
 boolean removeEventHandler(EventHandler ev)
          Removes an event handler(s) from the Cartridge.
 boolean shouldLogOnNullSet(String lhs, String rhs)
          Implementation of NullSetEventHandler method shouldLogOnNullSet().
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EventCartridge

public EventCartridge()
Method Detail

addEventHandler

public boolean addEventHandler(EventHandler ev)
Adds an event handler(s) to the Cartridge. This method will find all possible event handler interfaces supported by the passed in object.

Parameters:
ev - object impementing a valid EventHandler-derived interface
Returns:
true if a supported interface, false otherwise or if null

removeEventHandler

public boolean removeEventHandler(EventHandler ev)
Removes an event handler(s) from the Cartridge. This method will find all possible event handler interfaces supported by the passed in object and remove them.

Parameters:
ev - object impementing a valid EventHandler-derived interface
Returns:
true if a supported interface, false otherwise or if null

referenceInsert

public Object referenceInsert(String reference,
                              Object value)
Implementation of ReferenceInsertionEventHandler method referenceInsert(). Called during Velocity merge before a reference value will be inserted into the output stream.

Specified by:
referenceInsert in interface ReferenceInsertionEventHandler
Parameters:
reference - reference from template about to be inserted
value - value about to be inserted (after toString() )
Returns:
Object on which toString() should be called for output.

shouldLogOnNullSet

public boolean shouldLogOnNullSet(String lhs,
                                  String rhs)
Implementation of NullSetEventHandler method shouldLogOnNullSet(). Called during Velocity merge to determine if when a #set() results in a null assignment, a warning is logged.

Specified by:
shouldLogOnNullSet in interface NullSetEventHandler
Parameters:
lhs -
rhs -
Returns:
true if to be logged, false otherwise

methodException

public Object methodException(Class claz,
                              String method,
                              Exception e)
                       throws Exception
Implementation of MethodExceptionEventHandler method methodException(). Called during Velocity merge if a reference is null

Specified by:
methodException in interface MethodExceptionEventHandler
Parameters:
claz - Class that is causing the exception
method - method called that causes the exception
e - Exception thrown by the method
Returns:
Object to return as method result
Throws:
exception - to be wrapped and propogated to app
Exception

attachToContext

public final boolean attachToContext(Context context)
Attached the EventCartridge to the context Final because not something one should mess with lightly :)

Parameters:
context - context to attach to
Returns:
true if successful, false otherwise


Copyright © 2002 Apache Software Foundation. All Rights Reserved.