Author: jkuhnert
Date: Mon May 28 11:21:34 2007
New Revision: 542288

URL: http://svn.apache.org/viewvc?view=rev&rev=542288
Log:
Fixes TAPESTRY-738.  Changed method/field modifiers to less restrictive 
"protected" level access so that people can more easily plug in to the existing 
infrastructure to provide their own implementation strategies for various 
persistence schemes.

Modified:
    
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/record/ClientPropertyPersistenceScope.java
    
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/record/ClientPropertyPersistenceStrategy.java
    
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/record/PersistentPropertyDataEncoder.java
    
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/record/PersistentPropertyDataEncoderImpl.java
    
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/DataSqueezer.java
    
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/DataSqueezerFilter.java
    
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/util/io/DataSqueezerImpl.java
    
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/util/io/SqueezeAdaptor.java

Modified: 
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/record/ClientPropertyPersistenceScope.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/record/ClientPropertyPersistenceScope.java?view=diff&rev=542288&r1=542287&r2=542288
==============================================================================
--- 
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/record/ClientPropertyPersistenceScope.java
 (original)
+++ 
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/record/ClientPropertyPersistenceScope.java
 Mon May 28 11:21:34 2007
@@ -19,7 +19,7 @@
 /**
  * Service tapestry.persist.ClientPropertyPersistenceScope. Determines whether 
a particular property
  * needs to be persisted or not.
- * 
+ *
  * @author Mindbridge
  * @since 4.0
  * @see org.apache.tapestry.record.ClientPropertyPersistenceStrategy
@@ -28,25 +28,25 @@
 {
     /**
      * Determines whether state should be encoded for the request.
-     * 
+     *
      * @param encoding
      *            identifies the service, URL and base set of parameters
      * @param pageName
      *            the page for which data is potentially to be encoded
      * @param data
+     *              The data to check.
      * @return true if state should be encoded into the encoding, false 
otherwise
      */
 
-    boolean shouldEncodeState(ServiceEncoding encoding, String pageName,
-            PersistentPropertyData data);
+    boolean shouldEncodeState(ServiceEncoding encoding, String pageName, 
PersistentPropertyData data);
 
     /**
      * Constructs a parameter name for a particular page name. The parameter 
name can be recognized
      * (in a later request) by the [EMAIL PROTECTED] 
#isParameterForScope(String)} method.
-     * 
+     *
      * @param pageName
      *            the name of the page for which a corresponding parameter 
name should be generated.
-     * @returns a query parameter name that identifies the page and this 
client persistence scope.
+     * @return a query parameter name that identifies the page and this client 
persistence scope.
      */
 
     String constructParameterName(String pageName);
@@ -54,7 +54,7 @@
     /**
      * Checks a parameter to see if it was the result of [EMAIL PROTECTED] 
#constructParameterName(String)} for
      * this persistence scope.
-     * 
+     *
      * @param parameterName
      *            a query parameter name
      * @return true if the parameterName was genereted (i.e., is properly 
prefixed) by this scope,
@@ -65,7 +65,7 @@
 
     /**
      * Extracts a page name from a query parameter name.
-     * 
+     *
      * @param parameterName
      *            the paramter name, for which [EMAIL PROTECTED] 
#isParameterForScope(String)} must return true
      * @return the name of the page

Modified: 
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/record/ClientPropertyPersistenceStrategy.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/record/ClientPropertyPersistenceStrategy.java?view=diff&rev=542288&r1=542287&r2=542288
==============================================================================
--- 
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/record/ClientPropertyPersistenceStrategy.java
 (original)
+++ 
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/record/ClientPropertyPersistenceStrategy.java
 Mon May 28 11:21:34 2007
@@ -14,17 +14,12 @@
 
 package org.apache.tapestry.record;
 
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-
 import org.apache.hivemind.util.Defense;
 import org.apache.tapestry.engine.ServiceEncoding;
 import org.apache.tapestry.web.WebRequest;
 
+import java.util.*;
+
 /**
  * Service tapestry.persist.ClientPropertyPersistenceStrategy. Encodes 
persistent page properties on
  * the client as query parameters.
@@ -41,13 +36,13 @@
      * Keyed on page name (String), values are
      * [EMAIL PROTECTED] org.apache.tapestry.record.PersistentPropertyData}.
      */
-    private final Map _data = new LinkedHashMap();
+    protected final Map _data = new LinkedHashMap();
 
-    private PersistentPropertyDataEncoder _encoder;
+    protected PersistentPropertyDataEncoder _encoder;
 
-    private WebRequest _request;
+    protected WebRequest _request;
 
-    private ClientPropertyPersistenceScope _scope;
+    protected ClientPropertyPersistenceScope _scope;
 
     /**
      * Initializer for this service, invoked every time a service instance is 
created. This

Modified: 
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/record/PersistentPropertyDataEncoder.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/record/PersistentPropertyDataEncoder.java?view=diff&rev=542288&r1=542287&r2=542288
==============================================================================
--- 
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/record/PersistentPropertyDataEncoder.java
 (original)
+++ 
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/record/PersistentPropertyDataEncoder.java
 Mon May 28 11:21:34 2007
@@ -29,14 +29,23 @@
     /**
      * Encodes a (possibly empty) list of [EMAIL PROTECTED] PropertyChange}s 
into a string
      * representation that can later be decoded.
+     *
+     * @param changes
+     *          List of changes to encode into a persistable form.
      * 
-     * @returns encoded string (possibly empty, but not null)
+     * @return encoded string (possibly empty, but not null)
      */
     String encodePageChanges(List changes);
 
     /**
      * Takes a string with an encoded set of page changes, and converts it back
      * into a list of [EMAIL PROTECTED] 
org.apache.tapestry.record.PropertyChange}s.
+     *
+     * @param encoded
+     *          The data to un-encode, which should be equivalent to the same 
that
+     *          was passed in to [EMAIL PROTECTED] 
#encodePageChanges(java.util.List)}.
+     * 
+     * @return The decoded page data.
      */
 
     List decodePageChanges(String encoded);

Modified: 
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/record/PersistentPropertyDataEncoderImpl.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/record/PersistentPropertyDataEncoderImpl.java?view=diff&rev=542288&r1=542287&r2=542288
==============================================================================
--- 
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/record/PersistentPropertyDataEncoderImpl.java
 (original)
+++ 
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/record/PersistentPropertyDataEncoderImpl.java
 Mon May 28 11:21:34 2007
@@ -14,21 +14,6 @@
 
 package org.apache.tapestry.record;
 
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-import java.util.zip.GZIPInputStream;
-import java.util.zip.GZIPOutputStream;
-
 import org.apache.commons.codec.binary.Base64;
 import org.apache.hivemind.ApplicationRuntimeException;
 import org.apache.hivemind.ClassResolver;
@@ -37,19 +22,24 @@
 import org.apache.tapestry.util.io.ResolvingObjectInputStream;
 import org.apache.tapestry.util.io.TeeOutputStream;
 
+import java.io.*;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.zip.GZIPInputStream;
+import java.util.zip.GZIPOutputStream;
+
 /**
  * Responsible for converting lists of [EMAIL PROTECTED] 
org.apache.tapestry.record.PropertyChange}s back and
  * forth to a URL safe encoded string.
- * <p>
+ * <p/>
  * A possible improvement would be to encode the binary data with encryption 
both on and off, and
  * select the shortest (prefixing with a character that identifies whether 
encryption should be used
  * to decode).
- * 
- * @author Howard M. Lewis Ship
- * @since 4.0
+ * </p>
  */
-public class PersistentPropertyDataEncoderImpl implements 
PersistentPropertyDataEncoder
-{
+public class PersistentPropertyDataEncoderImpl implements 
PersistentPropertyDataEncoder {
     /**
      * Prefix on the MIME encoding that indicates that the encoded data is not 
encoded.
      */
@@ -62,8 +52,8 @@
 
     public static final String GZIP_BYTESTREAM_PREFIX = "Z";
 
-    private ClassResolver _classResolver;
-    
+    protected ClassResolver _classResolver;
+
     public String encodePageChanges(List changes)
     {
         Defense.notNull(changes, "changes");
@@ -71,8 +61,7 @@
         if (changes.isEmpty())
             return "";
 
-        try
-        {
+        try {
             ByteArrayOutputStream bosPlain = new ByteArrayOutputStream();
             ByteArrayOutputStream bosCompressed = new ByteArrayOutputStream();
 
@@ -96,8 +85,7 @@
 
             return prefix + new String(encoded);
         }
-        catch (Exception ex)
-        {
+        catch (Exception ex) {
             throw new 
ApplicationRuntimeException(RecordMessages.encodeFailure(ex), ex);
         }
     }
@@ -112,8 +100,7 @@
         if (!(prefix.equals(BYTESTREAM_PREFIX) || 
prefix.equals(GZIP_BYTESTREAM_PREFIX)))
             throw new 
ApplicationRuntimeException(RecordMessages.unknownPrefix(prefix));
 
-        try
-        {
+        try {
             // Strip off the prefix, feed that in as a MIME stream.
 
             byte[] decoded = 
Base64.decodeBase64(encoded.substring(1).getBytes());
@@ -129,8 +116,7 @@
             // a time. We use a resolving object input stream that knows how 
to find
             // classes not normally acessible.
 
-            ObjectInputStream ois = new 
ResolvingObjectInputStream(_classResolver,
-                    new BufferedInputStream(is));
+            ObjectInputStream ois = new 
ResolvingObjectInputStream(_classResolver, new BufferedInputStream(is));
 
             List result = readChangesFromStream(ois);
 
@@ -138,19 +124,18 @@
 
             return result;
         }
-        catch (Exception ex)
-        {
+        catch (Exception ex) {
             throw new 
ApplicationRuntimeException(RecordMessages.decodeFailure(ex), ex);
         }
     }
 
-    private void writeChangesToStream(List changes, ObjectOutputStream oos) 
throws IOException
+    protected void writeChangesToStream(List changes, ObjectOutputStream oos)
+            throws IOException
     {
         oos.writeInt(changes.size());
 
         Iterator i = changes.iterator();
-        while (i.hasNext())
-        {
+        while (i.hasNext()) {
             PropertyChange pc = (PropertyChange) i.next();
 
             String componentPath = pc.getComponentPath();
@@ -163,20 +148,19 @@
                 oos.writeUTF(componentPath);
 
             oos.writeUTF(propertyName);
-            
+
             oos.writeObject(value);
         }
     }
 
-    private List readChangesFromStream(ObjectInputStream ois) throws 
IOException,
-            ClassNotFoundException
+    protected List readChangesFromStream(ObjectInputStream ois)
+            throws IOException, ClassNotFoundException
     {
         List result = new ArrayList();
 
         int count = ois.readInt();
 
-        for (int i = 0; i < count; i++)
-        {
+        for (int i = 0; i < count; i++) {
             boolean hasPath = ois.readBoolean();
             String componentPath = hasPath ? ois.readUTF() : null;
             String propertyName = ois.readUTF();

Modified: 
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/DataSqueezer.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/DataSqueezer.java?view=diff&rev=542288&r1=542287&r2=542288
==============================================================================
--- 
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/DataSqueezer.java
 (original)
+++ 
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/DataSqueezer.java
 Mon May 28 11:21:34 2007
@@ -17,21 +17,28 @@
 /**
  * Lightweight serialization used to encode values into strings that are 
stored in query parameters
  * and hidden fields.
- * 
- * @author Howard Lewis Ship
- * @since 4.0
  */
 public interface DataSqueezer
 {
     /**
      * Squeezes the data object into a String by locating an appropriate 
adaptor that can perform
      * the conversion. data may be null.
+     *
+     * @param data
+     *          The object to squeeze.
+     *
+     * @return The string equivalent of the data in "squeezed" form.
      */
     String squeeze(Object data);
 
     /**
-     * A convenience; invokes [EMAIL PROTECTED] #squeeze(Object)}for each 
element in the data array. If data
+     * A convenience; invokes [EMAIL PROTECTED] #squeeze(Object)} for each 
element in the data array. If data
      * is null, returns null.
+     *
+     * @param data
+     *          Array of objects to squeeze.
+     *
+     * @return Squeezed string array.
      */
     String[] squeeze(Object[] data);
 
@@ -39,6 +46,12 @@
      * Unsqueezes the string. Note that in a special case, where the first 
character of the string
      * is not a recognized prefix, it is assumed that the string is simply a 
string, and returned
      * with no change.
+     *
+     * @param string
+     *          The data to unsqueeze.
+     *
+     * @return The object representation of the data - theoretically matching 
the object
+     *          passed in via [EMAIL PROTECTED] #squeeze(Object)}. 
      */
     Object unsqueeze(String string);
 
@@ -46,6 +59,12 @@
      * Convenience method for unsqueezing many strings (back into objects).
      * <p>
      * If strings is null, returns null.
+     * </p>
+     *
+     * @param strings
+     *          The string data array to unsqueeze.
+     *
+     * @return The data in its object form, as was passed in to [EMAIL 
PROTECTED] #squeeze(Object[])}. 
      */
     Object[] unsqueeze(String[] strings);
 }

Modified: 
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/DataSqueezerFilter.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/DataSqueezerFilter.java?view=diff&rev=542288&r1=542287&r2=542288
==============================================================================
--- 
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/DataSqueezerFilter.java
 (original)
+++ 
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/services/DataSqueezerFilter.java
 Mon May 28 11:21:34 2007
@@ -20,8 +20,10 @@
 
     /**
      * Optionally squeezes the data object into a String.
+     * 
      * @param data the data to squeeze
      * @param dataSqueezer the next squeezer in the pipeline
+     * 
      * @return the string representation
      */
     String squeeze(Object data, DataSqueezer dataSqueezer);
@@ -29,8 +31,10 @@
     /**
      * A convenience; invokes [EMAIL PROTECTED] #squeeze(Object, 
DataSqueezer)}for each element in the
      * data array. If data is null, returns null.
+     * 
      * @param data the data to squeeze
      * @param dataSqueezer the next squeezer in the pipeline
+     * 
      * @return the string representation
      */
     String[] squeeze(Object[] data, DataSqueezer dataSqueezer);
@@ -39,8 +43,10 @@
      * Unsqueezes the string. Note that in a special case, where the first
      * character of the string is not a recognized prefix, it is assumed that
      * the string is simply a string, and returned with no change.
+     * 
      * @param string the string representation of the data
      * @param dataSqueezer the next squeezer in the pipeline
+     * 
      * @return the unsqueezed data object
      */
     Object unsqueeze(String string, DataSqueezer dataSqueezer);
@@ -49,8 +55,10 @@
      * Convenience method for unsqueezing many strings (back into objects).
      * <p>
      * If strings is null, returns null.
+     * </p>
      * @param strings the string representation of the data
      * @param dataSqueezer the next squeezer in the pipeline
+     *
      * @return the unsqueezed data object
      */
     Object[] unsqueeze(String[] strings, DataSqueezer dataSqueezer);

Modified: 
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/util/io/DataSqueezerImpl.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/util/io/DataSqueezerImpl.java?view=diff&rev=542288&r1=542287&r2=542288
==============================================================================
--- 
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/util/io/DataSqueezerImpl.java
 (original)
+++ 
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/util/io/DataSqueezerImpl.java
 Mon May 28 11:21:34 2007
@@ -14,14 +14,14 @@
 
 package org.apache.tapestry.util.io;
 
-import java.util.Iterator;
-import java.util.List;
-
 import org.apache.hivemind.lib.util.StrategyRegistry;
 import org.apache.hivemind.lib.util.StrategyRegistryImpl;
 import org.apache.tapestry.Tapestry;
 import org.apache.tapestry.services.DataSqueezer;
 
+import java.util.Iterator;
+import java.util.List;
+
 /**
  * A class used to convert arbitrary objects to Strings and back. This has 
particular uses involving
  * HTTP URLs and Cookies.
@@ -31,11 +31,11 @@
 
 public class DataSqueezerImpl implements DataSqueezer
 {
-    private static final String NULL_PREFIX = "X";
+    protected static final String NULL_PREFIX = "X";
 
-    private static final int ARRAY_SIZE = 90;
+    protected static final int ARRAY_SIZE = 90;
 
-    private static final int FIRST_ADAPTOR_OFFSET = 33;
+    protected static final int FIRST_ADAPTOR_OFFSET = 33;
 
     /**
      * An array of adaptors; this is used as a cheap lookup-table when 
unsqueezing. Each adaptor is
@@ -43,13 +43,13 @@
      * offset into this table is the character minus 33.
      */
 
-    private SqueezeAdaptor[] _adaptorByPrefix = new SqueezeAdaptor[ARRAY_SIZE];
+    protected SqueezeAdaptor[] _adaptorByPrefix = new 
SqueezeAdaptor[ARRAY_SIZE];
 
     /**
      * AdaptorRegistry cache of adaptors.
      */
 
-    private StrategyRegistry _adaptors = new StrategyRegistryImpl();
+    protected StrategyRegistry _adaptors = new StrategyRegistryImpl();
 
     public void setSqueezeAdaptors(List adaptors)
     {

Modified: 
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/util/io/SqueezeAdaptor.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/util/io/SqueezeAdaptor.java?view=diff&rev=542288&r1=542287&r2=542288
==============================================================================
--- 
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/util/io/SqueezeAdaptor.java
 (original)
+++ 
tapestry/tapestry4/trunk/tapestry-framework/src/java/org/apache/tapestry/util/io/SqueezeAdaptor.java
 Mon May 28 11:21:34 2007
@@ -30,25 +30,42 @@
 {
     /**
      * Returns one or more characters, each of which will be a prefix for this 
adaptor.
+     *
+     * @return The prefix for this squeezer.
      */
 
     String getPrefix();
 
     /**
      * Returns the class (or interface) which can be encoded by this adaptor.
+     *
+     * @return The class type that this adaptor can manage.
      */
 
     Class getDataClass();
 
     /**
      * Converts the data object into a String.
-     * 
+     *
+     * @param squeezer
+     *          The squeezer that should be used to ultimately squeeze the 
data.
+     * @param data
+     *          The data to squeeze.
+     *
+     * @return String representation of data.
      */
 
     String squeeze(DataSqueezer squeezer, Object data);
 
     /**
      * Converts a String back into an appropriate object.
+     *
+     * @param squeezer
+     *          The squeezer to use to unsqueeze the data.
+     * @param string
+     *          The string data - as was returned from [EMAIL PROTECTED] 
#squeeze(org.apache.tapestry.services.DataSqueezer, Object)}.
+     *
+     * @return The re-constituded object representation of the string.
      */
 
     Object unsqueeze(DataSqueezer squeezer, String string);


Reply via email to