001: /*
002: Copyright (c) 2004-2007, 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.model;
030:
031: import org.jibx.binding.classes.ClassItem;
032:
033: /**
034: * Wrapper for class field or method item information. This wraps the BCEL-based
035: * class handling implementation to support the interface defined for use with
036: * the binding model.
037: *
038: * @author Dennis M. Sosnoski
039: */
040: public class ClassItemWrapper implements IClassItem {
041: private final IClass m_class;
042: private final ClassItem m_item;
043:
044: /**
045: * Constructor.
046: *
047: * @param clas
048: * @param item
049: */
050: protected ClassItemWrapper(IClass clas, ClassItem item) {
051: m_class = clas;
052: m_item = item;
053: }
054:
055: /**
056: * Get containing class information.
057: *
058: * @return class information
059: */
060: protected IClass getContainingClass() {
061: return m_class;
062: }
063:
064: /**
065: * Get class item information.
066: *
067: * @return item information
068: */
069: protected ClassItem getClassItem() {
070: return m_item;
071: }
072:
073: /* (non-Javadoc)
074: * @see org.jibx.binding.model.IClassItem#getOwningClass()
075: */
076: public IClass getOwningClass() {
077: return m_class;
078: }
079:
080: /* (non-Javadoc)
081: * @see org.jibx.binding.model.IClassItem#getName()
082: */
083: public String getName() {
084: return m_item.getName();
085: }
086:
087: /* (non-Javadoc)
088: * @see org.jibx.binding.model.IClassItem#getJavaDoc()
089: */
090: public String getJavaDoc() {
091: return null;
092: }
093:
094: /* (non-Javadoc)
095: * @see org.jibx.binding.model.IClassItem#getType()
096: */
097: public String getTypeName() {
098: return m_item.getTypeName();
099: }
100:
101: /* (non-Javadoc)
102: * @see org.jibx.binding.model.IClassItem#getReturnJavaDoc()
103: */
104: public String getReturnJavaDoc() {
105: if (m_item.isMethod()) {
106: return null;
107: } else {
108: throw new IllegalStateException(
109: "Internal error: not a method");
110: }
111: }
112:
113: /* (non-Javadoc)
114: * @see org.jibx.binding.model.IClassItem#getArgumentCount()
115: */
116: public int getArgumentCount() {
117: return m_item.getArgumentCount();
118: }
119:
120: /* (non-Javadoc)
121: * @see org.jibx.binding.model.IClassItem#getArgumentType(int)
122: */
123: public String getArgumentType(int index) {
124: return m_item.getArgumentTypes()[index];
125: }
126:
127: /* (non-Javadoc)
128: * @see org.jibx.binding.model.IClassItem#getParameterJavaDoc(int)
129: */
130: public String getParameterJavaDoc(int index) {
131: if (m_item.isMethod()) {
132: return null;
133: } else {
134: throw new IllegalStateException(
135: "Internal error: not a method");
136: }
137: }
138:
139: /* (non-Javadoc)
140: * @see org.jibx.binding.model.IClassItem#getParameterName(int)
141: */
142: public String getParameterName(int index) {
143: return m_item.getParameterName(index);
144: }
145:
146: /* (non-Javadoc)
147: * @see org.jibx.binding.model.IClassItem#getAccessFlags()
148: */
149: public int getAccessFlags() {
150: return m_item.getAccessFlags();
151: }
152:
153: /* (non-Javadoc)
154: * @see org.jibx.binding.model.IClassItem#getSignature()
155: */
156: public String getSignature() {
157: return m_item.getSignature();
158: }
159:
160: /* (non-Javadoc)
161: * @see org.jibx.binding.model.IClassItem#isMethod()
162: */
163: public boolean isMethod() {
164: return m_item.isMethod();
165: }
166:
167: /* (non-Javadoc)
168: * @see org.jibx.binding.model.IClassItem#isInitializer()
169: */
170: public boolean isInitializer() {
171: return m_item.isInitializer();
172: }
173:
174: /* (non-Javadoc)
175: * @see org.jibx.binding.model.IClassItem#getExceptions()
176: */
177: public String[] getExceptions() {
178: return m_item.getExceptions();
179: }
180:
181: /* (non-Javadoc)
182: * @see org.jibx.binding.model.IClassItem#getExceptionJavaDoc(int)
183: */
184: public String getExceptionJavaDoc(int index) {
185: if (m_item.isMethod()) {
186: return null;
187: } else {
188: throw new IllegalStateException(
189: "Internal error: not a method");
190: }
191: }
192:
193: /* (non-Javadoc)
194: * @see org.jibx.binding.model.IClassItem#getGenericsSignature()
195: */
196: public String getGenericsSignature() {
197: return m_item.getGenericsSignature();
198: }
199: }
|