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.util;
23 
24 import com.sun.org.apache.xerces.internal.impl.dv.xs.XSSimpleTypeDecl;
25 import com.sun.org.apache.xerces.internal.impl.xs.XSComplexTypeDecl;
26 import com.sun.org.apache.xerces.internal.xs.XSSimpleTypeDefinition;
27 import com.sun.org.apache.xerces.internal.xs.XSTypeDefinition;
28 
29 /**
30  * Class defining utility/helper methods to support XML Schema 1.0 implementation.
31  *
32  * @xerces.internal
33  *
34  * @author Mukul Gandhi, IBM
35  */
36 public class XS10TypeHelper {
37 
38     /*
39      * Class constructor.
40      */
XS10TypeHelper()41     private XS10TypeHelper() {
42        // a private constructor, to prohibit instantiating this class from an outside class/application.
43        // this is a good practice, since all methods of this class are "static".
44     }
45 
46     /*
47      * Get name of an XSD type definition as a string value (which will typically be the value of "name" attribute of a
48      * type definition, or an internal name determined by the validator for anonymous types).
49      */
getSchemaTypeName(XSTypeDefinition typeDefn)50     public static String getSchemaTypeName(XSTypeDefinition typeDefn) {
51 
52         String typeNameStr;
53         if (typeDefn instanceof XSSimpleTypeDefinition) {
54             typeNameStr = ((XSSimpleTypeDecl) typeDefn).getTypeName();
55         }
56         else {
57             typeNameStr = ((XSComplexTypeDecl) typeDefn).getTypeName();
58         }
59 
60         return typeNameStr;
61 
62     } // getSchemaTypeName
63 
64 
65 } // class XS10TypeHelper
66