public final class VelocityUtil extends Object
Modifier and Type | Field and Description |
---|---|
static org.apache.velocity.runtime.Renderable |
EMPTY_RENDERABLE
A renderable object that does not render anything.
|
Modifier and Type | Method and Description |
---|---|
static void |
evaluateBody(org.apache.velocity.context.InternalContextAdapter context,
Writer writer,
org.apache.velocity.runtime.parser.node.Node node)
Evaluates the body writing in the passed writer.
|
static String |
getBodyAsString(org.apache.velocity.context.InternalContextAdapter context,
org.apache.velocity.runtime.parser.node.Node node)
Evaluates the body (child node at position 1) and returns it as a string.
|
static Map<String,Object> |
getParameters(org.apache.velocity.context.InternalContextAdapter context,
org.apache.velocity.runtime.parser.node.Node node)
Extracts the parameters from the directives, by getting the child at
position 0 supposing it is a map.
|
static ArrayStack<Map<String,Object>> |
getParameterStack(org.apache.velocity.context.Context context)
Deprecated.
Use Velocity directives.
|
static void |
setAttribute(org.apache.velocity.context.Context velocityContext,
javax.servlet.http.HttpServletRequest request,
javax.servlet.ServletContext servletContext,
String name,
Object obj,
String scope)
Sets an attribute in the desired scope.
|
static boolean |
toSimpleBoolean(Boolean obj,
boolean defaultValue)
Null-safe conversion from Boolean to boolean.
|
public static final org.apache.velocity.runtime.Renderable EMPTY_RENDERABLE
public static boolean toSimpleBoolean(Boolean obj, boolean defaultValue)
obj
- The Boolean object.defaultValue
- This value will be returned if obj
is null.obj
or, if null, defaultValue
.@Deprecated public static ArrayStack<Map<String,Object>> getParameterStack(org.apache.velocity.context.Context context)
context
- The Velocity context.public static void setAttribute(org.apache.velocity.context.Context velocityContext, javax.servlet.http.HttpServletRequest request, javax.servlet.ServletContext servletContext, String name, Object obj, String scope)
velocityContext
- The Velocity context.request
- The HTTP request.servletContext
- The servlet context.name
- The name of the attribute.obj
- The value of the attribute.scope
- The scope. It can be page
, request
, session
, application
.public static String getBodyAsString(org.apache.velocity.context.InternalContextAdapter context, org.apache.velocity.runtime.parser.node.Node node) throws IOException
context
- The Velocity context.node
- The node to use.IOException
- If something goes wrong.public static void evaluateBody(org.apache.velocity.context.InternalContextAdapter context, Writer writer, org.apache.velocity.runtime.parser.node.Node node) throws IOException
context
- The Velocity context.writer
- The writer to write into.node
- The node to use.IOException
- If something goes wrong.public static Map<String,Object> getParameters(org.apache.velocity.context.InternalContextAdapter context, org.apache.velocity.runtime.parser.node.Node node)
context
- The Velocity context.node
- The node to use.Copyright © 2017. All rights reserved.