@OpenApiAll
public class VelocityReferenceHandler
extends org.apache.velocity.app.event.implement.ReportInvalidReferences
implements org.apache.velocity.app.event.ReferenceInsertionEventHandler, org.apache.velocity.app.event.MethodExceptionEventHandler
org.apache.velocity.app.event.ReferenceInsertionEventHandler.referenceInsertExecutor
org.apache.velocity.app.event.MethodExceptionEventHandler.MethodExceptionExecutor
org.apache.velocity.app.event.InvalidReferenceEventHandler.InvalidGetMethodExecutor, org.apache.velocity.app.event.InvalidReferenceEventHandler.InvalidMethodExecutor, org.apache.velocity.app.event.InvalidReferenceEventHandler.InvalidSetMethodExecutor
Constructor and Description |
---|
VelocityReferenceHandler(ITemplateEngine templateEngine)
Create the references handler.
|
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
invalidGetMethod(org.apache.velocity.context.Context context,
java.lang.String reference,
java.lang.Object object,
java.lang.String property,
org.apache.velocity.util.introspection.Info info)
Collect the error and/or throw an exception, depending on configuration.
|
java.lang.Object |
invalidMethod(org.apache.velocity.context.Context context,
java.lang.String reference,
java.lang.Object object,
java.lang.String method,
org.apache.velocity.util.introspection.Info info)
Collect the error and/or throw an exception, depending on configuration.
|
java.lang.Object |
methodException(java.lang.Class clazz,
java.lang.String method,
java.lang.Exception e)
Render the method exception, and optionally the exception message and stack trace.
|
java.lang.Object |
referenceInsert(java.lang.String reference,
java.lang.Object value)
A call-back which is executed during Velocity merge before a reference value is inserted into the output
stream.
|
void |
setInvalidReferenceHandlerList(java.util.List<IInvalidReferenceHandler> invalidReferenceHandlerList)
Set the list of
IInvalidReferenceHandler . |
void |
setProperties(java.util.Properties properties)
Set the properties of handler.
|
void |
setReferenceInsertionHandlerList(java.util.List<IReferenceInsertionHandler> referenceInsertionHandlerList)
Set the list of
IReferenceInsertionHandler . |
public VelocityReferenceHandler(ITemplateEngine templateEngine)
templateEngine
- template enginepublic void setProperties(java.util.Properties properties)
ITemplateEngine.getProperty(String)
properties
- a properties to be setpublic void setInvalidReferenceHandlerList(java.util.List<IInvalidReferenceHandler> invalidReferenceHandlerList)
IInvalidReferenceHandler
.invalidReferenceHandlerList
- a list of IInvalidReferenceHandler
to be setpublic void setReferenceInsertionHandlerList(java.util.List<IReferenceInsertionHandler> referenceInsertionHandlerList)
IReferenceInsertionHandler
.referenceInsertionHandlerList
- a list of IReferenceInsertionHandler
to be setpublic java.lang.Object invalidMethod(org.apache.velocity.context.Context context, java.lang.String reference, java.lang.Object object, java.lang.String method, org.apache.velocity.util.introspection.Info info)
invalidMethod
in interface org.apache.velocity.app.event.InvalidReferenceEventHandler
invalidMethod
in class org.apache.velocity.app.event.implement.ReportInvalidReferences
context
- the context when the reference was found invalidreference
- complete invalid referenceobject
- the object referred to, or null if not foundmethod
- the property name from the referenceinfo
- contains template, line, column detailsParseErrorException
- error when cannot parse methodpublic java.lang.Object invalidGetMethod(org.apache.velocity.context.Context context, java.lang.String reference, java.lang.Object object, java.lang.String property, org.apache.velocity.util.introspection.Info info)
IInvalidReferenceHandler
sequencely. And stop process when
IInvalidReferenceHandler.invalidReference(String, Object, String, Properties)
return Object.
for (Iterator it = invalidReferenceHandlerList.iterator(); it.hasNext();)
{
if ((result = invalidReferenceHandler.invalidReference(reference, object, property, properties)) != null)
break;
}
return result;
invalidGetMethod
in interface org.apache.velocity.app.event.InvalidReferenceEventHandler
invalidGetMethod
in class org.apache.velocity.app.event.implement.ReportInvalidReferences
context
- the context when the reference was found invalidreference
- string with complete invalid referenceobject
- the object referred to, or null if not foundproperty
- the property name from the referenceinfo
- contains template, line, column detailspublic java.lang.Object referenceInsert(java.lang.String reference, java.lang.Object value)
IReferenceInsertionHandler
sequencely.
for (Iterator it = referenceInsertionHandlerList.iterator(); it.hasNext();)
{
result = referenceInsertionHandler.referenceInsert(reference, result, properties));
}
return result;
referenceInsert
in interface org.apache.velocity.app.event.ReferenceInsertionEventHandler
reference
- Reference from template about to be inserted.value
- Value about to be inserted (after its toString()
method is called).toString()
should be called for output.public java.lang.Object methodException(java.lang.Class clazz, java.lang.String method, java.lang.Exception e) throws java.lang.Exception
null
to keep valid reference and property pass to
invalidGetMethod(org.apache.velocity.context.Context, java.lang.String, java.lang.Object, java.lang.String, org.apache.velocity.util.introspection.Info)
methodException
in interface org.apache.velocity.app.event.MethodExceptionEventHandler
clazz
- the class of the object the method is being applied tomethod
- the methode
- the thrown exceptionnull
object.java.lang.Exception
- an exception to be thrown instead inserting an objectCopyright © 2010 - No Magic Asia