001 // Copyright May 31, 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.data;
015
016 import org.apache.tapestry.services.DataSqueezer;
017 import org.apache.tapestry.services.DataSqueezerFilter;
018
019
020 /**
021 * A useful superclass for data squeezer filters. Subclasses only have
022 * to implement the single object versions of the squeeze/unsqueeze methods.
023 *
024 * @author jcarman
025 */
026 public abstract class AbstractDataSqueezerFilter implements DataSqueezerFilter
027 {
028
029 /**
030 * Merely calls squeeze(Object,DataSqueezer) on each object in
031 * the array.
032 */
033 public String[] squeeze( Object[] objects, DataSqueezer next )
034 {
035 final String[] squeezed = new String[objects.length];
036
037 for( int i = 0; i < squeezed.length; i++ ) {
038
039 squeezed[i] = squeeze( objects[i], next );
040 }
041
042 return squeezed;
043 }
044
045 /**
046 * Merely calls unsqueeze(String,DataSqueezer) on each object in
047 * the array.
048 */
049 public Object[] unsqueeze( String[] strings, DataSqueezer next )
050 {
051 final Object[] unsqueezed = new Object[strings.length];
052
053 for( int i = 0; i < unsqueezed.length; i++ ) {
054
055 unsqueezed[i] = unsqueeze( strings[i], next );
056 }
057
058 return unsqueezed;
059 }
060 }