01: /*
02: * GeoTools - OpenSource mapping toolkit
03: * http://geotools.org
04: * (C) 2002-2006, GeoTools Project Managment Committee (PMC)
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation;
09: * version 2.1 of the License.
10: *
11: * This library is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * Lesser General Public License for more details.
15: */
16: package org.geotools.xml;
17:
18: import java.util.List;
19:
20: import javax.xml.namespace.QName;
21:
22: import org.picocontainer.MutablePicoContainer;
23: import org.w3c.dom.Document;
24: import org.w3c.dom.Element;
25:
26: /**
27: * Base class for complex bindings.
28: *
29: * @author Justin Deoliveira, The Open Planning Project, jdeolive@openplans.org
30: *
31: */
32: public abstract class AbstractComplexBinding implements ComplexBinding {
33: /**
34: * Does nothing, subclasses should override this method.
35: */
36: public void initializeChildContext(ElementInstance childInstance,
37: Node node, MutablePicoContainer context) {
38: //does nothing, subclasses should override
39: }
40:
41: /**
42: * This implementation returns {@link Binding#OVERRIDE}.
43: * <p>
44: * Subclasses should override to change this behaviour.
45: * </p>
46: */
47: public int getExecutionMode() {
48: return OVERRIDE;
49: }
50:
51: /**
52: * Subclasses should ovverride this method if need be, the default implementation
53: * returns <param>value</param>.
54: *
55: * @see ComplexBinding#encode(Object, Document, Element).
56: */
57: public Element encode(Object object, Document document,
58: Element value) throws Exception {
59:
60: return value;
61: }
62:
63: /**
64: * Subclasses should override this method if need be, the default implementation
65: * returns <code>null</code>.
66: *
67: * @see ComplexBinding#getProperty(Object, QName)
68: */
69: public Object getProperty(Object object, QName name)
70: throws Exception {
71: //do nothing, subclasses should override
72: return null;
73: }
74:
75: /**
76: * Subclasses should override this method if need be, the default implementation
77: * returns <code>null</code>.
78: * <p>
79: * Note that this method only needs to be implemented for schema types which
80: * are open-ended in which the contents are not specifically specified by
81: * the schema.
82: * </p>
83: *
84: * @see ComplexBinding#getProperties(Object)
85: */
86: public List getProperties(Object object) throws Exception {
87: // do nothing, subclasses should override.
88: return null;
89: }
90:
91: }
|