001// Licensed under the Apache License, Version 2.0 (the "License");
002// you may not use this file except in compliance with the License.
003// You may obtain a copy of the License at
004//
005//     http://www.apache.org/licenses/LICENSE-2.0
006//
007// Unless required by applicable law or agreed to in writing, software
008// distributed under the License is distributed on an "AS IS" BASIS,
009// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
010// See the License for the specific language governing permissions and
011// limitations under the License.
012
013package org.apache.tapestry5.internal.parser;
014
015import java.util.List;
016import java.util.Map;
017
018import org.apache.tapestry5.commons.Location;
019import org.apache.tapestry5.commons.Resource;
020
021/**
022 * A parsed component template, containing all the tokens parsed from the template.
023 */
024public interface ComponentTemplate
025{
026    /**
027     * Returns true if no template could be found for the component.
028     */
029    boolean isMissing();
030
031    /**
032     * Returns true if this component template is an extension of its parent class' template.
033     *
034     * @since 5.1.0.1
035     */
036    boolean isExtension();
037
038    /**
039     * Indicates whether lax (the old default) or strict (the new default) mixin parameters are used.
040     * In strict mode, introduced with the 5.4 template DTD, mixin parameters must be qualified with the mixin name.
041     * In prior releases, Tapestry would attempt a search for a fit, and this causes ambiguities
042     * that can't be addressed.
043     *
044     * @since 5.4
045     * @return true if a 5.4 or later DTD
046     */
047    boolean usesStrictMixinParameters();
048
049    /**
050     * Returns a list of tokens associated with an extension point, or null if this template neither defines the
051     * extension point nor overrides it.
052     *
053     * @param extensionPointId
054     * @return list of tokens provided in this template, or null
055     * @since 5.1.0.1
056     */
057    List<TemplateToken> getExtensionPointTokens(String extensionPointId);
058
059    /**
060     * Returns the resource that was parsed to form the template.
061     */
062    Resource getResource();
063
064    /**
065     * Returns a list of tokens that were parsed from the template. The caller should not modify this list.
066     */
067    List<TemplateToken> getTokens();
068
069    /**
070     * Identifies     {@link org.apache.tapestry5.internal.parser.StartComponentToken}s with a non-blank id, mapping the
071     * id to its location (within the template). This is used to report unmatched ids (where the component, or its
072     * super-classes, do not define an embedded component).
073     *
074     * @see org.apache.tapestry5.annotations.Component (used to define an embedded component)
075     */
076    Map<String, Location> getComponentIds();
077}