Package org.apache.velocity.runtime.resource

Examples of org.apache.velocity.runtime.resource.Resource


         */
        boolean blockinput = false;
        if (arg == null)
            blockinput = true;

        Resource resource = null;

        try
        {
            if (!blockinput)
                resource = rsvc.getContent(arg, getInputEncoding(context));
        }
        catch ( ResourceNotFoundException rnfe )
        {
            /*
             * the arg wasn't found.  Note it and throw
             */
            rsvc.getLog().error("#include(): cannot find resource '" + arg +
                                "', called from template " +
                                context.getCurrentTemplateName() + " at (" +
                                getLine() + ", " + getColumn() + ")" );
            throw rnfe;
        }

        /**
         * pass through application level runtime exceptions
         */
        catch( RuntimeException e )
        {
            throw e;
        }
        catch (Exception e)
        {
            rsvc.getLog().error("#include(): arg = '" + arg +
                                "', called from template " +
                                context.getCurrentTemplateName() + " at (" +
                                getLine() + ", " + getColumn() + ')', e);
        }


        /*
         *    note - a blocked input is still a successful operation as this is
         *    expected behavior.
         */

        if ( blockinput )
            return true;

        else if ( resource == null )
            return false;

        writer.write((String)resource.getData());
        return true;
    }
View Full Code Here


         */
        boolean blockinput = false;
        if (arg == null)
            blockinput = true;

        Resource resource = null;

        try
        {
            if (!blockinput)
                resource = rsvc.getContent(arg, getInputEncoding(context));
        }
        catch ( ResourceNotFoundException rnfe )
        {
            /*
             * the arg wasn't found.  Note it and throw
             */
            rsvc.getLog().error("#include(): cannot find resource '" + arg +
                                "', called from template " +
                                context.getCurrentTemplateName() + " at (" +
                                getLine() + ", " + getColumn() + ")" );
            throw rnfe;
        }

        /**
         * pass through application level runtime exceptions
         */
        catch( RuntimeException e )
        {
            throw e;
        }
        catch (Exception e)
        {
            rsvc.getLog().error("#include(): arg = '" + arg +
                                "', called from template " +
                                context.getCurrentTemplateName() + " at (" +
                                getLine() + ", " + getColumn() + ')', e);
        }


        /*
         *    note - a blocked input is still a successful operation as this is
         *    expected behavior.
         */

        if ( blockinput )
            return true;

        else if ( resource == null )
            return false;

        writer.write((String)resource.getData());
        return true;
    }
View Full Code Here

     * from.
     * @return The encoding to use when processing this directive.    
     */
    protected String getInputEncoding(InternalContextAdapter context)
    {
        Resource current = context.getCurrentResource();
        if (current != null)
        {
            return current.getEncoding();
        }
        else
        {
            return (String) rsvc.getProperty(RuntimeConstants.INPUT_ENCODING);
        }
View Full Code Here

            rsvc.error( "Max recursion depth reached (" +
                templateStack.length + ")"  + " File stack:" + path );
            return false;
        }

        Resource current = context.getCurrentResource();

        /*
         *  get the resource, and assume that we use the encoding of the current template
         *  the 'current resource' can be null if we are processing a stream....
         */

        String encoding = null;

        if ( current != null)
        {
            encoding = current.getEncoding();
        }
        else
        {
            encoding = (String) rsvc.getProperty( RuntimeConstants.INPUT_ENCODING);
        }
View Full Code Here

        /*
         *  get the path
         */
        arg = value.toString();

        Resource resource = null;

        Resource current = context.getCurrentResource();

        try
        {
            /*
             *  get the resource, and assume that we use the encoding of the current template
             *  the 'current resource' can be null if we are processing a stream....
             */

            String encoding = null;

            if ( current != null)
            {
                encoding = current.getEncoding();
            }
            else
            {
                encoding = (String) rsvc.getProperty( RuntimeConstants.INPUT_ENCODING);
            }
View Full Code Here

         */
        boolean blockinput = false;
        if (arg == null)
            blockinput = true;

        Resource resource = null;

        try
        {
            if (!blockinput)
                resource = rsvc.getContent(arg, getInputEncoding(context));
        }
        catch ( ResourceNotFoundException rnfe )
        {
            /*
             * the arg wasn't found.  Note it and throw
             */
            rsvc.getLog().error("#include(): cannot find resource '" + arg +
                                "', called from template " +
                                context.getCurrentTemplateName() + " at (" +
                                getLine() + ", " + getColumn() + ")" );
            throw rnfe;
        }

        /**
         * pass through application level runtime exceptions
         */
        catch( RuntimeException e )
        {
            throw e;
        }
        catch (Exception e)
        {
            rsvc.getLog().error("#include(): arg = '" + arg +
                                "', called from template " +
                                context.getCurrentTemplateName() + " at (" +
                                getLine() + ", " + getColumn() + ')', e);
        }


        /*
         *    note - a blocked input is still a successful operation as this is
         *    expected behavior.
         */

        if ( blockinput )
            return true;

        else if ( resource == null )
            return false;

        writer.write((String)resource.getData());
        return true;
    }
View Full Code Here

public class SQLTemplateResourceManagerTest extends BasicCase {
    public void testFetResource() throws Exception {
        SQLTemplateResourceManager rm = new SQLTemplateResourceManager();
        rm.initialize(new MockupRuntimeServices());

        Resource resource =
            rm.getResource(
                "abc",
                ResourceManager.RESOURCE_TEMPLATE,
                RuntimeConstants.ENCODING_DEFAULT);
View Full Code Here

         */
        boolean blockinput = false;
        if (arg == null)
            blockinput = true;

        Resource resource = null;

        try
        {
            if (!blockinput)
                resource = rsvc.getContent(arg, getInputEncoding(context));
        }
        catch ( ResourceNotFoundException rnfe )
        {
            /*
             * the arg wasn't found.  Note it and throw
             */
            rsvc.getLog().error("#include(): cannot find resource '" + arg +
                                "', called at " + Log.formatFileString(this));
            throw rnfe;
        }

        /**
         * pass through application level runtime exceptions
         */
        catch( RuntimeException e )
        {
            rsvc.getLog().error("#include(): arg = '" + arg +
                                "', called at " + Log.formatFileString(this));
            throw e;
        }
        catch (Exception e)
        {
            String msg = "#include(): arg = '" + arg +
                        "', called at " + Log.formatFileString(this);
            rsvc.getLog().error(msg, e);
            throw new VelocityException(msg, e);
        }


        /*
         *    note - a blocked input is still a successful operation as this is
         *    expected behavior.
         */

        if ( blockinput )
            return true;

        else if ( resource == null )
            return false;

        writer.write((String)resource.getData());
        return true;
    }
View Full Code Here

        /*
         *  get the path
         */
        arg = value.toString();

        Resource resource = null;

        try
        {
            resource = rsvc.getContent(arg, getInputEncoding(context));
        }
        catch ( ResourceNotFoundException rnfe )
        {
           /*
            * the arg wasn't found.  Note it and throw
            */
           
          rsvc.error("#include(): cannot find resource '" + arg +
                       "', called from template " +
                       context.getCurrentTemplateName() + " at (" +
                       getLine() + ", " + getColumn() + ")" );
          throw rnfe;
        }

        catch (Exception e)
        {
          rsvc.error("#include(): arg = '" + arg +
                       "', called from template " +
                       context.getCurrentTemplateName() + " at (" +
                       getLine() + ", " + getColumn() + ") : " + e);
        }           
       
        if ( resource == null )
            return false;
      
        writer.write((String)resource.getData());      
        return true;
    }
View Full Code Here

         */
        boolean blockinput = false;
        if (arg == null)
            blockinput = true;

        Resource resource = null;

        try
        {
            if (!blockinput)
                resource = rsvc.getContent(arg, getInputEncoding(context));
        }
        catch ( ResourceNotFoundException rnfe )
        {
            /*
             * the arg wasn't found.  Note it and throw
             */
            rsvc.getLog().error("#include(): cannot find resource '" + arg +
                                "', called at " + Log.formatFileString(this));
            throw rnfe;
        }

        /**
         * pass through application level runtime exceptions
         */
        catch( RuntimeException e )
        {
            rsvc.getLog().error("#include(): arg = '" + arg +
                                "', called at " + Log.formatFileString(this));
            throw e;
        }
        catch (Exception e)
        {
            String msg = "#include(): arg = '" + arg +
                        "', called at " + Log.formatFileString(this);
            rsvc.getLog().error(msg, e);
            throw new VelocityException(msg, e);
        }


        /*
         *    note - a blocked input is still a successful operation as this is
         *    expected behavior.
         */

        if ( blockinput )
            return true;

        else if ( resource == null )
            return false;

        writer.write((String)resource.getData());
        return true;
    }
View Full Code Here

TOP

Related Classes of org.apache.velocity.runtime.resource.Resource

Copyright © 2018 www.massapicom. 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.