01: /*
02: * Created on Nov 24, 2005
03: */
04: package uk.org.ponder.rsf.mappings;
05:
06: import uk.org.ponder.rsf.components.UIComponent;
07: import uk.org.ponder.saxalizer.SAXAccessMethodSpec;
08: import uk.org.ponder.saxalizer.mapping.SAXalizerMapperEntry;
09: import uk.org.ponder.saxalizer.mapping.SAXalizerMapperInferrer;
10:
11: public class ComponentMapperInferrer implements SAXalizerMapperInferrer {
12:
13: private SAXalizerMapperInferrer upchain;
14:
15: public void setChainedInferrer(SAXalizerMapperInferrer target) {
16: upchain = target;
17: }
18:
19: private SAXalizerMapperEntry filterComponentEntry(Class clazz,
20: SAXalizerMapperEntry entry) {
21: for (int i = entry.size() - 1; i >= 0; --i) {
22: SAXAccessMethodSpec spec = entry.specAt(i);
23: if ("getFullID".equals(spec.getmethodname)
24: || "parent".equals(spec.fieldname))
25: entry.remove(i);
26: else if ("ID".equals(spec.fieldname)) {
27: spec.xmlform = SAXAccessMethodSpec.XML_ATTRIBUTE;
28: spec.xmlname = "id";
29: }
30: }
31: return entry;
32: }
33:
34: public SAXalizerMapperEntry inferEntry(Class clazz,
35: SAXalizerMapperEntry entry) {
36: SAXalizerMapperEntry togo = upchain.inferEntry(clazz, entry);
37: if (UIComponent.class.isAssignableFrom(clazz)) {
38: return filterComponentEntry(clazz, togo);
39: }
40: return togo;
41: }
42:
43: public boolean isDefaultInferrible(Class clazz) {
44: if (UIComponent.class.isAssignableFrom(clazz))
45: return true;
46: else
47: return upchain.isDefaultInferrible(clazz);
48: }
49:
50: public void setDefaultInferrible(Class clazz) {
51: upchain.setDefaultInferrible(clazz);
52: }
53:
54: }
|