src/share/jaxws_classes/com/sun/tools/internal/xjc/reader/xmlschema/bindinfo/BIEnum.java

Tue, 09 Apr 2013 14:51:13 +0100

author
alanb
date
Tue, 09 Apr 2013 14:51:13 +0100
changeset 368
0989ad8c0860
parent 0
373ffda63c9a
permissions
-rw-r--r--

8010393: Update JAX-WS RI to 2.2.9-b12941
Reviewed-by: alanb, erikj
Contributed-by: miroslav.kos@oracle.com, martin.grebac@oracle.com

     1 /*
     2  * Copyright (c) 1997, 2011, 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
    23  * questions.
    24  */
    26 package com.sun.tools.internal.xjc.reader.xmlschema.bindinfo;
    28 import java.util.HashMap;
    29 import java.util.Map;
    31 import javax.xml.bind.annotation.XmlAttribute;
    32 import javax.xml.bind.annotation.XmlElement;
    33 import javax.xml.bind.annotation.XmlRootElement;
    34 import javax.xml.bind.annotation.XmlTransient;
    35 import javax.xml.namespace.QName;
    37 import com.sun.tools.internal.xjc.reader.Const;
    38 import com.sun.tools.internal.xjc.reader.xmlschema.SimpleTypeBuilder;
    40 /**
    41  * Enumeration customization.
    42  * <p>
    43  * This customization binds a simple type to a type-safe enum class.
    44  * The actual binding process takes place in {@link SimpleTypeBuilder}.
    45  *
    46  * <p>
    47  * This customization is acknowledged by {@link SimpleTypeBuilder}.
    48  *
    49  * @author
    50  *  Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com)
    51  */
    52 @XmlRootElement(name="typesafeEnumClass")
    53 public final class BIEnum extends AbstractDeclarationImpl {
    55     /**
    56      * If false, it means not to bind to a type-safe enum.
    57      *
    58      * this takes precedence over all the other properties of this class.
    59      */
    60     @XmlAttribute(name="map")
    61     private boolean map = true;
    63     /** Gets the specified class name, or null if not specified. */
    64     @XmlAttribute(name="name")
    65     public String className = null;
    67     /**
    68      * @see BIClass#getExistingClassRef()
    69      */
    70     @XmlAttribute(name="ref")
    71     public String ref;
    73     /**
    74      * Gets the javadoc comment specified in the customization.
    75      * Can be null if none is specified.
    76      */
    77     @XmlElement
    78     public final String javadoc = null;
    80     public boolean isMapped() {
    81         return map;
    82     }
    84     /**
    85      * Gets the map that contains XML value->BIEnumMember pairs.
    86      * This table is built from &lt;enumMember> customizations.
    87      *
    88      * Always return non-null.
    89      */
    90     @XmlTransient
    91     public final Map<String,BIEnumMember> members = new HashMap<String,BIEnumMember>();
    93     public QName getName() { return NAME; }
    95     public void setParent(BindInfo p) {
    96         super.setParent(p);
    97         for( BIEnumMember mem : members.values() )
    98             mem.setParent(p);
   100         // if this specifies a reference to external class,
   101         // then it's OK even if noone actually refers this class.
   102         if(ref!=null)
   103             markAsAcknowledged();
   104     }
   106     /** Name of this declaration. */
   107     public static final QName NAME = new QName(
   108         Const.JAXB_NSURI, "enum" );
   110     // setter method for JAXB runtime
   111     @XmlElement(name="typesafeEnumMember")
   112     private void setMembers(BIEnumMember2[] mems) {
   113         for (BIEnumMember2 e : mems)
   114             members.put(e.value,e);
   115     }
   119     /**
   120      * {@link BIEnumMember} used inside {@link BIEnum} has additional 'value' attribute.
   121      */
   122     static class BIEnumMember2 extends BIEnumMember {
   123         /**
   124          * The lexical representaion of the constant to which we are attaching.
   125          */
   126         @XmlAttribute(required=true)
   127         String value;
   128     }
   129 }

mercurial