Examples of RuntimeServices


Examples of org.apache.velocity.runtime.RuntimeServices

     */
    public void init(RuntimeServices rs, InternalContextAdapter context, Node node)
        throws TemplateInitException
    {
        super.init(rs, context, node);
        RuntimeServices rsvc=VelocityUtil.getEngine().getRuntimeServices();

        // handle deprecated config settings
        counterName = rsvc.getString(RuntimeConstants.COUNTER_NAME);
        hasNextName = rsvc.getString(RuntimeConstants.HAS_NEXT_NAME);
        counterInitialValue = rsvc.getInt(RuntimeConstants.COUNTER_INITIAL_VALUE);
        // only warn once per instance...
        if (!warned && Logger.isWarnEnabled(this.getClass()))
        {
            warned = true;
            // ...and only if they customize these settings
            if (!"velocityCount".equals(counterName))
            {
                Logger.warn(this,"The "+RuntimeConstants.COUNTER_NAME+
                    " property has been deprecated. It will be removed"+
                    " (along with $velocityCount itself) in Velocity 2.0. "+
                    " Instead, please use $foreach.count to access"+
                    " the loop counter.");
            }
            if (!"velocityHasNext".equals(hasNextName))
            {
                Logger.warn(this,"The "+RuntimeConstants.HAS_NEXT_NAME+
                    " property has been deprecated. It will be removed"+
                    " (along with $velocityHasNext itself ) in Velocity 2.0. "+
                    " Instead, please use $foreach.hasNext to access"+
                    " this value from now on.");
            }
            if (counterInitialValue != 1)
            {
                Logger.warn(this,"The "+RuntimeConstants.COUNTER_INITIAL_VALUE+
                    " property has been deprecated. It will be removed"+
                    " (along with $velocityCount itself) in Velocity 2.0. "+
                    " Instead, please use $foreach.index to access"+
                    " the 0-based loop index and $foreach.count"+
                    " to access the 1-based loop counter.");
            }
        }

        maxNbrLoops = rsvc.getInt(RuntimeConstants.MAX_NUMBER_LOOPS,
                                  Integer.MAX_VALUE);
        if (maxNbrLoops < 1)
        {
            maxNbrLoops = Integer.MAX_VALUE;
        }
        skipInvalidIterator =
            rsvc.getBoolean(RuntimeConstants.SKIP_INVALID_ITERATOR, true);
       
        if (rsvc.getBoolean(RuntimeConstants.RUNTIME_REFERENCES_STRICT, false))
        {
          // If we are in strict mode then the default for skipInvalidItarator
          // is true.  However, if the property is explicitly set, then honor the setting.
          skipInvalidIterator = rsvc.getBoolean(RuntimeConstants.SKIP_INVALID_ITERATOR, false);
        }
               
        /*
         *  this is really the only thing we can do here as everything
         *  else is context sensitive
View Full Code Here

Examples of org.apache.velocity.runtime.RuntimeServices

        if (listObject == null)
             return false;

        Iterator i = null;
        RuntimeServices rsvc=VelocityUtil.getEngine().getRuntimeServices();
        try
        {
            i = rsvc.getUberspect().getIterator(listObject, uberInfo);
        }
        /**
         * pass through application level runtime exceptions
         */
        catch( RuntimeException e )
View Full Code Here

Examples of org.apache.velocity.runtime.RuntimeServices

        Object right = jjtGetChild(1).value( context );

        /*
         *  if either is null, lets log and bail
         */
        RuntimeServices rsvc=VelocityUtil.getEngine().getRuntimeServices();
        if (left == null || right == null)
        {
            String msg = (left == null ? "Left" : "Right")
                           + " side ("
                           + jjtGetChild( (left == null? 0 : 1) ).literal()
                           + ") of '<' operation has null value at "
                           + VelocityException.formatFileString(this);

            if (rsvc.getBoolean(RuntimeConstants.RUNTIME_REFERENCES_STRICT, false))
            {
              throw new VelocityException(msg);
            }
                       
            Logger.error(this,msg);
            return false;
        }

        /*
         *  convert to Number if applicable
         */
        if (left instanceof TemplateNumber)
        {
           left = ( (TemplateNumber) left).getAsNumber();
        }
        if (right instanceof TemplateNumber)
        {
           right = ( (TemplateNumber) right).getAsNumber();
        }

        /*
         *  Only compare Numbers
         */

        if ( !( left instanceof Number || !( right instanceof Number ))
        {
            String msg = (!(left instanceof Number) ? "Left" : "Right")
                           + " side of '>=' operation is not a valid Number at "
                           + VelocityException.formatFileString(this);

            if (rsvc.getBoolean(RuntimeConstants.RUNTIME_REFERENCES_STRICT, false))
            {
              throw new VelocityException(msg);
            }
           
            Logger.error(this,msg);
View Full Code Here

Examples of org.apache.velocity.runtime.RuntimeServices

     * {@inheritDoc}
     */
    public Object init(InternalContextAdapter context, Object data) throws TemplateInitException
    {
        super.init(context, data);
        RuntimeServices rsvc=VelocityUtil.getEngine().getRuntimeServices();
        strictMode = rsvc.getBoolean(RuntimeConstants.STRICT_MATH, false);
        return data;
    }
View Full Code Here

Examples of org.apache.velocity.runtime.RuntimeServices

                    getLine(), getColumn());
   
            right = getRightHandSide();
            left = getLeftHandSide();
   
            RuntimeServices rsvc=VelocityUtil.getEngine().getRuntimeServices();
            logOnNull = rsvc.getBoolean(RuntimeConstants.RUNTIME_LOG_REFERENCE_LOG_INVALID, true);
            allowNull = rsvc.getBoolean(RuntimeConstants.SET_NULL_ALLOWED, false);
            strictRef = rsvc.getBoolean(RuntimeConstants.RUNTIME_REFERENCES_STRICT, false);
            if (strictRef) allowNull = true// strictRef implies allowNull
           
            /*
             *  grab this now.  No need to redo each time
             */
 
View Full Code Here

Examples of org.apache.velocity.runtime.RuntimeServices

        /*
         * it's an error if we don't have a value of some sort AND
         * it is not allowed by configuration
         */

        RuntimeServices rsvc=VelocityUtil.getEngine().getRuntimeServices();
        if( !allowNull )
        {
           
            if ( value == null )
            {               
View Full Code Here

Examples of org.apache.velocity.runtime.RuntimeServices

         */

        methodName = tokens.get(0).image;
        paramCount = jjtGetNumChildren() - 1;
       
        RuntimeServices rsvc=VelocityUtil.getEngine().getRuntimeServices();
        strictRef = rsvc.getBoolean(RuntimeConstants.RUNTIME_REFERENCES_STRICT, false);
       
        return data;
    }
View Full Code Here

Examples of org.apache.velocity.runtime.RuntimeServices

         */
        else if (t instanceof Exception)
        {
            try
            {
                RuntimeServices rsvc=VelocityUtil.getEngine().getRuntimeServices();
                return EventHandlerUtil.methodException( rsvc, context, o.getClass(), methodName, (Exception) t );
            }

            /**
             * If the event handler throws an exception, then wrap it
View Full Code Here

Examples of org.apache.velocity.runtime.RuntimeServices

     */
    public Object init(InternalContextAdapter context, Object data)
    throws TemplateInitException
    {
        super.init(context, data);
        RuntimeServices rsvc=VelocityUtil.getEngine().getRuntimeServices();
       
        strictEscape = rsvc.getBoolean(RuntimeConstants.RUNTIME_REFERENCES_STRICT_ESCAPE, false);
        strictRef = rsvc.getBoolean(RuntimeConstants.RUNTIME_REFERENCES_STRICT, false);
        toStringNullCheck = rsvc.getBoolean(RuntimeConstants.DIRECTIVE_IF_TOSTRING_NULLCHECK, true);
           
        /*
         *  the only thing we can do in init() is getRoot()
         *  as that is template based, not context based,
         *  so it's thread- and context-safe
         */

        rootString = getRoot().intern();

        numChildren = jjtGetNumChildren();
       
        // This is an expensive call, so get it now.
        literal = literal();
       
        /*
         * and if appropriate...
         */

        if (numChildren > 0 )
        {
            Node lastNode = jjtGetChild(numChildren-1);
            if (lastNode instanceof ASTIndex)
                astIndex = (ASTIndex)lastNode;
            else
                identifier = lastNode.getTokens().get(0).image;           
        }

        /*
         * make an uberinfo - saves new's later on
         */
        uberInfo = new Info(getTemplateName(), getLine(),getColumn());

        /*
         * track whether we log invalid references
         */
        logOnNull =
            rsvc.getBoolean(RuntimeConstants.RUNTIME_LOG_REFERENCE_LOG_INVALID, true);

        /**
         * In the case we are referencing a variable with #if($foo) or
         * #if( ! $foo) then we allow variables to be undefined and we
         * set strictRef to false so that if the variable is undefined
View Full Code Here

Examples of org.apache.velocity.runtime.RuntimeServices

        /*
         *  get the root object from the context
         */

        Object result = getVariableValue(context, rootString);
        RuntimeServices rsvc=VelocityUtil.getEngine().getRuntimeServices();
       
        if (result == null && !strictRef)
        {
            return EventHandlerUtil.invalidGetMethod(rsvc, context,
                    getDollarBang() + rootString, null, null, uberInfo);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.