aboutsummaryrefslogtreecommitdiff
path: root/velocity-engine-core/src
diff options
context:
space:
mode:
authorClaude Brisson <cbrisson@apache.org>2016-12-11 10:21:28 +0000
committerClaude Brisson <cbrisson@apache.org>2016-12-11 10:21:28 +0000
commit77367bc84236c986af612d53f5b5e02afb847cbb (patch)
tree24d53349003c1656e6664ed2e313087be77e80cf /velocity-engine-core/src
parent5d70000132ba2eddf8f27f1ec38160ff3630a1dc (diff)
downloadapache-velocity-engine-77367bc84236c986af612d53f5b5e02afb847cbb.tar.gz
[engine] fix indentation
git-svn-id: https://svn.apache.org/repos/asf/velocity/engine/trunk@1773554 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'velocity-engine-core/src')
-rw-r--r--velocity-engine-core/src/main/java/org/apache/velocity/app/event/EventCartridge.java408
1 files changed, 204 insertions, 204 deletions
diff --git a/velocity-engine-core/src/main/java/org/apache/velocity/app/event/EventCartridge.java b/velocity-engine-core/src/main/java/org/apache/velocity/app/event/EventCartridge.java
index b3506fdb..0229a517 100644
--- a/velocity-engine-core/src/main/java/org/apache/velocity/app/event/EventCartridge.java
+++ b/velocity-engine-core/src/main/java/org/apache/velocity/app/event/EventCartridge.java
@@ -35,20 +35,18 @@ import java.util.List;
import java.util.Set;
/**
- * Stores the event handlers. Event handlers can be assigned on a per
+ * <p>Stores the event handlers. Event handlers can be assigned on a per
* VelocityEngine instance basis by specifying the class names in the
* velocity.properties file. Event handlers may also be assigned on a per-page
* basis by creating a new instance of EventCartridge, adding the event
* handlers, and then calling attachToContext. For clarity, it's recommended
* that one approach or the other be followed, as the second method is primarily
- * presented for backwards compatibility.
- *
- * <P>
- * Note that Event Handlers follow a filter pattern, with multiple event
+ * presented for backwards compatibility.</p>
+ * <p>Note that Event Handlers follow a filter pattern, with multiple event
* handlers allowed for each event. When the appropriate event occurs, all the
* appropriate event handlers are called in the sequence they were added to the
* Event Cartridge. See the javadocs of the specific event handler interfaces
- * for more details.
+ * for more details.</p>
*
* @author <a href="mailto:wglass@wglass@forio.com">Will Glass-Husain </a>
* @author <a href="mailto:geirm@optonline.net">Geir Magnusson Jr. </a>
@@ -56,7 +54,7 @@ import java.util.Set;
* @version $Id$
*/
public class EventCartridge
- {
+{
private List<ReferenceInsertionEventHandler> referenceHandlers = new ArrayList();
private MethodExceptionEventHandler methodExceptionHandler = null;
private List<IncludeEventHandler> includeHandlers = new ArrayList();
@@ -67,71 +65,72 @@ public class EventCartridge
*/
Set initializedHandlers = new HashSet();
- protected RuntimeServices rsvc = null;
-
- protected Logger getLog()
- {
- return rsvc == null ? LoggerFactory.getLogger(EventCartridge.class) : rsvc.getLog();
- }
-
- /**
- * runtime services setter, called during initialization
- * @param rs runtime services
- * @since 2.0
- */
- public synchronized void setRuntimeServices(RuntimeServices rs)
- {
- if (rsvc == null)
- {
- rsvc = rs;
+ protected RuntimeServices rsvc = null;
+
+ protected Logger getLog()
+ {
+ return rsvc == null ? LoggerFactory.getLogger(EventCartridge.class) : rsvc.getLog();
+ }
+
+ /**
+ * runtime services setter, called during initialization
+ *
+ * @param rs runtime services
+ * @since 2.0
+ */
+ public synchronized void setRuntimeServices(RuntimeServices rs)
+ {
+ if (rsvc == null)
+ {
+ rsvc = rs;
/* allow for this method to be called *after* adding event handlers */
- for (EventHandler handler : referenceHandlers)
- {
- if (handler instanceof RuntimeServicesAware && !initializedHandlers.contains(handler))
- {
- ((RuntimeServicesAware)handler).setRuntimeServices(rs);
- initializedHandlers.add(handler);
- }
- }
- if (methodExceptionHandler != null &&
- methodExceptionHandler instanceof RuntimeServicesAware &&
- !initializedHandlers.contains(methodExceptionHandler))
- {
- ((RuntimeServicesAware)methodExceptionHandler).setRuntimeServices(rs);
- initializedHandlers.add(methodExceptionHandler);
- }
- for (EventHandler handler : includeHandlers)
- {
- if (handler instanceof RuntimeServicesAware && !initializedHandlers.contains(handler))
- {
- ((RuntimeServicesAware)handler).setRuntimeServices(rs);
- initializedHandlers.add(handler);
- }
- }
- for (EventHandler handler : invalidReferenceHandlers)
- {
- if (handler instanceof RuntimeServicesAware && !initializedHandlers.contains(handler))
- {
- ((RuntimeServicesAware)handler).setRuntimeServices(rs);
- initializedHandlers.add(handler);
- }
- }
- }
- else if (rsvc != rs)
- {
- throw new VelocityException("an event cartridge cannot be used by several different runtime services instances");
- }
- }
+ for (EventHandler handler : referenceHandlers)
+ {
+ if (handler instanceof RuntimeServicesAware && !initializedHandlers.contains(handler))
+ {
+ ((RuntimeServicesAware) handler).setRuntimeServices(rs);
+ initializedHandlers.add(handler);
+ }
+ }
+ if (methodExceptionHandler != null &&
+ methodExceptionHandler instanceof RuntimeServicesAware &&
+ !initializedHandlers.contains(methodExceptionHandler))
+ {
+ ((RuntimeServicesAware) methodExceptionHandler).setRuntimeServices(rs);
+ initializedHandlers.add(methodExceptionHandler);
+ }
+ for (EventHandler handler : includeHandlers)
+ {
+ if (handler instanceof RuntimeServicesAware && !initializedHandlers.contains(handler))
+ {
+ ((RuntimeServicesAware) handler).setRuntimeServices(rs);
+ initializedHandlers.add(handler);
+ }
+ }
+ for (EventHandler handler : invalidReferenceHandlers)
+ {
+ if (handler instanceof RuntimeServicesAware && !initializedHandlers.contains(handler))
+ {
+ ((RuntimeServicesAware) handler).setRuntimeServices(rs);
+ initializedHandlers.add(handler);
+ }
+ }
+ }
+ else if (rsvc != rs)
+ {
+ throw new VelocityException("an event cartridge cannot be used by several different runtime services instances");
+ }
+ }
/**
- * Adds an event handler(s) to the Cartridge. This method
- * will find all possible event handler interfaces supported
- * by the passed in object.
+ * Adds an event handler(s) to the Cartridge. This method
+ * will find all possible event handler interfaces supported
+ * by the passed in object.
*
- * @param ev object implementing a valid EventHandler-derived interface
- * @return true if a supported interface, false otherwise or if null
+ * @param ev object implementing a valid EventHandler-derived interface
+ * @return true if a supported interface, false otherwise or if null
*/
- public boolean addEventHandler( EventHandler ev )
+ public boolean addEventHandler(EventHandler ev)
{
if (ev == null)
{
@@ -140,25 +139,25 @@ public class EventCartridge
boolean found = false;
- if ( ev instanceof ReferenceInsertionEventHandler)
+ if (ev instanceof ReferenceInsertionEventHandler)
{
- addReferenceInsertionEventHandler( (ReferenceInsertionEventHandler) ev );
+ addReferenceInsertionEventHandler((ReferenceInsertionEventHandler) ev);
found = true;
}
- if ( ev instanceof MethodExceptionEventHandler )
+ if (ev instanceof MethodExceptionEventHandler)
{
addMethodExceptionHandler((MethodExceptionEventHandler) ev);
found = true;
}
- if ( ev instanceof IncludeEventHandler )
+ if (ev instanceof IncludeEventHandler)
{
addIncludeEventHandler((IncludeEventHandler) ev);
found = true;
}
- if ( ev instanceof InvalidReferenceEventHandler )
+ if (ev instanceof InvalidReferenceEventHandler)
{
addInvalidReferenceEventHandler((InvalidReferenceEventHandler) ev);
found = true;
@@ -166,7 +165,7 @@ public class EventCartridge
if (found && rsvc != null && ev instanceof RuntimeServicesAware && !initializedHandlers.contains(ev))
{
- ((RuntimeServicesAware)ev).setRuntimeServices(rsvc);
+ ((RuntimeServicesAware) ev).setRuntimeServices(rsvc);
initializedHandlers.add(ev);
}
@@ -174,23 +173,23 @@ public class EventCartridge
}
/**
- * Add a reference insertion event handler to the Cartridge.
- *
- * @param ev ReferenceInsertionEventHandler
+ * Add a reference insertion event handler to the Cartridge.
+ *
+ * @param ev ReferenceInsertionEventHandler
* @since 1.5
*/
- public void addReferenceInsertionEventHandler( ReferenceInsertionEventHandler ev )
- {
- referenceHandlers.add( ev );
- }
+ public void addReferenceInsertionEventHandler(ReferenceInsertionEventHandler ev)
+ {
+ referenceHandlers.add(ev);
+ }
/**
- * Add a method exception event handler to the Cartridge.
+ * Add a method exception event handler to the Cartridge.
*
- * @param ev MethodExceptionEventHandler
- * @since 1.5
+ * @param ev MethodExceptionEventHandler
+ * @since 1.5
*/
- public void addMethodExceptionHandler( MethodExceptionEventHandler ev )
+ public void addMethodExceptionHandler(MethodExceptionEventHandler ev)
{
if (methodExceptionHandler == null)
{
@@ -203,25 +202,25 @@ public class EventCartridge
}
/**
- * Add an include event handler to the Cartridge.
+ * Add an include event handler to the Cartridge.
*
- * @param ev IncludeEventHandler
- * @since 1.5
+ * @param ev IncludeEventHandler
+ * @since 1.5
*/
- public void addIncludeEventHandler( IncludeEventHandler ev )
+ public void addIncludeEventHandler(IncludeEventHandler ev)
{
- includeHandlers.add( ev );
+ includeHandlers.add(ev);
}
/**
- * Add an invalid reference event handler to the Cartridge.
+ * Add an invalid reference event handler to the Cartridge.
*
- * @param ev InvalidReferenceEventHandler
- * @since 1.5
+ * @param ev InvalidReferenceEventHandler
+ * @since 1.5
*/
- public void addInvalidReferenceEventHandler( InvalidReferenceEventHandler ev )
+ public void addInvalidReferenceEventHandler(InvalidReferenceEventHandler ev)
{
- invalidReferenceHandlers.add( ev );
+ invalidReferenceHandlers.add(ev);
}
@@ -230,23 +229,23 @@ public class EventCartridge
* possible event handler interfaces supported by the passed in object and
* remove them.
*
- * @param ev object impementing a valid EventHandler-derived interface
+ * @param ev object impementing a valid EventHandler-derived interface
* @return true if event handler was previously registered, false if not
- * found
+ * found
*/
- public boolean removeEventHandler( EventHandler ev )
+ public boolean removeEventHandler(EventHandler ev)
{
- if ( ev == null )
+ if (ev == null)
{
return false;
}
- if ( ev instanceof ReferenceInsertionEventHandler )
+ if (ev instanceof ReferenceInsertionEventHandler)
{
return referenceHandlers.remove(ev);
}
- if ( ev instanceof MethodExceptionEventHandler )
+ if (ev instanceof MethodExceptionEventHandler)
{
if (ev == methodExceptionHandler)
{
@@ -255,12 +254,12 @@ public class EventCartridge
}
}
- if ( ev instanceof IncludeEventHandler )
+ if (ev instanceof IncludeEventHandler)
{
return includeHandlers.remove(ev);
}
- if ( ev instanceof InvalidReferenceEventHandler )
+ if (ev instanceof InvalidReferenceEventHandler)
{
return invalidReferenceHandlers.remove(ev);
}
@@ -270,7 +269,7 @@ public class EventCartridge
/**
* Call reference insertion handlers
- *
+ *
* @return value returned by handlers
* @since 2.0
*/
@@ -283,23 +282,24 @@ public class EventCartridge
return value;
}
- /**
- * Check whether this event cartridge has a method exception event handler
- * @return true if a method exception event handler has been registered
- * @since 2.0
- */
- boolean hasMethodExceptionEventHandler()
- {
- return methodExceptionHandler != null;
- }
+ /**
+ * Check whether this event cartridge has a method exception event handler
+ *
+ * @return true if a method exception event handler has been registered
+ * @since 2.0
+ */
+ boolean hasMethodExceptionEventHandler()
+ {
+ return methodExceptionHandler != null;
+ }
/**
* Call method exception event handler
- *
+ *
* @return value returned by handler
* @since 2.0
*/
- public Object methodException(Context context, Class claz, String method, Exception e, Info info )
+ public Object methodException(Context context, Class claz, String method, Exception e, Info info)
{
if (methodExceptionHandler != null)
{
@@ -310,7 +310,7 @@ public class EventCartridge
/**
* Call include event handlers
- *
+ *
* @return include path
* @since 2.0
*/
@@ -328,94 +328,94 @@ public class EventCartridge
return includeResourcePath;
}
- /**
- * Call invalid reference handlers for an invalid getter
- *
- * @return value returned by handlers
- * @since 2.0
- */
- public Object invalidGetMethod(Context context, String reference, Object object, String property, Info info)
- {
- Object result = null;
- for (InvalidReferenceEventHandler handler : invalidReferenceHandlers)
- {
- result = handler.invalidGetMethod(context, reference, object, property, info);
+ /**
+ * Call invalid reference handlers for an invalid getter
+ *
+ * @return value returned by handlers
+ * @since 2.0
+ */
+ public Object invalidGetMethod(Context context, String reference, Object object, String property, Info info)
+ {
+ Object result = null;
+ for (InvalidReferenceEventHandler handler : invalidReferenceHandlers)
+ {
+ result = handler.invalidGetMethod(context, reference, object, property, info);
/* reflect 1.x behavior: exit after at least one execution whenever a non-null value has been found */
- if (result != null)
- {
- break;
- }
- }
- return result;
- }
-
- /**
- * Call invalid reference handlers for an invalid setter
- *
- * @return whether to stop further chaining in the next cartridge
- * @since 2.0
- */
- public boolean invalidSetMethod(Context context, String leftreference, String rightreference, Info info)
- {
- for (InvalidReferenceEventHandler handler : invalidReferenceHandlers)
- {
- if (handler.invalidSetMethod(context, leftreference, rightreference, info))
- {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Call invalid reference handlers for an invalid method call
- *
- * @return value returned by handlers
- * @since 2.0
- */
- public Object invalidMethod(Context context, String reference, Object object, String method, Info info)
- {
- Object result = null;
- for (InvalidReferenceEventHandler handler : invalidReferenceHandlers)
- {
- result = handler.invalidMethod(context, reference, object, method, info);
+ if (result != null)
+ {
+ break;
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Call invalid reference handlers for an invalid setter
+ *
+ * @return whether to stop further chaining in the next cartridge
+ * @since 2.0
+ */
+ public boolean invalidSetMethod(Context context, String leftreference, String rightreference, Info info)
+ {
+ for (InvalidReferenceEventHandler handler : invalidReferenceHandlers)
+ {
+ if (handler.invalidSetMethod(context, leftreference, rightreference, info))
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Call invalid reference handlers for an invalid method call
+ *
+ * @return value returned by handlers
+ * @since 2.0
+ */
+ public Object invalidMethod(Context context, String reference, Object object, String method, Info info)
+ {
+ Object result = null;
+ for (InvalidReferenceEventHandler handler : invalidReferenceHandlers)
+ {
+ result = handler.invalidMethod(context, reference, object, method, info);
/* reflect 1.x behavior: exit after at least one execution whenever a non-null value has been found */
- if (result != null)
- {
- break;
- }
- }
- return result;
- }
-
- /**
- * Attached the EventCartridge to the context
- *
- * Final because not something one should mess with lightly :)
- *
- * @param context context to attach to
- * @return true if successful, false otherwise
- */
- public final boolean attachToContext( Context context )
- {
- if ( context instanceof InternalEventContext )
- {
- InternalEventContext iec = (InternalEventContext) context;
-
- iec.attachEventCartridge( this );
-
- /**
- * while it's tempting to call setContext on each handler from here,
- * this needs to be done before each method call. This is
- * because the specific context will change as inner contexts
- * are linked in through macros, foreach, or directly by the user.
- */
-
- return true;
- }
- else
- {
- return false;
- }
- }
- }
+ if (result != null)
+ {
+ break;
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Attached the EventCartridge to the context
+ *
+ * Final because not something one should mess with lightly :)
+ *
+ * @param context context to attach to
+ * @return true if successful, false otherwise
+ */
+ public final boolean attachToContext(Context context)
+ {
+ if (context instanceof InternalEventContext)
+ {
+ InternalEventContext iec = (InternalEventContext) context;
+
+ iec.attachEventCartridge(this);
+
+ /**
+ * while it's tempting to call setContext on each handler from here,
+ * this needs to be done before each method call. This is
+ * because the specific context will change as inner contexts
+ * are linked in through macros, foreach, or directly by the user.
+ */
+
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+}