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