Package org.apache.tapestry.parse

Source Code of org.apache.tapestry.parse.SpecificationParser

/* $$ Clover has instrumented this file $$ */// Copyright 2004 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package org.apache.tapestry.parse;

import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hivemind.ClassResolver;
import org.apache.hivemind.ErrorHandler;
import org.apache.hivemind.Resource;
import org.apache.hivemind.impl.DefaultErrorHandler;
import org.apache.hivemind.parse.AbstractParser;
import org.apache.hivemind.util.PropertyUtils;
import org.apache.tapestry.INamespace;
import org.apache.tapestry.Tapestry;
import org.apache.tapestry.bean.IBeanInitializer;
import org.apache.tapestry.services.ExpressionEvaluator;
import org.apache.tapestry.spec.AssetType;
import org.apache.tapestry.spec.BeanLifecycle;
import org.apache.tapestry.spec.BindingType;
import org.apache.tapestry.spec.Direction;
import org.apache.tapestry.spec.IApplicationSpecification;
import org.apache.tapestry.spec.IAssetSpecification;
import org.apache.tapestry.spec.IBeanSpecification;
import org.apache.tapestry.spec.IBindingSpecification;
import org.apache.tapestry.spec.IComponentSpecification;
import org.apache.tapestry.spec.IContainedComponent;
import org.apache.tapestry.spec.IExtensionSpecification;
import org.apache.tapestry.spec.ILibrarySpecification;
import org.apache.tapestry.spec.IListenerBindingSpecification;
import org.apache.tapestry.spec.IParameterSpecification;
import org.apache.tapestry.spec.IPropertySpecification;
import org.apache.tapestry.spec.SpecFactory;
import org.apache.tapestry.util.IPropertyHolder;
import org.apache.tapestry.util.RegexpMatcher;
import org.apache.tapestry.util.xml.DocumentParseException;
import org.apache.tapestry.util.xml.InvalidStringException;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;

/**
* Parses the different types of Tapestry specifications.
* <p>
* Not threadsafe; it is the callers responsibility to ensure thread safety.
*
* @author Howard Lewis Ship
*/
public class SpecificationParser extends AbstractParser implements ISpecificationParser
{public static com.cortexeb.tools.clover.d __CLOVER_225_0 = com.cortexeb.tools.clover.aq.getRecorder(new char[] {67,58,92,119,111,114,107,115,112,97,99,101,92,106,97,107,97,114,116,97,45,116,97,112,101,115,116,114,121,92,102,114,97,109,101,119,111,114,107,92,116,97,114,103,101,116,92,99,108,111,118,101,114,45,100,98},1097439627296L);
    /**
     * Perl5 pattern for asset names. Letter, followed by letter, number or underscore. Also allows
     * the special "$template" value.
     *
     * @since 2.2
     */

    public static final String ASSET_NAME_PATTERN = "(\\$template)|("
            + Tapestry.SIMPLE_PROPERTY_NAME_PATTERN + ")";

    /**
     * Perl5 pattern for helper bean names. Letter, followed by letter, number or underscore.
     *
     * @since 2.2
     */

    public static final String BEAN_NAME_PATTERN = Tapestry.SIMPLE_PROPERTY_NAME_PATTERN;

    /**
     * Perl5 pattern for component alias. Letter, followed by letter, number, or underscore. This is
     * used to validate component types registered in the application or library specifications.
     *
     * @since 2.2
     */

    public static final String COMPONENT_ALIAS_PATTERN = Tapestry.SIMPLE_PROPERTY_NAME_PATTERN;

    /**
     * Perl5 pattern for component ids. Letter, followed by letter, number or underscore.
     *
     * @since 2.2
     */

    public static final String COMPONENT_ID_PATTERN = Tapestry.SIMPLE_PROPERTY_NAME_PATTERN;

    /**
     * Perl5 pattern for component types. Component types are an optional namespace prefix followed
     * by a normal identifier.
     *
     * @since 2.2
     */

    public static final String COMPONENT_TYPE_PATTERN = "^(_?[a-zA-Z]\\w*:)?[a-zA-Z_](\\w)*$";

    /**
     * We can share a single map for all the XML attribute to object conversions, since the keys are
     * unique.
     */

    private final Map CONVERSION_MAP = new HashMap();

    /**
     * Like modified property name, but allows periods in the name as well.
     *
     * @since 2.2
     */

    public static final String EXTENDED_PROPERTY_NAME_PATTERN = "^_?[a-zA-Z](\\w|-|\\.)*$";

    /**
     * Per5 pattern for extension names. Letter followed by letter, number, dash, period or
     * underscore.
     *
     * @since 2.2
     */

    public static final String EXTENSION_NAME_PATTERN = EXTENDED_PROPERTY_NAME_PATTERN;

    /**
     * Perl5 pattern for library ids. Letter followed by letter, number or underscore.
     *
     * @since 2.2
     */

    public static final String LIBRARY_ID_PATTERN = Tapestry.SIMPLE_PROPERTY_NAME_PATTERN;

    /** @since 3.1 */
    private final Log _log;

    /** @since 3.1 */
    private final ErrorHandler _errorHandler;

    /**
     * Set to true if parsing the 3.1 DTD.
     *
     * @since 3.1
     */

    private boolean _DTD_3_1;

    /**
     * Perl5 pattern for page names. Letter followed by letter, number, dash, underscore or period.
     *
     * @since 2.2
     */

    public static final String PAGE_NAME_PATTERN = EXTENDED_PROPERTY_NAME_PATTERN;

    /**
     * Perl5 pattern that parameter names must conform to. Letter, followed by letter, number or
     * underscore.
     *
     * @since 2.2
     */

    public static final String PARAMETER_NAME_PATTERN = Tapestry.SIMPLE_PROPERTY_NAME_PATTERN;

    /**
     * Perl5 pattern that property names (that can be connected to parameters) must conform to.
     * Letter, followed by letter, number or underscore.
     *
     * @since 2.2
     */

    public static final String PROPERTY_NAME_PATTERN = Tapestry.SIMPLE_PROPERTY_NAME_PATTERN;

    /**
     * Perl5 pattern for service names. Letter followed by letter, number, dash, underscore or
     * period.
     *
     * @since 2.2
     * @deprecated As of release 3.1, the &lt;service&gt; element (in 3.0 DTDs) is no longer
     *             supported.
     */

    public static final String SERVICE_NAME_PATTERN = EXTENDED_PROPERTY_NAME_PATTERN;

    private static final int STATE_ALLOW_DESCRIPTION = 2000;

    private static final int STATE_ALLOW_PROPERTY = 2001;

    private static final int STATE_APPLICATION_SPECIFICATION_INITIAL = 1002;

    private static final int STATE_BEAN = 4;

    /** Very different between 3.0 and 3.1 DTD */

    private static final int STATE_BINDING_3_0 = 7;

    /** @since 3.1 */

    private static final int STATE_BINDING = 100;

    private static final int STATE_COMPONENT = 6;

    private static final int STATE_COMPONENT_SPECIFICATION = 1;

    private static final int STATE_COMPONENT_SPECIFICATION_INITIAL = 1000;

    private static final int STATE_CONFIGURE = 14;

    private static final int STATE_DESCRIPTION = 2;

    private static final int STATE_EXTENSION = 13;

    private static final int STATE_LIBRARY_SPECIFICATION = 12;

    private static final int STATE_LIBRARY_SPECIFICATION_INITIAL = 1003;

    private static final int STATE_LISTENER_BINDING = 8;

    private static final int STATE_NO_CONTENT = 3000;

    private static final int STATE_PAGE_SPECIFICATION = 11;

    private static final int STATE_PAGE_SPECIFICATION_INITIAL = 1001;

    private static final int STATE_META = 3;

    private static final int STATE_PROPERTY_SPECIFICATION = 10;

    private static final int STATE_SET_PROPERTY = 5;

    /** 3.0 DTD only */
    private static final int STATE_STATIC_BINDING = 9;

    /** @since 3.0 */

    public static final String TAPESTRY_DTD_3_0_PUBLIC_ID = "-//Apache Software Foundation//Tapestry Specification 3.0//EN";

    /** @since 3.1 */

    public static final String TAPESTRY_DTD_3_1_PUBLIC_ID = "-//Apache Software Foundation//Tapestry Specification 3.1//EN";

    /**
     * The attributes of the current element, as a map (string keyed on string).
     */

    private Map _attributes;

    /**
     * The name of the current element.
     */

    private String _elementName;

    /** @since 1.0.9 */

    private final SpecFactory _factory;

    private RegexpMatcher _matcher = new RegexpMatcher();

    private SAXParser _parser;

    private SAXParserFactory _parserFactory = SAXParserFactory.newInstance();

    /**
     * @since 3.0
     */

    private final ClassResolver _resolver;

    /**
     * The root object parsed: a component or page specification, a library specification, or an
     * application specification.
     */
    private Object _rootObject;

    // Identify all the different acceptible values.
    // We continue to sneak by with a single map because
    // there aren't conflicts; when we have 'foo' meaning
    // different things in different places in the DTD, we'll
    // need multiple maps.

    {

        __CLOVER_225_0.S[12919]++;CONVERSION_MAP.put("true", Boolean.TRUE);
        __CLOVER_225_0.S[12920]++;CONVERSION_MAP.put("t", Boolean.TRUE);
        __CLOVER_225_0.S[12921]++;CONVERSION_MAP.put("1", Boolean.TRUE);
        __CLOVER_225_0.S[12922]++;CONVERSION_MAP.put("y", Boolean.TRUE);
        __CLOVER_225_0.S[12923]++;CONVERSION_MAP.put("yes", Boolean.TRUE);
        __CLOVER_225_0.S[12924]++;CONVERSION_MAP.put("on", Boolean.TRUE);

        __CLOVER_225_0.S[12925]++;CONVERSION_MAP.put("false", Boolean.FALSE);
        __CLOVER_225_0.S[12926]++;CONVERSION_MAP.put("f", Boolean.FALSE);
        __CLOVER_225_0.S[12927]++;CONVERSION_MAP.put("0", Boolean.FALSE);
        __CLOVER_225_0.S[12928]++;CONVERSION_MAP.put("off", Boolean.FALSE);
        __CLOVER_225_0.S[12929]++;CONVERSION_MAP.put("no", Boolean.FALSE);
        __CLOVER_225_0.S[12930]++;CONVERSION_MAP.put("n", Boolean.FALSE);

        __CLOVER_225_0.S[12931]++;CONVERSION_MAP.put("none", BeanLifecycle.NONE);
        __CLOVER_225_0.S[12932]++;CONVERSION_MAP.put("request", BeanLifecycle.REQUEST);
        __CLOVER_225_0.S[12933]++;CONVERSION_MAP.put("page", BeanLifecycle.PAGE);
        __CLOVER_225_0.S[12934]++;CONVERSION_MAP.put("render", BeanLifecycle.RENDER);

        __CLOVER_225_0.S[12935]++;CONVERSION_MAP.put("in", Direction.IN);
        __CLOVER_225_0.S[12936]++;CONVERSION_MAP.put("form", Direction.FORM);
        __CLOVER_225_0.S[12937]++;CONVERSION_MAP.put("custom", Direction.CUSTOM);
        __CLOVER_225_0.S[12938]++;CONVERSION_MAP.put("auto", Direction.AUTO);

        __CLOVER_225_0.S[12939]++;_parserFactory.setNamespaceAware(false);
        __CLOVER_225_0.S[12940]++;_parserFactory.setValidating(true);
    }

    /** @since 3.1 */
   
    private ExpressionEvaluator _expressionEvaluator;
   
    /**
     * This constructor is a convienience used by some tests.
     */
    public SpecificationParser(ClassResolver resolver)
    {
        this(resolver, new SpecFactory());__CLOVER_225_0.S[12941]++;try { __CLOVER_225_0.M[3109]++;
    } finally { }}

    /**
     * Create a new instance with resolver and a provided SpecFactory (used by Spindle).
     *
     * @deprecated to be removed in release 3.2
     */
    public SpecificationParser(ClassResolver resolver, SpecFactory factory)
    {
        this(new DefaultErrorHandler(), LogFactory.getLog(SpecificationParser.class), resolver,
                factory);__CLOVER_225_0.S[12942]++;try { __CLOVER_225_0.M[3110]++;
    } finally { }}

    /**
     * The full constructor, used within Tapestry.
     */
    public SpecificationParser(ErrorHandler errorHandler, Log log, ClassResolver resolver,
            SpecFactory factory)
    {try { __CLOVER_225_0.M[3111]++;
        __CLOVER_225_0.S[12943]++;_errorHandler = errorHandler;
        __CLOVER_225_0.S[12944]++;_log = log;
        __CLOVER_225_0.S[12945]++;_resolver = resolver;
        __CLOVER_225_0.S[12946]++;_factory = factory;
    } finally { }}

    protected void begin(String elementName, Map attributes)
    {try { __CLOVER_225_0.M[3112]++;
        __CLOVER_225_0.S[12947]++;_elementName = elementName;
        __CLOVER_225_0.S[12948]++;_attributes = attributes;

        __CLOVER_225_0.S[12949]++;switch (getState())
        {
            case STATE_COMPONENT_SPECIFICATION_INITIAL:

                __CLOVER_225_0.S[12950]++;beginComponentSpecificationInitial();
                __CLOVER_225_0.S[12951]++;break;

            case STATE_PAGE_SPECIFICATION_INITIAL:

                __CLOVER_225_0.S[12952]++;beginPageSpecificationInitial();
                __CLOVER_225_0.S[12953]++;break;

            case STATE_APPLICATION_SPECIFICATION_INITIAL:

                __CLOVER_225_0.S[12954]++;beginApplicationSpecificationInitial();
                __CLOVER_225_0.S[12955]++;break;

            case STATE_LIBRARY_SPECIFICATION_INITIAL:

                __CLOVER_225_0.S[12956]++;beginLibrarySpecificationInitial();
                __CLOVER_225_0.S[12957]++;break;

            case STATE_COMPONENT_SPECIFICATION:

                __CLOVER_225_0.S[12958]++;beginComponentSpecification();
                __CLOVER_225_0.S[12959]++;break;

            case STATE_PAGE_SPECIFICATION:

                __CLOVER_225_0.S[12960]++;beginPageSpecification();
                __CLOVER_225_0.S[12961]++;break;

            case STATE_ALLOW_DESCRIPTION:

                __CLOVER_225_0.S[12962]++;beginAllowDescription();
                __CLOVER_225_0.S[12963]++;break;

            case STATE_ALLOW_PROPERTY:

                __CLOVER_225_0.S[12964]++;allowMetaData();
                __CLOVER_225_0.S[12965]++;break;

            case STATE_BEAN:

                __CLOVER_225_0.S[12966]++;beginBean();
                __CLOVER_225_0.S[12967]++;break;

            case STATE_COMPONENT:

                __CLOVER_225_0.S[12968]++;beginComponent();
                __CLOVER_225_0.S[12969]++;break;

            case STATE_LIBRARY_SPECIFICATION:

                __CLOVER_225_0.S[12970]++;beginLibrarySpecification();
                __CLOVER_225_0.S[12971]++;break;

            case STATE_EXTENSION:

                __CLOVER_225_0.S[12972]++;beginExtension();
                __CLOVER_225_0.S[12973]++;break;

            default:

                __CLOVER_225_0.S[12974]++;unexpectedElement(_elementName);
        }
    } finally { }}

    /**
     * Special state for a number of specification types that can support the &lt;description&gt;
     * element.
     */

    private void beginAllowDescription()
    {try { __CLOVER_225_0.M[3113]++;
        __CLOVER_225_0.S[12975]++;if ((((_elementName.equals("description")) && (++__CLOVER_225_0.CT[2197] != 0)) || (++__CLOVER_225_0.CF[2197] == 0))){
        {
            __CLOVER_225_0.S[12976]++;enterDescription();
            __CLOVER_225_0.S[12977]++;return;
        }}

        __CLOVER_225_0.S[12978]++;unexpectedElement(_elementName);
    } finally { }}

    /**
     * Special state for a number of elements that can support the nested &lt;meta&gt; meta data
     * element (&lt;property&gt; in 3.0 DTD).
     */

    private void allowMetaData()
    {try { __CLOVER_225_0.M[3114]++;
        __CLOVER_225_0.S[12979]++;if ((((_DTD_3_1) && (++__CLOVER_225_0.CT[2198] != 0)) || (++__CLOVER_225_0.CF[2198] == 0))){
        {
            __CLOVER_225_0.S[12980]++;if ((((_elementName.equals("meta")) && (++__CLOVER_225_0.CT[2199] != 0)) || (++__CLOVER_225_0.CF[2199] == 0))){
            {
                __CLOVER_225_0.S[12981]++;enterMeta();
                __CLOVER_225_0.S[12982]++;return;
            }}
        }}
        else{ __CLOVER_225_0.S[12983]++;if ((((_elementName.equals("property")) && (++__CLOVER_225_0.CT[2200] != 0)) || (++__CLOVER_225_0.CF[2200] == 0))){
        {
            __CLOVER_225_0.S[12984]++;enterProperty_3_0();
            __CLOVER_225_0.S[12985]++;return;
        }}}

        __CLOVER_225_0.S[12986]++;unexpectedElement(_elementName);
    } finally { }}

    private void beginApplicationSpecificationInitial()
    {try { __CLOVER_225_0.M[3115]++;
        __CLOVER_225_0.S[12987]++;expectElement("application");

        __CLOVER_225_0.S[12988]++;String name = getAttribute("name");
        __CLOVER_225_0.S[12989]++;String engineClassName = getAttribute("engine-class");

        __CLOVER_225_0.S[12990]++;IApplicationSpecification as = _factory.createApplicationSpecification();

        __CLOVER_225_0.S[12991]++;as.setName(name);

        __CLOVER_225_0.S[12992]++;if ((((Tapestry.isNonBlank(engineClassName)) && (++__CLOVER_225_0.CT[2201] != 0)) || (++__CLOVER_225_0.CF[2201] == 0))){
            __CLOVER_225_0.S[12993]++;as.setEngineClassName(engineClassName);}

        __CLOVER_225_0.S[12994]++;_rootObject = as;

        __CLOVER_225_0.S[12995]++;push(_elementName, as, STATE_LIBRARY_SPECIFICATION);
    } finally { }}

    private void beginBean()
    {try { __CLOVER_225_0.M[3116]++;
        __CLOVER_225_0.S[12996]++;if ((((_elementName.equals("set-property")) && (++__CLOVER_225_0.CT[2202] != 0)) || (++__CLOVER_225_0.CF[2202] == 0))){
        {
            __CLOVER_225_0.S[12997]++;enterSetProperty();
            __CLOVER_225_0.S[12998]++;return;
        }}

        __CLOVER_225_0.S[12999]++;if ((((_elementName.equals("set-message-property")) && (++__CLOVER_225_0.CT[2203] != 0)) || (++__CLOVER_225_0.CF[2203] == 0))){
        {
            __CLOVER_225_0.S[13000]++;enterSetMessage();
            __CLOVER_225_0.S[13001]++;return;
        }}

        __CLOVER_225_0.S[13002]++;if ((((_elementName.equals("description")) && (++__CLOVER_225_0.CT[2204] != 0)) || (++__CLOVER_225_0.CF[2204] == 0))){
        {
            __CLOVER_225_0.S[13003]++;enterDescription();
            __CLOVER_225_0.S[13004]++;return;
        }}

        __CLOVER_225_0.S[13005]++;allowMetaData();
    } finally { }}

    private void beginComponent()
    {try { __CLOVER_225_0.M[3117]++;
        __CLOVER_225_0.S[13006]++;if ((((_elementName.equals("binding")) && (++__CLOVER_225_0.CT[2205] != 0)) || (++__CLOVER_225_0.CF[2205] == 0))){
        {
            __CLOVER_225_0.S[13007]++;enterBinding();
            __CLOVER_225_0.S[13008]++;return;
        }}

        // 3.0 DTD only
        __CLOVER_225_0.S[13009]++;if ((((_elementName.equals("static-binding")) && (++__CLOVER_225_0.CT[2206] != 0)) || (++__CLOVER_225_0.CF[2206] == 0))){
        {
            __CLOVER_225_0.S[13010]++;enterStaticBinding();
            __CLOVER_225_0.S[13011]++;return;
        }}

        // 3.0 DTD only
        __CLOVER_225_0.S[13012]++;if ((((_elementName.equals("message-binding")) && (++__CLOVER_225_0.CT[2207] != 0)) || (++__CLOVER_225_0.CF[2207] == 0))){
        {
            __CLOVER_225_0.S[13013]++;enterMessageBinding();
            __CLOVER_225_0.S[13014]++;return;
        }}

        // 3.0 DTD only
        __CLOVER_225_0.S[13015]++;if ((((_elementName.equals("inherited-binding")) && (++__CLOVER_225_0.CT[2208] != 0)) || (++__CLOVER_225_0.CF[2208] == 0))){
        {
            __CLOVER_225_0.S[13016]++;enterInheritedBinding();
            __CLOVER_225_0.S[13017]++;return;
        }}

        __CLOVER_225_0.S[13018]++;if ((((_elementName.equals("listener-binding")) && (++__CLOVER_225_0.CT[2209] != 0)) || (++__CLOVER_225_0.CF[2209] == 0))){
        {
            __CLOVER_225_0.S[13019]++;enterListenerBinding();
            __CLOVER_225_0.S[13020]++;return;
        }}

        __CLOVER_225_0.S[13021]++;allowMetaData();
    } finally { }}

    private void beginComponentSpecification()
    {try { __CLOVER_225_0.M[3118]++;
        __CLOVER_225_0.S[13022]++;if ((((_elementName.equals("reserved-parameter")) && (++__CLOVER_225_0.CT[2210] != 0)) || (++__CLOVER_225_0.CF[2210] == 0))){
        {
            __CLOVER_225_0.S[13023]++;enterReservedParameter();
            __CLOVER_225_0.S[13024]++;return;
        }}

        __CLOVER_225_0.S[13025]++;if ((((_elementName.equals("parameter")) && (++__CLOVER_225_0.CT[2211] != 0)) || (++__CLOVER_225_0.CF[2211] == 0))){
        {
            __CLOVER_225_0.S[13026]++;enterParameter();
            __CLOVER_225_0.S[13027]++;return;
        }}

        // The remainder are common to both <component-specification> and
        // <page-specification>

        __CLOVER_225_0.S[13028]++;beginPageSpecification();
    } finally { }}

    private void beginComponentSpecificationInitial()
    {try { __CLOVER_225_0.M[3119]++;
        __CLOVER_225_0.S[13029]++;expectElement("component-specification");

        __CLOVER_225_0.S[13030]++;IComponentSpecification cs = _factory.createComponentSpecification();

        __CLOVER_225_0.S[13031]++;cs.setAllowBody(getBooleanAttribute("allow-body", true));
        __CLOVER_225_0.S[13032]++;cs.setAllowInformalParameters(getBooleanAttribute("allow-informal-parameters", true));

        __CLOVER_225_0.S[13033]++;String className = getAttribute("class");

        __CLOVER_225_0.S[13034]++;if ((((className != null) && (++__CLOVER_225_0.CT[2212] != 0)) || (++__CLOVER_225_0.CF[2212] == 0))){
            __CLOVER_225_0.S[13035]++;cs.setComponentClassName(className);}

        __CLOVER_225_0.S[13036]++;cs.setSpecificationLocation(getResource());

        __CLOVER_225_0.S[13037]++;_rootObject = cs;

        __CLOVER_225_0.S[13038]++;push(_elementName, cs, STATE_COMPONENT_SPECIFICATION);
    } finally { }}

    private void beginExtension()
    {try { __CLOVER_225_0.M[3120]++;
        __CLOVER_225_0.S[13039]++;if ((((_elementName.equals("configure")) && (++__CLOVER_225_0.CT[2213] != 0)) || (++__CLOVER_225_0.CF[2213] == 0))){
        {
            __CLOVER_225_0.S[13040]++;enterConfigure();
            __CLOVER_225_0.S[13041]++;return;
        }}

        __CLOVER_225_0.S[13042]++;allowMetaData();
    } finally { }}

    private void beginLibrarySpecification()
    {try { __CLOVER_225_0.M[3121]++;
        __CLOVER_225_0.S[13043]++;if ((((_elementName.equals("description")) && (++__CLOVER_225_0.CT[2214] != 0)) || (++__CLOVER_225_0.CF[2214] == 0))){
        {
            __CLOVER_225_0.S[13044]++;enterDescription();
            __CLOVER_225_0.S[13045]++;return;
        }}

        __CLOVER_225_0.S[13046]++;if ((((_elementName.equals("page")) && (++__CLOVER_225_0.CT[2215] != 0)) || (++__CLOVER_225_0.CF[2215] == 0))){
        {
            __CLOVER_225_0.S[13047]++;enterPage();
            __CLOVER_225_0.S[13048]++;return;
        }}

        __CLOVER_225_0.S[13049]++;if ((((_elementName.equals("component-type")) && (++__CLOVER_225_0.CT[2216] != 0)) || (++__CLOVER_225_0.CF[2216] == 0))){
        {
            __CLOVER_225_0.S[13050]++;enterComponentType();
            __CLOVER_225_0.S[13051]++;return;
        }}

        // Holdover from the 3.0 DTD, now ignored.

        __CLOVER_225_0.S[13052]++;if ((((_elementName.equals("service")) && (++__CLOVER_225_0.CT[2217] != 0)) || (++__CLOVER_225_0.CF[2217] == 0))){
        {
            __CLOVER_225_0.S[13053]++;enterService();
            __CLOVER_225_0.S[13054]++;return;
        }}

        __CLOVER_225_0.S[13055]++;if ((((_elementName.equals("library")) && (++__CLOVER_225_0.CT[2218] != 0)) || (++__CLOVER_225_0.CF[2218] == 0))){
        {
            __CLOVER_225_0.S[13056]++;enterLibrary();
            __CLOVER_225_0.S[13057]++;return;
        }}

        __CLOVER_225_0.S[13058]++;if ((((_elementName.equals("extension")) && (++__CLOVER_225_0.CT[2219] != 0)) || (++__CLOVER_225_0.CF[2219] == 0))){
        {
            __CLOVER_225_0.S[13059]++;enterExtension();
            __CLOVER_225_0.S[13060]++;return;
        }}

        __CLOVER_225_0.S[13061]++;allowMetaData();
    } finally { }}

    private void beginLibrarySpecificationInitial()
    {try { __CLOVER_225_0.M[3122]++;
        __CLOVER_225_0.S[13062]++;expectElement("library-specification");

        __CLOVER_225_0.S[13063]++;ILibrarySpecification ls = _factory.createLibrarySpecification();

        __CLOVER_225_0.S[13064]++;_rootObject = ls;

        __CLOVER_225_0.S[13065]++;push(_elementName, ls, STATE_LIBRARY_SPECIFICATION);
    } finally { }}

    private void beginPageSpecification()
    {try { __CLOVER_225_0.M[3123]++;
        __CLOVER_225_0.S[13066]++;if ((((_elementName.equals("component")) && (++__CLOVER_225_0.CT[2220] != 0)) || (++__CLOVER_225_0.CF[2220] == 0))){
        {
            __CLOVER_225_0.S[13067]++;enterComponent();
            __CLOVER_225_0.S[13068]++;return;
        }}

        __CLOVER_225_0.S[13069]++;if ((((_elementName.equals("bean")) && (++__CLOVER_225_0.CT[2221] != 0)) || (++__CLOVER_225_0.CF[2221] == 0))){
        {
            __CLOVER_225_0.S[13070]++;enterBean();
            __CLOVER_225_0.S[13071]++;return;
        }}

        __CLOVER_225_0.S[13072]++;if ((((_elementName.equals("property-specification")) && (++__CLOVER_225_0.CT[2222] != 0)) || (++__CLOVER_225_0.CF[2222] == 0))){
        {
            __CLOVER_225_0.S[13073]++;enterPropertySpecification();
            __CLOVER_225_0.S[13074]++;return;
        }}

        __CLOVER_225_0.S[13075]++;if ((((_elementName.equals("context-asset")) && (++__CLOVER_225_0.CT[2223] != 0)) || (++__CLOVER_225_0.CF[2223] == 0))){
        {
            __CLOVER_225_0.S[13076]++;enterContextAsset();
            __CLOVER_225_0.S[13077]++;return;
        }}

        __CLOVER_225_0.S[13078]++;if ((((_elementName.equals("private-asset")) && (++__CLOVER_225_0.CT[2224] != 0)) || (++__CLOVER_225_0.CF[2224] == 0))){
        {
            __CLOVER_225_0.S[13079]++;enterPrivateAsset();
            __CLOVER_225_0.S[13080]++;return;
        }}

        __CLOVER_225_0.S[13081]++;if ((((_elementName.equals("external-asset")) && (++__CLOVER_225_0.CT[2225] != 0)) || (++__CLOVER_225_0.CF[2225] == 0))){
        {
            __CLOVER_225_0.S[13082]++;enterExternalAsset();
            __CLOVER_225_0.S[13083]++;return;

        }}

        __CLOVER_225_0.S[13084]++;if ((((_elementName.equals("description")) && (++__CLOVER_225_0.CT[2226] != 0)) || (++__CLOVER_225_0.CF[2226] == 0))){
        {
            __CLOVER_225_0.S[13085]++;enterDescription();
            __CLOVER_225_0.S[13086]++;return;
        }}

        __CLOVER_225_0.S[13087]++;allowMetaData();
    } finally { }}

    private void beginPageSpecificationInitial()
    {try { __CLOVER_225_0.M[3124]++;
        __CLOVER_225_0.S[13088]++;expectElement("page-specification");

        __CLOVER_225_0.S[13089]++;IComponentSpecification cs = _factory.createComponentSpecification();

        __CLOVER_225_0.S[13090]++;String className = getAttribute("class");

        __CLOVER_225_0.S[13091]++;if ((((className != null) && (++__CLOVER_225_0.CT[2227] != 0)) || (++__CLOVER_225_0.CF[2227] == 0))){
            __CLOVER_225_0.S[13092]++;cs.setComponentClassName(className);}

        __CLOVER_225_0.S[13093]++;cs.setSpecificationLocation(getResource());
        __CLOVER_225_0.S[13094]++;cs.setPageSpecification(true);

        __CLOVER_225_0.S[13095]++;_rootObject = cs;

        __CLOVER_225_0.S[13096]++;push(_elementName, cs, STATE_PAGE_SPECIFICATION);
    } finally { }}

    /**
     * Close a stream (if not null), ignoring any errors.
     */
    private void close(InputStream stream)
    {try { __CLOVER_225_0.M[3125]++;
        __CLOVER_225_0.S[13097]++;try
        {
            __CLOVER_225_0.S[13098]++;if ((((stream != null) && (++__CLOVER_225_0.CT[2228] != 0)) || (++__CLOVER_225_0.CF[2228] == 0))){
                __CLOVER_225_0.S[13099]++;stream.close();}
        }
        catch (IOException ex)
        {
            // ignore
        }
    } finally { }}

    private void copyBindings(String sourceComponentId, IComponentSpecification cs,
            IContainedComponent target)
    {try { __CLOVER_225_0.M[3126]++;
        __CLOVER_225_0.S[13100]++;IContainedComponent source = cs.getComponent(sourceComponentId);
        __CLOVER_225_0.S[13101]++;if ((((source == null) && (++__CLOVER_225_0.CT[2229] != 0)) || (++__CLOVER_225_0.CF[2229] == 0))){
            __CLOVER_225_0.S[13102]++;throw new DocumentParseException(ParseMessages.unableToCopy(sourceComponentId),
                    getLocation(), null);}

        __CLOVER_225_0.S[13103]++;Iterator i = source.getBindingNames().iterator();
        __CLOVER_225_0.S[13104]++;while ((((i.hasNext()) && (++__CLOVER_225_0.CT[2230] != 0)) || (++__CLOVER_225_0.CF[2230] == 0))){
        {
            __CLOVER_225_0.S[13105]++;String bindingName = (String) i.next();
            __CLOVER_225_0.S[13106]++;IBindingSpecification binding = source.getBinding(bindingName);
            __CLOVER_225_0.S[13107]++;target.setBinding(bindingName, binding);
        }}

        __CLOVER_225_0.S[13108]++;target.setType(source.getType());
    } finally { }}

    protected void end(String elementName)
    {try { __CLOVER_225_0.M[3127]++;
        __CLOVER_225_0.S[13109]++;_elementName = elementName;

        __CLOVER_225_0.S[13110]++;switch (getState())
        {
            case STATE_DESCRIPTION:

                __CLOVER_225_0.S[13111]++;endDescription();
                __CLOVER_225_0.S[13112]++;break;

            case STATE_META:

                __CLOVER_225_0.S[13113]++;endProperty();
                __CLOVER_225_0.S[13114]++;break;

            case STATE_SET_PROPERTY:

                __CLOVER_225_0.S[13115]++;endSetProperty();
                __CLOVER_225_0.S[13116]++;break;

            case STATE_BINDING_3_0:

                __CLOVER_225_0.S[13117]++;endBinding_3_0();
                __CLOVER_225_0.S[13118]++;break;

            case STATE_BINDING:

                __CLOVER_225_0.S[13119]++;endBinding();
                __CLOVER_225_0.S[13120]++;break;

            case STATE_LISTENER_BINDING:

                __CLOVER_225_0.S[13121]++;endListenerBinding();
                __CLOVER_225_0.S[13122]++;break;

            case STATE_STATIC_BINDING:

                __CLOVER_225_0.S[13123]++;endStaticBinding();
                __CLOVER_225_0.S[13124]++;break;

            case STATE_PROPERTY_SPECIFICATION:

                __CLOVER_225_0.S[13125]++;endPropertySpecification();
                __CLOVER_225_0.S[13126]++;break;

            case STATE_LIBRARY_SPECIFICATION:

                __CLOVER_225_0.S[13127]++;endLibrarySpecification();
                __CLOVER_225_0.S[13128]++;break;

            case STATE_CONFIGURE:

                __CLOVER_225_0.S[13129]++;endConfigure();
                __CLOVER_225_0.S[13130]++;break;

            default:
                __CLOVER_225_0.S[13131]++;break;
        }

        // Pop the top element of the stack and continue processing from there.

        __CLOVER_225_0.S[13132]++;pop();
    } finally { }}

    private void endBinding_3_0()
    {try { __CLOVER_225_0.M[3128]++;
        __CLOVER_225_0.S[13133]++;BindingSetter bs = (BindingSetter) peekObject();

        __CLOVER_225_0.S[13134]++;String expression = getExtendedValue(bs.getValue(), "expression", true);

        __CLOVER_225_0.S[13135]++;IBindingSpecification spec = _factory.createBindingSpecification();

        __CLOVER_225_0.S[13136]++;spec.setType(BindingType.PREFIXED);
        __CLOVER_225_0.S[13137]++;spec.setValue("ognl:" + expression);

        __CLOVER_225_0.S[13138]++;bs.apply(spec);
    } finally { }}

    private void endConfigure()
    {try { __CLOVER_225_0.M[3129]++;
        __CLOVER_225_0.S[13139]++;ExtensionConfigurationSetter setter = (ExtensionConfigurationSetter) peekObject();

        __CLOVER_225_0.S[13140]++;String finalValue = getExtendedValue(setter.getValue(), "value", true);

        __CLOVER_225_0.S[13141]++;setter.apply(finalValue);
    } finally { }}

    private void endDescription()
    {try { __CLOVER_225_0.M[3130]++;
        __CLOVER_225_0.S[13142]++;DescriptionSetter setter = (DescriptionSetter) peekObject();

        __CLOVER_225_0.S[13143]++;String description = peekContent();

        __CLOVER_225_0.S[13144]++;setter.apply(description);
    } finally { }}

    private void endLibrarySpecification()
    {try { __CLOVER_225_0.M[3131]++;
        __CLOVER_225_0.S[13145]++;ILibrarySpecification spec = (ILibrarySpecification) peekObject();

        __CLOVER_225_0.S[13146]++;spec.setResourceResolver(_resolver);
        __CLOVER_225_0.S[13147]++;spec.setSpecificationLocation(getResource());

        __CLOVER_225_0.S[13148]++;spec.instantiateImmediateExtensions();
    } finally { }}

    private void endListenerBinding()
    {try { __CLOVER_225_0.M[3132]++;
        __CLOVER_225_0.S[13149]++;BindingSetter bs = (BindingSetter) peekObject();

        __CLOVER_225_0.S[13150]++;IListenerBindingSpecification lbs = _factory.createListenerBindingSpecification();

        __CLOVER_225_0.S[13151]++;lbs.setLanguage(bs.getValue());

        // Do we need a check for no body content?

        __CLOVER_225_0.S[13152]++;lbs.setValue(peekContent());
        __CLOVER_225_0.S[13153]++;lbs.setLocation(getLocation());

        __CLOVER_225_0.S[13154]++;bs.apply(lbs);
    } finally { }}

    private void endProperty()
    {try { __CLOVER_225_0.M[3133]++;
        __CLOVER_225_0.S[13155]++;PropertyValueSetter pvs = (PropertyValueSetter) peekObject();

        __CLOVER_225_0.S[13156]++;String finalValue = getExtendedValue(pvs.getPropertyValue(), "value", true);

        __CLOVER_225_0.S[13157]++;pvs.applyValue(finalValue);
    } finally { }}

    private void endPropertySpecification()
    {try { __CLOVER_225_0.M[3134]++;
        __CLOVER_225_0.S[13158]++;IPropertySpecification ps = (IPropertySpecification) peekObject();

        __CLOVER_225_0.S[13159]++;String initialValue = getExtendedValue(ps.getInitialValue(), "initial-value", false);

        __CLOVER_225_0.S[13160]++;ps.setInitialValue(initialValue);
    } finally { }}

    private void endSetProperty()
    {try { __CLOVER_225_0.M[3135]++;
        __CLOVER_225_0.S[13161]++;BeanSetPropertySetter bs = (BeanSetPropertySetter) peekObject();

        __CLOVER_225_0.S[13162]++;String finalValue = getExtendedValue(bs.getExpression(), "expression", true);

        __CLOVER_225_0.S[13163]++;bs.applyExpression(finalValue);
    } finally { }}

    private void endStaticBinding()
    {try { __CLOVER_225_0.M[3136]++;
        __CLOVER_225_0.S[13164]++;BindingSetter bs = (BindingSetter) peekObject();

        __CLOVER_225_0.S[13165]++;String literalValue = getExtendedValue(bs.getValue(), "value", true);

        __CLOVER_225_0.S[13166]++;IBindingSpecification spec = _factory.createBindingSpecification();

        __CLOVER_225_0.S[13167]++;spec.setType(BindingType.PREFIXED);
        __CLOVER_225_0.S[13168]++;spec.setValue("literal:" + literalValue);

        __CLOVER_225_0.S[13169]++;bs.apply(spec);
    } finally { }}

    private void enterAsset(String pathAttributeName, AssetType type)
    {try { __CLOVER_225_0.M[3137]++;
        __CLOVER_225_0.S[13170]++;String name = getValidatedAttribute("name", ASSET_NAME_PATTERN, "invalid-asset-name");
        __CLOVER_225_0.S[13171]++;String path = getAttribute(pathAttributeName);

        __CLOVER_225_0.S[13172]++;IAssetSpecification ia = _factory.createAssetSpecification();

        __CLOVER_225_0.S[13173]++;ia.setType(type);
        __CLOVER_225_0.S[13174]++;ia.setPath(path);

        __CLOVER_225_0.S[13175]++;IComponentSpecification cs = (IComponentSpecification) peekObject();

        __CLOVER_225_0.S[13176]++;cs.addAsset(name, ia);

        __CLOVER_225_0.S[13177]++;push(_elementName, ia, STATE_ALLOW_PROPERTY);
    } finally { }}

    private void enterBean()
    {try { __CLOVER_225_0.M[3138]++;
        __CLOVER_225_0.S[13178]++;String name = getValidatedAttribute("name", BEAN_NAME_PATTERN, "invalid-bean-name");
        __CLOVER_225_0.S[13179]++;String className = getAttribute("class");
        __CLOVER_225_0.S[13180]++;BeanLifecycle lifecycle = (BeanLifecycle) getConvertedAttribute(
                "lifecycle",
                BeanLifecycle.REQUEST);

        __CLOVER_225_0.S[13181]++;IBeanSpecification bs = _factory.createBeanSpecification();

        __CLOVER_225_0.S[13182]++;bs.setClassName(className);
        __CLOVER_225_0.S[13183]++;bs.setLifecycle(lifecycle);

        __CLOVER_225_0.S[13184]++;IComponentSpecification cs = (IComponentSpecification) peekObject();

        __CLOVER_225_0.S[13185]++;cs.addBeanSpecification(name, bs);

        __CLOVER_225_0.S[13186]++;push(_elementName, bs, STATE_BEAN);
    } finally { }}

    private void enterBinding()
    {try { __CLOVER_225_0.M[3139]++;
        __CLOVER_225_0.S[13187]++;if ((((!_DTD_3_1) && (++__CLOVER_225_0.CT[2231] != 0)) || (++__CLOVER_225_0.CF[2231] == 0))){
        {
            __CLOVER_225_0.S[13188]++;enterBinding_3_0();
            __CLOVER_225_0.S[13189]++;return;
        }}

        // 3.1 stuff

        __CLOVER_225_0.S[13190]++;String name = getValidatedAttribute(
                "name",
                PARAMETER_NAME_PATTERN,
                "invalid-parameter-name");
        __CLOVER_225_0.S[13191]++;String value = getAttribute("value");

        __CLOVER_225_0.S[13192]++;IContainedComponent cc = (IContainedComponent) peekObject();

        __CLOVER_225_0.S[13193]++;BindingSetter bs = new BindingSetter(cc, name, value);

        __CLOVER_225_0.S[13194]++;push(_elementName, bs, STATE_BINDING, false);
    } finally { }}

    private void endBinding()
    {try { __CLOVER_225_0.M[3140]++;
        __CLOVER_225_0.S[13195]++;BindingSetter bs = (BindingSetter) peekObject();

        __CLOVER_225_0.S[13196]++;String value = getExtendedValue(bs.getValue(), "value", true);

        __CLOVER_225_0.S[13197]++;IBindingSpecification spec = _factory.createBindingSpecification();

        __CLOVER_225_0.S[13198]++;spec.setType(BindingType.PREFIXED);
        __CLOVER_225_0.S[13199]++;spec.setValue(value);

        __CLOVER_225_0.S[13200]++;bs.apply(spec);
    } finally { }}

    /**
     * Handles a binding in a 3.0 DTD.
     */

    private void enterBinding_3_0()
    {try { __CLOVER_225_0.M[3141]++;
        __CLOVER_225_0.S[13201]++;String name = getAttribute("name");
        __CLOVER_225_0.S[13202]++;String expression = getAttribute("expression");

        __CLOVER_225_0.S[13203]++;IContainedComponent cc = (IContainedComponent) peekObject();

        __CLOVER_225_0.S[13204]++;BindingSetter bs = new BindingSetter(cc, name, expression);

        __CLOVER_225_0.S[13205]++;push(_elementName, bs, STATE_BINDING_3_0, false);
    } finally { }}

    private void enterComponent()
    {try { __CLOVER_225_0.M[3142]++;
        __CLOVER_225_0.S[13206]++;String id = getValidatedAttribute("id", COMPONENT_ID_PATTERN, "invalid-component-id");

        __CLOVER_225_0.S[13207]++;String type = getValidatedAttribute(
                "type",
                COMPONENT_TYPE_PATTERN,
                "invalid-component-type");
        __CLOVER_225_0.S[13208]++;String copyOf = getAttribute("copy-of");
        __CLOVER_225_0.S[13209]++;boolean inherit = getBooleanAttribute("inherit-informal-parameters", false);

        // Check that either copy-of or type, but not both

        __CLOVER_225_0.S[13210]++;boolean hasCopyOf = Tapestry.isNonBlank(copyOf);

        __CLOVER_225_0.S[13211]++;if ((((hasCopyOf) && (++__CLOVER_225_0.CT[2232] != 0)) || (++__CLOVER_225_0.CF[2232] == 0))){
        {
            __CLOVER_225_0.S[13212]++;if ((((Tapestry.isNonBlank(type)) && (++__CLOVER_225_0.CT[2233] != 0)) || (++__CLOVER_225_0.CF[2233] == 0))){
                __CLOVER_225_0.S[13213]++;throw new DocumentParseException(ParseMessages.bothTypeAndCopyOf(id),
                        getLocation(), null);}
        }}
        else{
        {
            __CLOVER_225_0.S[13214]++;if ((((Tapestry.isBlank(type)) && (++__CLOVER_225_0.CT[2234] != 0)) || (++__CLOVER_225_0.CF[2234] == 0))){
                __CLOVER_225_0.S[13215]++;throw new DocumentParseException(ParseMessages.missingTypeOrCopyOf(id),
                        getLocation(), null);}
        }}

        __CLOVER_225_0.S[13216]++;IContainedComponent cc = _factory.createContainedComponent();
        __CLOVER_225_0.S[13217]++;cc.setType(type);
        __CLOVER_225_0.S[13218]++;cc.setCopyOf(copyOf);
        __CLOVER_225_0.S[13219]++;cc.setInheritInformalParameters(inherit);

        __CLOVER_225_0.S[13220]++;IComponentSpecification cs = (IComponentSpecification) peekObject();

        __CLOVER_225_0.S[13221]++;cs.addComponent(id, cc);

        __CLOVER_225_0.S[13222]++;if ((((hasCopyOf) && (++__CLOVER_225_0.CT[2235] != 0)) || (++__CLOVER_225_0.CF[2235] == 0))){
            __CLOVER_225_0.S[13223]++;copyBindings(copyOf, cs, cc);}

        __CLOVER_225_0.S[13224]++;push(_elementName, cc, STATE_COMPONENT);
    } finally { }}

    private void enterComponentType()
    {try { __CLOVER_225_0.M[3143]++;
        __CLOVER_225_0.S[13225]++;String type = getValidatedAttribute(
                "type",
                COMPONENT_ALIAS_PATTERN,
                "invalid-component-type");
        __CLOVER_225_0.S[13226]++;String path = getAttribute("specification-path");

        __CLOVER_225_0.S[13227]++;ILibrarySpecification ls = (ILibrarySpecification) peekObject();

        __CLOVER_225_0.S[13228]++;ls.setComponentSpecificationPath(type, path);

        __CLOVER_225_0.S[13229]++;push(_elementName, null, STATE_NO_CONTENT);
    } finally { }}

    private void enterConfigure()
    {try { __CLOVER_225_0.M[3144]++;
        __CLOVER_225_0.S[13230]++;String propertyName = getValidatedAttribute(
                "property-name",
                PROPERTY_NAME_PATTERN,
                "invalid-property-name");

        __CLOVER_225_0.S[13231]++;String value = getAttribute("value");

        __CLOVER_225_0.S[13232]++;IExtensionSpecification es = (IExtensionSpecification) peekObject();

        __CLOVER_225_0.S[13233]++;ExtensionConfigurationSetter setter = new ExtensionConfigurationSetter(es, propertyName,
                value);

        __CLOVER_225_0.S[13234]++;push(_elementName, setter, STATE_CONFIGURE, false);
    } finally { }}

    private void enterContextAsset()
    {try { __CLOVER_225_0.M[3145]++;
        __CLOVER_225_0.S[13235]++;enterAsset("path", AssetType.CONTEXT);
    } finally { }}

    private void enterDescription()
    {try { __CLOVER_225_0.M[3146]++;
        __CLOVER_225_0.S[13236]++;push(_elementName, new DescriptionSetter(peekObject()), STATE_DESCRIPTION, false);
    } finally { }}

    private void enterExtension()
    {try { __CLOVER_225_0.M[3147]++;
        __CLOVER_225_0.S[13237]++;String name = getValidatedAttribute(
                "name",
                EXTENSION_NAME_PATTERN,
                "invalid-extension-name");

        __CLOVER_225_0.S[13238]++;boolean immediate = getBooleanAttribute("immediate", false);
        __CLOVER_225_0.S[13239]++;String className = getAttribute("class");

        __CLOVER_225_0.S[13240]++;IExtensionSpecification es = _factory.createExtensionSpecification(_expressionEvaluator);

        __CLOVER_225_0.S[13241]++;es.setClassName(className);
        __CLOVER_225_0.S[13242]++;es.setImmediate(immediate);

        __CLOVER_225_0.S[13243]++;ILibrarySpecification ls = (ILibrarySpecification) peekObject();

        __CLOVER_225_0.S[13244]++;ls.addExtensionSpecification(name, es);

        __CLOVER_225_0.S[13245]++;push(_elementName, es, STATE_EXTENSION);
    } finally { }}

    private void enterExternalAsset()
    {try { __CLOVER_225_0.M[3148]++;
        __CLOVER_225_0.S[13246]++;enterAsset("URL", AssetType.EXTERNAL);
    } finally { }}

    private void enterInheritedBinding()
    {try { __CLOVER_225_0.M[3149]++;
        __CLOVER_225_0.S[13247]++;String name = getAttribute("name");
        __CLOVER_225_0.S[13248]++;String parameterName = getAttribute("parameter-name");

        __CLOVER_225_0.S[13249]++;IBindingSpecification bs = _factory.createBindingSpecification();
        __CLOVER_225_0.S[13250]++;bs.setType(BindingType.INHERITED);
        __CLOVER_225_0.S[13251]++;bs.setValue(parameterName);

        __CLOVER_225_0.S[13252]++;IContainedComponent cc = (IContainedComponent) peekObject();

        __CLOVER_225_0.S[13253]++;cc.setBinding(name, bs);

        __CLOVER_225_0.S[13254]++;push(_elementName, null, STATE_NO_CONTENT);
    } finally { }}

    private void enterLibrary()
    {try { __CLOVER_225_0.M[3150]++;
        __CLOVER_225_0.S[13255]++;String libraryId = getValidatedAttribute("id", LIBRARY_ID_PATTERN, "invalid-library-id");
        __CLOVER_225_0.S[13256]++;String path = getAttribute("specification-path");

        __CLOVER_225_0.S[13257]++;if ((((libraryId.equals(INamespace.FRAMEWORK_NAMESPACE)) && (++__CLOVER_225_0.CT[2236] != 0)) || (++__CLOVER_225_0.CF[2236] == 0))){
            __CLOVER_225_0.S[13258]++;throw new DocumentParseException(ParseMessages
                    .frameworkLibraryIdIsReserved(INamespace.FRAMEWORK_NAMESPACE), getLocation(),
                    null);}

        __CLOVER_225_0.S[13259]++;ILibrarySpecification ls = (ILibrarySpecification) peekObject();

        __CLOVER_225_0.S[13260]++;ls.setLibrarySpecificationPath(libraryId, path);

        __CLOVER_225_0.S[13261]++;push(_elementName, null, STATE_NO_CONTENT);
    } finally { }}

    private void enterListenerBinding()
    {try { __CLOVER_225_0.M[3151]++;
        __CLOVER_225_0.S[13262]++;String name = getAttribute("name");
        __CLOVER_225_0.S[13263]++;String language = getAttribute("language");

        __CLOVER_225_0.S[13264]++;IContainedComponent cc = (IContainedComponent) peekObject();
        __CLOVER_225_0.S[13265]++;BindingSetter bs = new BindingSetter(cc, name, language);

        __CLOVER_225_0.S[13266]++;push(_elementName, bs, STATE_LISTENER_BINDING, false);
    } finally { }}

    private void enterMessageBinding()
    {try { __CLOVER_225_0.M[3152]++;
        __CLOVER_225_0.S[13267]++;String name = getAttribute("name");
        __CLOVER_225_0.S[13268]++;String key = getAttribute("key");

        __CLOVER_225_0.S[13269]++;IBindingSpecification bs = _factory.createBindingSpecification();
        __CLOVER_225_0.S[13270]++;bs.setType(BindingType.PREFIXED);
        __CLOVER_225_0.S[13271]++;bs.setValue("message:" + key);
        __CLOVER_225_0.S[13272]++;bs.setLocation(getLocation());

        __CLOVER_225_0.S[13273]++;IContainedComponent cc = (IContainedComponent) peekObject();

        __CLOVER_225_0.S[13274]++;cc.setBinding(name, bs);

        __CLOVER_225_0.S[13275]++;push(_elementName, null, STATE_NO_CONTENT);
    } finally { }}

    private void enterPage()
    {try { __CLOVER_225_0.M[3153]++;
        __CLOVER_225_0.S[13276]++;String name = getValidatedAttribute("name", PAGE_NAME_PATTERN, "invalid-page-name");
        __CLOVER_225_0.S[13277]++;String path = getAttribute("specification-path");

        __CLOVER_225_0.S[13278]++;ILibrarySpecification ls = (ILibrarySpecification) peekObject();

        __CLOVER_225_0.S[13279]++;ls.setPageSpecificationPath(name, path);

        __CLOVER_225_0.S[13280]++;push(_elementName, null, STATE_NO_CONTENT);
    } finally { }}

    private void enterParameter()
    {try { __CLOVER_225_0.M[3154]++;
        __CLOVER_225_0.S[13281]++;IParameterSpecification ps = _factory.createParameterSpecification();

        __CLOVER_225_0.S[13282]++;String name = getValidatedAttribute(
                "name",
                PARAMETER_NAME_PATTERN,
                "invalid-parameter-name");

        __CLOVER_225_0.S[13283]++;String propertyName = getValidatedAttribute(
                "property-name",
                PROPERTY_NAME_PATTERN,
                "invalid-property-name");

        __CLOVER_225_0.S[13284]++;if ((((propertyName == null) && (++__CLOVER_225_0.CT[2237] != 0)) || (++__CLOVER_225_0.CF[2237] == 0))){
            __CLOVER_225_0.S[13285]++;propertyName = name;}

        __CLOVER_225_0.S[13286]++;ps.setPropertyName(propertyName);

        __CLOVER_225_0.S[13287]++;ps.setRequired(getBooleanAttribute("required", false));
        __CLOVER_225_0.S[13288]++;ps.setDefaultValue(getAttribute("default-value"));
        __CLOVER_225_0.S[13289]++;ps.setDirection((Direction) getConvertedAttribute("direction", Direction.CUSTOM));

        __CLOVER_225_0.S[13290]++;String type = getAttribute("type"); // Current, 3.0+ DTD

        __CLOVER_225_0.S[13291]++;if ((((type != null) && (++__CLOVER_225_0.CT[2238] != 0)) || (++__CLOVER_225_0.CF[2238] == 0))){
            __CLOVER_225_0.S[13292]++;ps.setType(type);}

        __CLOVER_225_0.S[13293]++;IComponentSpecification cs = (IComponentSpecification) peekObject();

        __CLOVER_225_0.S[13294]++;cs.addParameter(name, ps);

        __CLOVER_225_0.S[13295]++;push(_elementName, ps, STATE_ALLOW_DESCRIPTION);
    } finally { }}

    private void enterPrivateAsset()
    {try { __CLOVER_225_0.M[3155]++;
        __CLOVER_225_0.S[13296]++;enterAsset("resource-path", AssetType.PRIVATE);
    } finally { }}

    private void enterMeta()
    {try { __CLOVER_225_0.M[3156]++;
        __CLOVER_225_0.S[13297]++;String key = getAttribute("key");
        __CLOVER_225_0.S[13298]++;String value = getAttribute("value");

        // Value may be null, in which case the value is set from the element content

        __CLOVER_225_0.S[13299]++;IPropertyHolder ph = (IPropertyHolder) peekObject();

        __CLOVER_225_0.S[13300]++;push(_elementName, new PropertyValueSetter(ph, key, value), STATE_META, false);
    } finally { }}

    private void enterProperty_3_0()
    {try { __CLOVER_225_0.M[3157]++;
        __CLOVER_225_0.S[13301]++;String name = getAttribute("name");
        __CLOVER_225_0.S[13302]++;String value = getAttribute("value");

        // Value may be null, in which case the value is set from the element content

        __CLOVER_225_0.S[13303]++;IPropertyHolder ph = (IPropertyHolder) peekObject();

        __CLOVER_225_0.S[13304]++;push(_elementName, new PropertyValueSetter(ph, name, value), STATE_META, false);
    } finally { }}

    private void enterPropertySpecification()
    {try { __CLOVER_225_0.M[3158]++;
        __CLOVER_225_0.S[13305]++;String name = getValidatedAttribute("name", PROPERTY_NAME_PATTERN, "invalid-property-name");
        __CLOVER_225_0.S[13306]++;String type = getAttribute("type");
        __CLOVER_225_0.S[13307]++;boolean persistent = getBooleanAttribute("persistent", false);
        __CLOVER_225_0.S[13308]++;String initialValue = getAttribute("initial-value");

        __CLOVER_225_0.S[13309]++;IPropertySpecification ps = _factory.createPropertySpecification();
        __CLOVER_225_0.S[13310]++;ps.setName(name);

        __CLOVER_225_0.S[13311]++;if ((((Tapestry.isNonBlank(type)) && (++__CLOVER_225_0.CT[2239] != 0)) || (++__CLOVER_225_0.CF[2239] == 0))){
            __CLOVER_225_0.S[13312]++;ps.setType(type);}

        __CLOVER_225_0.S[13313]++;ps.setPersistent(persistent);
        __CLOVER_225_0.S[13314]++;ps.setInitialValue(initialValue);

        __CLOVER_225_0.S[13315]++;IComponentSpecification cs = (IComponentSpecification) peekObject();
        __CLOVER_225_0.S[13316]++;cs.addPropertySpecification(ps);

        __CLOVER_225_0.S[13317]++;push(_elementName, ps, STATE_PROPERTY_SPECIFICATION, false);
    } finally { }}

    private void enterReservedParameter()
    {try { __CLOVER_225_0.M[3159]++;
        __CLOVER_225_0.S[13318]++;String name = getAttribute("name");
        __CLOVER_225_0.S[13319]++;IComponentSpecification cs = (IComponentSpecification) peekObject();

        __CLOVER_225_0.S[13320]++;cs.addReservedParameterName(name);

        __CLOVER_225_0.S[13321]++;push(_elementName, null, STATE_NO_CONTENT);
    } finally { }}

    private void enterService()
    {try { __CLOVER_225_0.M[3160]++;
        __CLOVER_225_0.S[13322]++;_errorHandler.error(_log, ParseMessages.serviceElementNotSupported(), getLocation(), null);

        __CLOVER_225_0.S[13323]++;push(_elementName, null, STATE_NO_CONTENT);
    } finally { }}

    private void enterSetMessage()
    {try { __CLOVER_225_0.M[3161]++;
        __CLOVER_225_0.S[13324]++;String name = getAttribute("name");
        __CLOVER_225_0.S[13325]++;String key = getAttribute("key");

        __CLOVER_225_0.S[13326]++;IBeanInitializer bi = _factory.createMessageBeanInitializer();

        __CLOVER_225_0.S[13327]++;PropertyUtils.write(bi, "propertyName", name);
        __CLOVER_225_0.S[13328]++;PropertyUtils.write(bi, "key", key);

        __CLOVER_225_0.S[13329]++;bi.setLocation(getLocation());

        __CLOVER_225_0.S[13330]++;IBeanSpecification bs = (IBeanSpecification) peekObject();

        __CLOVER_225_0.S[13331]++;bs.addInitializer(bi);

        __CLOVER_225_0.S[13332]++;push(_elementName, null, STATE_NO_CONTENT);
    } finally { }}

    private void enterSetProperty()
    {try { __CLOVER_225_0.M[3162]++;
        __CLOVER_225_0.S[13333]++;String name = getAttribute("name");
        __CLOVER_225_0.S[13334]++;String expression = getAttribute("expression");

        __CLOVER_225_0.S[13335]++;IBeanInitializer bi = _factory.createExpressionBeanInitializer(_expressionEvaluator);

        __CLOVER_225_0.S[13336]++;PropertyUtils.write(bi, "propertyName", name);

        __CLOVER_225_0.S[13337]++;IBeanSpecification bs = (IBeanSpecification) peekObject();

        __CLOVER_225_0.S[13338]++;push(_elementName, new BeanSetPropertySetter(bs, bi, expression), STATE_SET_PROPERTY, false);
    } finally { }}

    private void enterStaticBinding()
    {try { __CLOVER_225_0.M[3163]++;
        __CLOVER_225_0.S[13339]++;String name = getAttribute("name");
        __CLOVER_225_0.S[13340]++;String expression = getAttribute("value");

        __CLOVER_225_0.S[13341]++;IContainedComponent cc = (IContainedComponent) peekObject();

        __CLOVER_225_0.S[13342]++;BindingSetter bs = new BindingSetter(cc, name, expression);

        __CLOVER_225_0.S[13343]++;push(_elementName, bs, STATE_STATIC_BINDING, false);
    } finally { }}

    private void expectElement(String elementName)
    {try { __CLOVER_225_0.M[3164]++;
        __CLOVER_225_0.S[13344]++;if ((((_elementName.equals(elementName)) && (++__CLOVER_225_0.CT[2240] != 0)) || (++__CLOVER_225_0.CF[2240] == 0))){
            __CLOVER_225_0.S[13345]++;return;}

        __CLOVER_225_0.S[13346]++;throw new DocumentParseException(ParseMessages.incorrectDocumentType(
                _elementName,
                elementName), getLocation(), null);

    } finally { }}

    private String getAttribute(String name)
    {try { __CLOVER_225_0.M[3165]++;
        __CLOVER_225_0.S[13347]++;return (String) _attributes.get(name);
    } finally { }}

    private boolean getBooleanAttribute(String name, boolean defaultValue)
    {try { __CLOVER_225_0.M[3166]++;
        __CLOVER_225_0.S[13348]++;String value = getAttribute(name);

        __CLOVER_225_0.S[13349]++;if ((((value == null) && (++__CLOVER_225_0.CT[2241] != 0)) || (++__CLOVER_225_0.CF[2241] == 0))){
            __CLOVER_225_0.S[13350]++;return defaultValue;}

        __CLOVER_225_0.S[13351]++;return value.equals("yes");
    } finally { }}

    private Object getConvertedAttribute(String name, Object defaultValue)
    {try { __CLOVER_225_0.M[3167]++;
        __CLOVER_225_0.S[13352]++;String key = getAttribute(name);

        __CLOVER_225_0.S[13353]++;if ((((key == null) && (++__CLOVER_225_0.CT[2242] != 0)) || (++__CLOVER_225_0.CF[2242] == 0))){
            __CLOVER_225_0.S[13354]++;return defaultValue;}

        __CLOVER_225_0.S[13355]++;return CONVERSION_MAP.get(key);
    } finally { }}

    private InputSource getDTDInputSource(String name)
    {try { __CLOVER_225_0.M[3168]++;
        __CLOVER_225_0.S[13356]++;InputStream stream = getClass().getResourceAsStream(name);

        __CLOVER_225_0.S[13357]++;return new InputSource(stream);
    } finally { }}

    private String getExtendedValue(String attributeValue, String attributeName, boolean required)
    {try { __CLOVER_225_0.M[3169]++;
        __CLOVER_225_0.S[13358]++;String contentValue = peekContent();

        __CLOVER_225_0.S[13359]++;boolean asAttribute = Tapestry.isNonBlank(attributeValue);
        __CLOVER_225_0.S[13360]++;boolean asContent = Tapestry.isNonBlank(contentValue);

        __CLOVER_225_0.S[13361]++;if ((((asAttribute && asContent) && (++__CLOVER_225_0.CT[2243] != 0)) || (++__CLOVER_225_0.CF[2243] == 0))){
        {
            __CLOVER_225_0.S[13362]++;throw new DocumentParseException(ParseMessages.noAttributeAndBody(
                    attributeName,
                    _elementName), getLocation(), null);
        }}

        __CLOVER_225_0.S[13363]++;if ((((required && !(asAttribute || asContent)) && (++__CLOVER_225_0.CT[2244] != 0)) || (++__CLOVER_225_0.CF[2244] == 0))){
        {
            __CLOVER_225_0.S[13364]++;throw new DocumentParseException(ParseMessages.requiredExtendedAttribute(
                    _elementName,
                    attributeName), getLocation(), null);
        }}

        __CLOVER_225_0.S[13365]++;if ((((asAttribute) && (++__CLOVER_225_0.CT[2245] != 0)) || (++__CLOVER_225_0.CF[2245] == 0))){
            __CLOVER_225_0.S[13366]++;return attributeValue;}

        __CLOVER_225_0.S[13367]++;return contentValue;
    } finally { }}

    private String getValidatedAttribute(String name, String pattern, String errorKey)
    {try { __CLOVER_225_0.M[3170]++;
        __CLOVER_225_0.S[13368]++;String value = getAttribute(name);

        __CLOVER_225_0.S[13369]++;if ((((value == null) && (++__CLOVER_225_0.CT[2246] != 0)) || (++__CLOVER_225_0.CF[2246] == 0))){
            __CLOVER_225_0.S[13370]++;return null;}

        __CLOVER_225_0.S[13371]++;if ((((_matcher.matches(pattern, value)) && (++__CLOVER_225_0.CT[2247] != 0)) || (++__CLOVER_225_0.CF[2247] == 0))){
            __CLOVER_225_0.S[13372]++;return value;}

        __CLOVER_225_0.S[13373]++;throw new InvalidStringException(ParseMessages.invalidAttribute(errorKey, value), value,
                getLocation());
    } finally { }}

    protected void initializeParser(Resource resource, int startState)
    {try { __CLOVER_225_0.M[3171]++;
        __CLOVER_225_0.S[13374]++;super.initializeParser(resource, startState);

        __CLOVER_225_0.S[13375]++;_rootObject = null;
        __CLOVER_225_0.S[13376]++;_attributes = new HashMap();
    } finally { }}

    public IApplicationSpecification parseApplicationSpecification(Resource resource)
    {try { __CLOVER_225_0.M[3172]++;
        __CLOVER_225_0.S[13377]++;initializeParser(resource, STATE_APPLICATION_SPECIFICATION_INITIAL);

        __CLOVER_225_0.S[13378]++;try
        {
            __CLOVER_225_0.S[13379]++;parseDocument();

            __CLOVER_225_0.S[13380]++;return (IApplicationSpecification) _rootObject;
        }
        finally
        {
            __CLOVER_225_0.S[13381]++;resetParser();
        }
    } finally { }}

    public IComponentSpecification parseComponentSpecification(Resource resource)
    {try { __CLOVER_225_0.M[3173]++;
        __CLOVER_225_0.S[13382]++;initializeParser(resource, STATE_COMPONENT_SPECIFICATION_INITIAL);

        __CLOVER_225_0.S[13383]++;try
        {
            __CLOVER_225_0.S[13384]++;parseDocument();

            __CLOVER_225_0.S[13385]++;return (IComponentSpecification) _rootObject;
        }
        finally
        {
            __CLOVER_225_0.S[13386]++;resetParser();
        }
    } finally { }}

    private void parseDocument()
    {try { __CLOVER_225_0.M[3174]++;
        __CLOVER_225_0.S[13387]++;InputStream stream = null;

        __CLOVER_225_0.S[13388]++;Resource resource = getResource();

        __CLOVER_225_0.S[13389]++;boolean success = false;

        __CLOVER_225_0.S[13390]++;try
        {
            __CLOVER_225_0.S[13391]++;if ((((_parser == null) && (++__CLOVER_225_0.CT[2248] != 0)) || (++__CLOVER_225_0.CF[2248] == 0))){
                __CLOVER_225_0.S[13392]++;_parser = _parserFactory.newSAXParser();}

            __CLOVER_225_0.S[13393]++;URL resourceURL = resource.getResourceURL();

            __CLOVER_225_0.S[13394]++;if ((((resourceURL == null) && (++__CLOVER_225_0.CT[2249] != 0)) || (++__CLOVER_225_0.CF[2249] == 0))){
                __CLOVER_225_0.S[13395]++;throw new DocumentParseException(ParseMessages.missingResource(resource), resource);}

            __CLOVER_225_0.S[13396]++;InputStream rawStream = resourceURL.openStream();
            __CLOVER_225_0.S[13397]++;stream = new BufferedInputStream(rawStream);

            __CLOVER_225_0.S[13398]++;_parser.parse(stream, this, resourceURL.toExternalForm());

            __CLOVER_225_0.S[13399]++;stream.close();
            __CLOVER_225_0.S[13400]++;stream = null;

            __CLOVER_225_0.S[13401]++;success = true;
        }
        catch (Exception ex)
        {
            __CLOVER_225_0.S[13402]++;_parser = null;

            __CLOVER_225_0.S[13403]++;throw new DocumentParseException(ParseMessages.errorReadingResource(resource, ex),
                    resource, ex);
        }
        finally
        {
            __CLOVER_225_0.S[13404]++;if ((((!success) && (++__CLOVER_225_0.CT[2250] != 0)) || (++__CLOVER_225_0.CF[2250] == 0))){
                __CLOVER_225_0.S[13405]++;_parser = null;}

            __CLOVER_225_0.S[13406]++;close(stream);
        }
    } finally { }}

    public ILibrarySpecification parseLibrarySpecification(Resource resource)
    {try { __CLOVER_225_0.M[3175]++;
        __CLOVER_225_0.S[13407]++;initializeParser(resource, STATE_LIBRARY_SPECIFICATION_INITIAL);

        __CLOVER_225_0.S[13408]++;try
        {
            __CLOVER_225_0.S[13409]++;parseDocument();

            __CLOVER_225_0.S[13410]++;return (ILibrarySpecification) _rootObject;
        }
        finally
        {
            __CLOVER_225_0.S[13411]++;resetParser();
        }
    } finally { }}

    public IComponentSpecification parsePageSpecification(Resource resource)
    {try { __CLOVER_225_0.M[3176]++;
        __CLOVER_225_0.S[13412]++;initializeParser(resource, STATE_PAGE_SPECIFICATION_INITIAL);

        __CLOVER_225_0.S[13413]++;try
        {
            __CLOVER_225_0.S[13414]++;parseDocument();

            __CLOVER_225_0.S[13415]++;return (IComponentSpecification) _rootObject;
        }
        finally
        {
            __CLOVER_225_0.S[13416]++;resetParser();
        }
    } finally { }}

    protected String peekContent()
    {try { __CLOVER_225_0.M[3177]++;
        __CLOVER_225_0.S[13417]++;String content = super.peekContent();

        __CLOVER_225_0.S[13418]++;if ((((content == null) && (++__CLOVER_225_0.CT[2251] != 0)) || (++__CLOVER_225_0.CF[2251] == 0))){
            __CLOVER_225_0.S[13419]++;return null;}

        __CLOVER_225_0.S[13420]++;return content.trim();
    } finally { }}

    protected void resetParser()
    {try { __CLOVER_225_0.M[3178]++;
        __CLOVER_225_0.S[13421]++;_rootObject = null;
        __CLOVER_225_0.S[13422]++;_DTD_3_1 = false;

        __CLOVER_225_0.S[13423]++;_attributes.clear();
    } finally { }}

    /**
     * Resolved an external entity, which is assumed to be the doctype. Might need a check to ensure
     * that specs without a doctype fail.
     */
    public InputSource resolveEntity(String publicId, String systemId) throws SAXException
    {try { __CLOVER_225_0.M[3179]++;
        __CLOVER_225_0.S[13424]++;if ((((TAPESTRY_DTD_3_1_PUBLIC_ID.equals(publicId)) && (++__CLOVER_225_0.CT[2252] != 0)) || (++__CLOVER_225_0.CF[2252] == 0))){
        {
            __CLOVER_225_0.S[13425]++;_DTD_3_1 = true;
            __CLOVER_225_0.S[13426]++;return getDTDInputSource("Tapestry_3_1.dtd");
        }}

        __CLOVER_225_0.S[13427]++;if ((((TAPESTRY_DTD_3_0_PUBLIC_ID.equals(publicId)) && (++__CLOVER_225_0.CT[2253] != 0)) || (++__CLOVER_225_0.CF[2253] == 0))){
            __CLOVER_225_0.S[13428]++;return getDTDInputSource("Tapestry_3_0.dtd");}

        __CLOVER_225_0.S[13429]++;throw new DocumentParseException(ParseMessages.unknownPublicId(getResource(), publicId),
                getResource());
    } finally { }}
   
    /** @since 3.1 */
    public void setExpressionEvaluator(ExpressionEvaluator expressionEvaluator)
    {try { __CLOVER_225_0.M[3180]++;
        __CLOVER_225_0.S[13430]++;_expressionEvaluator = expressionEvaluator;
    } finally { }}
}
TOP

Related Classes of org.apache.tapestry.parse.SpecificationParser

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.