< prev index next >

src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/reader/xmlschema/bindinfo/BIGlobalBinding.java

Print this page


   1 /*
   2  * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


  54 import com.sun.xml.internal.xsom.XSDeclaration;
  55 import com.sun.xml.internal.xsom.XSSchemaSet;
  56 import com.sun.xml.internal.xsom.XSSimpleType;
  57 
  58 /**
  59  * Global binding customization. The code is highly temporary.
  60  *
  61  * <p>
  62  * One of the information contained in a global customization
  63  * is the default binding for properties. This object contains a
  64  * BIProperty object to keep this information.
  65  *
  66  * @author
  67  *  Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com)
  68  */
  69 @XmlRootElement(name="globalBindings")
  70 public final class BIGlobalBinding extends AbstractDeclarationImpl {
  71 
  72 
  73     /**
  74      * Gets the name converter that will govern the XML->Java
  75      * name conversion process for this compilation.
  76      *
  77      * <p>
  78      * The "underscoreBinding" customization will determine
  79      * the exact object returned from this method. The rest of XJC
  80      * should just use the NameConverter interface.
  81      *
  82      * <p>
  83      * Always non-null.
  84      */
  85     @XmlTransient
  86     public NameConverter nameConverter = NameConverter.standard;
  87 
  88     // JAXB will use this property to set nameConverter
  89     @XmlAttribute
  90     void setUnderscoreBinding( UnderscoreBinding ub ) {
  91         nameConverter = ub.nc;
  92     }
  93 
  94     UnderscoreBinding getUnderscoreBinding() {


 241     @XmlAttribute(name="generateValueClass")
 242     ImplStructureStrategy codeGenerationStrategy = BEAN_ONLY;
 243 
 244     /**
 245      * Set of datatype names. For a type-safe enum class
 246      * to be generated, the underlying XML datatype must be derived from
 247      * one of the types in this set.
 248      */
 249     // default value is set in the post-init action
 250     @XmlAttribute(name="typesafeEnumBase")
 251     private Set<QName> enumBaseTypes;
 252 
 253     /**
 254      * Returns {@link BISerializable} if the extension is specified,
 255      * or null otherwise.
 256      */
 257     @XmlElement
 258     private BISerializable serializable = null;
 259 
 260     /**
 261      * If &lt;xjc:superClass> extension is specified,
 262      * returns the specified root class. Otherwise null.
 263      */
 264     @XmlElement(namespace=Const.XJC_EXTENSION_URI)
 265     ClassNameBean superClass = null;
 266 
 267     /**
 268      * If &lt;xjc:superInterface> extension is specified,
 269      * returns the specified root class. Otherwise null.
 270      */
 271     @XmlElement(namespace=Const.XJC_EXTENSION_URI)
 272     ClassNameBean superInterface = null;
 273 
 274     /**
 275      * Generate the simpler optimized code, but not necessarily
 276      * conforming to the spec.
 277      */
 278     @XmlElement(name="simple",namespace=Const.XJC_EXTENSION_URI)
 279     String simpleMode = null;
 280 
 281     /**
 282      * Handles complex type restriction as if it were a new type.
 283      */
 284     @XmlElement(name="treatRestrictionLikeNewType",namespace=Const.XJC_EXTENSION_URI)
 285     String treatRestrictionLikeNewType = null;
 286 
 287     /**
 288      * True to generate a class for elements by default.


 471         JDefinedClass getClazz(ClassType t) {
 472             if (clazz != null) return clazz;
 473             try {
 474                 JCodeModel codeModel = Ring.get(JCodeModel.class);
 475                 clazz = codeModel._class(name, t);
 476                 clazz.hide();
 477                 return clazz;
 478             } catch (JClassAlreadyExistsException e) {
 479                 return e.getExistingClass();
 480             }
 481         }
 482     }
 483 
 484     static final class ClassNameAdapter extends ReadOnlyAdapter<ClassNameBean,String> {
 485         public String unmarshal(ClassNameBean bean) throws Exception {
 486             return bean.name;
 487         }
 488     }
 489 
 490     /**
 491      * Global &lt;jaxb:javaType>.
 492      */
 493     static final class GlobalStandardConversion extends BIConversion.User {
 494         @XmlAttribute
 495         QName xmlType;
 496 
 497         @Override
 498         public boolean equals(Object obj) {
 499             if(obj instanceof GlobalStandardConversion) {
 500                 return ((GlobalStandardConversion)obj).xmlType.equals(xmlType);
 501     }
 502 
 503             return false;
 504         }
 505 
 506         @Override
 507         public int hashCode() {
 508             int hash = 7;
 509             hash = 73 * hash + (this.xmlType != null ? this.xmlType.hashCode() : 0);
 510             return hash;
 511         }
 512     }
 513 
 514     /**
 515      * Global &lt;xjc:javaType>.
 516      */
 517     static final class GlobalVendorConversion extends BIConversion.UserAdapter {
 518         @XmlAttribute
 519         QName xmlType;
 520 
 521         @Override
 522         public boolean equals(Object obj) {
 523             if(obj instanceof GlobalVendorConversion) {
 524                 return ((GlobalVendorConversion)obj).xmlType.equals(xmlType);
 525     }
 526 
 527             return false;
 528         }
 529 
 530         @Override
 531         public int hashCode() {
 532             int hash = 7;
 533             hash = 73 * hash + (this.xmlType != null ? this.xmlType.hashCode() : 0);
 534             return hash;
 535         }


   1 /*
   2  * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


  54 import com.sun.xml.internal.xsom.XSDeclaration;
  55 import com.sun.xml.internal.xsom.XSSchemaSet;
  56 import com.sun.xml.internal.xsom.XSSimpleType;
  57 
  58 /**
  59  * Global binding customization. The code is highly temporary.
  60  *
  61  * <p>
  62  * One of the information contained in a global customization
  63  * is the default binding for properties. This object contains a
  64  * BIProperty object to keep this information.
  65  *
  66  * @author
  67  *  Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com)
  68  */
  69 @XmlRootElement(name="globalBindings")
  70 public final class BIGlobalBinding extends AbstractDeclarationImpl {
  71 
  72 
  73     /**
  74      * Gets the name converter that will govern the {@code XML -> Java}
  75      * name conversion process for this compilation.
  76      *
  77      * <p>
  78      * The "underscoreBinding" customization will determine
  79      * the exact object returned from this method. The rest of XJC
  80      * should just use the NameConverter interface.
  81      *
  82      * <p>
  83      * Always non-null.
  84      */
  85     @XmlTransient
  86     public NameConverter nameConverter = NameConverter.standard;
  87 
  88     // JAXB will use this property to set nameConverter
  89     @XmlAttribute
  90     void setUnderscoreBinding( UnderscoreBinding ub ) {
  91         nameConverter = ub.nc;
  92     }
  93 
  94     UnderscoreBinding getUnderscoreBinding() {


 241     @XmlAttribute(name="generateValueClass")
 242     ImplStructureStrategy codeGenerationStrategy = BEAN_ONLY;
 243 
 244     /**
 245      * Set of datatype names. For a type-safe enum class
 246      * to be generated, the underlying XML datatype must be derived from
 247      * one of the types in this set.
 248      */
 249     // default value is set in the post-init action
 250     @XmlAttribute(name="typesafeEnumBase")
 251     private Set<QName> enumBaseTypes;
 252 
 253     /**
 254      * Returns {@link BISerializable} if the extension is specified,
 255      * or null otherwise.
 256      */
 257     @XmlElement
 258     private BISerializable serializable = null;
 259 
 260     /**
 261      * If {@code <xjc:superClass>} extension is specified,
 262      * returns the specified root class. Otherwise null.
 263      */
 264     @XmlElement(namespace=Const.XJC_EXTENSION_URI)
 265     ClassNameBean superClass = null;
 266 
 267     /**
 268      * If {@code <xjc:superInterface>} extension is specified,
 269      * returns the specified root class. Otherwise null.
 270      */
 271     @XmlElement(namespace=Const.XJC_EXTENSION_URI)
 272     ClassNameBean superInterface = null;
 273 
 274     /**
 275      * Generate the simpler optimized code, but not necessarily
 276      * conforming to the spec.
 277      */
 278     @XmlElement(name="simple",namespace=Const.XJC_EXTENSION_URI)
 279     String simpleMode = null;
 280 
 281     /**
 282      * Handles complex type restriction as if it were a new type.
 283      */
 284     @XmlElement(name="treatRestrictionLikeNewType",namespace=Const.XJC_EXTENSION_URI)
 285     String treatRestrictionLikeNewType = null;
 286 
 287     /**
 288      * True to generate a class for elements by default.


 471         JDefinedClass getClazz(ClassType t) {
 472             if (clazz != null) return clazz;
 473             try {
 474                 JCodeModel codeModel = Ring.get(JCodeModel.class);
 475                 clazz = codeModel._class(name, t);
 476                 clazz.hide();
 477                 return clazz;
 478             } catch (JClassAlreadyExistsException e) {
 479                 return e.getExistingClass();
 480             }
 481         }
 482     }
 483 
 484     static final class ClassNameAdapter extends ReadOnlyAdapter<ClassNameBean,String> {
 485         public String unmarshal(ClassNameBean bean) throws Exception {
 486             return bean.name;
 487         }
 488     }
 489 
 490     /**
 491      * Global {@code <jaxb:javaType>}.
 492      */
 493     static final class GlobalStandardConversion extends BIConversion.User {
 494         @XmlAttribute
 495         QName xmlType;
 496 
 497         @Override
 498         public boolean equals(Object obj) {
 499             if(obj instanceof GlobalStandardConversion) {
 500                 return ((GlobalStandardConversion)obj).xmlType.equals(xmlType);
 501     }
 502 
 503             return false;
 504         }
 505 
 506         @Override
 507         public int hashCode() {
 508             int hash = 7;
 509             hash = 73 * hash + (this.xmlType != null ? this.xmlType.hashCode() : 0);
 510             return hash;
 511         }
 512     }
 513 
 514     /**
 515      * Global {@code <xjc:javaType>}.
 516      */
 517     static final class GlobalVendorConversion extends BIConversion.UserAdapter {
 518         @XmlAttribute
 519         QName xmlType;
 520 
 521         @Override
 522         public boolean equals(Object obj) {
 523             if(obj instanceof GlobalVendorConversion) {
 524                 return ((GlobalVendorConversion)obj).xmlType.equals(xmlType);
 525     }
 526 
 527             return false;
 528         }
 529 
 530         @Override
 531         public int hashCode() {
 532             int hash = 7;
 533             hash = 73 * hash + (this.xmlType != null ? this.xmlType.hashCode() : 0);
 534             return hash;
 535         }


< prev index next >