Package org.apache.cocoon.taglib

Examples of org.apache.cocoon.taglib.Tag


    /**
     *
     */
    public static UIComponentTag findParentUIComponentTag(Tag tag) {
        Tag parent = tag;
        do {
            parent = parent.getParent();
        } while (parent != null && !(parent instanceof UIComponentTag));

        return (UIComponentTag) parent;
    }
View Full Code Here


            manager.release(xmlSerializer);
            xmlSerializer = null;
        }

        while (!tagStack.isEmpty()) {
            Tag tag = (Tag) tagStack.pop();
            if (tag == null)
                continue;
            ComponentSelector tagSelector = (ComponentSelector)tagSelectorStack.pop();
            tagSelector.release(tag);
View Full Code Here

            this.skipLevel ++;
            // and ignore this start element
            return;
        }

        Tag tag = null;
        if (namespaceURI != null && namespaceURI.length() > 0) {
            // Try to find Tag corresponding to this element
            ComponentSelector tagSelector = null;
            try {
                tagSelector = (ComponentSelector) tagNamespaceSelector.select(namespaceURI);
                tagSelectorStack.push(tagSelector);

                // namespace matches tag library, lookup tag now.
                tag = (Tag) tagSelector.select(localName);
                if (getLogger().isDebugEnabled()) {
                    getLogger().debug("startElement: Got tag " + qName);
                }

                setupTag(tag, qName, atts);
            } catch (SAXException e) {
                throw e;
            } catch (Exception ignore) {
                // No namespace or tag found, process it as normal element (tag == null)
            }
        }

        tagStack.push(tag);
        if (tag == null) {
            currentConsumer.startElement(namespaceURI, localName, qName, atts);
            return;
        }

        // Execute Tag
        int eval = tag.doStartTag(namespaceURI, localName, qName, atts);
        switch (eval) {
            case Tag.EVAL_BODY :
                skipLevel = 0;
                if (tag instanceof IterationTag) {
                    // start recording for IterationTag
                    startRecording();
                }
                break;

            case Tag.SKIP_BODY :
                skipLevel = 1;
                break;

            default :
                String tagName = tag.getClass().getName();
                getLogger().warn("Bad return value from doStartTag(" + tagName + "): " + eval);
                break;
        }
    }
View Full Code Here

            if (--skipLevel > 0) {
                return;
            }
        }

        Tag tag = (Tag) tagStack.pop();
        if (tag != null) {
            ComponentSelector tagSelector = (ComponentSelector)tagSelectorStack.pop();
            try {
                if (saxFragment != null) {
                    // Start Iteration
                    IterationTag iterTag = (IterationTag) tag;
                    XMLDeserializer xmlDeserializer = null;
                    try {
                        xmlDeserializer = (XMLDeserializer) manager.lookup(XMLDeserializer.ROLE);
                        xmlDeserializer.setConsumer(this);

                        // BodyTag Support
                        XMLConsumer backup = this.currentConsumer;
                        if (tag instanceof BodyTag) {
                            SaxBuffer content = new SaxBuffer();
                            this.currentConsumer = content;
                            ((BodyTag)tag).setBodyContent(new BodyContent(content, backup));
                            ((BodyTag)tag).doInitBody();
                        }

                        do {
                            xmlDeserializer.deserialize(saxFragment);
                        } while (iterTag.doAfterBody() != Tag.SKIP_BODY);

                        // BodyTag Support
                        if (tag instanceof BodyTag) {
                            this.currentConsumer = backup;
                        }

                    } catch (ServiceException e) {
                        throw new SAXException("Can't obtain XMLDeserializer", e);
                    } finally {
                        if (xmlDeserializer != null) {
                            manager.release(xmlDeserializer);
                        }
                    }
                }
                tag.doEndTag(namespaceURI, localName, qName);
                currentTag = tag.getParent();

                if (tag == this.currentConsumer) {
                    popConsumer();
                }
            } finally {
View Full Code Here

    /**
     * Find previous XML consumer when processing of current consumer
     * is complete.
     */
    private void popConsumer() {
        Tag loop = this.currentTag;
        for (; loop != null; loop = loop.getParent()) {
            if (loop instanceof XMLConsumer) {
                this.currentConsumer = (XMLConsumer) loop;
                return;
            }
        }
View Full Code Here

            manager.release(xmlSerializer);
            xmlSerializer = null;
        }

        while (!tagStack.isEmpty()) {
            Tag tag = (Tag) tagStack.pop();
            if (tag == null)
                continue;
            ComponentSelector tagSelector = (ComponentSelector)tagSelectorStack.pop();
            tagSelector.release(tag);
View Full Code Here

            this.skipLevel ++;
            // and ignore this start element
            return;
        }

        Tag tag = null;
        if (namespaceURI != null && namespaceURI.length() > 0) {
            // Try to find Tag corresponding to this element
            ComponentSelector tagSelector = null;
            try {
                tagSelector = (ComponentSelector) tagNamespaceSelector.select(namespaceURI);
                tagSelectorStack.push(tagSelector);

                // namespace matches tag library, lookup tag now.
                tag = (Tag) tagSelector.select(localName);
                if (getLogger().isDebugEnabled()) {
                    getLogger().debug("startElement: Got tag " + qName);
                }

                setupTag(tag, qName, atts);
            } catch (SAXException e) {
                throw e;
            } catch (Exception ignore) {
                // No namespace or tag found, process it as normal element (tag == null)
            }
        }

        tagStack.push(tag);
        if (tag == null) {
            currentConsumer.startElement(namespaceURI, localName, qName, atts);
            return;
        }

        // Execute Tag
        int eval = tag.doStartTag(namespaceURI, localName, qName, atts);
        switch (eval) {
            case Tag.EVAL_BODY :
                skipLevel = 0;
                if (tag instanceof IterationTag) {
                    // start recording for IterationTag
                    startRecording();
                }
                break;

            case Tag.SKIP_BODY :
                skipLevel = 1;
                break;

            default :
                String tagName = tag.getClass().getName();
                getLogger().warn("Bad return value from doStartTag(" + tagName + "): " + eval);
                break;
        }
    }
View Full Code Here

            if (--skipLevel > 0) {
                return;
            }
        }

        Tag tag = (Tag) tagStack.pop();
        if (tag != null) {
            ComponentSelector tagSelector = (ComponentSelector)tagSelectorStack.pop();
            try {
                if (saxFragment != null) {
                    // Start Iteration
                    IterationTag iterTag = (IterationTag) tag;
                    XMLDeserializer xmlDeserializer = null;
                    try {
                        xmlDeserializer = (XMLDeserializer) manager.lookup(XMLDeserializer.ROLE);
                        xmlDeserializer.setConsumer(this);

                        // BodyTag Support
                        XMLConsumer backup = this.currentConsumer;
                        if (tag instanceof BodyTag) {
                            SaxBuffer content = new SaxBuffer();
                            this.currentConsumer = content;
                            ((BodyTag)tag).setBodyContent(new BodyContent(content, backup));
                            ((BodyTag)tag).doInitBody();
                        }

                        do {
                            xmlDeserializer.deserialize(saxFragment);
                        } while (iterTag.doAfterBody() != Tag.SKIP_BODY);

                        // BodyTag Support
                        if (tag instanceof BodyTag) {
                            this.currentConsumer = backup;
                        }

                    } catch (ServiceException e) {
                        throw new SAXException("Can't obtain XMLDeserializer", e);
                    } finally {
                        if (xmlDeserializer != null) {
                            manager.release(xmlDeserializer);
                        }
                    }
                }
                tag.doEndTag(namespaceURI, localName, qName);
                currentTag = tag.getParent();

                if (tag == this.currentConsumer) {
                    popConsumer();
                }
            } finally {
View Full Code Here

    /**
     * Find previous XML consumer when processing of current consumer
     * is complete.
     */
    private void popConsumer() {
        Tag loop = this.currentTag;
        for (; loop != null; loop = loop.getParent()) {
            if (loop instanceof XMLConsumer) {
                this.currentConsumer = (XMLConsumer) loop;
                return;
            }
        }
View Full Code Here

    /**
     *
     */
    public static UIComponentTag findParentUIComponentTag(Tag tag) {
        Tag parent = tag;
        do {
            parent = parent.getParent();
        } while (parent != null && !(parent instanceof UIComponentTag));

        return (UIComponentTag) parent;
    }
View Full Code Here

TOP

Related Classes of org.apache.cocoon.taglib.Tag

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.