freemarker.template
Class TemplateEventAdapter

java.lang.Object
  |
  +--freemarker.template.TemplateEventAdapter
All Implemented Interfaces:
TemplateRuntimeHandler

public class TemplateEventAdapter
extends java.lang.Object
implements TemplateRuntimeHandler

Adapter class for firing events that could happen at Template runtime. Different listeners can be registered for different events that can occur. So far only one listener class is defined: TemplateExceptionEvent.

Version:
$Id$
See Also:
SimpleEventAdapter

Field Summary
static TemplateRuntimeHandler DefaultEventAdapter
          The default TemplateRuntimeHandler instance when no other one is specified.
protected  ListenerAdapter exceptionThrownAdapter
          A ListenerAdapter for exceptionThrown events.
static TemplateRuntimeHandler NullEventAdapter
          The trivial TemplateRuntimeHandler instance where no events are fired.
static int SEVERITY_DEPRECATION
          Deprecated. this constant has moved to the TemplateRuntimeHandler interface
static int SEVERITY_ERROR
          Deprecated. this constant has moved to the TemplateRuntimeHandler interface
static int SEVERITY_WARNING
          Deprecated. this constant has moved to the TemplateRuntimeHandler interface
protected  GenericEventMulticaster templateExceptionListeners
          The multicaster that notifies all event listeners when an exception occurs.
 
Constructor Summary
TemplateEventAdapter()
          Creates new TemplateEventAdapter.
 
Method Summary
 void addTemplateExceptionListener(TemplateExceptionListener el)
          Adds a listener for TemplateExceptionEvent events.
 void fireExceptionThrown(java.lang.Object source, java.lang.Exception exception, java.io.Writer output, java.lang.String sourceName, int severity)
          Fires a TemplateExceptionEvent to all the current listeners.
 TemplateExceptionListener[] getTemplateExceptionListeners()
          Retrieves all the current TemplateExceptionListeners that are listening for events.
 void removeTemplateExceptionListener(TemplateExceptionListener el)
          Removes the specified listener.
 java.lang.String toString()
          Returns a string representation of the object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SEVERITY_ERROR

public static final int SEVERITY_ERROR
Deprecated. this constant has moved to the TemplateRuntimeHandler interface

A severe error has occurred, that may prevent FM-Classic from processing the template.

SEVERITY_WARNING

public static final int SEVERITY_WARNING
Deprecated. this constant has moved to the TemplateRuntimeHandler interface

An error that is non-critical to the continuation of processing.

SEVERITY_DEPRECATION

public static final int SEVERITY_DEPRECATION
Deprecated. this constant has moved to the TemplateRuntimeHandler interface

Used whenever a deprecated construct is encountered.

DefaultEventAdapter

public static final TemplateRuntimeHandler DefaultEventAdapter
The default TemplateRuntimeHandler instance when no other one is specified.

NullEventAdapter

public static final TemplateRuntimeHandler NullEventAdapter
The trivial TemplateRuntimeHandler instance where no events are fired.

templateExceptionListeners

protected GenericEventMulticaster templateExceptionListeners
The multicaster that notifies all event listeners when an exception occurs.

exceptionThrownAdapter

protected ListenerAdapter exceptionThrownAdapter
A ListenerAdapter for exceptionThrown events.
Constructor Detail

TemplateEventAdapter

public TemplateEventAdapter()
Creates new TemplateEventAdapter.
Method Detail

fireExceptionThrown

public void fireExceptionThrown(java.lang.Object source,
                                java.lang.Exception exception,
                                java.io.Writer output,
                                java.lang.String sourceName,
                                int severity)
Fires a TemplateExceptionEvent to all the current listeners.
Specified by:
fireExceptionThrown in interface TemplateRuntimeHandler
Parameters:
source - the source object of the event
exception - the exception that caused the event to be fired
output - the current Template output stream
sourceName - the name of the source class and method that fired the event
severity - the severity of the exception

addTemplateExceptionListener

public void addTemplateExceptionListener(TemplateExceptionListener el)
Adds a listener for TemplateExceptionEvent events.
Parameters:
el - the event listener to be added

removeTemplateExceptionListener

public void removeTemplateExceptionListener(TemplateExceptionListener el)
Removes the specified listener.
Parameters:
el - the event listener to be removed

getTemplateExceptionListeners

public TemplateExceptionListener[] getTemplateExceptionListeners()
Retrieves all the current TemplateExceptionListeners that are listening for events.
Returns:
an array of TemplateExceptionListeners

toString

public java.lang.String toString()
Returns a string representation of the object.
Overrides:
toString in class java.lang.Object
Returns:
a String representation of the object