Package freemarker.core

Examples of freemarker.core.TemplateElement


        }
    }

    private static void insertDebugBreak(Template t, Breakpoint breakpoint)
    {
        TemplateElement te = findTemplateElement(t.getRootTreeNode(), breakpoint.getLine());
        if(te == null)
        {
            return;
        }
        TemplateElement parent = (TemplateElement)te.getParent();
        DebugBreak db = new DebugBreak(te);
        // TODO: Ensure there always is a parent by making sure
        // that the root element in the template is always a MixedContent
        // Also make sure it doesn't conflict with anyone's code.
        parent.setChildAt(parent.getIndex(te), db);
    }
View Full Code Here


            return null;
        }
        // Find the narrowest match
        for(Enumeration children = te.children(); children.hasMoreElements();)
        {
            TemplateElement child = (TemplateElement)children.nextElement();
            TemplateElement childmatch = findTemplateElement(child, line);
            if(childmatch != null)
            {
                return childmatch;
            }
        }
View Full Code Here

        }
    }

    private void removeDebugBreak(Template t, Breakpoint breakpoint)
    {
        TemplateElement te = findTemplateElement(t.getRootTreeNode(), breakpoint.getLine());
        if(te == null)
        {
            return;
        }
        DebugBreak db = null;
        while(te != null)
        {
            if(te instanceof DebugBreak)
            {
                db = (DebugBreak)te;
                break;
            }
            te = (TemplateElement)te.getParent();
        }
        if(db == null)
        {
            return;
        }
        TemplateElement parent = (TemplateElement)db.getParent();
        parent.setChildAt(parent.getIndex(db), (TemplateElement)db.getChildAt(0));
    }
View Full Code Here

    private void removeDebugBreaks(TemplateElement te)
    {
        int count = te.getChildCount();
        for(int i = 0; i < count; ++i)
        {
            TemplateElement child = (TemplateElement)te.getChildAt(i);
            while(child instanceof DebugBreak)
            {
                TemplateElement dbchild = (TemplateElement)child.getChildAt(0);
                te.setChildAt(i, dbchild);
                child = dbchild;
            }
            removeDebugBreaks(child);
        }
View Full Code Here

     * @param column the column    
     * @param line the line
     */
    public List containingElements(int column, int line) {
        ArrayList elements = new ArrayList();
        TemplateElement element = rootElement;
mainloop:
        while (element.contains(column, line)) {
            elements.add(element);
            for (Enumeration enumeration = element.children(); enumeration.hasMoreElements();) {
                TemplateElement elem = (TemplateElement) enumeration.nextElement();
                if (elem.contains(column, line)) {
                    element = elem;
                    continue mainloop;
                }
            }
            break;
View Full Code Here

        }
    }

    private static void insertDebugBreak(Template t, Breakpoint breakpoint)
    {
        TemplateElement te = findTemplateElement(t.getRootTreeNode(), breakpoint.getLine());
        if(te == null)
        {
            return;
        }
        TemplateElement parent = (TemplateElement)te.getParent();
        DebugBreak db = new DebugBreak(te);
        // TODO: Ensure there always is a parent by making sure
        // that the root element in the template is always a MixedContent
        // Also make sure it doesn't conflict with anyone's code.
        parent.setChildAt(parent.getIndex(te), db);
    }
View Full Code Here

        }
        // Find the narrowest match
        List childMatches = new ArrayList();
        for(Enumeration children = te.children(); children.hasMoreElements();)
        {
            TemplateElement child = (TemplateElement)children.nextElement();
            TemplateElement childmatch = findTemplateElement(child, line);
            if(childmatch != null)
            {
                childMatches.add(childmatch);
            }
        }
        //find a match that exactly matches the begin/end line
        TemplateElement bestMatch = null;
        for(int i = 0; i < childMatches.size(); i++)
        {
            TemplateElement e = (TemplateElement) childMatches.get(i);

            if( bestMatch == null )
            {
                bestMatch = e;
            }

            if( e.getBeginLine() == line && e.getEndLine() > line )
            {
                bestMatch = e;
            }

            if( e.getBeginLine() == e.getEndLine() && e.getBeginLine() == line)
            {
                bestMatch = e;
                break;
            }
        }
View Full Code Here

        }
    }

    private void removeDebugBreak(Template t, Breakpoint breakpoint)
    {
        TemplateElement te = findTemplateElement(t.getRootTreeNode(), breakpoint.getLine());
        if(te == null)
        {
            return;
        }
        DebugBreak db = null;
        while(te != null)
        {
            if(te instanceof DebugBreak)
            {
                db = (DebugBreak)te;
                break;
            }
            te = (TemplateElement)te.getParent();
        }
        if(db == null)
        {
            return;
        }
        TemplateElement parent = (TemplateElement)db.getParent();
        parent.setChildAt(parent.getIndex(db), (TemplateElement)db.getChildAt(0));
    }
View Full Code Here

    private void removeDebugBreaks(TemplateElement te)
    {
        int count = te.getChildCount();
        for(int i = 0; i < count; ++i)
        {
            TemplateElement child = (TemplateElement)te.getChildAt(i);
            while(child instanceof DebugBreak)
            {
                TemplateElement dbchild = (TemplateElement)child.getChildAt(0);
                te.setChildAt(i, dbchild);
                child = dbchild;
            }
            removeDebugBreaks(child);
        }
View Full Code Here

     * @param expression the given expression, for example,
     * "${aVariable}", "&lt;#list recentComments as comment&gt;"
     * @return {@code true} if it exists, returns {@code false} otherwise
     */
    public static boolean hasExpression(final Template template, final String expression) {
        final TemplateElement rootTreeNode = template.getRootTreeNode();

        return hasExpression(template, expression, rootTreeNode);
    }
View Full Code Here

TOP

Related Classes of freemarker.core.TemplateElement

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.