001/*
002 * Copyright (c) 2006-2011 Nuxeo SA (http://nuxeo.com/) and others.
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the Eclipse Public License v1.0
006 * which accompanies this distribution, and is available at
007 * http://www.eclipse.org/legal/epl-v10.html
008 *
009 * Contributors:
010 *     bstefanescu
011 *
012 * $Id$
013 */
014
015package org.nuxeo.ecm.core.schema;
016
017import java.util.Collection;
018import java.util.HashMap;
019import java.util.Map;
020
021import org.nuxeo.ecm.core.schema.types.SimpleType;
022import org.nuxeo.ecm.core.schema.types.primitives.BinaryType;
023import org.nuxeo.ecm.core.schema.types.primitives.BooleanType;
024import org.nuxeo.ecm.core.schema.types.primitives.DateType;
025import org.nuxeo.ecm.core.schema.types.primitives.DoubleType;
026import org.nuxeo.ecm.core.schema.types.primitives.LongType;
027import org.nuxeo.ecm.core.schema.types.primitives.StringType;
028
029/**
030 * @author <a href="mailto:bs@nuxeo.com">Bogdan Stefanescu</a>
031 */
032public class XSDTypes {
033
034    private static final Map<String, SimpleType> xsdBaseTypes = new HashMap<String, SimpleType>();
035
036    // Utility class.
037    private XSDTypes() {
038    }
039
040    static {
041        xsdBaseTypes.put("string", StringType.INSTANCE);
042        xsdBaseTypes.put("normalizedString", StringType.INSTANCE);
043        xsdBaseTypes.put("integer", LongType.INSTANCE);
044        xsdBaseTypes.put("long", LongType.INSTANCE);
045        xsdBaseTypes.put("int", LongType.INSTANCE);
046        xsdBaseTypes.put("short", LongType.INSTANCE);
047        xsdBaseTypes.put("unsignedShort", LongType.INSTANCE);
048        xsdBaseTypes.put("positiveInteger", LongType.INSTANCE);
049        xsdBaseTypes.put("nonPositiveInteger", LongType.INSTANCE);
050        xsdBaseTypes.put("nonNegativeInteger", LongType.INSTANCE);
051        xsdBaseTypes.put("unsignedInt", LongType.INSTANCE);
052        xsdBaseTypes.put("unsignedLong", LongType.INSTANCE);
053        xsdBaseTypes.put("decimal", DoubleType.INSTANCE);
054        xsdBaseTypes.put("double", DoubleType.INSTANCE);
055        xsdBaseTypes.put("float", DoubleType.INSTANCE);
056        xsdBaseTypes.put("date", DateType.INSTANCE);
057        xsdBaseTypes.put("dateTime", DateType.INSTANCE);
058        xsdBaseTypes.put("time", DateType.INSTANCE);
059        xsdBaseTypes.put("boolean", BooleanType.INSTANCE);
060        xsdBaseTypes.put("base64Binary", BinaryType.INSTANCE);
061        xsdBaseTypes.put("hexBinary", BinaryType.INSTANCE);
062        xsdBaseTypes.put("duration", StringType.INSTANCE);
063        xsdBaseTypes.put("anyType", StringType.INSTANCE);
064        xsdBaseTypes.put("anySimpleType", StringType.INSTANCE);
065        xsdBaseTypes.put("anyURI", StringType.INSTANCE);
066    }
067
068    public static SimpleType getType(String name) {
069        return xsdBaseTypes.get(name);
070    }
071
072    public static Collection<SimpleType> getTypes() {
073        return xsdBaseTypes.values();
074    }
075
076}