1 /* 2 * Redistribution and use of this software and associated documentation ("Software"), with or 3 * without modification, are permitted provided that the following conditions are met: 4 * 5 * 1. Redistributions of source code must retain copyright statements and notices. Redistributions 6 * must also contain a copy of this document. 7 * 8 * 2. Redistributions in binary form must reproduce the above copyright notice, this list of 9 * conditions and the following disclaimer in the documentation and/or other materials provided with 10 * the distribution. 11 * 12 * 3. The name "Exolab" must not be used to endorse or promote products derived from this Software 13 * without prior written permission of Intalio, Inc. For written permission, please contact 14 * info@exolab.org. 15 * 16 * 4. Products derived from this Software may not be called "Exolab" nor may "Exolab" appear in 17 * their names without prior written permission of Intalio, Inc. Exolab is a registered trademark of 18 * Intalio, Inc. 19 * 20 * 5. Due credit should be given to the Exolab Project (http://www.exolab.org/). 21 * 22 * THIS SOFTWARE IS PROVIDED BY INTALIO, INC. AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESSED OR 23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 24 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTALIO, INC. OR ITS 25 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY 29 * WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 * 31 * Copyright 2002 (C) Intalio Inc. All Rights Reserved. 32 * 33 * $Id$ 34 */ 35 package org.exolab.castor.builder; 36 37 import org.exolab.castor.builder.binding.xml.EnumBindingType; 38 import org.exolab.castor.builder.types.XSType; 39 40 /** 41 * This interface is the abstraction of any type of source that can interact with the Source Code 42 * Generator. From the Source Code Generator point of view, the source document used to generate 43 * Java source code is totally transparent and is not exposed. 44 * <p> 45 * Specific implementation of that class will represent the source document used. For instance when 46 * generating source code from an XML Schema, the source generator will interact with an 47 * {@link org.exolab.castor.builder.binding.XMLBindingComponent} whereas when generating source code 48 * from an UML model object model, the source generator will interact with an UMLBindingComponent 49 * (This is obviously just an example, no UML Object Model has been as of today integrated in 50 * Castor). 51 * <p> 52 * A binding component can be of three different types: 53 * <ul> 54 * <li>MEMBER: this type of BindingComponent will represent a java class member.</li> 55 * <li>INTERFACE: this type of BindingComponent will represent a java interface.</li> 56 * <li>CLASS: this type of BindingComponent will represent a java class.</li> 57 * </ul> 58 * 59 * @author <a href="mailto:blandin@intalio.com">Arnaud Blandin</a> 60 * @version $Revision$ $Date: 2005-03-05 06:42:06 -0700 (Sat, 05 Mar 2005) $ 61 */ 62 public interface BindingComponent { 63 64 /** An interface binding component. */ 65 short INTERFACE = 0; 66 /** A class binding component. */ 67 short CLASS = 1; 68 /** A member binding component. */ 69 short MEMBER = 2; 70 /** An enum binding component. */ 71 short ENUM_TYPE = 3; 72 /** A content member binding component. */ 73 short CONTENT_MEMBER_TYPE = 4; 74 75 /** 76 * Returns true if the given Object is equal to this instance of BindingComponent. 77 * 78 * @param object the object to compare to this instance 79 * @return true if the given Object is equal to this instance of BindingComponent. 80 * @see java.lang.Object#equals(java.lang.Object) 81 */ 82 boolean equals(Object object); 83 84 /** 85 * Returns the name of collection type such as 'arraylist' in which we will store the different 86 * occurrences of the java member generated to represent that BindingComponent. 87 * 88 * @return a string that represents the collection type such as 'arraylist' name in which we will 89 * store the different occurrences of the java member generated to represent that 90 * BindingComponent. 91 */ 92 String getCollectionType(); 93 94 /** 95 * Returns the name of a super class for the current BindingComponent. Null is returned if this 96 * BindingComponent is not meant to be mapped to a java class. 97 * 98 * @return the name of a super class for the current BindingComponent. Null is returned if this 99 * BindingComponent is not meant to be mapped to a java class. 100 */ 101 String getExtends(); 102 103 /** 104 * Returns an array of the different interface names implemented by the class that will represent 105 * the current BindingComponent. Null is returned if this BindingComponent is not meant to be 106 * mapped to a java class. 107 * 108 * @return an array of the different interface names implemented by the class that will represent 109 * the current BindingComponent. Null is returned if this BindingComponent is not meant to 110 * be mapped to a java class. 111 */ 112 String[] getImplements(); 113 114 /** 115 * Returns a valid Java Class Name corresponding to this BindingComponent. This name is not 116 * qualified, this is only a local Java class name. 117 * 118 * @return a valid Java Class Name corresponding to this BindingComponent. This name is not 119 * qualified, this is only a local Java class name. 120 * @see #getQualifiedName 121 */ 122 String getJavaClassName(); 123 124 /** 125 * Returns a valid Java Member Name corresponding to this BindingComponent. This name is not 126 * qualified, this is only a local Java Member name. 127 * 128 * @return a valid Java Member Name corresponding to this BindingComponent. This name is not 129 * qualified, this is only a local Java member name. 130 * @see #getQualifiedName 131 */ 132 String getJavaMemberName(); 133 134 /** 135 * Returns the java package associated with this BindingComponent. 136 * 137 * @return the java package associated with this BindingComponent. 138 */ 139 String getJavaPackage(); 140 141 /** 142 * Returns the XSType that corresponds to the Java type chosen to represent this BindingComponent. 143 * An XSType is an abstraction of a Java type used in the Source Generator. It wraps a JType as 144 * well as the necessary methods to convert to/from String. 145 * 146 * @return an XSType that corresponds to the Java type chosen to represent this BindingComponent. 147 */ 148 XSType getJavaType(); 149 150 /** 151 * Returns the lower bound of the collection that is generated from this BindingComponent. The 152 * lower bound is a positive integer. 153 * 154 * @return an int representing the lower bound of the collection generated from this 155 * BindingComponent. 156 */ 157 int getLowerBound(); 158 159 /** 160 * Returns a fully qualified java class name. This name corresponds to the class name that will be 161 * generated from this BindingComponent. 162 * 163 * @return a fully qualified java class name. This name corresponds to the class name 164 * corresponding to this BindingComponent. 165 */ 166 String getQualifiedName(); 167 168 /** 169 * Returns the type of this component binding. A component binding can be of three different 170 * types: 171 * <ul> 172 * <li>Interface: it represents the binding to a java interface.</li> 173 * <li>Class: it represents the binding to a java class.</li> 174 * <li>Member: it represents the binding to a java class member.</li> 175 * </ul> 176 * -1 is returned if the component binding is null. 177 * 178 * @return the type of this component binding. 179 */ 180 short getType(); 181 182 /** 183 * Returns the upper bound of the collection that is generated from this BindingComponent. The 184 * upper bound is a positive integer. -1 is returned to indicate that the upper bound is 185 * unbounded. 186 * 187 * @return an int representing the lower bound of the collection generated from this 188 * BindingComponent. -1 is returned to indicate that the upper bound is uinbounded. 189 */ 190 int getUpperBound(); 191 192 /** 193 * Returns the default value of the member generated from this binding component. The value is 194 * returned as its string representation. 195 * 196 * @return a string representation of default value for the member generated from this binding 197 * component. 198 */ 199 String getValue(); 200 201 /** 202 * Returns the fully qualified name of the Validator to use. 203 * 204 * @return the fully qualified name of the Validator to use. 205 */ 206 String getValidator(); 207 208 /** 209 * Returns the EnumBindingType instance for the active binding component. 210 * 211 * @return The EnumBindingType instance 212 */ 213 EnumBindingType getEnumBinding(); 214 215 /** 216 * Returns the fully qualified name of the XMLFieldHandler to use. This handler will be used when 217 * generating ClassDescriptors meant to be used in the marshalling framework. 218 * 219 * @return the fully qualified name of the XMLFieldHandler to use. 220 */ 221 String getXMLFieldHandler(); 222 223 /** 224 * Returns true if bound properties must be generated for the class that will represent the 225 * current BindingComponent. 226 * 227 * @return true if bound properties must be generated for the class the class that will represent 228 * the current BindingComponent. 229 */ 230 boolean hasBoundProperties(); 231 232 /** 233 * Returns true if equal method must be generated for the class that will represent the current 234 * BindingComponent. 235 * 236 * @return true if equal method must be generated for the class the class that will represent the 237 * current BindingComponent. 238 */ 239 boolean hasEquals(); 240 241 /** 242 * Returns the hashCode value for this object. 243 * 244 * @return the hashcode value for this object. 245 * @see java.lang.Object#hashCode() 246 */ 247 int hashCode(); 248 249 /** 250 * Returns true if the class generated from the current BindingComponent will be abstract. 251 * 252 * @return true if the class generated from the current BindingComponent will be abstract. 253 */ 254 boolean isAbstract(); 255 256 /** 257 * Returns true if the class generated from the current BindingComponent will be final. 258 * 259 * @return true if the class generated from the current BindingComponent will be final. 260 */ 261 boolean isFinal(); 262 263 /** 264 * Returns true if the member represented by that BindingComponent is to be represented by an 265 * Object wrapper. For instance an int will be represented by a java Integer if the property is 266 * set to true. 267 * 268 * @return true if the member represented by that BindingComponent is to be represented by an 269 * Object wrapper. 270 */ 271 boolean useWrapper(); 272 273 }