< prev index next >

src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/XSComplexTypeDecl.java

Print this page


   1 /*
   2  * reserved comment block
   3  * DO NOT REMOVE OR ALTER!
   4  */
   5 /*
   6  * Licensed to the Apache Software Foundation (ASF) under one or more
   7  * contributor license agreements.  See the NOTICE file distributed with
   8  * this work for additional information regarding copyright ownership.
   9  * The ASF licenses this file to You under the Apache License, Version 2.0
  10  * (the "License"); you may not use this file except in compliance with
  11  * the License.  You may obtain a copy of the License at
  12  *
  13  *      http://www.apache.org/licenses/LICENSE-2.0
  14  *
  15  * Unless required by applicable law or agreed to in writing, software
  16  * distributed under the License is distributed on an "AS IS" BASIS,
  17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  18  * See the License for the specific language governing permissions and
  19  * limitations under the License.
  20  */
  21 
  22 package com.sun.org.apache.xerces.internal.impl.xs;
  23 


 243     }
 244 
 245     public boolean derivedFrom(String ancestorNS, String ancestorName, short derivationMethod) {
 246         // ancestor is null, retur false
 247         if (ancestorName == null)
 248             return false;
 249         // ancestor is anyType, return true
 250         if (ancestorNS != null &&
 251             ancestorNS.equals(SchemaSymbols.URI_SCHEMAFORSCHEMA) &&
 252             ancestorName.equals(SchemaSymbols.ATTVAL_ANYTYPE)) {
 253             return true;
 254         }
 255 
 256         // recursively get base, and compare it with ancestor
 257         XSTypeDefinition type = this;
 258         while (!(ancestorName.equals(type.getName()) &&
 259                  ((ancestorNS == null && type.getNamespace() == null) ||
 260                   (ancestorNS != null && ancestorNS.equals(type.getNamespace())))) &&   // compare with ancestor
 261                type != SchemaGrammar.fAnySimpleType &&  // reached anySimpleType
 262                type != SchemaGrammar.fAnyType) {        // reached anyType
 263             type = (XSTypeDefinition)type.getBaseType();
 264         }
 265 
 266         return type != SchemaGrammar.fAnySimpleType &&
 267         type != SchemaGrammar.fAnyType;
 268     }
 269 
 270     /**
 271      * Checks if a type is derived from another given the the name, namespace
 272      * and derivation method. See:
 273      * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#TypeInfo-isDerivedFrom
 274      *
 275      * @param ancestorNS
 276      *            The namspace of the ancestor type declaration
 277      * @param ancestorName
 278      *            The name of the ancestor type declaration
 279      * @param derivationMethod
 280      *            The derivation method
 281      *
 282      * @return boolean True if the ancestor type is derived from the reference
 283      *         type by the specifiied derivation method.


   1 /*
   2  * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
   3  * @LastModified: Nov 2017
   4  */
   5 /*
   6  * Licensed to the Apache Software Foundation (ASF) under one or more
   7  * contributor license agreements.  See the NOTICE file distributed with
   8  * this work for additional information regarding copyright ownership.
   9  * The ASF licenses this file to You under the Apache License, Version 2.0
  10  * (the "License"); you may not use this file except in compliance with
  11  * the License.  You may obtain a copy of the License at
  12  *
  13  *      http://www.apache.org/licenses/LICENSE-2.0
  14  *
  15  * Unless required by applicable law or agreed to in writing, software
  16  * distributed under the License is distributed on an "AS IS" BASIS,
  17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  18  * See the License for the specific language governing permissions and
  19  * limitations under the License.
  20  */
  21 
  22 package com.sun.org.apache.xerces.internal.impl.xs;
  23 


 243     }
 244 
 245     public boolean derivedFrom(String ancestorNS, String ancestorName, short derivationMethod) {
 246         // ancestor is null, retur false
 247         if (ancestorName == null)
 248             return false;
 249         // ancestor is anyType, return true
 250         if (ancestorNS != null &&
 251             ancestorNS.equals(SchemaSymbols.URI_SCHEMAFORSCHEMA) &&
 252             ancestorName.equals(SchemaSymbols.ATTVAL_ANYTYPE)) {
 253             return true;
 254         }
 255 
 256         // recursively get base, and compare it with ancestor
 257         XSTypeDefinition type = this;
 258         while (!(ancestorName.equals(type.getName()) &&
 259                  ((ancestorNS == null && type.getNamespace() == null) ||
 260                   (ancestorNS != null && ancestorNS.equals(type.getNamespace())))) &&   // compare with ancestor
 261                type != SchemaGrammar.fAnySimpleType &&  // reached anySimpleType
 262                type != SchemaGrammar.fAnyType) {        // reached anyType
 263             type = type.getBaseType();
 264         }
 265 
 266         return type != SchemaGrammar.fAnySimpleType &&
 267         type != SchemaGrammar.fAnyType;
 268     }
 269 
 270     /**
 271      * Checks if a type is derived from another given the the name, namespace
 272      * and derivation method. See:
 273      * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#TypeInfo-isDerivedFrom
 274      *
 275      * @param ancestorNS
 276      *            The namspace of the ancestor type declaration
 277      * @param ancestorName
 278      *            The name of the ancestor type declaration
 279      * @param derivationMethod
 280      *            The derivation method
 281      *
 282      * @return boolean True if the ancestor type is derived from the reference
 283      *         type by the specifiied derivation method.


< prev index next >