1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 package org.apache.openoffice.ooxml.schema.model.simple; 23 24 import org.apache.openoffice.ooxml.schema.model.base.QualifiedName; 25 import org.apache.openoffice.ooxml.schema.parser.XsdNamespace; 26 27 public enum BuiltInType 28 { 29 AnyURI, 30 Base64Binary, 31 Boolean, 32 Byte, 33 Float, 34 DateTime, 35 Double, 36 HexBinary, 37 ID, 38 Int, 39 Integer, 40 Long, 41 NcName, 42 Short, 43 String, 44 Token, 45 UnsignedByte, 46 UnsignedInt, 47 UnsignedLong, 48 UnsignedShort; 49 GetForName(final QualifiedName aName)50 public static BuiltInType GetForName (final QualifiedName aName) 51 { 52 assert(aName.GetNamespacePrefix().equals(XsdNamespace.Prefix)); 53 switch(aName.GetLocalPart()) 54 { 55 case "anyURI": return AnyURI; 56 case "base64Binary": return Base64Binary; 57 case "boolean": return Boolean; 58 case "byte": return Byte; 59 case "dateTime": return DateTime; 60 case "double": return Double; 61 case "float": return Float; 62 case "hexBinary": return HexBinary; 63 case "ID": return ID; 64 case "int" : return Int; 65 case "integer": return Integer; 66 case "long": return Long; 67 case "NCName": return NcName; 68 case "short": return Short; 69 case "string": return String; 70 case "token": return Token; 71 case "unsignedByte": return UnsignedByte; 72 case "unsignedInt": return UnsignedInt; 73 case "unsignedLong": return UnsignedLong; 74 case "unsignedShort": return UnsignedShort; 75 default: throw new RuntimeException("there is no builtin type named "+aName.GetDisplayName()); 76 } 77 } 78 GetQualifiedName()79 public QualifiedName GetQualifiedName () 80 { 81 final String sTypeName; 82 switch(this) 83 { 84 case AnyURI: sTypeName = "anyURI"; break; 85 case Base64Binary: sTypeName = "base64Binary"; break; 86 case Boolean: sTypeName = "boolean"; break; 87 case Byte: sTypeName = "byte"; break; 88 case Double: sTypeName = "double"; break; 89 case DateTime: sTypeName = "dateTime"; break; 90 case Float: sTypeName = "float"; break; 91 case HexBinary: sTypeName = "hexBinary"; break; 92 case ID: sTypeName = "ID"; break; 93 case Int: sTypeName = "int"; break; 94 case Integer: sTypeName = "integer"; break; 95 case Long: sTypeName = "long"; break; 96 case NcName: sTypeName = "NCName"; break; 97 case Short: sTypeName = "short"; break; 98 case String: sTypeName = "string"; break; 99 case Token: sTypeName = "token"; break; 100 case UnsignedByte: sTypeName = "unsignedByte"; break; 101 case UnsignedInt: sTypeName = "unsignedInt"; break; 102 case UnsignedLong: sTypeName = "unsignedLong"; break; 103 case UnsignedShort: sTypeName = "unsignedShort"; break; 104 default: 105 throw new RuntimeException(); 106 } 107 return new QualifiedName(XsdNamespace.URI, XsdNamespace.Prefix, sTypeName); 108 } 109 } 110