List of usage examples for java.lang Short valueOf
@HotSpotIntrinsicCandidate public static Short valueOf(short s)
From source file:Main.java
/** * Converts to object array.//from w ww . ja v a2 s .c o m */ public static Short[] valuesOf(short[] array) { Short[] dest = new Short[array.length]; for (int i = 0; i < array.length; i++) { dest[i] = Short.valueOf(array[i]); } return dest; }
From source file:Main.java
@SuppressWarnings("unchecked") public static <T> T parse(Class<T> type, String stringValue) throws IllegalArgumentException { if (type.equals(String.class)) { return (T) stringValue; }/*from w w w. j a va2s. c o m*/ if (type.equals(Boolean.class) || type.equals(boolean.class)) { return (T) Boolean.valueOf(stringValue); } try { if (type.equals(Integer.class) || type.equals(int.class)) { return (T) Integer.valueOf(stringValue); } if (type.equals(Long.class) || type.equals(long.class)) { return (T) Long.valueOf(stringValue); } if (type.equals(Short.class) || type.equals(short.class)) { return (T) Short.valueOf(stringValue); } if (type.equals(Byte.class) || type.equals(byte.class)) { return (T) Byte.valueOf(stringValue); } if (type.equals(Double.class) || type.equals(double.class)) { return (T) Double.valueOf(stringValue); } if (type.equals(Float.class) || type.equals(float.class)) { return (T) Float.valueOf(stringValue); } if (type.equals(File.class)) { return (T) new File(stringValue); } } catch (final NumberFormatException e) { throw new IllegalArgumentException(e.getMessage(), e); } if (type.isEnum()) { @SuppressWarnings("rawtypes") final Class enumType = type; return (T) Enum.valueOf(enumType, stringValue); } throw new IllegalArgumentException("Can't handle type " + type); }
From source file:Main.java
static short shortElement(Element row, String name) { return Short.valueOf(stringElement(row, name)); }
From source file:PrimitiveUtils.java
public static Object read(String value, Class type) { Object ret = value;/*from w w w .j ava 2 s. co m*/ if (Integer.TYPE.equals(type)) { ret = Integer.valueOf(value); } if (Byte.TYPE.equals(type)) { ret = Byte.valueOf(value); } if (Short.TYPE.equals(type)) { ret = Short.valueOf(value); } if (Long.TYPE.equals(type)) { ret = Long.valueOf(value); } if (Float.TYPE.equals(type)) { ret = Float.valueOf(value); } if (Double.TYPE.equals(type)) { ret = Double.valueOf(value); } if (Boolean.TYPE.equals(type)) { ret = Boolean.valueOf(value); } if (Character.TYPE.equals(type)) { ret = value.charAt(0); } // TODO others. return ret; }
From source file:Main.java
/** * Utility method that puts the named short value to the given map. * * @param properties map of properties (String -> Object) * @param name property name/*ww w .ja va 2 s . co m*/ * @param value property value */ private static void putShort(Map<String, Object> properties, String name, short value) { properties.put(name, Short.valueOf(value)); }
From source file:com.yoncabt.ebr.executor.jasper.Convert.java
private static <T> T str2Number(String val, Class<T> valueClass) { if (StringUtils.isBlank(val)) { return null; }/*w w w .ja va 2 s. c o m*/ if (valueClass == Integer.class) { return (T) Integer.valueOf(val); } if (valueClass == Long.class) { return (T) Long.valueOf(val); } if (valueClass == Short.class) { return (T) Short.valueOf(val); } if (valueClass == Double.class) { return (T) Double.valueOf(val); } if (valueClass == BigDecimal.class) { return (T) new BigDecimal(val); } throw new IllegalArgumentException(val.getClass() + "->" + valueClass.getName()); }
From source file:com.alibaba.doris.admin.service.impl.ValueParseUtil.java
/** * ?,?,// w w w. j av a 2s . c o m * * @param clazz * @return */ @SuppressWarnings("unchecked") private static <T> T getInternalDefaultValue(Class<T> clazz) { if (!clazz.isPrimitive()) { return null; } if (Short.TYPE.equals(clazz)) { return (T) Short.valueOf((short) 0); } if (Integer.TYPE.equals(clazz)) { return (T) Integer.valueOf(0); } if (Long.TYPE.equals(clazz)) { return (T) Long.valueOf(0); } if (Boolean.TYPE.equals(clazz)) { return (T) Boolean.valueOf(false); } if (Float.TYPE.equals(clazz)) { return (T) Float.valueOf(0); } if (Double.TYPE.equals(clazz)) { return (T) Double.valueOf(0); } if (Byte.TYPE.equals(clazz)) { return (T) Byte.valueOf((byte) 0); } if (Character.TYPE.equals(clazz)) { return (T) Character.valueOf('\0'); } return null; }
From source file:Main.java
public static Object typeConversion(Class<?> cls, String str) { Object obj = null;// ww w. j a v a 2 s .c om String nameType = cls.getSimpleName(); if ("Integer".equals(nameType)) { obj = Integer.valueOf(str); } if ("String".equals(nameType)) { obj = str; } if ("Float".equals(nameType)) { obj = Float.valueOf(str); } if ("Double".equals(nameType)) { obj = Double.valueOf(str); } if ("Boolean".equals(nameType)) { obj = Boolean.valueOf(str); } if ("Long".equals(nameType)) { obj = Long.valueOf(str); } if ("Short".equals(nameType)) { obj = Short.valueOf(str); } if ("Character".equals(nameType)) { obj = str.charAt(1); } return obj; }
From source file:org.exolab.castor.xml.parsing.primitive.objects.PrimitiveShort.java
@Override public Object getObject(Class<?> type, String value) { if (StringUtils.isEmpty(value)) { return Short.valueOf((short) 0); }//from w w w .j ava 2s . c om return Short.valueOf(Short.parseShort(value)); }
From source file:edu.umd.cs.findbugs.detect.LpUtil.java
/** * // w w w.j a va2 s. com */ public static boolean isMulOrDiv(int seen) { return mulOrDivList.contains(Short.valueOf(String.valueOf(seen))); }