1 |
|
package org.apache.tapestry.engine.encoders; |
2 |
|
|
3 |
|
import org.apache.tapestry.engine.ServiceEncoder; |
4 |
|
import org.apache.tapestry.engine.ServiceEncoding; |
5 |
|
import org.apache.tapestry.services.ServiceConstants; |
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
3 |
public class PathEncoder implements ServiceEncoder { |
11 |
|
|
12 |
|
private String _path; |
13 |
|
|
14 |
|
private String _service; |
15 |
|
|
16 |
|
public void setPath(String path) |
17 |
|
{ |
18 |
2 |
_path = path; |
19 |
2 |
} |
20 |
|
|
21 |
|
public void setService(String service) |
22 |
|
{ |
23 |
3 |
_service = service; |
24 |
3 |
} |
25 |
|
|
26 |
|
public void encode(ServiceEncoding encoding) |
27 |
|
{ |
28 |
2 |
if (!encoding.getParameterValue(ServiceConstants.SERVICE).equals(_service)) |
29 |
1 |
return; |
30 |
|
|
31 |
1 |
encoding.setServletPath(_path); |
32 |
1 |
encoding.setParameterValue(ServiceConstants.SERVICE, null); |
33 |
1 |
} |
34 |
|
|
35 |
|
public void decode(ServiceEncoding encoding) |
36 |
|
{ |
37 |
1 |
if (!encoding.getServletPath().equals(_path)) |
38 |
1 |
return; |
39 |
|
|
40 |
0 |
encoding.setParameterValue(ServiceConstants.SERVICE, _service); |
41 |
0 |
} |
42 |
|
} |