|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectfreemarker.template.TemplateEventAdapter
public class TemplateEventAdapter
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.
Usage example:
// Configure Log4j ... // Set up the template Template template = new Template(filename); // Set up the model TemplateModelRoot modelRoot = (...) // Set up the listener TemplateEventAdapter adapter = new TemplateEventAdapter(); adapter.addTemplateExceptionListener( new Log4jExceptionListener() ); // Add more listeners as required adapter.addTemplateExceptionListener( ... ); // Call the template template.process( modelRoot, writer, adapter );
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 |
|---|
public static final int SEVERITY_ERROR
TemplateRuntimeHandler interface
public static final int SEVERITY_WARNING
TemplateRuntimeHandler interface
public static final int SEVERITY_DEPRECATION
TemplateRuntimeHandler interface
public static final TemplateRuntimeHandler DefaultEventAdapter
TemplateRuntimeHandler instance when no other
one is specified.
public static final TemplateRuntimeHandler NullEventAdapter
TemplateRuntimeHandler instance where no events
are fired.
protected GenericEventMulticaster templateExceptionListeners
protected ListenerAdapter exceptionThrownAdapter
| Constructor Detail |
|---|
public TemplateEventAdapter()
| Method Detail |
|---|
public void fireExceptionThrown(java.lang.Object source,
java.lang.Exception exception,
java.io.Writer output,
java.lang.String sourceName,
int severity)
TemplateExceptionEvent to all the current listeners.
fireExceptionThrown in interface TemplateRuntimeHandlersource - the source object of the eventexception - the exception that caused the event to be firedoutput - the current Template output streamsourceName - the name of the source class and method that fired the eventseverity - the severity of the exceptionpublic void addTemplateExceptionListener(TemplateExceptionListener el)
TemplateExceptionEvent events.
el - the event listener to be addedpublic void removeTemplateExceptionListener(TemplateExceptionListener el)
el - the event listener to be removedpublic TemplateExceptionListener[] getTemplateExceptionListeners()
TemplateExceptionListeners that
are listening for events.
TemplateExceptionListenerspublic java.lang.String toString()
toString in class java.lang.ObjectString representation of the object
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||