KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tapestry > services > DataSqueezer


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 import java.io.IOException JavaDoc;
18
19 import org.apache.hivemind.ClassResolver;
20 import org.apache.tapestry.util.io.ISqueezeAdaptor;
21
22 /**
23  * Lightweight serialization used to encode values into strings that are stored
24  * in query parameters and hidden fields.
25  *
26  * @author Howard Lewis Ship
27  * @since 4.0
28  */

29 public interface DataSqueezer
30 {
31     /**
32      * Squeezes the data object into a String by locating an appropriate adaptor
33      * that can perform the conversion. data may be null.
34      */

35     public String JavaDoc squeeze(Object JavaDoc data) throws IOException JavaDoc;
36
37     /**
38      * A convenience; invokes {@link #squeeze(Object)}for each element in the
39      * data array. If data is null, returns null.
40      */

41     public String JavaDoc[] squeeze(Object JavaDoc[] data) throws IOException JavaDoc;
42
43     /**
44      * Unsqueezes the string. Note that in a special case, where the first
45      * character of the string is not a recognized prefix, it is assumed that
46      * the string is simply a string, and returned with no change.
47      */

48     public Object JavaDoc unsqueeze(String JavaDoc string) throws IOException JavaDoc;
49
50     /**
51      * Convenience method for unsqueezing many strings (back into objects).
52      * <p>
53      * If strings is null, returns null.
54      */

55     public Object JavaDoc[] unsqueeze(String JavaDoc[] strings) throws IOException JavaDoc;
56
57     /**
58      * Registers the adaptor with one or more single-character prefixes.
59      *
60      * @param prefix
61      * one or more characters, each of which will be a prefix for the
62      * adaptor.
63      * @param dataClass
64      * the class (or interface) which can be encoded by the adaptor.
65      * @param adaptor
66      * the adaptor which to be registered.
67      * @deprecated registration is changing as DataSqueezer evolves into a
68      * service.
69      */

70
71     /**
72      * @deprecated as DataSqueezer evolves into a service.
73      */

74     public void register(String JavaDoc prefix, Class JavaDoc dataClass, ISqueezeAdaptor adaptor);
75
76     public ClassResolver getResolver();
77 }
Popular Tags