KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > zeus > util > SchemaUtils


1 /*
2  * Enhydra Java Application Server Project
3  *
4  * The contents of this file are subject to the Enhydra Public License
5  * Version 1.1 (the "License"); you may not use this file except in
6  * compliance with the License. You may obtain a copy of the License on
7  * the Enhydra web site ( http://www.enhydra.org/ ).
8  *
9  * Software distributed under the License is distributed on an "AS IS"
10  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
11  * the License for the specific terms governing rights and limitations
12  * under the License.
13  *
14  * The Initial Developer of the Enhydra Application Server is Lutris
15  * Technologies, Inc. The Enhydra Application Server and portions created
16  * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
17  * All Rights Reserved.
18  */

19 package org.enhydra.zeus.util;
20
21 /**
22  * <p>
23  * <code>SchemaUtils</code> provides utility methods specific to XML Schema
24  * and code dealing with schemas.
25  * </p>
26  *
27  * @author Brett McLaughlin
28  */

29 public class SchemaUtils {
30
31     /**
32      * <p>
33      * This will take as input an XML Schema data type (such as "string")
34      * and convert it to a Java data type (such as "String"). It includes,
35      * if needed, the fully-qualified package (such as "java.util.List") to
36      * prevent import problems.
37      * </p>
38      * <p><b>Note:</b> Eventually this should probably work in concert with
39      * some methodology that handles package imports and the like.</p>
40      *
41      * @param schemaType the XML Schema data type (as a <code>String</code>)
42      * @return <code>String</code> - the Java data type.
43      * @throws <code>UnsupportedSchemaTypeException</code> - when the supplied
44      * schema type is not supported.
45      */

46     public static String JavaDoc getJavaType(String JavaDoc schemaType)
47         throws UnsupportedSchemaTypeException {
48             
49         if (schemaType == null) {
50             throw new IllegalArgumentException JavaDoc("A non-null schema type must " +
51                 "be supplied to SchemaUtils methods.");
52         }
53         
54         if (schemaType.equals("string")) {
55             return "String";
56         }
57
58         // If we got here, it's an unsupported or incorrect data type
59
throw new UnsupportedSchemaTypeException(schemaType);
60     }
61 }
62
Popular Tags