    001// Copyright 2013 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.services;
    016
    017import org.apache.tapestry5.http.services.Dispatcher;
    018
    019/**
    020 * Central location for logic related to building client-side paths, taking into account
    021 * the context path (if any), and the {@link org.apache.tapestry5.SymbolConstants#APPLICATION_FOLDER}
    022 * (if any).
    023 *
    024 * @since 5.4
    025 */
    026public interface PathConstructor
    027{
    028    /**
    029     * Constructs a client path, the path portion of an absolute URL. The result consists of the
    030     * the context path (if any), the application folder (if any), then the series of terms.
    031     *
    032     * @param terms
    033     *         additional terms (folder names, or a file name) following the context path and application folder.
    034     * @return the full path, starting with a leading slash, and including the context path, application folder, and the terms,
    035     *         all seperated with slashes
    036     */
    037    String constructClientPath(String... terms);
    038
    039    /**
    040     * Constructs the dispatch path, which is like the client path, but omits the context path; this aligns
    041     * the result with the value returned from {@link org.apache.tapestry5.http.services.Request#getPath()}, and is used
    042     * in code, typically {@link Dispatcher} implementations, that are attempting to route based on the incoming request path.
    043     *
    044     * @param terms
    045     *         additional terms (folder names, or a file name) following the context path and application folder.
    046     * @return path string starting with a leading slash, and including the application folder (if any) and the individual terms,
    047     *         seperated by slashes
    048     */
    049    String constructDispatchPath(String... terms);
    050}