|
|||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
SqueezeAdaptor.java | - | - | - | - |
|
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 java.io.IOException; | |
18 | ||
19 | import org.apache.tapestry.services.DataSqueezer; | |
20 | ||
21 | /** | |
22 | * Interface which defines a class used to convert data for a specific Java type into a String | |
23 | * format (squeeze it), or convert from a String back into a Java type (unsqueeze). | |
24 | * <p> | |
25 | * This interface is somewhat misnamed; this is more of the GoF Strategy pattern than GoF Adaptor | |
26 | * pattern. | |
27 | * | |
28 | * @author Howard Lewis Ship | |
29 | */ | |
30 | ||
31 | public interface SqueezeAdaptor | |
32 | { | |
33 | /** | |
34 | * Returns one or more characters, each of which will be a prefix for this adaptor. | |
35 | */ | |
36 | ||
37 | public String getPrefix(); | |
38 | ||
39 | /** | |
40 | * Returns the class (or interface) which can be encoded by this adaptor. | |
41 | */ | |
42 | ||
43 | public Class getDataClass(); | |
44 | ||
45 | /** | |
46 | * Converts the data object into a String. | |
47 | * | |
48 | * @throws IOException | |
49 | * if the object can't be converted. | |
50 | */ | |
51 | ||
52 | public String squeeze(DataSqueezer squeezer, Object data); | |
53 | ||
54 | /** | |
55 | * Converts a String back into an appropriate object. | |
56 | * | |
57 | * @throws IOException | |
58 | * if the String can't be converted. | |
59 | */ | |
60 | ||
61 | public Object unsqueeze(DataSqueezer squeezer, String string); | |
62 | } |
|