src/share/jaxws_classes/com/sun/xml/internal/xsom/impl/SimpleTypeImpl.java

Thu, 12 Oct 2017 19:44:07 +0800

author
aoqi
date
Thu, 12 Oct 2017 19:44:07 +0800
changeset 760
e530533619ec
parent 0
373ffda63c9a
permissions
-rw-r--r--

merge

     1 /*
     2  * Copyright (c) 1997, 2010, 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.xml.internal.xsom.impl;
    28 import com.sun.xml.internal.xsom.XSComplexType;
    29 import com.sun.xml.internal.xsom.XSContentType;
    30 import com.sun.xml.internal.xsom.XSListSimpleType;
    31 import com.sun.xml.internal.xsom.XSParticle;
    32 import com.sun.xml.internal.xsom.XSRestrictionSimpleType;
    33 import com.sun.xml.internal.xsom.XSSimpleType;
    34 import com.sun.xml.internal.xsom.XSType;
    35 import com.sun.xml.internal.xsom.XSUnionSimpleType;
    36 import com.sun.xml.internal.xsom.XSVariety;
    37 import com.sun.xml.internal.xsom.impl.parser.SchemaDocumentImpl;
    38 import com.sun.xml.internal.xsom.visitor.XSContentTypeFunction;
    39 import com.sun.xml.internal.xsom.visitor.XSContentTypeVisitor;
    40 import com.sun.xml.internal.xsom.visitor.XSFunction;
    41 import com.sun.xml.internal.xsom.visitor.XSVisitor;
    42 import org.xml.sax.Locator;
    44 import java.util.Set;
    46 public abstract class SimpleTypeImpl extends DeclarationImpl
    47     implements XSSimpleType, ContentTypeImpl, Ref.SimpleType
    48 {
    49     SimpleTypeImpl(
    50         SchemaDocumentImpl _parent,
    51         AnnotationImpl _annon,
    52         Locator _loc,
    53         ForeignAttributesImpl _fa,
    54         String _name,
    55         boolean _anonymous,
    56         Set<XSVariety> finalSet,
    57         Ref.SimpleType _baseType) {
    59         super(_parent, _annon, _loc, _fa, _parent.getTargetNamespace(), _name, _anonymous);
    61         this.baseType = _baseType;
    62         this.finalSet = finalSet;
    63     }
    65     private Ref.SimpleType baseType;
    67     public XSType[] listSubstitutables() {
    68         return Util.listSubstitutables(this);
    69     }
    71     public void redefine( SimpleTypeImpl st ) {
    72         baseType = st;
    73         st.redefinedBy = this;
    74         redefiningCount = (short)(st.redefiningCount+1);
    75     }
    77     /**
    78      * Number of times this component redefines other components.
    79      */
    80     private short redefiningCount = 0;
    82     private SimpleTypeImpl redefinedBy = null;
    84     public XSSimpleType getRedefinedBy() {
    85         return redefinedBy;
    86     }
    88     public int getRedefinedCount() {
    89         int i=0;
    90         for( SimpleTypeImpl st =this.redefinedBy; st !=null; st =st.redefinedBy)
    91             i++;
    92         return i;
    93     }
    95     public XSType getBaseType() { return baseType.getType(); }
    96     public XSSimpleType getSimpleBaseType() { return baseType.getType(); }
    97     public boolean isPrimitive() { return false; }
    99     public XSListSimpleType getBaseListType() {
   100         return getSimpleBaseType().getBaseListType();
   101     }
   103     public XSUnionSimpleType getBaseUnionType() {
   104         return getSimpleBaseType().getBaseUnionType();
   105     }
   107     private final Set<XSVariety> finalSet;
   109     public boolean isFinal(XSVariety v) {
   110         return finalSet.contains(v);
   111     }
   114     public final int getDerivationMethod() { return XSType.RESTRICTION; }
   117     public final XSSimpleType asSimpleType()  { return this; }
   118     public final XSComplexType asComplexType(){ return null; }
   120     public boolean isDerivedFrom(XSType t) {
   121         XSType x = this;
   122         while(true) {
   123             if(t==x)
   124                 return true;
   125             XSType s = x.getBaseType();
   126             if(s==x)
   127                 return false;
   128             x = s;
   129         }
   130     }
   132     public final boolean isSimpleType()       { return true; }
   133     public final boolean isComplexType()      { return false; }
   134     public final XSParticle asParticle()      { return null; }
   135     public final XSContentType asEmpty()      { return null; }
   138     public boolean isRestriction() { return false; }
   139     public boolean isList() { return false; }
   140     public boolean isUnion() { return false; }
   141     public XSRestrictionSimpleType asRestriction() { return null; }
   142     public XSListSimpleType asList() { return null; }
   143     public XSUnionSimpleType asUnion() { return null; }
   148     public final void visit( XSVisitor visitor ) {
   149         visitor.simpleType(this);
   150     }
   151     public final void visit( XSContentTypeVisitor visitor ) {
   152         visitor.simpleType(this);
   153     }
   154     public final Object apply( XSFunction function ) {
   155         return function.simpleType(this);
   156     }
   157     public final Object apply( XSContentTypeFunction function ) {
   158         return function.simpleType(this);
   159     }
   161     // Ref.ContentType implementation
   162     public XSContentType getContentType() { return this; }
   163     // Ref.SimpleType implementation
   164     public XSSimpleType getType() { return this; }
   165 }

mercurial