|
|||||||||||||||||||
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 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 | ||
35 | public String getPrefix(); | |
36 | ||
37 | /** | |
38 | * Returns the class (or interface) which can be encoded by this adaptor. | |
39 | */ | |
40 | ||
41 | public Class getDataClass(); | |
42 | ||
43 | /** | |
44 | * Converts the data object into a String. | |
45 | * | |
46 | * @throws IOException | |
47 | * if the object can't be converted. | |
48 | */ | |
49 | ||
50 | public String squeeze(DataSqueezer squeezer, Object data); | |
51 | ||
52 | /** | |
53 | * Converts a String back into an appropriate object. | |
54 | * | |
55 | * @throws IOException | |
56 | * if the String can't be converted. | |
57 | */ | |
58 | ||
59 | public Object unsqueeze(DataSqueezer squeezer, String string); | |
60 | } |
|