Package org.apache.cocoon.el.parsing

Examples of org.apache.cocoon.el.parsing.Subst


            ObjectModel objectModel,
            ExecutionContext executionContext, MacroContext macroContext,
            NamespacesTable namespaces, Event startEvent, Event endEvent) throws SAXException {
        Iterator iter = getSubstitutions().iterator();
        while (iter.hasNext()) {
            Subst subst = (Subst) iter.next();
            char[] chars;
            if (subst instanceof Literal) {
                chars = ((Literal) subst).getCharArray();
                consumer.characters(chars, 0, chars.length);
            } else {
                Subst expr = (Subst) subst;
                try {
                    Object val = expr.getNode(objectModel);
                    Invoker.executeNode(consumer, val);
                } catch (Exception e) {
                    throw new SAXParseException(e.getMessage(), getLocation(), e);
                } catch (Error err) {
                    throw new SAXParseException(err.getMessage(), getLocation(), new ErrorHolder(err));
View Full Code Here


        // <import uri="${root}/foo/bar.xml" context="${foo}"/>
        Locator locator = getLocation();
        Iterator iter = raw.getAttributeEvents().iterator();
        AttributeEvent uri = null;
        Subst select = null;
        while (iter.hasNext()) {
            AttributeEvent e = (AttributeEvent) iter.next();
            if (e.getLocalName().equals("uri")) {
                uri = e;
                break;
View Full Code Here

        } else {
            StringBuffer buf = new StringBuffer();
            SubstituteAttribute substAttr = (SubstituteAttribute) e;
            Iterator i = substAttr.getSubstitutions().iterator();
            while (i.hasNext()) {
                Subst subst = (Subst) i.next();
                Object val;
                try {
                    val = subst.getValue(objectModel);
                } catch (Exception exc) {
                    throw new SAXParseException(exc.getMessage(), getLocation(), exc);
                } catch (Error err) {
                    throw new SAXParseException(err.getMessage(), getLocation(), new ErrorHolder(err));
                }
View Full Code Here

        super(raw);

        Locator locator = getLocation();
        String var = attrs.getValue("var");
        String value = attrs.getValue("value");
        Subst varExpr = null;
        Subst valueExpr = null;
        if (var != null) {
            varExpr = parsingContext.getStringTemplateParser().compileExpr(var, "set: \"var\":", locator);
        }
        if (value != null) {
            valueExpr = parsingContext.getStringTemplateParser().compileExpr(value, "set: \"value\":", locator);
View Full Code Here

    /**
     * @see org.apache.cocoon.caching.CacheableProcessingComponent#getKey()
     */
    public Serializable getKey() {
        Subst cacheKeyExpr = (Subst) this.startDocument
                .getTemplateProperty(JXTemplateGenerator.CACHE_KEY);
        if (cacheKeyExpr == null) {
            return null;
        }
        try {
            final Serializable templateKey = (Serializable) cacheKeyExpr.getValue(this.newObjectModel);
            if (templateKey != null) {
                return new JXCacheKey(this.startDocument.getUri(), templateKey);
            }
        } catch (Exception e) {
            getLogger().error("error evaluating cache key", e);
View Full Code Here

    /**
     * @see org.apache.cocoon.caching.CacheableProcessingComponent#getValidity()
     */
    public SourceValidity getValidity() {
        Subst validityExpr = (Subst) this.startDocument
                .getTemplateProperty(JXTemplateGenerator.VALIDITY);
        if (validityExpr == null) {
            return null;
        }
        try {
            final SourceValidity sourceValidity = this.startDocument.getSourceValidity();
            final SourceValidity templateValidity = (SourceValidity) validityExpr.getValue(this.newObjectModel);
            if (sourceValidity != null && templateValidity != null) {
                return new JXSourceValidity(sourceValidity, templateValidity);
            }
        } catch (Exception e) {
            getLogger().error("error evaluating cache validity", e);
View Full Code Here

            Object subst = iter.next();
            char[] chars;
            if (subst instanceof Literal) {
                chars = ((Literal) subst).getCharArray();
            } else {
                Subst expr = (Subst) subst;
                try {
                    Object val = expr.getValue(objectModel);
                    chars = val != null ? val.toString().toCharArray()
                            : ArrayUtils.EMPTY_CHAR_ARRAY;
                } catch (Exception e) {
                    throw new SAXParseException(e.getMessage(), event
                            .getLocation(), e);
View Full Code Here

        if (this.macro instanceof Define)
            return (Define) macro;

        Object macroName;
        Object namespace;
        Subst macroNameExpression = (Subst) macro;
        try {
            macroName = macroNameExpression.getValue(objectModel);
            namespace = targetNamespace.getValue(objectModel);
            if (namespace == null)
                namespace = "";
        } catch (Exception e) {
            throw new SAXParseException(e.getMessage(), getLocation(), e);
View Full Code Here

    public String toString(Locator location, ObjectModel objectModel) throws SAXException {
        StringBuffer buf = new StringBuffer();

        Iterator i = iterator();
        while (i.hasNext()) {
            Subst subst = (Subst) i.next();

            Object val;
            try {
                val = subst.getValue(objectModel);
            } catch (Exception e) {
                throw new SAXParseException(e.getMessage(), location, e);
            //FIXME: Don't catch java.lang.Error
            //} catch (Error err) {
            //    throw new SAXParseException(err.getMessage(), location, new ErrorHolder(err));
View Full Code Here

    /**
     * @see org.apache.cocoon.el.parsing.StringTemplateParser#compileBoolean(String, String, Locator)
     */
    public Subst compileBoolean(String val, String msg, Locator location) throws SAXException {
        Subst res = compileExpr(val, msg, location);
        if (res instanceof Literal) {
            res = new Literal(Boolean.valueOf(res.getRaw()));
        }

        return res;
    }
View Full Code Here

TOP

Related Classes of org.apache.cocoon.el.parsing.Subst

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.