001: /*
002: Copyright (c) 2003, Dennis M. Sosnoski
003: All rights reserved.
004:
005: Redistribution and use in source and binary forms, with or without modification,
006: are permitted provided that the following conditions are met:
007:
008: * Redistributions of source code must retain the above copyright notice, this
009: list of conditions and the following disclaimer.
010: * Redistributions in binary form must reproduce the above copyright notice,
011: this list of conditions and the following disclaimer in the documentation
012: and/or other materials provided with the distribution.
013: * Neither the name of JiBX nor the names of its contributors may be used
014: to endorse or promote products derived from this software without specific
015: prior written permission.
016:
017: THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
018: ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
019: WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
020: DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
021: ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
022: (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
023: LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
024: ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
025: (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
026: SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
027: */
028:
029: package org.jibx.binding.def;
030:
031: import org.jibx.binding.classes.ContextMethodBuilder;
032: import org.jibx.runtime.JiBXException;
033:
034: /**
035: * Default component decorator. This just passes through all method calls to
036: * the wrapped component.
037: *
038: * @author Dennis M. Sosnoski
039: * @version 1.0
040: */
041:
042: public class PassThroughComponent implements IComponent {
043: /** Property value binding component. */
044: protected IComponent m_component;
045:
046: /**
047: * No argument constructor. This requires the component to be set later,
048: * using the {@link #setWrappedComponent} method.
049: */
050:
051: protected PassThroughComponent() {
052: }
053:
054: /**
055: * Constructor.
056: *
057: * @param comp wrapped component
058: */
059:
060: protected PassThroughComponent(IComponent comp) {
061: m_component = comp;
062: }
063:
064: /**
065: * Set the wrapped component.
066: *
067: * @param comp wrapped component
068: */
069:
070: protected void setWrappedComponent(IComponent comp) {
071: m_component = comp;
072: }
073:
074: //
075: // IComponent interface method definitions
076:
077: public boolean isOptional() {
078: return m_component.isOptional();
079: }
080:
081: public boolean hasAttribute() {
082: return m_component.hasAttribute();
083: }
084:
085: public void genAttrPresentTest(ContextMethodBuilder mb)
086: throws JiBXException {
087: m_component.genAttrPresentTest(mb);
088: }
089:
090: public void genAttributeUnmarshal(ContextMethodBuilder mb)
091: throws JiBXException {
092: m_component.genAttributeUnmarshal(mb);
093: }
094:
095: public void genAttributeMarshal(ContextMethodBuilder mb)
096: throws JiBXException {
097: m_component.genAttributeMarshal(mb);
098: }
099:
100: public boolean hasContent() {
101: return m_component.hasContent();
102: }
103:
104: public void genContentPresentTest(ContextMethodBuilder mb)
105: throws JiBXException {
106: m_component.genContentPresentTest(mb);
107: }
108:
109: public void genContentUnmarshal(ContextMethodBuilder mb)
110: throws JiBXException {
111: m_component.genContentUnmarshal(mb);
112: }
113:
114: public void genContentMarshal(ContextMethodBuilder mb)
115: throws JiBXException {
116: m_component.genContentMarshal(mb);
117: }
118:
119: public void genNewInstance(ContextMethodBuilder mb)
120: throws JiBXException {
121: m_component.genNewInstance(mb);
122: }
123:
124: public String getType() {
125: return m_component.getType();
126: }
127:
128: public boolean hasId() {
129: return m_component.hasId();
130: }
131:
132: public void genLoadId(ContextMethodBuilder mb) throws JiBXException {
133: m_component.genLoadId(mb);
134: }
135:
136: public NameDefinition getWrapperName() {
137: return m_component.getWrapperName();
138: }
139:
140: public void setLinkages() throws JiBXException {
141: m_component.setLinkages();
142: }
143:
144: // DEBUG
145: public void print(int depth) {
146: throw new IllegalStateException(
147: "Method must be overridden by subclass"
148: + getClass().getName());
149: }
150: }
|