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.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},1097019445706L);
    /**
     * 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[11114]++;CONVERSION_MAP.put("true", Boolean.TRUE);
        __CLOVER_225_0.S[11115]++;CONVERSION_MAP.put("t", Boolean.TRUE);
        __CLOVER_225_0.S[11116]++;CONVERSION_MAP.put("1", Boolean.TRUE);
        __CLOVER_225_0.S[11117]++;CONVERSION_MAP.put("y", Boolean.TRUE);
        __CLOVER_225_0.S[11118]++;CONVERSION_MAP.put("yes", Boolean.TRUE);
        __CLOVER_225_0.S[11119]++;CONVERSION_MAP.put("on", Boolean.TRUE);

        __CLOVER_225_0.S[11120]++;CONVERSION_MAP.put("false", Boolean.FALSE);
        __CLOVER_225_0.S[11121]++;CONVERSION_MAP.put("f", Boolean.FALSE);
        __CLOVER_225_0.S[11122]++;CONVERSION_MAP.put("0", Boolean.FALSE);
        __CLOVER_225_0.S[11123]++;CONVERSION_MAP.put("off", Boolean.FALSE);
        __CLOVER_225_0.S[11124]++;CONVERSION_MAP.put("no", Boolean.FALSE);
        __CLOVER_225_0.S[11125]++;CONVERSION_MAP.put("n", Boolean.FALSE);

        __CLOVER_225_0.S[11126]++;CONVERSION_MAP.put("none", BeanLifecycle.NONE);
        __CLOVER_225_0.S[11127]++;CONVERSION_MAP.put("request", BeanLifecycle.REQUEST);
        __CLOVER_225_0.S[11128]++;CONVERSION_MAP.put("page", BeanLifecycle.PAGE);
        __CLOVER_225_0.S[11129]++;CONVERSION_MAP.put("render", BeanLifecycle.RENDER);

        __CLOVER_225_0.S[11130]++;CONVERSION_MAP.put("in", Direction.IN);
        __CLOVER_225_0.S[11131]++;CONVERSION_MAP.put("form", Direction.FORM);
        __CLOVER_225_0.S[11132]++;CONVERSION_MAP.put("custom", Direction.CUSTOM);
        __CLOVER_225_0.S[11133]++;CONVERSION_MAP.put("auto", Direction.AUTO);

        __CLOVER_225_0.S[11134]++;_parserFactory.setNamespaceAware(false);
        __CLOVER_225_0.S[11135]++;_parserFactory.setValidating(true);
    }

    /**
     * This constructor is a convienience used by some tests.
     */
    public SpecificationParser(ClassResolver resolver)
    {
        this(resolver, new SpecFactory());__CLOVER_225_0.S[11136]++;try { __CLOVER_225_0.M[2755]++;
    } 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[11137]++;try { __CLOVER_225_0.M[2756]++;
    } finally { }}

    /**
     * The full constructor, used within Tapestry.
     */
    public SpecificationParser(ErrorHandler errorHandler, Log log, ClassResolver resolver,
            SpecFactory factory)
    {try { __CLOVER_225_0.M[2757]++;
        __CLOVER_225_0.S[11138]++;_errorHandler = errorHandler;
        __CLOVER_225_0.S[11139]++;_log = log;
        __CLOVER_225_0.S[11140]++;_resolver = resolver;
        __CLOVER_225_0.S[11141]++;_factory = factory;
    } finally { }}

    protected void begin(String elementName, Map attributes)
    {try { __CLOVER_225_0.M[2758]++;
        __CLOVER_225_0.S[11142]++;_elementName = elementName;
        __CLOVER_225_0.S[11143]++;_attributes = attributes;

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

                __CLOVER_225_0.S[11145]++;beginComponentSpecificationInitial();
                __CLOVER_225_0.S[11146]++;break;

            case STATE_PAGE_SPECIFICATION_INITIAL:

                __CLOVER_225_0.S[11147]++;beginPageSpecificationInitial();
                __CLOVER_225_0.S[11148]++;break;

            case STATE_APPLICATION_SPECIFICATION_INITIAL:

                __CLOVER_225_0.S[11149]++;beginApplicationSpecificationInitial();
                __CLOVER_225_0.S[11150]++;break;

            case STATE_LIBRARY_SPECIFICATION_INITIAL:

                __CLOVER_225_0.S[11151]++;beginLibrarySpecificationInitial();
                __CLOVER_225_0.S[11152]++;break;

            case STATE_COMPONENT_SPECIFICATION:

                __CLOVER_225_0.S[11153]++;beginComponentSpecification();
                __CLOVER_225_0.S[11154]++;break;

            case STATE_PAGE_SPECIFICATION:

                __CLOVER_225_0.S[11155]++;beginPageSpecification();
                __CLOVER_225_0.S[11156]++;break;

            case STATE_ALLOW_DESCRIPTION:

                __CLOVER_225_0.S[11157]++;beginAllowDescription();
                __CLOVER_225_0.S[11158]++;break;

            case STATE_ALLOW_PROPERTY:

                __CLOVER_225_0.S[11159]++;allowMetaData();
                __CLOVER_225_0.S[11160]++;break;

            case STATE_BEAN:

                __CLOVER_225_0.S[11161]++;beginBean();
                __CLOVER_225_0.S[11162]++;break;

            case STATE_COMPONENT:

                __CLOVER_225_0.S[11163]++;beginComponent();
                __CLOVER_225_0.S[11164]++;break;

            case STATE_LIBRARY_SPECIFICATION:

                __CLOVER_225_0.S[11165]++;beginLibrarySpecification();
                __CLOVER_225_0.S[11166]++;break;

            case STATE_EXTENSION:

                __CLOVER_225_0.S[11167]++;beginExtension();
                __CLOVER_225_0.S[11168]++;break;

            default:

                __CLOVER_225_0.S[11169]++;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[2759]++;
        __CLOVER_225_0.S[11170]++;if ((((_elementName.equals("description")) && (++__CLOVER_225_0.CT[1929] != 0)) || (++__CLOVER_225_0.CF[1929] == 0))){
        {
            __CLOVER_225_0.S[11171]++;enterDescription();
            __CLOVER_225_0.S[11172]++;return;
        }}

        __CLOVER_225_0.S[11173]++;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[2760]++;
        __CLOVER_225_0.S[11174]++;if ((((_DTD_3_1) && (++__CLOVER_225_0.CT[1930] != 0)) || (++__CLOVER_225_0.CF[1930] == 0))){
        {
            __CLOVER_225_0.S[11175]++;if ((((_elementName.equals("meta")) && (++__CLOVER_225_0.CT[1931] != 0)) || (++__CLOVER_225_0.CF[1931] == 0))){
            {
                __CLOVER_225_0.S[11176]++;enterMeta();
                __CLOVER_225_0.S[11177]++;return;
            }}
        }}
        else{ __CLOVER_225_0.S[11178]++;if ((((_elementName.equals("property")) && (++__CLOVER_225_0.CT[1932] != 0)) || (++__CLOVER_225_0.CF[1932] == 0))){
        {
            __CLOVER_225_0.S[11179]++;enterProperty_3_0();
            __CLOVER_225_0.S[11180]++;return;
        }}}

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

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

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

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

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

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

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

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

    private void beginBean()
    {try { __CLOVER_225_0.M[2762]++;
        __CLOVER_225_0.S[11191]++;if ((((_elementName.equals("set-property")) && (++__CLOVER_225_0.CT[1934] != 0)) || (++__CLOVER_225_0.CF[1934] == 0))){
        {
            __CLOVER_225_0.S[11192]++;enterSetProperty();
            __CLOVER_225_0.S[11193]++;return;
        }}

        __CLOVER_225_0.S[11194]++;if ((((_elementName.equals("set-message-property")) && (++__CLOVER_225_0.CT[1935] != 0)) || (++__CLOVER_225_0.CF[1935] == 0))){
        {
            __CLOVER_225_0.S[11195]++;enterSetMessage();
            __CLOVER_225_0.S[11196]++;return;
        }}

        __CLOVER_225_0.S[11197]++;if ((((_elementName.equals("description")) && (++__CLOVER_225_0.CT[1936] != 0)) || (++__CLOVER_225_0.CF[1936] == 0))){
        {
            __CLOVER_225_0.S[11198]++;enterDescription();
            __CLOVER_225_0.S[11199]++;return;
        }}

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

    private void beginComponent()
    {try { __CLOVER_225_0.M[2763]++;
        __CLOVER_225_0.S[11201]++;if ((((_elementName.equals("binding")) && (++__CLOVER_225_0.CT[1937] != 0)) || (++__CLOVER_225_0.CF[1937] == 0))){
        {
            __CLOVER_225_0.S[11202]++;enterBinding();
            __CLOVER_225_0.S[11203]++;return;
        }}

        // 3.0 DTD only
        __CLOVER_225_0.S[11204]++;if ((((_elementName.equals("static-binding")) && (++__CLOVER_225_0.CT[1938] != 0)) || (++__CLOVER_225_0.CF[1938] == 0))){
        {
            __CLOVER_225_0.S[11205]++;enterStaticBinding();
            __CLOVER_225_0.S[11206]++;return;
        }}

        // 3.0 DTD only
        __CLOVER_225_0.S[11207]++;if ((((_elementName.equals("message-binding")) && (++__CLOVER_225_0.CT[1939] != 0)) || (++__CLOVER_225_0.CF[1939] == 0))){
        {
            __CLOVER_225_0.S[11208]++;enterMessageBinding();
            __CLOVER_225_0.S[11209]++;return;
        }}

        // 3.0 DTD only
        __CLOVER_225_0.S[11210]++;if ((((_elementName.equals("inherited-binding")) && (++__CLOVER_225_0.CT[1940] != 0)) || (++__CLOVER_225_0.CF[1940] == 0))){
        {
            __CLOVER_225_0.S[11211]++;enterInheritedBinding();
            __CLOVER_225_0.S[11212]++;return;
        }}

        __CLOVER_225_0.S[11213]++;if ((((_elementName.equals("listener-binding")) && (++__CLOVER_225_0.CT[1941] != 0)) || (++__CLOVER_225_0.CF[1941] == 0))){
        {
            __CLOVER_225_0.S[11214]++;enterListenerBinding();
            __CLOVER_225_0.S[11215]++;return;
        }}

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

    private void beginComponentSpecification()
    {try { __CLOVER_225_0.M[2764]++;
        __CLOVER_225_0.S[11217]++;if ((((_elementName.equals("reserved-parameter")) && (++__CLOVER_225_0.CT[1942] != 0)) || (++__CLOVER_225_0.CF[1942] == 0))){
        {
            __CLOVER_225_0.S[11218]++;enterReservedParameter();
            __CLOVER_225_0.S[11219]++;return;
        }}

        __CLOVER_225_0.S[11220]++;if ((((_elementName.equals("parameter")) && (++__CLOVER_225_0.CT[1943] != 0)) || (++__CLOVER_225_0.CF[1943] == 0))){
        {
            __CLOVER_225_0.S[11221]++;enterParameter();
            __CLOVER_225_0.S[11222]++;return;
        }}

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

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

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

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

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

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

        __CLOVER_225_0.S[11229]++;if ((((className != null) && (++__CLOVER_225_0.CT[1944] != 0)) || (++__CLOVER_225_0.CF[1944] == 0))){
            __CLOVER_225_0.S[11230]++;cs.setComponentClassName(className);}

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

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

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

    private void beginExtension()
    {try { __CLOVER_225_0.M[2766]++;
        __CLOVER_225_0.S[11234]++;if ((((_elementName.equals("configure")) && (++__CLOVER_225_0.CT[1945] != 0)) || (++__CLOVER_225_0.CF[1945] == 0))){
        {
            __CLOVER_225_0.S[11235]++;enterConfigure();
            __CLOVER_225_0.S[11236]++;return;
        }}

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

    private void beginLibrarySpecification()
    {try { __CLOVER_225_0.M[2767]++;
        __CLOVER_225_0.S[11238]++;if ((((_elementName.equals("description")) && (++__CLOVER_225_0.CT[1946] != 0)) || (++__CLOVER_225_0.CF[1946] == 0))){
        {
            __CLOVER_225_0.S[11239]++;enterDescription();
            __CLOVER_225_0.S[11240]++;return;
        }}

        __CLOVER_225_0.S[11241]++;if ((((_elementName.equals("page")) && (++__CLOVER_225_0.CT[1947] != 0)) || (++__CLOVER_225_0.CF[1947] == 0))){
        {
            __CLOVER_225_0.S[11242]++;enterPage();
            __CLOVER_225_0.S[11243]++;return;
        }}

        __CLOVER_225_0.S[11244]++;if ((((_elementName.equals("component-type")) && (++__CLOVER_225_0.CT[1948] != 0)) || (++__CLOVER_225_0.CF[1948] == 0))){
        {
            __CLOVER_225_0.S[11245]++;enterComponentType();
            __CLOVER_225_0.S[11246]++;return;
        }}

        // Holdover from the 3.0 DTD, now ignored.

        __CLOVER_225_0.S[11247]++;if ((((_elementName.equals("service")) && (++__CLOVER_225_0.CT[1949] != 0)) || (++__CLOVER_225_0.CF[1949] == 0))){
        {
            __CLOVER_225_0.S[11248]++;enterService();
            __CLOVER_225_0.S[11249]++;return;
        }}

        __CLOVER_225_0.S[11250]++;if ((((_elementName.equals("library")) && (++__CLOVER_225_0.CT[1950] != 0)) || (++__CLOVER_225_0.CF[1950] == 0))){
        {
            __CLOVER_225_0.S[11251]++;enterLibrary();
            __CLOVER_225_0.S[11252]++;return;
        }}

        __CLOVER_225_0.S[11253]++;if ((((_elementName.equals("extension")) && (++__CLOVER_225_0.CT[1951] != 0)) || (++__CLOVER_225_0.CF[1951] == 0))){
        {
            __CLOVER_225_0.S[11254]++;enterExtension();
            __CLOVER_225_0.S[11255]++;return;
        }}

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

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

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

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

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

    private void beginPageSpecification()
    {try { __CLOVER_225_0.M[2769]++;
        __CLOVER_225_0.S[11261]++;if ((((_elementName.equals("component")) && (++__CLOVER_225_0.CT[1952] != 0)) || (++__CLOVER_225_0.CF[1952] == 0))){
        {
            __CLOVER_225_0.S[11262]++;enterComponent();
            __CLOVER_225_0.S[11263]++;return;
        }}

        __CLOVER_225_0.S[11264]++;if ((((_elementName.equals("bean")) && (++__CLOVER_225_0.CT[1953] != 0)) || (++__CLOVER_225_0.CF[1953] == 0))){
        {
            __CLOVER_225_0.S[11265]++;enterBean();
            __CLOVER_225_0.S[11266]++;return;
        }}

        __CLOVER_225_0.S[11267]++;if ((((_elementName.equals("property-specification")) && (++__CLOVER_225_0.CT[1954] != 0)) || (++__CLOVER_225_0.CF[1954] == 0))){
        {
            __CLOVER_225_0.S[11268]++;enterPropertySpecification();
            __CLOVER_225_0.S[11269]++;return;
        }}

        __CLOVER_225_0.S[11270]++;if ((((_elementName.equals("context-asset")) && (++__CLOVER_225_0.CT[1955] != 0)) || (++__CLOVER_225_0.CF[1955] == 0))){
        {
            __CLOVER_225_0.S[11271]++;enterContextAsset();
            __CLOVER_225_0.S[11272]++;return;
        }}

        __CLOVER_225_0.S[11273]++;if ((((_elementName.equals("private-asset")) && (++__CLOVER_225_0.CT[1956] != 0)) || (++__CLOVER_225_0.CF[1956] == 0))){
        {
            __CLOVER_225_0.S[11274]++;enterPrivateAsset();
            __CLOVER_225_0.S[11275]++;return;
        }}

        __CLOVER_225_0.S[11276]++;if ((((_elementName.equals("external-asset")) && (++__CLOVER_225_0.CT[1957] != 0)) || (++__CLOVER_225_0.CF[1957] == 0))){
        {
            __CLOVER_225_0.S[11277]++;enterExternalAsset();
            __CLOVER_225_0.S[11278]++;return;

        }}

        __CLOVER_225_0.S[11279]++;if ((((_elementName.equals("description")) && (++__CLOVER_225_0.CT[1958] != 0)) || (++__CLOVER_225_0.CF[1958] == 0))){
        {
            __CLOVER_225_0.S[11280]++;enterDescription();
            __CLOVER_225_0.S[11281]++;return;
        }}

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

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

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

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

        __CLOVER_225_0.S[11286]++;if ((((className != null) && (++__CLOVER_225_0.CT[1959] != 0)) || (++__CLOVER_225_0.CF[1959] == 0))){
            __CLOVER_225_0.S[11287]++;cs.setComponentClassName(className);}

        __CLOVER_225_0.S[11288]++;cs.setSpecificationLocation(getResource());
        __CLOVER_225_0.S[11289]++;cs.setPageSpecification(true);

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

        __CLOVER_225_0.S[11291]++;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[2771]++;
        __CLOVER_225_0.S[11292]++;try
        {
            __CLOVER_225_0.S[11293]++;if ((((stream != null) && (++__CLOVER_225_0.CT[1960] != 0)) || (++__CLOVER_225_0.CF[1960] == 0))){
                __CLOVER_225_0.S[11294]++;stream.close();}
        }
        catch (IOException ex)
        {
            // ignore
        }
    } finally { }}

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

        __CLOVER_225_0.S[11298]++;Iterator i = source.getBindingNames().iterator();
        __CLOVER_225_0.S[11299]++;while ((((i.hasNext()) && (++__CLOVER_225_0.CT[1962] != 0)) || (++__CLOVER_225_0.CF[1962] == 0))){
        {
            __CLOVER_225_0.S[11300]++;String bindingName = (String) i.next();
            __CLOVER_225_0.S[11301]++;IBindingSpecification binding = source.getBinding(bindingName);
            __CLOVER_225_0.S[11302]++;target.setBinding(bindingName, binding);
        }}

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

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

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

                __CLOVER_225_0.S[11306]++;endDescription();
                __CLOVER_225_0.S[11307]++;break;

            case STATE_META:

                __CLOVER_225_0.S[11308]++;endProperty();
                __CLOVER_225_0.S[11309]++;break;

            case STATE_SET_PROPERTY:

                __CLOVER_225_0.S[11310]++;endSetProperty();
                __CLOVER_225_0.S[11311]++;break;

            case STATE_BINDING_3_0:

                __CLOVER_225_0.S[11312]++;endBinding_3_0();
                __CLOVER_225_0.S[11313]++;break;

            case STATE_BINDING:

                __CLOVER_225_0.S[11314]++;endBinding();
                __CLOVER_225_0.S[11315]++;break;

            case STATE_LISTENER_BINDING:

                __CLOVER_225_0.S[11316]++;endListenerBinding();
                __CLOVER_225_0.S[11317]++;break;

            case STATE_STATIC_BINDING:

                __CLOVER_225_0.S[11318]++;endStaticBinding();
                __CLOVER_225_0.S[11319]++;break;

            case STATE_PROPERTY_SPECIFICATION:

                __CLOVER_225_0.S[11320]++;endPropertySpecification();
                __CLOVER_225_0.S[11321]++;break;

            case STATE_LIBRARY_SPECIFICATION:

                __CLOVER_225_0.S[11322]++;endLibrarySpecification();
                __CLOVER_225_0.S[11323]++;break;

            case STATE_CONFIGURE:

                __CLOVER_225_0.S[11324]++;endConfigure();
                __CLOVER_225_0.S[11325]++;break;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        __CLOVER_225_0.S[11341]++;spec.setResourceResolver(_resolver);
        __CLOVER_225_0.S[11342]++;spec.setSpecificationLocation(getResource());

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

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

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

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

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

        __CLOVER_225_0.S[11347]++;lbs.setValue(peekContent());
        __CLOVER_225_0.S[11348]++;lbs.setLocation(getLocation());

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        __CLOVER_225_0.S[11368]++;ia.setType(type);
        __CLOVER_225_0.S[11369]++;ia.setPath(path);

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

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

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

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

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

        __CLOVER_225_0.S[11377]++;bs.setClassName(className);
        __CLOVER_225_0.S[11378]++;bs.setLifecycle(lifecycle);

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

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

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

    private void enterBinding()
    {try { __CLOVER_225_0.M[2785]++;
        __CLOVER_225_0.S[11382]++;if ((((!_DTD_3_1) && (++__CLOVER_225_0.CT[1963] != 0)) || (++__CLOVER_225_0.CF[1963] == 0))){
        {
            __CLOVER_225_0.S[11383]++;enterBinding_3_0();
            __CLOVER_225_0.S[11384]++;return;
        }}

        // 3.1 stuff

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

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

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

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

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

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

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

        __CLOVER_225_0.S[11393]++;spec.setType(BindingType.PREFIXED);
        __CLOVER_225_0.S[11394]++;spec.setValue(value);

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

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

    private void enterBinding_3_0()
    {try { __CLOVER_225_0.M[2787]++;
        __CLOVER_225_0.S[11396]++;String name = getAttribute("name");
        __CLOVER_225_0.S[11397]++;String expression = getAttribute("expression");

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

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

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

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

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

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

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

        __CLOVER_225_0.S[11406]++;if ((((hasCopyOf) && (++__CLOVER_225_0.CT[1964] != 0)) || (++__CLOVER_225_0.CF[1964] == 0))){
        {
            __CLOVER_225_0.S[11407]++;if ((((Tapestry.isNonBlank(type)) && (++__CLOVER_225_0.CT[1965] != 0)) || (++__CLOVER_225_0.CF[1965] == 0))){
                __CLOVER_225_0.S[11408]++;throw new DocumentParseException(ParseMessages.bothTypeAndCopyOf(id),
                        getLocation(), null);}
        }}
        else{
        {
            __CLOVER_225_0.S[11409]++;if ((((Tapestry.isBlank(type)) && (++__CLOVER_225_0.CT[1966] != 0)) || (++__CLOVER_225_0.CF[1966] == 0))){
                __CLOVER_225_0.S[11410]++;throw new DocumentParseException(ParseMessages.missingTypeOrCopyOf(id),
                        getLocation(), null);}
        }}

        __CLOVER_225_0.S[11411]++;IContainedComponent cc = _factory.createContainedComponent();
        __CLOVER_225_0.S[11412]++;cc.setType(type);
        __CLOVER_225_0.S[11413]++;cc.setCopyOf(copyOf);
        __CLOVER_225_0.S[11414]++;cc.setInheritInformalParameters(inherit);

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        __CLOVER_225_0.S[11436]++;es.setClassName(className);
        __CLOVER_225_0.S[11437]++;es.setImmediate(immediate);

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

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

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

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

    private void enterInheritedBinding()
    {try { __CLOVER_225_0.M[2795]++;
        __CLOVER_225_0.S[11442]++;String name = getAttribute("name");
        __CLOVER_225_0.S[11443]++;String parameterName = getAttribute("parameter-name");

        __CLOVER_225_0.S[11444]++;IBindingSpecification bs = _factory.createBindingSpecification();
        __CLOVER_225_0.S[11445]++;bs.setType(BindingType.INHERITED);
        __CLOVER_225_0.S[11446]++;bs.setValue(parameterName);

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

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

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

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

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

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

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

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

    private void enterListenerBinding()
    {try { __CLOVER_225_0.M[2797]++;
        __CLOVER_225_0.S[11457]++;String name = getAttribute("name");
        __CLOVER_225_0.S[11458]++;String language = getAttribute("language");

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

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

    private void enterMessageBinding()
    {try { __CLOVER_225_0.M[2798]++;
        __CLOVER_225_0.S[11462]++;String name = getAttribute("name");
        __CLOVER_225_0.S[11463]++;String key = getAttribute("key");

        __CLOVER_225_0.S[11464]++;IBindingSpecification bs = _factory.createBindingSpecification();
        __CLOVER_225_0.S[11465]++;bs.setType(BindingType.PREFIXED);
        __CLOVER_225_0.S[11466]++;bs.setValue("message:" + key);
        __CLOVER_225_0.S[11467]++;bs.setLocation(getLocation());

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

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

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

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

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

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

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

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

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

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

        __CLOVER_225_0.S[11479]++;if ((((propertyName == null) && (++__CLOVER_225_0.CT[1969] != 0)) || (++__CLOVER_225_0.CF[1969] == 0))){
            __CLOVER_225_0.S[11480]++;propertyName = name;}

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

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

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

        __CLOVER_225_0.S[11486]++;if ((((type != null) && (++__CLOVER_225_0.CT[1970] != 0)) || (++__CLOVER_225_0.CF[1970] == 0))){
            __CLOVER_225_0.S[11487]++;ps.setType(type);}

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

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

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

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

    private void enterMeta()
    {try { __CLOVER_225_0.M[2802]++;
        __CLOVER_225_0.S[11492]++;String key = getAttribute("key");
        __CLOVER_225_0.S[11493]++;String value = getAttribute("value");

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

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

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

    private void enterProperty_3_0()
    {try { __CLOVER_225_0.M[2803]++;
        __CLOVER_225_0.S[11496]++;String name = getAttribute("name");
        __CLOVER_225_0.S[11497]++;String value = getAttribute("value");

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

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

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

    private void enterPropertySpecification()
    {try { __CLOVER_225_0.M[2804]++;
        __CLOVER_225_0.S[11500]++;String name = getValidatedAttribute("name", PROPERTY_NAME_PATTERN, "invalid-property-name");
        __CLOVER_225_0.S[11501]++;String type = getAttribute("type");
        __CLOVER_225_0.S[11502]++;boolean persistent = getBooleanAttribute("persistent", false);
        __CLOVER_225_0.S[11503]++;String initialValue = getAttribute("initial-value");

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

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

        __CLOVER_225_0.S[11508]++;ps.setPersistent(persistent);
        __CLOVER_225_0.S[11509]++;ps.setInitialValue(initialValue);

        __CLOVER_225_0.S[11510]++;IComponentSpecification cs = (IComponentSpecification) peekObject();
        __CLOVER_225_0.S[11511]++;cs.addPropertySpecification(ps);

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

    private void enterReservedParameter()
    {try { __CLOVER_225_0.M[2805]++;
        __CLOVER_225_0.S[11513]++;String name = getAttribute("name");
        __CLOVER_225_0.S[11514]++;IComponentSpecification cs = (IComponentSpecification) peekObject();

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

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

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

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

    private void enterSetMessage()
    {try { __CLOVER_225_0.M[2807]++;
        __CLOVER_225_0.S[11519]++;String name = getAttribute("name");
        __CLOVER_225_0.S[11520]++;String key = getAttribute("key");

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

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

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

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

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

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

    private void enterSetProperty()
    {try { __CLOVER_225_0.M[2808]++;
        __CLOVER_225_0.S[11528]++;String name = getAttribute("name");
        __CLOVER_225_0.S[11529]++;String expression = getAttribute("expression");

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

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

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

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

    private void enterStaticBinding()
    {try { __CLOVER_225_0.M[2809]++;
        __CLOVER_225_0.S[11534]++;String name = getAttribute("name");
        __CLOVER_225_0.S[11535]++;String expression = getAttribute("value");

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

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

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

    private void expectElement(String elementName)
    {try { __CLOVER_225_0.M[2810]++;
        __CLOVER_225_0.S[11539]++;if ((((_elementName.equals(elementName)) && (++__CLOVER_225_0.CT[1972] != 0)) || (++__CLOVER_225_0.CF[1972] == 0))){
            __CLOVER_225_0.S[11540]++;return;}

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

    } finally { }}

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

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

        __CLOVER_225_0.S[11544]++;if ((((value == null) && (++__CLOVER_225_0.CT[1973] != 0)) || (++__CLOVER_225_0.CF[1973] == 0))){
            __CLOVER_225_0.S[11545]++;return defaultValue;}

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

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

        __CLOVER_225_0.S[11548]++;if ((((key == null) && (++__CLOVER_225_0.CT[1974] != 0)) || (++__CLOVER_225_0.CF[1974] == 0))){
            __CLOVER_225_0.S[11549]++;return defaultValue;}

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

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

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

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

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

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

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

        __CLOVER_225_0.S[11560]++;if ((((asAttribute) && (++__CLOVER_225_0.CT[1977] != 0)) || (++__CLOVER_225_0.CF[1977] == 0))){
            __CLOVER_225_0.S[11561]++;return attributeValue;}

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

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

        __CLOVER_225_0.S[11564]++;if ((((value == null) && (++__CLOVER_225_0.CT[1978] != 0)) || (++__CLOVER_225_0.CF[1978] == 0))){
            __CLOVER_225_0.S[11565]++;return null;}

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

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

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

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

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

        __CLOVER_225_0.S[11573]++;try
        {
            __CLOVER_225_0.S[11574]++;parseDocument();

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

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

        __CLOVER_225_0.S[11578]++;try
        {
            __CLOVER_225_0.S[11579]++;parseDocument();

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

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

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

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

        __CLOVER_225_0.S[11585]++;try
        {
            __CLOVER_225_0.S[11586]++;if ((((_parser == null) && (++__CLOVER_225_0.CT[1980] != 0)) || (++__CLOVER_225_0.CF[1980] == 0))){
                __CLOVER_225_0.S[11587]++;_parser = _parserFactory.newSAXParser();}

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

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

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

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

            __CLOVER_225_0.S[11594]++;stream.close();
            __CLOVER_225_0.S[11595]++;stream = null;

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

            __CLOVER_225_0.S[11598]++;throw new DocumentParseException(ParseMessages.errorReadingResource(resource, ex),
                    resource, ex);
        }
        finally
        {
            __CLOVER_225_0.S[11599]++;if ((((!success) && (++__CLOVER_225_0.CT[1982] != 0)) || (++__CLOVER_225_0.CF[1982] == 0))){
                __CLOVER_225_0.S[11600]++;_parser = null;}

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

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

        __CLOVER_225_0.S[11603]++;try
        {
            __CLOVER_225_0.S[11604]++;parseDocument();

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

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

        __CLOVER_225_0.S[11608]++;try
        {
            __CLOVER_225_0.S[11609]++;parseDocument();

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

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

        __CLOVER_225_0.S[11613]++;if ((((content == null) && (++__CLOVER_225_0.CT[1983] != 0)) || (++__CLOVER_225_0.CF[1983] == 0))){
            __CLOVER_225_0.S[11614]++;return null;}

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

    protected void resetParser()
    {try { __CLOVER_225_0.M[2824]++;
        __CLOVER_225_0.S[11616]++;_rootObject = null;
        __CLOVER_225_0.S[11617]++;_DTD_3_1 = false;

        __CLOVER_225_0.S[11618]++;_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[2825]++;
        __CLOVER_225_0.S[11619]++;if ((((TAPESTRY_DTD_3_1_PUBLIC_ID.equals(publicId)) && (++__CLOVER_225_0.CT[1984] != 0)) || (++__CLOVER_225_0.CF[1984] == 0))){
        {
            __CLOVER_225_0.S[11620]++;_DTD_3_1 = true;
            __CLOVER_225_0.S[11621]++;return getDTDInputSource("Tapestry_3_1.dtd");
        }}

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

        __CLOVER_225_0.S[11624]++;throw new DocumentParseException(ParseMessages.unknownPublicId(getResource(), publicId),
                getResource());
    } 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.