01: /*
02: * Created on 23 Jul 2007
03: */
04: package uk.org.ponder.rsf.viewstate.support;
05:
06: import java.util.List;
07: import java.util.Map;
08:
09: import uk.org.ponder.rsf.viewstate.RawURLState;
10: import uk.org.ponder.rsf.viewstate.ViewParameters;
11: import uk.org.ponder.rsf.viewstate.ViewParamsCodec;
12: import uk.org.ponder.rsf.viewstate.ViewParamsMapInfo;
13:
14: public class ViewParamsCodecManager implements ViewParamsCodec {
15: private List codecs;
16:
17: public void setViewParamsCodecs(List codecs) {
18: this .codecs = codecs;
19: }
20:
21: public ViewParamsCodec getCodec(ViewParameters viewparams) {
22: for (int i = 0; i < codecs.size(); ++i) {
23: ViewParamsCodec codec = (ViewParamsCodec) codecs.get(i);
24: if (codec.isSupported(viewparams))
25: return codec;
26: }
27: return null;
28: }
29:
30: public boolean isSupported(ViewParameters viewparams) {
31: return true;
32: }
33:
34: public boolean parseViewParams(ViewParameters target,
35: RawURLState rawstate, Map unusedParams) {
36: return getCodec(target).parseViewParams(target, rawstate,
37: unusedParams);
38: }
39:
40: public RawURLState renderViewParams(ViewParameters toparse) {
41: return getCodec(toparse).renderViewParams(toparse);
42: }
43:
44: public ViewParamsMapInfo getMappingInfo(ViewParameters viewparams) {
45: return getCodec(viewparams).getMappingInfo(viewparams);
46: }
47:
48: }
|