001    // Copyright 2006 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    package org.apache.tapestry.services;
015    
016    /**
017     * @author James Carman
018     */
019    public interface DataSqueezerFilter {
020    
021        /**
022         * Optionally squeezes the data object into a String.
023         * 
024         * @param data the data to squeeze
025         * @param dataSqueezer the next squeezer in the pipeline
026         * 
027         * @return the string representation
028         */
029        String squeeze(Object data, DataSqueezer dataSqueezer);
030    
031        /**
032         * A convenience; invokes {@link #squeeze(Object, DataSqueezer)}for each element in the
033         * data array. If data is null, returns null.
034         * 
035         * @param data the data to squeeze
036         * @param dataSqueezer the next squeezer in the pipeline
037         * 
038         * @return the string representation
039         */
040        String[] squeeze(Object[] data, DataSqueezer dataSqueezer);
041    
042        /**
043         * Unsqueezes the string. Note that in a special case, where the first
044         * character of the string is not a recognized prefix, it is assumed that
045         * the string is simply a string, and returned with no change.
046         * 
047         * @param string the string representation of the data
048         * @param dataSqueezer the next squeezer in the pipeline
049         * 
050         * @return the unsqueezed data object
051         */
052        Object unsqueeze(String string, DataSqueezer dataSqueezer);
053    
054        /**
055         * Convenience method for unsqueezing many strings (back into objects).
056         * <p>
057         * If strings is null, returns null.
058         * </p>
059         * @param strings the string representation of the data
060         * @param dataSqueezer the next squeezer in the pipeline
061         *
062         * @return the unsqueezed data object
063         */
064        Object[] unsqueeze(String[] strings, DataSqueezer dataSqueezer);
065    }