Java examples for java.lang:String SQL
Convert the provided sqlite primitive data type into a java primitive type
//package com.java2s; public class Main { public static void main(String[] argv) { String sqliteType = "String"; System.out.println(convertSQLiteTypeToJavaType(sqliteType)); }//from www . j a v a 2s. c o m private final static String JAVA_TYPE_STRING = "String"; private final static String JAVA_TYPE_INTEGER = "int"; private final static String JAVA_TYPE_LONG = "long"; private final static String JAVA_TYPE_DOUBLE = "double"; private final static String JAVA_TYPE_BYTE_ARRAY = "byte[]"; public final static String SQL_TYPE_VARCHAR = "varchar"; public final static String SQL_TYPE_INTEGER = "integer"; public final static String SQL_TYPE_LONG = "long"; public final static String SQL_TYPE_REAL = "real"; public final static String SQL_TYPE_BLOB = "blob"; /** * Convert the provided sqlite primitive data type into a java primitive type * @param sqliteType The sqlite primitive data type to convert into a java primitive type * @return The java primitive data type that relates to the provided sqliteType */ public static String convertSQLiteTypeToJavaType(String sqliteType) { String javaType = ""; if (sqliteType.equals(SQL_TYPE_VARCHAR)) { javaType = JAVA_TYPE_STRING; } else if (sqliteType.equals(SQL_TYPE_INTEGER)) { javaType = JAVA_TYPE_INTEGER; } else if (sqliteType.equals(SQL_TYPE_LONG)) { javaType = JAVA_TYPE_LONG; } else if (sqliteType.equals(SQL_TYPE_REAL)) { javaType = JAVA_TYPE_DOUBLE; } else if (sqliteType.equals(SQL_TYPE_BLOB)) { javaType = JAVA_TYPE_BYTE_ARRAY; } else { javaType = JAVA_TYPE_STRING; } return javaType; } }