Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * JBoss, Home of Professional Open Source.
   * See the COPYRIGHT.txt file distributed with this work for information
   * regarding copyright ownership.  Some portions may be licensed
   * to Red Hat, Inc. under one or more contributor license agreements.
   *
   * This library is free software; you can redistribute it and/or
   * modify it under the terms of the GNU Lesser General Public
   * License as published by the Free Software Foundation; either
  * version 2.1 of the License, or (at your option) any later version.
  *
  * This library is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  * 02110-1301 USA.
  */
 package org.teiid.olingo;
 
 
 import  org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
 import  org.apache.olingo.commons.core.edm.primitivetype.EdmBinary;
 import  org.apache.olingo.commons.core.edm.primitivetype.EdmBoolean;
 import  org.apache.olingo.commons.core.edm.primitivetype.EdmByte;
 import  org.apache.olingo.commons.core.edm.primitivetype.EdmDate;
 import  org.apache.olingo.commons.core.edm.primitivetype.EdmDateTime;
 import  org.apache.olingo.commons.core.edm.primitivetype.EdmDateTimeOffset;
 import  org.apache.olingo.commons.core.edm.primitivetype.EdmDecimal;
 import  org.apache.olingo.commons.core.edm.primitivetype.EdmDouble;
 import  org.apache.olingo.commons.core.edm.primitivetype.EdmDuration;
 import  org.apache.olingo.commons.core.edm.primitivetype.EdmGuid;
 import  org.apache.olingo.commons.core.edm.primitivetype.EdmInt16;
 import  org.apache.olingo.commons.core.edm.primitivetype.EdmInt32;
 import  org.apache.olingo.commons.core.edm.primitivetype.EdmInt64;
 import  org.apache.olingo.commons.core.edm.primitivetype.EdmSByte;
 import  org.apache.olingo.commons.core.edm.primitivetype.EdmSingle;
 import  org.apache.olingo.commons.core.edm.primitivetype.EdmStream;
 import  org.apache.olingo.commons.core.edm.primitivetype.EdmString;
 import  org.apache.olingo.commons.core.edm.primitivetype.EdmTimeOfDay;
 import  org.apache.olingo.commons.core.edm.primitivetype.SingletonPrimitiveType;
 
 public class ODataTypeManager {
 
     private static HashMap<String, EdmPrimitiveTypeKind> teiidkeyed = new HashMap<String, EdmPrimitiveTypeKind>();
     private static HashMap<EdmPrimitiveTypeKind, Stringodatakeyed = new HashMap<EdmPrimitiveTypeKind, String>();
 
     static {
         .put(.., EdmPrimitiveTypeKind.String);
         .put(.., EdmPrimitiveTypeKind.Boolean);
         .put(.., EdmPrimitiveTypeKind.Byte);
         .put(.., EdmPrimitiveTypeKind.Int16);
         .put(.., EdmPrimitiveTypeKind.String);
         .put(.., EdmPrimitiveTypeKind.Int32);
         .put(.., EdmPrimitiveTypeKind.Int64);
         .put(.., EdmPrimitiveTypeKind.Int64);
         .put(.., EdmPrimitiveTypeKind.Single);
         .put(.., EdmPrimitiveTypeKind.Double);
         .put(.., EdmPrimitiveTypeKind.Decimal);
         .put(.., EdmPrimitiveTypeKind.Date);
         .put(.., EdmPrimitiveTypeKind.Time);
         .put(.., EdmPrimitiveTypeKind.DateTime);
         .put(.., EdmPrimitiveTypeKind.Stream); // currently
                                                                                               // problematic
         .put(.., EdmPrimitiveTypeKind.Stream);
         .put(.., EdmPrimitiveTypeKind.Stream);
         .put(.., EdmPrimitiveTypeKind.Stream);
         .put(.., EdmPrimitiveTypeKind.Stream);
 
         .put(EdmPrimitiveTypeKind.String, ..);
         .put(EdmPrimitiveTypeKind.Boolean, ..);
         .put(EdmPrimitiveTypeKind.Byte, ..);
         .put(EdmPrimitiveTypeKind.SByte, ..);
         .put(EdmPrimitiveTypeKind.Int16, ..);
         .put(EdmPrimitiveTypeKind.Int32, ..);
         .put(EdmPrimitiveTypeKind.Int64, ..);
         .put(EdmPrimitiveTypeKind.Single, ..);
         .put(EdmPrimitiveTypeKind.Double, ..);
         .put(EdmPrimitiveTypeKind.Decimal, ..);
         .put(EdmPrimitiveTypeKind.Date, ..);
         .put(EdmPrimitiveTypeKind.Time, ..);
         .put(EdmPrimitiveTypeKind.DateTime, ..);
         .put(EdmPrimitiveTypeKind.Stream, ..);
         .put(EdmPrimitiveTypeKind.Guid, ..);
         .put(EdmPrimitiveTypeKind.Binary, .. + "[]"); //$NON-NLS-1$
     }
 
     public static String teiidType(EdmPrimitiveTypeKind odataType) {
         return .get(odataType);
     }
 
     public static EdmPrimitiveTypeKind odataType(String teiidType) {
         if (DataTypeManager.isArrayType(teiidType)) {
             return odataType(DataTypeManager.getComponentType(teiidType));
        }
        return .get(teiidType);
    }
    public static String teiidType(SingletonPrimitiveType type) {
        if (type instanceof EdmBinary) {
            return .get(EdmPrimitiveTypeKind.Binary);
        } else if (type instanceof EdmBoolean) {
            return .get(EdmPrimitiveTypeKind.Boolean);
        } else if (type instanceof EdmByte) {
            return .get(EdmPrimitiveTypeKind.Byte);
        } else if (type instanceof EdmDate) {
            return .get(EdmPrimitiveTypeKind.Date);
        } else if (type instanceof EdmDateTime) {
            return .get(EdmPrimitiveTypeKind.DateTime);
        } else if (type instanceof EdmDateTimeOffset) {
            return .get(EdmPrimitiveTypeKind.DateTime);
        } else if (type instanceof EdmDecimal) {
            return .get(EdmPrimitiveTypeKind.Decimal);
        } else if (type instanceof EdmDouble) {
            return .get(EdmPrimitiveTypeKind.Double);
        } else if (type instanceof EdmDuration) {
            return .get(EdmPrimitiveTypeKind.Int32);
        } else if (type instanceof EdmGuid) {
            return .get(EdmPrimitiveTypeKind.String);
        } else if (type instanceof EdmInt16) {
            return .get(EdmPrimitiveTypeKind.Int16);
        } else if (type instanceof EdmInt32) {
            return .get(EdmPrimitiveTypeKind.Int32);
        } else if (type instanceof EdmInt64) {
            return .get(EdmPrimitiveTypeKind.Int64);
        } else if (type instanceof EdmSByte) {
            return .get(EdmPrimitiveTypeKind.SByte);
        } else if (type instanceof EdmSingle) {
            return .get(EdmPrimitiveTypeKind.Single);
        } else if (type instanceof EdmStream) {
            return .get(EdmPrimitiveTypeKind.Stream);
        } else if (type instanceof EdmString) {
            return .get(EdmPrimitiveTypeKind.String);
        } else if (type instanceof EdmTimeOfDay) {
            return .get(EdmPrimitiveTypeKind.Time);
        }
        return null;
    }
New to GrepCode? Check out our FAQ X