List of usage examples for java.lang Double TYPE
Class TYPE
To view the source code for java.lang Double TYPE.
Click Source Link
From source file:com.twitter.elephantbird.pig.piggybank.Invoker.java
private static Class<?> stringToClass(String klass) throws FrontendException { if ("string".equalsIgnoreCase(klass)) { return String.class; } else if ("int".equalsIgnoreCase(klass)) { return Integer.TYPE; } else if ("double".equalsIgnoreCase(klass)) { return Double.TYPE; } else if ("float".equalsIgnoreCase(klass)) { return Float.TYPE; } else if ("long".equalsIgnoreCase(klass)) { return Long.TYPE; } else if ("double[]".equalsIgnoreCase(klass)) { return DOUBLE_ARRAY_CLASS; } else if ("int[]".equalsIgnoreCase(klass)) { return INT_ARRAY_CLASS; } else if ("long[]".equalsIgnoreCase(klass)) { return LONG_ARRAY_CLASS; } else if ("float[]".equalsIgnoreCase(klass)) { return FLOAT_ARRAY_CLASS; } else if ("string[]".equalsIgnoreCase(klass)) { return STRING_ARRAY_CLASS; } else {/*from ww w.j a v a 2 s . co m*/ throw new FrontendException("unable to find matching class for " + klass); } }
From source file:org.eclipse.gyrex.monitoring.internal.mbeans.MetricSetMBean.java
private OpenType detectType(final Class type) { if ((Long.class == type) || (Long.TYPE == type)) { return SimpleType.LONG; } else if ((Integer.class == type) || (Integer.TYPE == type)) { return SimpleType.INTEGER; } else if ((Double.class == type) || (Double.TYPE == type)) { return SimpleType.DOUBLE; } else if ((Float.class == type) || (Float.TYPE == type)) { return SimpleType.FLOAT; } else if ((Byte.class == type) || (Byte.TYPE == type)) { return SimpleType.BYTE; } else if ((Short.class == type) || (Short.TYPE == type)) { return SimpleType.SHORT; } else if ((Boolean.class == type) || (Boolean.TYPE == type)) { return SimpleType.BOOLEAN; } else if (BigDecimal.class == type) { return SimpleType.BIGDECIMAL; } else if (BigInteger.class == type) { return SimpleType.BIGINTEGER; } else if ((Character.class == type) || (Character.TYPE == type)) { return SimpleType.CHARACTER; }//from w ww . ja va 2 s .c o m // last fallback to strings if (isConvertibleToString(type)) { return SimpleType.STRING; } // give up return null; }
From source file:com.browseengine.bobo.serialize.JSONSerializer.java
private static void loadObject(Object retObj, Field f, JSONObject jsonObj) throws JSONSerializationException { String key = f.getName();/* w w w. j av a 2s . c o m*/ Class type = f.getType(); try { if (type.isPrimitive()) { if (type == Integer.TYPE) { f.setInt(retObj, jsonObj.getInt(key)); } else if (type == Long.TYPE) { f.setLong(retObj, jsonObj.getInt(key)); } else if (type == Short.TYPE) { f.setShort(retObj, (short) jsonObj.getInt(key)); } else if (type == Boolean.TYPE) { f.setBoolean(retObj, jsonObj.getBoolean(key)); } else if (type == Double.TYPE) { f.setDouble(retObj, jsonObj.getDouble(key)); } else if (type == Float.TYPE) { f.setFloat(retObj, (float) jsonObj.getDouble(key)); } else if (type == Character.TYPE) { char ch = jsonObj.getString(key).charAt(0); f.setChar(retObj, ch); } else if (type == Byte.TYPE) { f.setByte(retObj, (byte) jsonObj.getInt(key)); } else { throw new JSONSerializationException("Unknown primitive: " + type); } } else if (type == String.class) { f.set(retObj, jsonObj.getString(key)); } else if (JSONSerializable.class.isAssignableFrom(type)) { JSONObject jObj = jsonObj.getJSONObject(key); JSONSerializable serObj = deSerialize(type, jObj); f.set(retObj, serObj); } } catch (Exception e) { throw new JSONSerializationException(e.getMessage(), e); } }
From source file:nz.co.senanque.validationengine.ConvertUtils.java
public static Object convertToObject(Class<?> clazz) { if (clazz.isPrimitive()) { if (clazz.equals(Long.TYPE)) { return new Long(0L); } else if (clazz.equals(Integer.TYPE)) { return new Integer(0); } else if (clazz.equals(Float.TYPE)) { return new Float(0F); } else if (clazz.equals(Double.TYPE)) { return new Double(0D); } else if (clazz.equals(Boolean.TYPE)) { return new Boolean(false); }//from w w w .j ava2 s.co m } return null; }
From source file:com.fjn.helper.common.io.file.common.FileUpAndDownloadUtil.java
/** * ???????// ww w . j a v a 2s. com * @param klass ???klass?Class * @param filepath ? * @param sizeThreshold ?? * @param isFileNameBaseTime ???? * @return bean */ public static <T> Object upload(HttpServletRequest request, Class<T> klass, String filepath, int sizeThreshold, boolean isFileNameBaseTime) throws Exception { FileItemFactory fileItemFactory = null; if (sizeThreshold > 0) { File repository = new File(filepath); fileItemFactory = new DiskFileItemFactory(sizeThreshold, repository); } else { fileItemFactory = new DiskFileItemFactory(); } ServletFileUpload upload = new ServletFileUpload(fileItemFactory); ServletRequestContext requestContext = new ServletRequestContext(request); T bean = null; if (klass != null) { bean = klass.newInstance(); } // if (ServletFileUpload.isMultipartContent(requestContext)) { File parentDir = new File(filepath); List<FileItem> fileItemList = upload.parseRequest(requestContext); for (int i = 0; i < fileItemList.size(); i++) { FileItem item = fileItemList.get(i); // ?? if (item.isFormField()) { String paramName = item.getFieldName(); String paramValue = item.getString("UTF-8"); log.info("?" + paramName + "=" + paramValue); request.setAttribute(paramName, paramValue); // ?bean if (klass != null) { Field field = null; try { field = klass.getDeclaredField(paramName); if (field != null) { field.setAccessible(true); Class type = field.getType(); if (type == Integer.TYPE) { field.setInt(bean, Integer.valueOf(paramValue)); } else if (type == Double.TYPE) { field.setDouble(bean, Double.valueOf(paramValue)); } else if (type == Float.TYPE) { field.setFloat(bean, Float.valueOf(paramValue)); } else if (type == Boolean.TYPE) { field.setBoolean(bean, Boolean.valueOf(paramValue)); } else if (type == Character.TYPE) { field.setChar(bean, paramValue.charAt(0)); } else if (type == Long.TYPE) { field.setLong(bean, Long.valueOf(paramValue)); } else if (type == Short.TYPE) { field.setShort(bean, Short.valueOf(paramValue)); } else { field.set(bean, paramValue); } } } catch (NoSuchFieldException e) { log.info("" + klass.getName() + "?" + paramName); } } } // else { // <input type='file' name='xxx'> xxx String paramName = item.getFieldName(); log.info("?" + item.getSize()); if (sizeThreshold > 0) { if (item.getSize() > sizeThreshold) continue; } String clientFileName = item.getName(); int index = -1; // ?IE? if ((index = clientFileName.lastIndexOf("\\")) != -1) { clientFileName = clientFileName.substring(index + 1); } if (clientFileName == null || "".equals(clientFileName)) continue; String filename = null; log.info("" + paramName + "\t??" + clientFileName); if (isFileNameBaseTime) { filename = buildFileName(clientFileName); } else filename = clientFileName; request.setAttribute(paramName, filename); // ?bean if (klass != null) { Field field = null; try { field = klass.getDeclaredField(paramName); if (field != null) { field.setAccessible(true); field.set(bean, filename); } } catch (NoSuchFieldException e) { log.info("" + klass.getName() + "? " + paramName); continue; } } if (!parentDir.exists()) { parentDir.mkdirs(); } File newfile = new File(parentDir, filename); item.write(newfile); String serverPath = newfile.getPath(); log.info("?" + serverPath); } } } return bean; }
From source file:de.micromata.genome.util.strings.converter.StandardStringConverter.java
@Override public char getTypeChar(Object value) { if (value == null) { return ConvertedStringTypes.NULL.getShortType(); }/* ww w . j av a 2 s .co m*/ Class<?> cls = value.getClass(); if (value instanceof String) { return ConvertedStringTypes.STRING.getShortType(); } Class<?> vclass = value.getClass(); if (value instanceof Boolean || vclass == Boolean.TYPE) { return ConvertedStringTypes.BOOLEAN.getShortType(); } if (value instanceof Byte || vclass == Byte.TYPE) { return ConvertedStringTypes.BYTE.getShortType(); } if (value instanceof Short || vclass == Short.TYPE) { return ConvertedStringTypes.SHORT.getShortType(); } if (value instanceof Integer || vclass == Integer.TYPE) { return ConvertedStringTypes.INTEGER.getShortType(); } if (value instanceof Long || vclass == Long.TYPE) { return ConvertedStringTypes.LONG.getShortType(); } if (value instanceof Float || vclass == Float.TYPE) { return ConvertedStringTypes.FLOAT.getShortType(); } if (value instanceof Double || vclass == Double.TYPE) { return ConvertedStringTypes.DOUBLE.getShortType(); } if (value instanceof Character || vclass == Character.TYPE) { return ConvertedStringTypes.CHAR.getShortType(); } if (value instanceof Date) { return ConvertedStringTypes.DATE.getShortType(); } if (value instanceof BigDecimal) { return ConvertedStringTypes.BIGDECIMAL.getShortType(); } if (value instanceof Character) { return ConvertedStringTypes.CHAR.getShortType(); } if (value instanceof byte[]) { return ConvertedStringTypes.BYTEARRAY.getShortType(); } if (value instanceof String[]) { return ConvertedStringTypes.STRINGARRAY.getShortType(); } if (value instanceof Long[]) { return ConvertedStringTypes.LONGARRAY.getShortType(); } // if (value instanceof Serializable) // return ConvertedStringTypes.XMLOBJECT; return ConvertedStringTypes.CUSTOM.getShortType(); }
From source file:org.briljantframework.data.Na.java
/** * Returns the {@code NA} value for the class {@code T}. For reference types (excluding * {@link Complex} and {@link Logical}) {@code NA} is represented as {@code null}, but for * primitive types a special convention is used. * * <ul>/* w w w. j a v a 2s . c om*/ * <li>{@code double}: {@link Na#DOUBLE}</li> * <li>{@code int}: {@link Na#INT}</li> * <li>{@code long}: {@link Long#MAX_VALUE}</li> * <li>{@link Logical}: {@link Logical#NA}</li> * <li>{@link Complex}: {@link Na#COMPLEX}</li> * </ul> * * @param cls the class * @param <T> the type of {@code cls} * @return a {@code NA} value of type {@code T} */ @SuppressWarnings("unchecked") public static <T> T of(Class<T> cls) { if (cls == null) { return null; } else if (Double.class.equals(cls) || Double.TYPE.equals(cls)) { return (T) BOXED_DOUBLE; } else if (Float.class.equals(cls) || Float.TYPE.equals(cls)) { return (T) BOXED_FLOAT; } else if (Long.class.equals(cls) || Long.TYPE.equals(cls)) { return (T) BOXED_LONG; } else if (Integer.class.equals(cls) || Integer.TYPE.equals(cls)) { return (T) BOXED_INT; } else if (Short.class.equals(cls) || Short.TYPE.equals(cls)) { return (T) BOXED_SHORT; } else if (Byte.class.equals(cls) || Byte.TYPE.equals(cls)) { return (T) BOXED_BYTE; } else if (Character.class.equals(cls) || Character.TYPE.equals(cls)) { return (T) BOXED_CHAR; } else if (Logical.class.equals(cls)) { return (T) Logical.NA; } else if (Complex.class.equals(cls)) { return (T) COMPLEX; } else { return null; } }
From source file:org.openflexo.antar.binding.TypeUtils.java
public static Class toPrimitive(Class<?> aClass) { if (isDouble(aClass)) { return Double.TYPE; }/*from ww w . j a v a 2 s .co m*/ if (isFloat(aClass)) { return Float.TYPE; } if (isLong(aClass)) { return Long.TYPE; } if (isInteger(aClass)) { return Integer.TYPE; } if (isShort(aClass)) { return Short.TYPE; } if (isByte(aClass)) { return Byte.TYPE; } if (isBoolean(aClass)) { return Boolean.TYPE; } if (isChar(aClass)) { return Character.TYPE; } return aClass; }
From source file:com.github.jknack.handlebars.helper.MethodHelper.java
/** * Wrap (if possible) a primitive type to their wrapper. * * @param type The candidate type./*from w ww .ja v a 2 s. c om*/ * @return A wrapper for the primitive type or the original type. */ private static Class<?> wrap(final Class<?> type) { if (type.isPrimitive()) { if (type == Integer.TYPE) { return Integer.class; } else if (type == Boolean.TYPE) { return Boolean.class; } else if (type == Character.TYPE) { return Character.class; } else if (type == Double.TYPE) { return Double.class; } else if (type == Long.TYPE) { return Long.class; } else if (type == Float.TYPE) { return Float.class; } else if (type == Short.TYPE) { return Short.class; } else if (type == Byte.TYPE) { return Byte.class; } } return type; }
From source file:org.yccheok.jstock.gui.POIUtils.java
private static void handlePrimitive(Method method, Class<?> clazz) { if (clazz == Boolean.TYPE) { parameterTypeMap.put(Boolean.class, method); } else if (clazz == Character.TYPE) { parameterTypeMap.put(Character.class, method); } else if (clazz == Byte.TYPE) { parameterTypeMap.put(Byte.class, method); } else if (clazz == Short.TYPE) { parameterTypeMap.put(Short.class, method); } else if (clazz == Integer.TYPE) { parameterTypeMap.put(Integer.class, method); } else if (clazz == Long.TYPE) { parameterTypeMap.put(Long.class, method); } else if (clazz == Float.TYPE) { parameterTypeMap.put(Float.class, method); } else if (clazz == Double.TYPE) { parameterTypeMap.put(Double.class, method); } // ... and so on for the other six primitive types (void doesn't matter) }