Java Java String Format toJavaTypeName(String edmTypeName)

Here you can find the source of toJavaTypeName(String edmTypeName)

Description

Returns the name of the corresponding Java class or scalar type.

License

Open Source License

Parameter

Parameter Description
edmTypeName The type name.

Return

The name of the corresponding Java class or scalar type.

Declaration

public static String toJavaTypeName(String edmTypeName) 

Method Source Code

//package com.java2s;
/**//from   w  ww .ja  va  2 s.  c om
 * Copyright 2005-2014 Restlet
 * 
 * The contents of this file are subject to the terms of one of the following
 * open source licenses: Apache 2.0 or or EPL 1.0 (the "Licenses"). You can
 * select the license that you prefer but you may not use this file except in
 * compliance with one of these Licenses.
 * 
 * You can obtain a copy of the Apache 2.0 license at
 * http://www.opensource.org/licenses/apache-2.0
 * 
 * You can obtain a copy of the EPL 1.0 license at
 * http://www.opensource.org/licenses/eclipse-1.0
 * 
 * See the Licenses for the specific language governing permissions and
 * limitations under the Licenses.
 * 
 * Alternatively, you can obtain a royalty free commercial license with less
 * limitations, transferable or non-transferable, directly at
 * http://restlet.com/products/restlet-framework
 * 
 * Restlet is a registered trademark of Restlet S.A.S.
 */

public class Main {
    /**
     * Returns the name of the corresponding Java class or scalar type.
     * 
     * @param edmTypeName
     *            The type name.
     * @return The name of the corresponding Java class or scalar type.
     */
    public static String toJavaTypeName(String edmTypeName) {
        String result = "Object";
        if (edmTypeName.endsWith("Binary")) {
            result = "byte[]";
        } else if (edmTypeName.endsWith("Boolean")) {
            result = "boolean";
        } else if (edmTypeName.endsWith("DateTime")) {
            result = "Date";
        } else if (edmTypeName.endsWith("DateTimeOffset")) {
            result = "Date";
        } else if (edmTypeName.endsWith("Time")) {
            result = "long";
        } else if (edmTypeName.endsWith("Decimal")) {
            result = "double";
        } else if (edmTypeName.endsWith("Single")) {
            result = "double";
        } else if (edmTypeName.endsWith("Double")) {
            result = "double";
        } else if (edmTypeName.endsWith("Guid")) {
            result = "String";
        } else if (edmTypeName.endsWith("Int16")) {
            result = "short";
        } else if (edmTypeName.endsWith("Int32")) {
            result = "int";
        } else if (edmTypeName.endsWith("Int64")) {
            result = "long";
        } else if (edmTypeName.endsWith("Byte")) {
            result = "byte";
        } else if (edmTypeName.endsWith("String")) {
            result = "String";
        }

        return result;
    }
}

Related

  1. toJavaString(final String s)
  2. toJavaString(String buf)
  3. toJavaString(String text)
  4. toJavaTime(double time)
  5. toJavaTypeIdentifier(String string)
  6. toJavaTypes(Class clazz, String value)
  7. toJavaVariable(Class compClass, String name)