01: /*
02: * Copyright 2005 Joe Walker
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package jsx3.net;
17:
18: import org.directwebremoting.convert.BaseV20Converter;
19: import org.directwebremoting.extend.Converter;
20: import org.directwebremoting.extend.InboundContext;
21: import org.directwebremoting.extend.InboundVariable;
22: import org.directwebremoting.extend.MarshallException;
23: import org.directwebremoting.extend.NonNestedOutboundVariable;
24: import org.directwebremoting.extend.OutboundContext;
25: import org.directwebremoting.extend.OutboundVariable;
26:
27: /**
28: * @author Joe Walker [joe at getahead dot ltd dot uk]
29: */
30: public class URIResolverConverter extends BaseV20Converter implements
31: Converter {
32: /* (non-Javadoc)
33: * @see org.directwebremoting.extend.Converter#convertInbound(java.lang.Class, org.directwebremoting.extend.InboundVariable, org.directwebremoting.extend.InboundContext)
34: */
35: public Object convertInbound(Class<?> paramType,
36: InboundVariable data, InboundContext inctx)
37: throws MarshallException {
38: URIResolver reply = URIResolver.toURIResolver(paramType
39: .toString());
40: if (reply == null) {
41: throw new MarshallException(paramType);
42: }
43:
44: return reply;
45: }
46:
47: /* (non-Javadoc)
48: * @see org.directwebremoting.extend.Converter#convertOutbound(java.lang.Object, org.directwebremoting.extend.OutboundContext)
49: */
50: public OutboundVariable convertOutbound(Object data,
51: OutboundContext outctx) throws MarshallException {
52: URIResolver resolver = (URIResolver) data;
53: return new NonNestedOutboundVariable(resolver.constant);
54: }
55: }
|