001// Copyright 2004, 2005 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.tapestry.engine;
016
017/**
018 * Encapsulates the logic for encoding and decoding service requests.
019 * 
020 * @author Howard M. Lewis Ship
021 * @since 4.0
022 */
023public interface ServiceEncoder
024{
025    /**
026     * Invoked by the {@link org.apache.tapestry.services.LinkFactory} to encode the request.
027     * Encoding is the process of modifying the encoding object to represent the same data in a
028     * different format; the canoncial example is to replace the
029     * {@link org.apache.tapestry.services.ServiceConstants#PAGE}and
030     * {@link org.apache.tapestry.services.ServiceConstants#SERVICE}query parameters with a servlet
031     * path (i.e., "/Home.html", if the ".html" extension is mapped to the page service).
032     * <p>
033     * The {@link org.apache.tapestry.services.LinkFactory}&nbsp;iterates over a collection of
034     * encoders, stopping once the ServiceRequestEncoding is modified in any way.
035     */
036
037    public void encode(ServiceEncoding encoding);
038
039    /**
040     * Invoked to decode a request. The encoder is responsible for recognizing a request it may have
041     * encoded, and for restoring any query parameters is may have removed.
042     */
043
044    public void decode(ServiceEncoding encoding);
045}