001: /*
002: * Redistribution and use of this software and associated documentation
003: * ("Software"), with or without modification, are permitted provided
004: * that the following conditions are met:
005: *
006: * 1. Redistributions of source code must retain copyright
007: * statements and notices. Redistributions must also contain a
008: * copy of this document.
009: *
010: * 2. Redistributions in binary form must reproduce the
011: * above copyright notice, this list of conditions and the
012: * following disclaimer in the documentation and/or other
013: * materials provided with the distribution.
014: *
015: * 3. The name "Exolab" must not be used to endorse or promote
016: * products derived from this Software without prior written
017: * permission of Intalio, Inc. For written permission,
018: * please contact info@exolab.org.
019: *
020: * 4. Products derived from this Software may not be called "Exolab"
021: * nor may "Exolab" appear in their names without prior written
022: * permission of Intalio, Inc. Exolab is a registered
023: * trademark of Intalio, Inc.
024: *
025: * 5. Due credit should be given to the Exolab Project
026: * (http://www.exolab.org/).
027: *
028: * THIS SOFTWARE IS PROVIDED BY INTALIO, INC. AND CONTRIBUTORS
029: * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
030: * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
031: * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
032: * INTALIO, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
033: * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
034: * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
035: * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
036: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
037: * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
038: * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
039: * OF THE POSSIBILITY OF SUCH DAMAGE.
040: *
041: * Copyright 2002 (C) Intalio Inc. All Rights Reserved.
042: *
043: * $Id: BindingComponent.java 6919 2007-04-01 18:11:00Z wguttmn $
044: */
045: package org.exolab.castor.builder;
046:
047: import org.exolab.castor.builder.binding.xml.EnumBindingType;
048: import org.exolab.castor.builder.types.XSType;
049:
050: /**
051: * This interface is the abstraction of any type of source that can interact
052: * with the Source Code Generator. From the Source Code Generator point of view,
053: * the source document used to generate Java source code is totally transparent
054: * and is not exposed.
055: * <p>
056: * Specific implementation of that class will represent the source document
057: * used. For instance when generating source code from an XML Schema, the source
058: * generator will interact with an
059: * {@link org.exolab.castor.builder.binding.XMLBindingComponent} whereas when
060: * generating source code from an UML model object model, the source generator
061: * will interact with an UMLBindingComponent (This is obviously just an example,
062: * no UML Object Model has been as of today integrated in Castor).
063: * <p>
064: * A binding component can be of three different types:
065: * <ul>
066: * <li>MEMBER: this type of BindingComponent will represent a java class
067: * member.</li>
068: * <li>INTERFACE: this type of BindingComponent will represent a java
069: * interface.</li>
070: * <li>CLASS: this type of BindingComponent will represent a java class.</li>
071: * </ul>
072: *
073: * @author <a href="mailto:blandin@intalio.com">Arnaud Blandin</a>
074: * @version $Revision: 6919 $ $Date: 2005-03-05 06:42:06 -0700 (Sat, 05 Mar
075: * 2005) $
076: */
077: public interface BindingComponent {
078:
079: /** An interface binding component. */
080: short INTERFACE = 0;
081: /** A class binding component. */
082: short CLASS = 1;
083: /** A member binding component. */
084: short MEMBER = 2;
085: /** An enum binding component. */
086: short ENUM_TYPE = 3;
087: /** A content member binding component. */
088: short CONTENT_MEMBER_TYPE = 4;
089:
090: /**
091: * Returns true if the given Object is equal to this instance of
092: * BindingComponent.
093: *
094: * @param object the object to compare to this instance
095: * @return true if the given Object is equal to this instance of
096: * BindingComponent.
097: * @see java.lang.Object#equals(java.lang.Object)
098: */
099: boolean equals(Object object);
100:
101: /**
102: * Returns the name of collection type such as 'arraylist' in which we will
103: * store the different occurrences of the java member generated to represent
104: * that BindingComponent.
105: *
106: * @return a string that represents the collection type such as 'arraylist'
107: * name in which we will store the different occurrences of the java
108: * member generated to represent that BindingComponent.
109: */
110: String getCollectionType();
111:
112: /**
113: * Returns the name of a super class for the current BindingComponent. Null
114: * is returned if this BindingComponent is not meant to be mapped to a java
115: * class.
116: *
117: * @return the name of a super class for the current BindingComponent. Null
118: * is returned if this BindingComponent is not meant to be mapped to
119: * a java class.
120: */
121: String getExtends();
122:
123: /**
124: * Returns an array of the different interface names implemented by the
125: * class that will represent the current BindingComponent. Null is returned
126: * if this BindingComponent is not meant to be mapped to a java class.
127: *
128: * @return an array of the different interface names implemented by the
129: * class that will represent the current BindingComponent. Null is
130: * returned if this BindingComponent is not meant to be mapped to a
131: * java class.
132: */
133: String[] getImplements();
134:
135: /**
136: * Returns a valid Java Class Name corresponding to this BindingComponent.
137: * This name is not qualified, this is only a local Java class name.
138: *
139: * @return a valid Java Class Name corresponding to this BindingComponent.
140: * This name is not qualified, this is only a local Java class name.
141: * @see #getQualifiedName
142: */
143: String getJavaClassName();
144:
145: /**
146: * Returns a valid Java Member Name corresponding to this BindingComponent.
147: * This name is not qualified, this is only a local Java Member name.
148: *
149: * @return a valid Java Member Name corresponding to this BindingComponent.
150: * This name is not qualified, this is only a local Java member
151: * name.
152: * @see #getQualifiedName
153: */
154: String getJavaMemberName();
155:
156: /**
157: * Returns the java package associated with this BindingComponent.
158: *
159: * @return the java package associated with this BindingComponent.
160: */
161: String getJavaPackage();
162:
163: /**
164: * Returns the XSType that corresponds to the Java type chosen to represent
165: * this BindingComponent. An XSType is an abstraction of a Java type used in
166: * the Source Generator. It wraps a JType as well as the necessary methods
167: * to convert to/from String.
168: *
169: * @return an XSType that corresponds to the Java type chosen to represent
170: * this BindingComponent.
171: */
172: XSType getJavaType();
173:
174: /**
175: * Returns the lower bound of the collection that is generated from this
176: * BindingComponent. The lower bound is a positive integer.
177: *
178: * @return an int representing the lower bound of the collection generated
179: * from this BindingComponent.
180: */
181: int getLowerBound();
182:
183: /**
184: * Returns a fully qualified java class name. This name corresponds to the
185: * class name that will be generated from this BindingComponent.
186: *
187: * @return a fully qualified java class name. This name corresponds to the
188: * class name corresponding to this BindingComponent.
189: */
190: String getQualifiedName();
191:
192: /**
193: * Returns the type of this component binding. A component binding can be of
194: * three different types:
195: * <ul>
196: * <li>Interface: it represents the binding to a java interface.</li>
197: * <li>Class: it represents the binding to a java class.</li>
198: * <li>Member: it represents the binding to a java class member.</li>
199: * </ul>
200: * -1 is returned if the component binding is null.
201: *
202: * @return the type of this component binding.
203: */
204: short getType();
205:
206: /**
207: * Returns the upper bound of the collection that is generated from this
208: * BindingComponent. The upper bound is a positive integer. -1 is returned
209: * to indicate that the upper bound is unbounded.
210: *
211: * @return an int representing the lower bound of the collection generated
212: * from this BindingComponent. -1 is returned to indicate that the
213: * upper bound is uinbounded.
214: */
215: int getUpperBound();
216:
217: /**
218: * Returns the default value of the member generated from this binding
219: * component. The value is returned as its string representation.
220: *
221: * @return a string representation of default value for the member generated
222: * from this binding component.
223: */
224: String getValue();
225:
226: /**
227: * Returns the fully qualified name of the Validator to use.
228: *
229: * @return the fully qualified name of the Validator to use.
230: */
231: String getValidator();
232:
233: /**
234: * Returns the EnumBindingType instance for the active binding component.
235: * @return The EnumBindingType instance
236: */
237: EnumBindingType getEnumBinding();
238:
239: /**
240: * Returns the fully qualified name of the XMLFieldHandler to use. This
241: * handler will be used when generating ClassDescriptors meant to be used in
242: * the marshalling framework.
243: *
244: * @return the fully qualified name of the XMLFieldHandler to use.
245: */
246: String getXMLFieldHandler();
247:
248: /**
249: * Returns true if bound properties must be generated for the class that
250: * will represent the current BindingComponent.
251: *
252: * @return true if bound properties must be generated for the class the
253: * class that will represent the current BindingComponent.
254: */
255: boolean hasBoundProperties();
256:
257: /**
258: * Returns true if equal method must be generated for the class that will
259: * represent the current BindingComponent.
260: *
261: * @return true if equal method must be generated for the class the class
262: * that will represent the current BindingComponent.
263: */
264: boolean hasEquals();
265:
266: /**
267: * Returns the hashCode value for this object.
268: *
269: * @return the hashcode value for this object.
270: * @see java.lang.Object#hashCode()
271: */
272: int hashCode();
273:
274: /**
275: * Returns true if the class generated from the current BindingComponent
276: * will be abstract.
277: *
278: * @return true if the class generated from the current BindingComponent
279: * will be abstract.
280: */
281: boolean isAbstract();
282:
283: /**
284: * Returns true if the class generated from the current BindingComponent
285: * will be final.
286: *
287: * @return true if the class generated from the current BindingComponent
288: * will be final.
289: */
290: boolean isFinal();
291:
292: /**
293: * Returns true if the member represented by that BindingComponent is to be
294: * represented by an Object wrapper. For instance an int will be represented
295: * by a java Integer if the property is set to true.
296: *
297: * @return true if the member represented by that BindingComponent is to be
298: * represented by an Object wrapper.
299: */
300: boolean useWrapper();
301:
302: }
|