Java Code Examples for org.apache.velocity.exception.TemplateInitException

The following examples show how to use org.apache.velocity.exception.TemplateInitException. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: velocity-engine   Source File: ASTMethod.java    License: Apache License 2.0 6 votes vote down vote up
/**
 *  simple init - init our subtree and get what we can from
 *  the AST
 * @param context
 * @param data
 * @return The init result
 * @throws TemplateInitException
 */
public Object init(  InternalContextAdapter context, Object data)
    throws TemplateInitException
{
    super.init(  context, data );

    /*
     * make an uberinfo - saves new's later on
     */

    uberInfo = new Info(getTemplateName(),
            getLine(),getColumn());
    /*
     *  this is about all we can do
     */

    methodName = getFirstToken().image;
    paramCount = jjtGetNumChildren() - 1;

    strictRef = rsvc.getBoolean(RuntimeConstants.RUNTIME_REFERENCES_STRICT, false);
    logOnInvalid = rsvc.getBoolean(RuntimeConstants.RUNTIME_LOG_METHOD_CALL_LOG_INVALID, true);

    cleanupParserAndTokens();

    return data;
}
 
Example 2
Source Project: velocity-engine   Source File: ASTText.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * @see org.apache.velocity.runtime.parser.node.SimpleNode#init(org.apache.velocity.context.InternalContextAdapter, java.lang.Object)
 */
public Object init( InternalContextAdapter context, Object data)
throws TemplateInitException
{
    StringBuilder builder = new StringBuilder();
    Token t = getFirstToken();
    for (; t != getLastToken(); t = t.next)
    {
        builder.append(NodeUtils.tokenLiteral(parser, t));
    }
    builder.append(NodeUtils.tokenLiteral(parser, t));
    ctext = builder.toString();

    cleanupParserAndTokens();

    return data;
}
 
Example 3
Source Project: velocity-engine   Source File: SimpleNode.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * @throws TemplateInitException
 * @see org.apache.velocity.runtime.parser.node.Node#init(org.apache.velocity.context.InternalContextAdapter, java.lang.Object)
 */
public Object init( InternalContextAdapter context, Object data) throws TemplateInitException
{
    /*
     * hold onto the RuntimeServices
     */

    rsvc = (RuntimeServices) data;
    log = rsvc.getLog("rendering");

    int i, k = jjtGetNumChildren();

    for (i = 0; i < k; i++)
    {
        jjtGetChild(i).init( context, data);
    }

    line = first.beginLine;
    column = first.beginColumn;

    return data;
}
 
Example 4
Source Project: velocity-engine   Source File: ASTIdentifier.java    License: Apache License 2.0 6 votes vote down vote up
/**
 *  simple init - don't do anything that is context specific.
 *  just get what we need from the AST, which is static.
 * @param context
 * @param data
 * @return The data object.
 * @throws TemplateInitException
 */
public  Object init(InternalContextAdapter context, Object data)
    throws TemplateInitException
{
    super.init(context, data);

    identifier = rsvc.useStringInterning() ? getFirstToken().image.intern() : getFirstToken().image;

    uberInfo = new Info(getTemplateName(), getLine(), getColumn());

    strictRef = rsvc.getBoolean(RuntimeConstants.RUNTIME_REFERENCES_STRICT, false);

    saveTokenImages();
    cleanupParserAndTokens();

    return data;
}
 
Example 5
Source Project: velocity-engine   Source File: ASTTextblock.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * @see org.apache.velocity.runtime.parser.node.SimpleNode#init(org.apache.velocity.context.InternalContextAdapter, java.lang.Object)
 */
public Object init( InternalContextAdapter context, Object data)
throws TemplateInitException
{
    Token t = getFirstToken();

    String text = t.image;

    // t.image is in format: #[[ <string> ]]#
    // we must strip away the hash tags
    text = text.substring(START.length(), text.length() - END.length());

    ctext = text.toCharArray();

    cleanupParserAndTokens();

    return data;
}
 
Example 6
Source Project: velocity-engine   Source File: BlockMacro.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Initializes the directive.
 *
 * @param rs
 * @param macroName
 * @param context
 * @param node
 * @throws TemplateInitException
 */
public void init(RuntimeServices rs, String macroName, InternalContextAdapter context, Node node)
    throws TemplateInitException
{
    this.name = macroName;

    super.init(rs, context, node);

    // get name of the reference that refers to AST block passed to block macro call
    key = rsvc.getString(RuntimeConstants.VM_BODY_REFERENCE, "bodyContent");

    // use the macro max depth for bodyContent max depth as well
    maxDepth = rsvc.getInt(RuntimeConstants.VM_MAX_DEPTH);

    macro = new RuntimeMacro();
    macro.setLocation(getLine(), getColumn(), getTemplate());
    macro.init(rsvc, name, context, node);
}
 
Example 7
Source Project: velocity-engine   Source File: Include.java    License: Apache License 2.0 6 votes vote down vote up
/**
 *  simple init - init the tree and get the elementKey from
 *  the AST
 * @param rs
 * @param context
 * @param node
 * @throws TemplateInitException
 */
public void init(RuntimeServices rs, InternalContextAdapter context,
                 Node node)
    throws TemplateInitException
{
    super.init( rs, context, node );

    /*
     *  get the msg, and add the space so we don't have to
     *  do it each time
     */
    outputMsgStart = rsvc.getString(RuntimeConstants.ERRORMSG_START);
    outputMsgStart = outputMsgStart + " ";

    outputMsgEnd = rsvc.getString(RuntimeConstants.ERRORMSG_END );
    outputMsgEnd = " " + outputMsgEnd;
}
 
Example 8
@Override
public void init(RuntimeServices rs, InternalContextAdapter context, Node node) throws TemplateInitException {
	super.init(rs, context, node);
	log = rs.getLog();
	
	//set compressor properties
	enabled = rs.getBoolean("userdirective.compressJs.enabled", true);
	jsCompressor = rs.getString("userdirective.compressHtml.jsCompressor", HtmlCompressor.JS_COMPRESSOR_YUI);
	yuiJsNoMunge = rs.getBoolean("userdirective.compressJs.yuiJsNoMunge", false);
	yuiJsPreserveAllSemiColons = rs.getBoolean("userdirective.compressJs.yuiJsPreserveAllSemiColons", false);
	yuiJsLineBreak = rs.getInt("userdirective.compressJs.yuiJsLineBreak", -1);
	closureOptLevel = rs.getString("userdirective.compressHtml.closureOptLevel", ClosureJavaScriptCompressor.COMPILATION_LEVEL_SIMPLE);
}
 
Example 9
Source Project: htmlcompressor   Source File: CssCompressorDirective.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void init(RuntimeServices rs, InternalContextAdapter context, Node node) throws TemplateInitException {
	super.init(rs, context, node);
	log = rs.getLog();
	
	//set compressor properties
	enabled = rs.getBoolean("userdirective.compressCss.enabled", true);
	yuiCssLineBreak = rs.getInt("userdirective.compressCss.yuiCssLineBreak", -1);
}
 
Example 10
Source Project: htmlcompressor   Source File: XmlCompressorDirective.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void init(RuntimeServices rs, InternalContextAdapter context, Node node) throws TemplateInitException {
	super.init(rs, context, node);
	log = rs.getLog();
	
	//set compressor properties
	xmlCompressor.setEnabled(rs.getBoolean("userdirective.compressXml.enabled", true));
	xmlCompressor.setRemoveComments(rs.getBoolean("userdirective.compressXml.removeComments", true));
	xmlCompressor.setRemoveIntertagSpaces(rs.getBoolean("userdirective.compressXml.removeIntertagSpaces", true));
}
 
Example 11
Source Project: velocity-engine   Source File: ASTLogicalOperator.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * @throws TemplateInitException
 * @see org.apache.velocity.runtime.parser.node.Node#init(org.apache.velocity.context.InternalContextAdapter, java.lang.Object)
 */
public Object init( InternalContextAdapter context, Object data) throws TemplateInitException
{
    Object obj = super.init(context, data);
    cleanupParserAndTokens(); // drop reference to Parser and all JavaCC Tokens
    return obj;
}
 
Example 12
Source Project: velocity-engine   Source File: ASTAssignment.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * @throws TemplateInitException
 * @see org.apache.velocity.runtime.parser.node.Node#init(org.apache.velocity.context.InternalContextAdapter, java.lang.Object)
 */
public Object init( InternalContextAdapter context, Object data) throws TemplateInitException
{
	Object obj = super.init(context, data);
	cleanupParserAndTokens(); // drop reference to Parser and all JavaCC Tokens
	return obj;
}
 
Example 13
Source Project: velocity-engine   Source File: ASTIfStatement.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * @throws TemplateInitException
 * @see org.apache.velocity.runtime.parser.node.Node#init(org.apache.velocity.context.InternalContextAdapter, java.lang.Object)
 */
public Object init( InternalContextAdapter context, Object data) throws TemplateInitException
{
    Object obj = super.init(context, data);

    /*
     * handle '$' and '#' chars prefix
     */
    Token t = getFirstToken();
    int pos = -1;
    while (t != null && (pos = t.image.lastIndexOf(rsvc.getParserConfiguration().getHashChar())) == -1)
    {
        t = t.next;
    }
    if (t != null && pos > 0)
    {
        morePrefix = t.image.substring(0, pos);
    }

    /* handle structured space gobbling */
    if (rsvc.getSpaceGobbling() == SpaceGobbling.STRUCTURED && postfix.length() > 0)
    {
        NodeUtils.fixIndentation(this, prefix);
    }

    cleanupParserAndTokens(); // drop reference to Parser and all JavaCC Tokens
    return obj;
}
 
Example 14
Source Project: velocity-engine   Source File: ASTWord.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * @throws TemplateInitException
 * @see org.apache.velocity.runtime.parser.node.Node#init(org.apache.velocity.context.InternalContextAdapter, java.lang.Object)
 */
public Object init( InternalContextAdapter context, Object data) throws TemplateInitException
{
	Object obj = super.init(context, data);
	saveTokenImages();
	cleanupParserAndTokens(); // drop reference to Parser and all JavaCC Tokens
	return obj;
}
 
Example 15
Source Project: velocity-engine   Source File: ASTEscapedDirective.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * @throws TemplateInitException
 * @see org.apache.velocity.runtime.parser.node.Node#init(org.apache.velocity.context.InternalContextAdapter, java.lang.Object)
 */
public Object init( InternalContextAdapter context, Object data) throws TemplateInitException
{
	Object obj = super.init(context, data);
	saveTokenImages();
	cleanupParserAndTokens(); // drop reference to Parser and all JavaCC Tokens
	return obj;
}
 
Example 16
Source Project: velocity-engine   Source File: ASTExpression.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * @throws TemplateInitException
 * @see org.apache.velocity.runtime.parser.node.Node#init(org.apache.velocity.context.InternalContextAdapter, java.lang.Object)
 */
public Object init( InternalContextAdapter context, Object data) throws TemplateInitException
{
	Object obj = super.init(context, data);
	saveTokenImages();
	cleanupParserAndTokens(); // drop reference to Parser and all JavaCC Tokens
	return obj;
}
 
Example 17
Source Project: velocity-engine   Source File: ASTElseStatement.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * @throws TemplateInitException
 * @see org.apache.velocity.runtime.parser.node.Node#init(org.apache.velocity.context.InternalContextAdapter, java.lang.Object)
 */
public Object init( InternalContextAdapter context, Object data) throws TemplateInitException
{
	Object obj = super.init(context, data);
	cleanupParserAndTokens(); // drop reference to Parser and all JavaCC Tokens
	return obj;
}
 
Example 18
Source Project: velocity-engine   Source File: ASTBinaryOperator.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * @throws TemplateInitException
 * @see org.apache.velocity.runtime.parser.node.Node#init(org.apache.velocity.context.InternalContextAdapter, java.lang.Object)
 */
public Object init( InternalContextAdapter context, Object data) throws TemplateInitException
{
    Object obj = super.init(context, data);
    cleanupParserAndTokens(); // drop reference to Parser and all JavaCC Tokens
    return obj;
}
 
Example 19
Source Project: velocity-engine   Source File: ASTMulNode.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * @throws TemplateInitException
 * @see org.apache.velocity.runtime.parser.node.Node#init(org.apache.velocity.context.InternalContextAdapter, java.lang.Object)
 */
public Object init( InternalContextAdapter context, Object data) throws TemplateInitException
{
	Object obj = super.init(context, data);
	cleanupParserAndTokens(); // drop reference to Parser and all JavaCC Tokens
	return obj;
}
 
Example 20
Source Project: velocity-engine   Source File: ASTBlock.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * @throws TemplateInitException
 * @see org.apache.velocity.runtime.parser.node.Node#init(org.apache.velocity.context.InternalContextAdapter, java.lang.Object)
 */
public Object init( InternalContextAdapter context, Object data) throws TemplateInitException
{
    Object obj = super.init(context, data);
    cleanupParserAndTokens(); // drop reference to Parser and all JavaCC Tokens
    return obj;
}
 
Example 21
Source Project: velocity-engine   Source File: ASTprocess.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * @throws TemplateInitException
 * @see org.apache.velocity.runtime.parser.node.Node#init(org.apache.velocity.context.InternalContextAdapter, java.lang.Object)
 */
public Object init( InternalContextAdapter context, Object data) throws TemplateInitException
{
	Object obj = super.init(context, data);
	cleanupParserAndTokens(); // drop reference to Parser and all JavaCC Tokens
	return obj;
}
 
Example 22
Source Project: velocity-engine   Source File: ASTIncludeStatement.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * @throws TemplateInitException
 * @see org.apache.velocity.runtime.parser.node.Node#init(org.apache.velocity.context.InternalContextAdapter, java.lang.Object)
 */
public Object init( InternalContextAdapter context, Object data) throws TemplateInitException
{
	Object obj = super.init(context, data);
	cleanupParserAndTokens(); // drop reference to Parser and all JavaCC Tokens
	return obj;
}
 
Example 23
Source Project: velocity-engine   Source File: ASTVariable.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * @throws TemplateInitException
 * @see org.apache.velocity.runtime.parser.node.Node#init(org.apache.velocity.context.InternalContextAdapter, java.lang.Object)
 */
public Object init( InternalContextAdapter context, Object data) throws TemplateInitException
{
	Object obj = super.init(context, data);
	cleanupParserAndTokens(); // drop reference to Parser and all JavaCC Tokens
	return obj;
}
 
Example 24
Source Project: velocity-engine   Source File: ASTMap.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * @throws TemplateInitException
 * @see org.apache.velocity.runtime.parser.node.Node#init(org.apache.velocity.context.InternalContextAdapter, java.lang.Object)
 */
public Object init( InternalContextAdapter context, Object data) throws TemplateInitException
{
	Object obj = super.init(context, data);
	cleanupParserAndTokens(); // drop reference to Parser and all JavaCC Tokens
	return obj;
}
 
Example 25
Source Project: velocity-engine   Source File: ASTFalse.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * @throws TemplateInitException
 * @see org.apache.velocity.runtime.parser.node.Node#init(org.apache.velocity.context.InternalContextAdapter, java.lang.Object)
 */
public Object init( InternalContextAdapter context, Object data) throws TemplateInitException
{
	Object obj = super.init(context, data);
	cleanupParserAndTokens(); // drop reference to Parser and all JavaCC Tokens
	return obj;
}
 
Example 26
Source Project: velocity-engine   Source File: ASTElseIfStatement.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * @throws TemplateInitException
 * @see org.apache.velocity.runtime.parser.node.Node#init(org.apache.velocity.context.InternalContextAdapter, java.lang.Object)
 */
public Object init( InternalContextAdapter context, Object data) throws TemplateInitException
{
    Object obj = super.init(context, data);
     cleanupParserAndTokens(); // drop reference to Parser and all JavaCC Tokens
    return obj;
}
 
Example 27
Source Project: velocity-engine   Source File: ASTDirectiveAssign.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * @throws TemplateInitException
 * @see org.apache.velocity.runtime.parser.node.Node#init(org.apache.velocity.context.InternalContextAdapter, java.lang.Object)
 */
public Object init( InternalContextAdapter context, Object data) throws TemplateInitException
{
	Object obj = super.init(context, data);
	saveTokenImages();
	cleanupParserAndTokens(); // drop reference to Parser and all JavaCC Tokens
	return obj;
}
 
Example 28
Source Project: velocity-engine   Source File: ASTIntegerRange.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * @throws TemplateInitException
 * @see org.apache.velocity.runtime.parser.node.Node#init(org.apache.velocity.context.InternalContextAdapter, java.lang.Object)
 */
public Object init( InternalContextAdapter context, Object data) throws TemplateInitException
{
	Object obj = super.init(context, data);
	cleanupParserAndTokens(); // drop reference to Parser and all JavaCC Tokens
	return obj;
}
 
Example 29
Source Project: velocity-engine   Source File: ASTObjectArray.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * @throws TemplateInitException
 * @see org.apache.velocity.runtime.parser.node.Node#init(org.apache.velocity.context.InternalContextAdapter, java.lang.Object)
 */
public Object init( InternalContextAdapter context, Object data) throws TemplateInitException
{
	Object obj = super.init(context, data);
	cleanupParserAndTokens(); // drop reference to Parser and all JavaCC Tokens
	return obj;
}
 
Example 30
Source Project: velocity-engine   Source File: ASTModNode.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * @throws TemplateInitException
 * @see org.apache.velocity.runtime.parser.node.Node#init(org.apache.velocity.context.InternalContextAdapter, java.lang.Object)
 */
public Object init( InternalContextAdapter context, Object data) throws TemplateInitException
{
	Object obj = super.init(context, data);
	cleanupParserAndTokens(); // drop reference to Parser and all JavaCC Tokens
	return obj;
}