jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/model/CClassInfo.java
author mkos
Sun, 30 Dec 2012 00:00:00 +0100
changeset 22678 ac1ea46be942
parent 12009 4abb694f273a
permissions -rw-r--r--
8029237: Update copyright year to match last edit in jaxws repository for 2012 Reviewed-by: chegar
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
     1
/*
22678
ac1ea46be942 8029237: Update copyright year to match last edit in jaxws repository for 2012
mkos
parents: 12009
diff changeset
     2
 * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
     4
 *
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    10
 *
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    15
 * accompanied this code).
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    16
 *
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    20
 *
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    23
 * questions.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    24
 */
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    25
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    26
package com.sun.tools.internal.xjc.model;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    27
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    28
import java.util.ArrayList;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    29
import java.util.Collection;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    30
import java.util.HashSet;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    31
import java.util.Iterator;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    32
import java.util.List;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    33
import java.util.Set;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    34
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    35
import javax.xml.bind.annotation.XmlElement;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    36
import javax.xml.bind.annotation.XmlID;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    37
import javax.xml.bind.annotation.XmlIDREF;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    38
import javax.xml.bind.annotation.XmlRootElement;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    39
import javax.xml.namespace.QName;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    40
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    41
import com.sun.codemodel.internal.JClass;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    42
import com.sun.codemodel.internal.JCodeModel;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    43
import com.sun.codemodel.internal.JPackage;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    44
import com.sun.istack.internal.Nullable;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    45
import com.sun.tools.internal.xjc.Language;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    46
import com.sun.tools.internal.xjc.model.nav.NClass;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    47
import com.sun.tools.internal.xjc.model.nav.NType;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    48
import com.sun.tools.internal.xjc.outline.Aspect;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    49
import com.sun.tools.internal.xjc.outline.Outline;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    50
import com.sun.tools.internal.xjc.reader.Ring;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    51
import com.sun.tools.internal.xjc.reader.xmlschema.BGMBuilder;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    52
import com.sun.tools.internal.xjc.reader.xmlschema.bindinfo.BIFactoryMethod;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    53
import com.sun.xml.internal.bind.v2.model.core.ClassInfo;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    54
import com.sun.xml.internal.bind.v2.model.core.Element;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    55
import com.sun.xml.internal.xsom.XSComponent;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    56
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    57
import org.xml.sax.Locator;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    58
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    59
/**
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    60
 * Mutable {@link ClassInfo} represenatation.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    61
 *
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    62
 * <p>
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    63
 * Schema parsers build these objects.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    64
 *
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    65
 * @author Kohsuke Kawaguchi
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    66
 */
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    67
public final class CClassInfo extends AbstractCElement implements ClassInfo<NType,NClass>, CClassInfoParent, CClass, NClass {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    68
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    69
    @XmlIDREF
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    70
    private CClass baseClass;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    71
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    72
    /**
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    73
     * List of all subclasses, together with {@link #nextSibling}.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    74
     *
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    75
     * If this class has no sub-class, this field is null. Otherwise,
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    76
     * this field points to a sub-class of this class. From there you can enumerate
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    77
     * all the sub-classes by using {@link #nextSibling}.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    78
     */
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    79
    private CClassInfo firstSubclass;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    80
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    81
    /**
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    82
     * @see #firstSubclass
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    83
     */
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    84
    private CClassInfo nextSibling = null;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    85
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    86
    /**
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    87
     * @see #getTypeName()
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    88
     */
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    89
    private final QName typeName;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    90
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    91
    /**
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    92
     * Custom {@link #getSqueezedName() squeezed name}, if any.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    93
     */
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    94
    private /*almost final*/ @Nullable String squeezedName;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    95
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    96
    /**
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    97
     * If this class also gets {@link XmlRootElement}, the class name.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    98
     */
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    99
    private final @Nullable QName elementName;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   100
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   101
    private boolean isOrdered = true;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   102
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   103
    private final List<CPropertyInfo> properties = new ArrayList<CPropertyInfo>();
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   104
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   105
    /**
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   106
     * TODO: revisit this design.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   107
     * we should at least do a basic encapsulation to avoid careless
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   108
     * mistakes. Maybe we should even differ the javadoc generation
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   109
     * by queueing runners.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   110
     */
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   111
    public String javadoc;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   112
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   113
    @XmlIDREF
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   114
    private final CClassInfoParent parent;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   115
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   116
    /**
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   117
     * short name.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   118
     */
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   119
    public final String shortName;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   120
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   121
    /**
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   122
     * Optional user-specified implementation override class.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   123
     */
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   124
    private @Nullable String implClass;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   125
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   126
    /**
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   127
     * The {@link Model} object to which this bean belongs.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   128
     */
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   129
    public final Model model;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   130
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   131
    /**
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   132
     * @see #hasAttributeWildcard()
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   133
     */
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   134
    private boolean hasAttributeWildcard;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   135
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   136
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   137
    public CClassInfo(Model model,JPackage pkg, String shortName, Locator location, QName typeName, QName elementName, XSComponent source, CCustomizations customizations) {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   138
        this(model,model.getPackage(pkg),shortName,location,typeName,elementName,source,customizations);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   139
    }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   140
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   141
    public CClassInfo(Model model,CClassInfoParent p, String shortName, Locator location, QName typeName, QName elementName, XSComponent source, CCustomizations customizations) {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   142
        super(model,source,location,customizations);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   143
        this.model = model;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   144
        this.parent = p;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   145
        this.shortName = model.allocator.assignClassName(parent,shortName);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   146
        this.typeName = typeName;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   147
        this.elementName = elementName;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   148
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   149
        Language schemaLanguage = model.options.getSchemaLanguage();
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   150
        if ((schemaLanguage != null) &&
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   151
            (schemaLanguage.equals(Language.XMLSCHEMA) || schemaLanguage.equals(Language.WSDL))) {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   152
            BIFactoryMethod factoryMethod = Ring.get(BGMBuilder.class).getBindInfo(source).get(BIFactoryMethod.class);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   153
            if(factoryMethod!=null) {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   154
                factoryMethod.markAsAcknowledged();
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   155
                this.squeezedName = factoryMethod.name;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   156
            }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   157
        }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   158
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   159
        model.add(this);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   160
    }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   161
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   162
    public CClassInfo(Model model,JCodeModel cm, String fullName, Locator location, QName typeName, QName elementName, XSComponent source, CCustomizations customizations) {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   163
        super(model,source,location,customizations);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   164
        this.model = model;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   165
        int idx = fullName.indexOf('.');
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   166
        if(idx<0) {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   167
            this.parent = model.getPackage(cm.rootPackage());
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   168
            this.shortName = model.allocator.assignClassName(parent,fullName);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   169
        } else {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   170
            this.parent = model.getPackage(cm._package(fullName.substring(0,idx)));
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   171
            this.shortName = model.allocator.assignClassName(parent,fullName.substring(idx+1));
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   172
        }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   173
        this.typeName = typeName;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   174
        this.elementName = elementName;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   175
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   176
        model.add(this);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   177
    }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   178
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   179
    public boolean hasAttributeWildcard() {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   180
        return hasAttributeWildcard;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   181
    }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   182
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   183
    public void hasAttributeWildcard(boolean hasAttributeWildcard) {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   184
        this.hasAttributeWildcard = hasAttributeWildcard;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   185
    }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   186
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   187
    public boolean hasSubClasses() {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   188
        return firstSubclass!=null;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   189
    }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   190
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   191
    /**
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   192
     * Returns true if a new attribute wildcard property needs to be
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   193
     * declared on this class.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   194
     */
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   195
    public boolean declaresAttributeWildcard() {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   196
        return hasAttributeWildcard && !inheritsAttributeWildcard();
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   197
    }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   198
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   199
    /**
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   200
     * Returns true if this class inherits a wildcard attribute property
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   201
     * from its ancestor classes.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   202
     */
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   203
    public boolean inheritsAttributeWildcard() {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   204
        if (getRefBaseClass() != null) {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   205
            CClassRef cref = (CClassRef)baseClass;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   206
            if (cref.getSchemaComponent().getForeignAttributes().size() > 0) {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   207
                return true;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   208
            }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   209
        } else {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   210
            for( CClassInfo c=getBaseClass(); c!=null; c=c.getBaseClass() ) {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   211
                if(c.hasAttributeWildcard)
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   212
                    return true;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   213
            }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   214
        }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   215
        return false;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   216
    }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   217
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   218
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   219
    public NClass getClazz() {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   220
        return this;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   221
    }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   222
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   223
    public CClassInfo getScope() {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   224
        return null;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   225
    }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   226
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   227
    @XmlID
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   228
    public String getName() {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   229
        return fullName();
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   230
    }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   231
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   232
    /**
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   233
     * Returns the "squeezed name" of this bean token.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   234
     * <p>
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   235
     * The squeezed name of a bean is the concatenation of
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   236
     * the names of its outer classes and itself.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   237
     * <p>
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   238
     * Thus if the bean is "org.acme.foo.Bean", then the squeezed name is "Bean",
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   239
     * if the bean is "org.acme.foo.Outer1.Outer2.Bean", then "Outer1Outer2Bean".
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   240
     * <p>
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   241
     * This is used by the code generator
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   242
     */
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   243
    @XmlElement
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   244
    public String getSqueezedName() {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   245
        if (squeezedName != null)  return squeezedName;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   246
        return calcSqueezedName.onBean(this);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   247
    }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   248
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   249
    private static final CClassInfoParent.Visitor<String> calcSqueezedName = new Visitor<String>() {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   250
        public String onBean(CClassInfo bean) {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   251
            return bean.parent.accept(this)+bean.shortName;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   252
        }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   253
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   254
        public String onElement(CElementInfo element) {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   255
            return element.parent.accept(this)+element.shortName();
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   256
        }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   257
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   258
        public String onPackage(JPackage pkg) {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   259
            return "";
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   260
        }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   261
    };
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   262
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   263
    /**
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   264
     * Returns a mutable list.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   265
     */
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   266
    public List<CPropertyInfo> getProperties() {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   267
        return properties;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   268
    }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   269
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   270
    public boolean hasValueProperty() {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   271
        throw new UnsupportedOperationException();
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   272
    }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   273
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   274
    /**
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   275
     * Gets a propery by name.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   276
     */
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   277
    public CPropertyInfo getProperty(String name) {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   278
        // TODO: does this method need to be fast?
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   279
        for( CPropertyInfo p : properties )
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   280
            if(p.getName(false).equals(name))
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   281
                return p;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   282
        return null;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   283
    }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   284
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   285
    public boolean hasProperties() {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   286
        return !getProperties().isEmpty();
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   287
    }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   288
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   289
    public boolean isElement() {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   290
        return elementName!=null;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   291
    }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   292
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   293
    /**
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   294
     * Guaranteed to return this.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   295
     */
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   296
    @Deprecated
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   297
    public CNonElement getInfo() {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   298
        return this;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   299
    }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   300
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   301
    public Element<NType,NClass> asElement() {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   302
        if(isElement())
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   303
            return this;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   304
        else
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   305
            return null;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   306
    }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   307
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   308
    public boolean isOrdered() {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   309
        return isOrdered;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   310
    }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   311
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   312
    /**
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   313
     * @deprecated
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   314
     *      if you are calling this method directly, you must be doing something wrong.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   315
     */
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   316
    public boolean isFinal() {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   317
        return false;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   318
    }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   319
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   320
    public void setOrdered(boolean value) {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   321
        isOrdered = value;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   322
    }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   323
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   324
    public QName getElementName() {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   325
        return elementName;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   326
    }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   327
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   328
    public QName getTypeName() {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   329
        return typeName;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   330
    }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   331
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   332
    public boolean isSimpleType() {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   333
        throw new UnsupportedOperationException();
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   334
    }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   335
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   336
    /**
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   337
     * Returns the FQCN of this bean.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   338
     */
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   339
    public String fullName() {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   340
        String r = parent.fullName();
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   341
        if(r.length()==0)   return shortName;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   342
        else                return r+'.'+shortName;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   343
    }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   344
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   345
    public CClassInfoParent parent() {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   346
        return parent;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   347
    }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   348
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   349
    public void setUserSpecifiedImplClass(String implClass) {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   350
        assert this.implClass==null;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   351
        assert implClass!=null;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   352
        this.implClass = implClass;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   353
    }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   354
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   355
    public String getUserSpecifiedImplClass() {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   356
        return implClass;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   357
    }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   358
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   359
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   360
    /**
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   361
     * Adds a new property.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   362
     */
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   363
    public void addProperty(CPropertyInfo prop) {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   364
        if(prop.ref().isEmpty())
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   365
            // this property isn't contributing anything
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   366
            // this happens when you try to map an empty sequence to a property
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   367
            return;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   368
        prop.setParent(this);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   369
        properties.add(prop);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   370
    }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   371
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   372
    /**
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   373
     * This method accepts both {@link CClassInfo} (which means the base class
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   374
     * is also generated), or {@link CClassRef} (which means the base class is
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   375
     * already generated and simply referenced.)
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   376
     *
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   377
     * The latter is treated somewhat special --- from the rest of the model
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   378
     * this external base class is invisible. This modeling might need more
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   379
     * thoughts to get right.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   380
     */
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   381
    public void setBaseClass(CClass base) {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   382
        assert baseClass==null;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   383
        assert base!=null;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   384
        baseClass = base;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   385
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   386
        assert nextSibling==null;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   387
        if (base instanceof CClassInfo) {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   388
            CClassInfo realBase = (CClassInfo) base;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   389
            this.nextSibling = realBase.firstSubclass;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   390
            realBase.firstSubclass = this;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   391
        }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   392
    }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   393
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   394
    /**
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   395
     * This inherited version returns null if this class extends from {@link CClassRef}.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   396
     *
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   397
     * @see #getRefBaseClass()
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   398
     */
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   399
    public CClassInfo getBaseClass() {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   400
        if (baseClass instanceof CClassInfo) {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   401
            return (CClassInfo) baseClass;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   402
        } else {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   403
            return null;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   404
        }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   405
    }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   406
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   407
    public CClassRef getRefBaseClass() {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   408
        if (baseClass instanceof CClassRef) {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   409
            return (CClassRef) baseClass;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   410
        } else {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   411
            return null;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   412
        }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   413
    }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   414
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   415
    /**
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   416
     * Enumerates all the sub-classes of this class.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   417
     */
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   418
    public Iterator<CClassInfo> listSubclasses() {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   419
        return new Iterator<CClassInfo>() {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   420
            CClassInfo cur = firstSubclass;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   421
            public boolean hasNext() {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   422
                return cur!=null;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   423
            }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   424
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   425
            public CClassInfo next() {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   426
                CClassInfo r = cur;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   427
                cur = cur.nextSibling;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   428
                return r;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   429
            }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   430
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   431
            public void remove() {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   432
                throw new UnsupportedOperationException();
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   433
            }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   434
        };
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   435
    }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   436
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   437
    public CClassInfo getSubstitutionHead() {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   438
        CClassInfo c=getBaseClass();
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   439
        while(c!=null && !c.isElement())
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   440
            c=c.getBaseClass();
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   441
        return c;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   442
    }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   443
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   444
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   445
    /**
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   446
     * Interfaces to be implemented.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   447
     * Lazily constructed.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   448
     */
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   449
    private Set<JClass> _implements = null;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   450
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   451
    public void _implements(JClass c) {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   452
        if(_implements==null)
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   453
            _implements = new HashSet<JClass>();
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   454
        _implements.add(c);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   455
    }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   456
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   457
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   458
    /** Constructor declarations. array of {@link Constructor}s. */
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   459
    private final List<Constructor> constructors = new ArrayList<Constructor>(1);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   460
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   461
    /** Creates a new constructor declaration and adds it. */
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   462
    public void addConstructor( String... fieldNames ) {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   463
        constructors.add(new Constructor(fieldNames));
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   464
    }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   465
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   466
    /** list all constructor declarations. */
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   467
    public Collection<? extends Constructor> getConstructors() {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   468
        return constructors;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   469
    }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   470
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   471
    public final <T> T accept(Visitor<T> visitor) {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   472
        return visitor.onBean(this);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   473
    }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   474
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   475
    public JPackage getOwnerPackage() {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   476
        return parent.getOwnerPackage();
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   477
    }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   478
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   479
    public final NClass getType() {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   480
        return this;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   481
    }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   482
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   483
    public final JClass toType(Outline o, Aspect aspect) {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   484
        switch(aspect) {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   485
        case IMPLEMENTATION:
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   486
            return o.getClazz(this).implRef;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   487
        case EXPOSED:
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   488
            return o.getClazz(this).ref;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   489
        default:
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   490
            throw new IllegalStateException();
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   491
        }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   492
    }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   493
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   494
    public boolean isBoxedType() {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   495
        return false;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   496
    }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   497
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   498
    public String toString() {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   499
        return fullName();
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   500
    }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   501
}