    001// Copyright 2006, 2007, 2008, 2009 The Apache Software Foundation
    002//
    003// Licensed under the Apache License, Version 2.0 (the "License");
    004// you may not use this file except in compliance with the License.
    005// You may obtain a copy of the License at
    006//
    007//     http://www.apache.org/licenses/LICENSE-2.0
    008//
    009// Unless required by applicable law or agreed to in writing, software
    010// distributed under the License is distributed on an "AS IS" BASIS,
    011// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    012// See the License for the specific language governing permissions and
    013// limitations under the License.
    014
    015package org.apache.tapestry5.internal.services;
    016
    017import org.apache.tapestry5.Binding;
    018import org.apache.tapestry5.ComponentResources;
    019import org.apache.tapestry5.commons.Location;
    020import org.apache.tapestry5.internal.parser.AttributeToken;
    021import org.apache.tapestry5.internal.parser.ExpansionToken;
    022import org.apache.tapestry5.runtime.RenderCommand;
    023import org.apache.tapestry5.services.BindingSource;
    024
    025/**
    026 * Used by the {@link org.apache.tapestry5.internal.services.PageLoader} to create partialar page elements. This has
    027 * evolved and focused to mostly concern bindings and expansions.
    028 */
    029public interface PageElementFactory
    030{
    031    /**
    032     * Creates a RenderCommand for rendering an attribute, when the attribute contains expansions.
    033     *
    034     * @param componentResources identifies component
    035     * @param token              token containing value with expansions
    036     * @return render command to render the text with expansions expanded
    037     */
    038    RenderCommand newAttributeElement(ComponentResources componentResources, AttributeToken token);
    039
    040    /**
    041     * Converts an expansion token into a command that renders the expanded value.
    042     *
    043     * @param componentResources identifies the component
    044     * @param token              contains expansion expression
    045     * @return command to render expansion
    046     */
    047    RenderCommand newExpansionElement(ComponentResources componentResources, ExpansionToken token);
    048
    049    /**
    050     * Creates a new binding as with {@link BindingSource#newBinding(String, ComponentResources, ComponentResources,
    051     * String, String, Location)}. However, if the binding contains an expansion (i.e., <code>${...}</code>), then a
    052     * binding that returns the fully expanded expression will be returned.
    053     */
    054    Binding newBinding(String parameterName, ComponentResources loadingComponentResources,
    055                       ComponentResources embeddedComponentResources, String defaultBindingPrefix, String expression,
    056                       Location location);
    057
    058}