List of usage examples for java.lang Short TYPE
Class TYPE
To view the source code for java.lang Short TYPE.
Click Source Link
From source file:Main.java
public static void main(String[] args) { System.out.println("Short.TYPE" + Short.TYPE); }
From source file:Main.java
public static void main(String[] args) { Class c = boolean.class; c = Boolean.TYPE;/*from w ww . jav a 2s . c om*/ c = byte.class; c = Byte.TYPE; c = char.class; c = Character.TYPE; c = short.class; c = Short.TYPE; c = int.class; c = Integer.TYPE; c = long.class; c = Long.TYPE; c = float.class; c = Float.TYPE; c = double.class; c = Double.TYPE; c = void.class; c = Void.TYPE; }
From source file:Main.java
public static void keep_setShort(Field field, Object obj, Cursor cursor, int i) { try {/*from w w w .j av a 2 s. co m*/ if (field.getType().equals(Short.TYPE)) field.setShort(obj, cursor.getShort(i)); else field.set(obj, Short.valueOf(cursor.getShort(i))); } catch (Exception exception) { exception.printStackTrace(); } }
From source file:Main.java
private static Map<Class<?>, Class<?>> getWrapperTypes() { Map<Class<?>, Class<?>> ret = new HashMap<Class<?>, Class<?>>(); ret.put(Boolean.TYPE, Boolean.class); ret.put(Character.TYPE, Character.class); ret.put(Byte.TYPE, Byte.class); ret.put(Short.TYPE, Short.class); ret.put(Integer.TYPE, Integer.class); ret.put(Long.TYPE, Long.class); ret.put(Float.TYPE, Float.class); ret.put(Double.TYPE, Double.class); ret.put(Void.TYPE, Void.class); return ret;/* w w w.ja va 2s. c o m*/ }
From source file:Main.java
public static void addBaseClassMappings() { mappings.put("byte", Byte.TYPE); mappings.put("short", Short.TYPE); mappings.put("int", Integer.TYPE); mappings.put("long", Long.TYPE); mappings.put("float", Float.TYPE); mappings.put("double", Double.TYPE); mappings.put("boolean", Boolean.TYPE); mappings.put("char", Character.TYPE); mappings.put("[byte", byte[].class); mappings.put("[short", short[].class); mappings.put("[int", int[].class); mappings.put("[long", long[].class); mappings.put("[float", float[].class); mappings.put("[double", double[].class); mappings.put("[boolean", boolean[].class); mappings.put("[char", char[].class); mappings.put(HashMap.class.getName(), HashMap.class); }
From source file:Main.java
public static Class<?> wrapperType(Class<?> paramClass) { if (paramClass == Integer.TYPE) return Integer.class; if (paramClass == Long.TYPE) return Long.class; if (paramClass == Boolean.TYPE) return Boolean.class; if (paramClass == Double.TYPE) return Double.class; if (paramClass == Float.TYPE) return Float.class; if (paramClass == Byte.TYPE) return Byte.class; if (paramClass == Short.TYPE) return Short.class; if (paramClass == Character.TYPE) return Character.class; throw new IllegalArgumentException("Class " + paramClass.getName() + " is not a primitive type"); }
From source file:Main.java
/** * This method parses the given value into the specified primitive or wrapper class. * @param clazz - primitive or wrapper class used to parse * @param value - string to be parsed/*from ww w . j av a2 s . com*/ * @return object of type clazz parsed from the string * @author Trisan Bepler */ public static Object toObject(Class<?> clazz, String value) { if (Boolean.TYPE == clazz) return Boolean.parseBoolean(value); if (Byte.TYPE == clazz) return Byte.parseByte(value); if (Short.TYPE == clazz) return Short.parseShort(value); if (Integer.TYPE == clazz) return Integer.parseInt(value); if (Long.TYPE == clazz) return Long.parseLong(value); if (Float.TYPE == clazz) return Float.parseFloat(value); if (Double.TYPE == clazz) return Double.parseDouble(value); if (Boolean.class == clazz) return Boolean.parseBoolean(value); if (Byte.class == clazz) return Byte.parseByte(value); if (Short.class == clazz) return Short.parseShort(value); if (Integer.class == clazz) return Integer.parseInt(value); if (Long.class == clazz) return Long.parseLong(value); if (Float.class == clazz) return Float.parseFloat(value); if (Double.class == clazz) return Double.parseDouble(value); if (Character.class == clazz) return value.charAt(0); if (Character.TYPE == clazz) return value.charAt(0); return value; }
From source file:Main.java
/** * Helper method used to get default value for wrappers used for primitive types * (0 for Integer etc)//from www . j a va 2 s .c om */ public static Object defaultValue(Class<?> cls) { if (cls == Integer.TYPE) { return Integer.valueOf(0); } if (cls == Long.TYPE) { return Long.valueOf(0L); } if (cls == Boolean.TYPE) { return Boolean.FALSE; } if (cls == Double.TYPE) { return Double.valueOf(0.0); } if (cls == Float.TYPE) { return Float.valueOf(0.0f); } if (cls == Byte.TYPE) { return Byte.valueOf((byte) 0); } if (cls == Short.TYPE) { return Short.valueOf((short) 0); } if (cls == Character.TYPE) { return '\0'; } throw new IllegalArgumentException("Class " + cls.getName() + " is not a primitive type"); }
From source file:Main.java
/** * Helper method for finding wrapper type for given primitive type (why isn't * there one in JDK?)/*from w ww.java 2 s. co m*/ */ public static Class<?> wrapperType(Class<?> primitiveType) { if (primitiveType == Integer.TYPE) { return Integer.class; } if (primitiveType == Long.TYPE) { return Long.class; } if (primitiveType == Boolean.TYPE) { return Boolean.class; } if (primitiveType == Double.TYPE) { return Double.class; } if (primitiveType == Float.TYPE) { return Float.class; } if (primitiveType == Byte.TYPE) { return Byte.class; } if (primitiveType == Short.TYPE) { return Short.class; } if (primitiveType == Character.TYPE) { return Character.class; } throw new IllegalArgumentException("Class " + primitiveType.getName() + " is not a primitive type"); }
From source file:Main.java
private static boolean isWideningPrimitiveNumberConversion(final Class source, final Class target) { if (target == Short.TYPE && (source == Byte.TYPE)) { return true; } else if (target == Integer.TYPE && (source == Short.TYPE || source == Byte.TYPE)) { return true; } else if (target == Long.TYPE && (source == Integer.TYPE || source == Short.TYPE || source == Byte.TYPE)) { return true; } else if (target == Float.TYPE && (source == Long.TYPE || source == Integer.TYPE || source == Short.TYPE || source == Byte.TYPE)) { return true; } else if (target == Double.TYPE && (source == Float.TYPE || source == Long.TYPE || source == Integer.TYPE || source == Short.TYPE || source == Byte.TYPE)) { return true; } else {//from ww w. j ava 2 s. c o m return false; } }