Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
SqueezeAdaptor |
|
| 1.0;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.util.io; | |
16 | ||
17 | import org.apache.tapestry.services.DataSqueezer; | |
18 | ||
19 | /** | |
20 | * Interface which defines a class used to convert data for a specific Java type into a String | |
21 | * format (squeeze it), or convert from a String back into a Java type (unsqueeze). | |
22 | * <p> | |
23 | * This interface is somewhat misnamed; this is more of the GoF Strategy pattern than GoF Adaptor | |
24 | * pattern. | |
25 | * | |
26 | * @author Howard Lewis Ship | |
27 | */ | |
28 | ||
29 | public interface SqueezeAdaptor | |
30 | { | |
31 | /** | |
32 | * Returns one or more characters, each of which will be a prefix for this adaptor. | |
33 | * | |
34 | * @return The prefix for this squeezer. | |
35 | */ | |
36 | ||
37 | String getPrefix(); | |
38 | ||
39 | /** | |
40 | * Returns the class (or interface) which can be encoded by this adaptor. | |
41 | * | |
42 | * @return The class type that this adaptor can manage. | |
43 | */ | |
44 | ||
45 | Class getDataClass(); | |
46 | ||
47 | /** | |
48 | * Converts the data object into a String. | |
49 | * | |
50 | * @param squeezer | |
51 | * The squeezer that should be used to ultimately squeeze the data. | |
52 | * @param data | |
53 | * The data to squeeze. | |
54 | * | |
55 | * @return String representation of data. | |
56 | */ | |
57 | ||
58 | String squeeze(DataSqueezer squeezer, Object data); | |
59 | ||
60 | /** | |
61 | * Converts a String back into an appropriate object. | |
62 | * | |
63 | * @param squeezer | |
64 | * The squeezer to use to unsqueeze the data. | |
65 | * @param string | |
66 | * The string data - as was returned from {@link #squeeze(org.apache.tapestry.services.DataSqueezer, Object)}. | |
67 | * | |
68 | * @return The re-constituded object representation of the string. | |
69 | */ | |
70 | ||
71 | Object unsqueeze(DataSqueezer squeezer, String string); | |
72 | } |