001    // Copyright 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    
015    package org.apache.tapestry.markup;
016    
017    import java.io.PrintWriter;
018    
019    /**
020     * Filter used with {@link org.apache.tapestry.markup.MarkupWriterImpl}to determine how to convert
021     * the output into a format compatible with the content type. Typically, this means translating
022     * certain characters into escape codes (for example, in HTML, convert '<' to '&lt;'.
023     * <p>
024     * Implementations should be stateless and thread safe.
025     * 
026     * @author Howard M. Lewis Ship
027     * @since 4.0
028     */
029    public interface MarkupFilter
030    {
031        /**
032         * Print the value to the writer, escaping characters as necessary.
033         * 
034         * @param writer
035         *            the write to which converted content should be output
036         * @param data
037         *            a character array containing the characters to be output
038         * @param offset
039         *            the offset within the array to begin output
040         * @param length
041         *            the number of characters to output
042         * @param escapeQuotes
043         *            if true, the value is being rendered as an attribute value and double quotes
044         *            within the value should be escaped. If false, then then double quotes may pass
045         *            through unchanged.
046         */
047    
048        public void print(PrintWriter writer, char[] data, int offset, int length, boolean escapeQuotes);
049    
050    }