Coverage Report - org.apache.tapestry.services.DataSqueezer
 
Classes in this File Line Coverage Branch Coverage Complexity
DataSqueezer
N/A
N/A
1
 
 1  
 // Copyright 2004, 2005 The Apache Software Foundation
 2  
 //
 3  
 // Licensed under the Apache License, Version 2.0 (the "License");
 4  
 // you may not use this file except in compliance with the License.
 5  
 // You may obtain a copy of the License at
 6  
 //
 7  
 //     http://www.apache.org/licenses/LICENSE-2.0
 8  
 //
 9  
 // Unless required by applicable law or agreed to in writing, software
 10  
 // distributed under the License is distributed on an "AS IS" BASIS,
 11  
 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 12  
 // See the License for the specific language governing permissions and
 13  
 // limitations under the License.
 14  
 
 15  
 package org.apache.tapestry.services;
 16  
 
 17  
 /**
 18  
  * Lightweight serialization used to encode values into strings that are stored in query parameters
 19  
  * and hidden fields.
 20  
  */
 21  
 public interface DataSqueezer
 22  
 {
 23  
     /**
 24  
      * Squeezes the data object into a String by locating an appropriate adaptor that can perform
 25  
      * the conversion. data may be null.
 26  
      *
 27  
      * @param data
 28  
      *          The object to squeeze.
 29  
      *
 30  
      * @return The string equivalent of the data in "squeezed" form.
 31  
      */
 32  
     String squeeze(Object data);
 33  
 
 34  
     /**
 35  
      * A convenience; invokes {@link #squeeze(Object)} for each element in the data array. If data
 36  
      * is null, returns null.
 37  
      *
 38  
      * @param data
 39  
      *          Array of objects to squeeze.
 40  
      *
 41  
      * @return Squeezed string array.
 42  
      */
 43  
     String[] squeeze(Object[] data);
 44  
 
 45  
     /**
 46  
      * Unsqueezes the string. Note that in a special case, where the first character of the string
 47  
      * is not a recognized prefix, it is assumed that the string is simply a string, and returned
 48  
      * with no change.
 49  
      *
 50  
      * @param string
 51  
      *          The data to unsqueeze.
 52  
      *
 53  
      * @return The object representation of the data - theoretically matching the object
 54  
      *          passed in via {@link #squeeze(Object)}. 
 55  
      */
 56  
     Object unsqueeze(String string);
 57  
 
 58  
     /**
 59  
      * Convenience method for unsqueezing many strings (back into objects).
 60  
      * <p>
 61  
      * If strings is null, returns null.
 62  
      * </p>
 63  
      *
 64  
      * @param strings
 65  
      *          The string data array to unsqueeze.
 66  
      *
 67  
      * @return The data in its object form, as was passed in to {@link #squeeze(Object[])}. 
 68  
      */
 69  
     Object[] unsqueeze(String[] strings);
 70  
 }