01: /**
02: * Licensed to the Apache Software Foundation (ASF) under one
03: * or more contributor license agreements. See the NOTICE file
04: * distributed with this work for additional information
05: * regarding copyright ownership. The ASF licenses this file
06: * to you under the Apache License, Version 2.0 (the
07: * "License"); you may not use this file except in compliance
08: * with the License. You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing,
13: * software distributed under the License is distributed on an
14: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15: * KIND, either express or implied. See the License for the
16: * specific language governing permissions and limitations
17: * under the License.
18: */package org.apache.cxf.tools.util;
19:
20: import java.util.HashMap;
21: import java.util.HashSet;
22: import java.util.Map;
23: import java.util.Set;
24:
25: public final class BuiltInTypesJavaMappingUtil {
26: private static final String XML_SCHEMA_NS = "http://www.w3.org/2000/10/XMLSchema";
27: private static final String NS_XMLNS = "http://www.w3.org/2000/xmlns/";
28: private static final String NS_XSD = "http://www.w3.org/2001/XMLSchema";
29: private static final String NS_XSI = "http://www.w3.org/2001/XMLSchema-instance";
30:
31: private static Set<String> nameSpaces = new HashSet<String>();
32: static {
33: nameSpaces.add(XML_SCHEMA_NS.toLowerCase());
34: nameSpaces.add(NS_XMLNS.toLowerCase());
35: nameSpaces.add(NS_XSD.toLowerCase());
36: nameSpaces.add(NS_XSI.toLowerCase());
37: }
38:
39: private static Map<String, String> jTypeMapping = new HashMap<String, String>();
40: static {
41: jTypeMapping.put("string", "java.lang.String");
42: jTypeMapping.put("integer", "java.math.BigInteger");
43: jTypeMapping.put("int", "int");
44: jTypeMapping.put("long", "long");
45: jTypeMapping.put("short", "short");
46: jTypeMapping.put("decimal", "java.math.BigDecimal");
47: jTypeMapping.put("float", "float");
48: jTypeMapping.put("double", "double");
49: jTypeMapping.put("boolean", "boolean");
50: jTypeMapping.put("byte", "byte");
51: jTypeMapping.put("qname", "javax.xml.namespace.QName");
52: jTypeMapping.put("dataTime",
53: "javax.xml.datatype.XMLGregorianCalendar");
54: jTypeMapping.put("time",
55: "javax.xml.datatype.XMLGregorianCalendar");
56: jTypeMapping.put("date",
57: "javax.xml.datatype.XMLGregorianCalendar");
58: jTypeMapping.put("dataTime",
59: "javax.xml.datatype.XMLGregorianCalendar");
60: jTypeMapping.put("gday",
61: "javax.xml.datatype.XMLGregorianCalendar");
62: jTypeMapping.put("gmonth",
63: "javax.xml.datatype.XMLGregorianCalendar");
64: jTypeMapping.put("gyear",
65: "javax.xml.datatype.XMLGregorianCalendar");
66: jTypeMapping.put("gmonthday",
67: "javax.xml.datatype.XMLGregorianCalendar");
68: jTypeMapping.put("base64binary", "byte[]");
69: jTypeMapping.put("hexbinary", "byte[]");
70: jTypeMapping.put("unsignedint", "long");
71: jTypeMapping.put("unsignedshort", "int");
72: jTypeMapping.put("unsignedbyte", "short");
73: jTypeMapping.put("anytype", "Object");
74:
75: }
76:
77: private BuiltInTypesJavaMappingUtil() {
78: }
79:
80: public static String getJType(String nameSpace, String type) {
81: if (type == null || nameSpace == null
82: || !nameSpaces.contains(nameSpace.toLowerCase())) {
83: return null;
84: }
85: return jTypeMapping.get(type.toLowerCase());
86: }
87:
88: }
|