001/* 002 * (C) Copyright 2006-2011 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 * 016 * Contributors: 017 * bstefanescu 018 * 019 * $Id$ 020 */ 021 022package org.nuxeo.ecm.core.schema; 023 024import java.util.Collection; 025import java.util.HashMap; 026import java.util.Map; 027 028import org.nuxeo.ecm.core.schema.types.SimpleType; 029import org.nuxeo.ecm.core.schema.types.primitives.BinaryType; 030import org.nuxeo.ecm.core.schema.types.primitives.BooleanType; 031import org.nuxeo.ecm.core.schema.types.primitives.DateType; 032import org.nuxeo.ecm.core.schema.types.primitives.DoubleType; 033import org.nuxeo.ecm.core.schema.types.primitives.LongType; 034import org.nuxeo.ecm.core.schema.types.primitives.StringType; 035 036/** 037 * @author <a href="mailto:bs@nuxeo.com">Bogdan Stefanescu</a> 038 */ 039public class XSDTypes { 040 041 private static final Map<String, SimpleType> xsdBaseTypes = new HashMap<String, SimpleType>(); 042 043 // Utility class. 044 private XSDTypes() { 045 } 046 047 static { 048 xsdBaseTypes.put("string", StringType.INSTANCE); 049 xsdBaseTypes.put("normalizedString", StringType.INSTANCE); 050 xsdBaseTypes.put("integer", LongType.INSTANCE); 051 xsdBaseTypes.put("long", LongType.INSTANCE); 052 xsdBaseTypes.put("int", LongType.INSTANCE); 053 xsdBaseTypes.put("short", LongType.INSTANCE); 054 xsdBaseTypes.put("unsignedShort", LongType.INSTANCE); 055 xsdBaseTypes.put("positiveInteger", LongType.INSTANCE); 056 xsdBaseTypes.put("nonPositiveInteger", LongType.INSTANCE); 057 xsdBaseTypes.put("nonNegativeInteger", LongType.INSTANCE); 058 xsdBaseTypes.put("unsignedInt", LongType.INSTANCE); 059 xsdBaseTypes.put("unsignedLong", LongType.INSTANCE); 060 xsdBaseTypes.put("decimal", DoubleType.INSTANCE); 061 xsdBaseTypes.put("double", DoubleType.INSTANCE); 062 xsdBaseTypes.put("float", DoubleType.INSTANCE); 063 xsdBaseTypes.put("date", DateType.INSTANCE); 064 xsdBaseTypes.put("dateTime", DateType.INSTANCE); 065 xsdBaseTypes.put("time", DateType.INSTANCE); 066 xsdBaseTypes.put("boolean", BooleanType.INSTANCE); 067 xsdBaseTypes.put("base64Binary", BinaryType.INSTANCE); 068 xsdBaseTypes.put("hexBinary", BinaryType.INSTANCE); 069 xsdBaseTypes.put("duration", StringType.INSTANCE); 070 xsdBaseTypes.put("anyType", StringType.INSTANCE); 071 xsdBaseTypes.put("anySimpleType", StringType.INSTANCE); 072 xsdBaseTypes.put("anyURI", StringType.INSTANCE); 073 } 074 075 public static SimpleType getType(String name) { 076 return xsdBaseTypes.get(name); 077 } 078 079 public static Collection<SimpleType> getTypes() { 080 return xsdBaseTypes.values(); 081 } 082 083}