1 /* 2 * Redistribution and use of this software and associated documentation 3 * ("Software"), with or without modification, are permitted provided 4 * that the following conditions are met: 5 * 6 * 1. Redistributions of source code must retain copyright 7 * statements and notices. Redistributions must also contain a 8 * copy of this document. 9 * 10 * 2. Redistributions in binary form must reproduce the 11 * above copyright notice, this list of conditions and the 12 * following disclaimer in the documentation and/or other 13 * materials provided with the distribution. 14 * 15 * 3. The name "Exolab" must not be used to endorse or promote 16 * products derived from this Software without prior written 17 * permission of Intalio, Inc. For written permission, 18 * please contact info@exolab.org. 19 * 20 * 4. Products derived from this Software may not be called "Exolab" 21 * nor may "Exolab" appear in their names without prior written 22 * permission of Intalio, Inc. Exolab is a registered 23 * trademark of Intalio, Inc. 24 * 25 * 5. Due credit should be given to the Exolab Project 26 * (http://www.exolab.org/). 27 * 28 * THIS SOFTWARE IS PROVIDED BY INTALIO, INC. AND CONTRIBUTORS 29 * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT 30 * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 31 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 32 * INTALIO, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 33 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 34 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 35 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 36 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 37 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 38 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 39 * OF THE POSSIBILITY OF SUCH DAMAGE. 40 * 41 * Copyright 2002 (C) Intalio Inc. All Rights Reserved. 42 * 43 * $Id$ 44 */ 45 package org.exolab.castor.builder; 46 47 import org.exolab.castor.builder.binding.xml.EnumBindingType; 48 import org.exolab.castor.builder.types.XSType; 49 50 /** 51 * This interface is the abstraction of any type of source that can interact 52 * with the Source Code Generator. From the Source Code Generator point of view, 53 * the source document used to generate Java source code is totally transparent 54 * and is not exposed. 55 * <p> 56 * Specific implementation of that class will represent the source document 57 * used. For instance when generating source code from an XML Schema, the source 58 * generator will interact with an 59 * {@link org.exolab.castor.builder.binding.XMLBindingComponent} whereas when 60 * generating source code from an UML model object model, the source generator 61 * will interact with an UMLBindingComponent (This is obviously just an example, 62 * no UML Object Model has been as of today integrated in Castor). 63 * <p> 64 * A binding component can be of three different types: 65 * <ul> 66 * <li>MEMBER: this type of BindingComponent will represent a java class 67 * member.</li> 68 * <li>INTERFACE: this type of BindingComponent will represent a java 69 * interface.</li> 70 * <li>CLASS: this type of BindingComponent will represent a java class.</li> 71 * </ul> 72 * 73 * @author <a href="mailto:blandin@intalio.com">Arnaud Blandin</a> 74 * @version $Revision$ $Date: 2005-03-05 06:42:06 -0700 (Sat, 05 Mar 75 * 2005) $ 76 */ 77 public interface BindingComponent { 78 79 /** An interface binding component. */ 80 short INTERFACE = 0; 81 /** A class binding component. */ 82 short CLASS = 1; 83 /** A member binding component. */ 84 short MEMBER = 2; 85 /** An enum binding component. */ 86 short ENUM_TYPE = 3; 87 /** A content member binding component. */ 88 short CONTENT_MEMBER_TYPE = 4; 89 90 /** 91 * Returns true if the given Object is equal to this instance of 92 * BindingComponent. 93 * 94 * @param object the object to compare to this instance 95 * @return true if the given Object is equal to this instance of 96 * BindingComponent. 97 * @see java.lang.Object#equals(java.lang.Object) 98 */ 99 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 }