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:jef.tools.ArrayUtils.java
/** * ?//from w w w. ja v a2 s. c o m * * @param obj * @return */ public static Object[] toObject(Object obj) { Class<?> c = obj.getClass(); Assert.isTrue(c.isArray()); Class<?> priType = c.getComponentType(); if (!priType.isPrimitive()) return (Object[]) obj; if (priType == Boolean.TYPE) { return toObject((boolean[]) obj); } else if (priType == Byte.TYPE) { return toObject((byte[]) obj); } else if (priType == Character.TYPE) { return toObject((char[]) obj); } else if (priType == Integer.TYPE) { return toObject((int[]) obj); } else if (priType == Long.TYPE) { return toObject((long[]) obj); } else if (priType == Float.TYPE) { return toObject((float[]) obj); } else if (priType == Double.TYPE) { return toObject((double[]) obj); } else if (priType == Short.TYPE) { return toObject((short[]) obj); } throw new IllegalArgumentException(); }
From source file:org.evosuite.regression.ObjectFields.java
private static Object getFieldValue(Field field, Object p) { try {/*from w ww .j a va 2 s . c o m*/ /*Class objClass = p.getClass(); if(p instanceof java.lang.String){ ((String) p).hashCode(); }*/ Class<?> fieldType = field.getType(); field.setAccessible(true); if (fieldType.isPrimitive()) { if (fieldType.equals(Boolean.TYPE)) { return field.getBoolean(p); } if (fieldType.equals(Integer.TYPE)) { return field.getInt(p); } if (fieldType.equals(Byte.TYPE)) { return field.getByte(p); } if (fieldType.equals(Short.TYPE)) { return field.getShort(p); } if (fieldType.equals(Long.TYPE)) { return field.getLong(p); } if (fieldType.equals(Double.TYPE)) { return field.getDouble(p); } if (fieldType.equals(Float.TYPE)) { return field.getFloat(p); } if (fieldType.equals(Character.TYPE)) { return field.getChar(p); } throw new UnsupportedOperationException("Primitive type " + fieldType + " not implemented!"); } return field.get(p); } catch (IllegalAccessException exc) { throw new RuntimeException(exc); } catch (OutOfMemoryError e) { e.printStackTrace(); if (MAX_RECURSION != 0) MAX_RECURSION = 0; else throw new RuntimeErrorException(e); return getFieldValue(field, p); } }
From source file:com.link_intersystems.lang.Conversions.java
/** * <em>java language specification - 5.1.3 Narrowing Primitive Conversions</em> * ./*from www. j a v a2s.c om*/ * * <code> * <blockquote>The following 22 specific conversions on primitive types * are called the narrowing primitive conversions: * <ul> * <li>short to byte or char</li> * <li>char to byte or short</li> * <li>int to byte, short, or char</li> * <li>long to byte, short, char, or int</li> * <li>float to byte, short, char, int, or long</li> * <li>double to byte, short, char, int, long, or float </li> * </blockquote> * </code> * * @param from * the base type * @param to * the widening type * @return true if from to to is a primitive widening. * @since 1.0.0.0 */ public static boolean isPrimitiveNarrowing(Class<?> from, Class<?> to) { Assert.isTrue(Primitives.isPrimitive(from), "mustBeAPrimitive", "form"); Assert.isTrue(Primitives.isPrimitive(to), "mustBeAPrimitive", "to"); boolean isPrimitiveNarrowing = false; if (isIdentity(from, Double.TYPE)) { isPrimitiveNarrowing = isPrimitiveDoubleNarrowing(to); } else if (isIdentity(from, Short.TYPE)) { isPrimitiveNarrowing = isPrimitiveShortNarrowing(to); } else if (isIdentity(from, Character.TYPE)) { isPrimitiveNarrowing = isPrimitiveCharacterNarrowing(to); } else if (isIdentity(from, Integer.TYPE)) { isPrimitiveNarrowing = isPrimitiveIntegerNarrowing(to); } else if (isIdentity(from, Long.TYPE)) { isPrimitiveNarrowing = isPrimitiveLongNarrowing(to); } else if (isIdentity(from, Float.TYPE)) { isPrimitiveNarrowing = isPrimitiveFloatNarrowing(to); } /* * must be a byte */ return isPrimitiveNarrowing; }
From source file:com.adobe.acs.commons.mcp.util.AnnotatedFieldDeserializer.java
@SuppressWarnings("squid:S3776") private static Object convertPrimitiveValue(String value, Class<?> type) throws ParseException { if (type.equals(Boolean.class) || type.equals(Boolean.TYPE)) { return value.toLowerCase().trim().equals("true"); } else {/*from ww w . j av a 2 s . c o m*/ NumberFormat numberFormat = NumberFormat.getNumberInstance(); Number num = numberFormat.parse(value); if (type.equals(Byte.class) || type.equals(Byte.TYPE)) { return num.byteValue(); } else if (type.equals(Double.class) || type.equals(Double.TYPE)) { return num.doubleValue(); } else if (type.equals(Float.class) || type.equals(Float.TYPE)) { return num.floatValue(); } else if (type.equals(Integer.class) || type.equals(Integer.TYPE)) { return num.intValue(); } else if (type.equals(Long.class) || type.equals(Long.TYPE)) { return num.longValue(); } else if (type.equals(Short.class) || type.equals(Short.TYPE)) { return num.shortValue(); } else { return null; } } }
From source file:org.skfiy.typhon.spi.GMConsoleProvider.java
/** * * @param uid//w w w. jav a 2 s .c om * @param propertyName * @param val * @throws javax.management.MBeanException */ public void changeProperty(final String uid, final String propertyName, final String val) throws MBeanException { try { invoke(transcoding(uid), new Handler() { @Override void execute() { Player player = SessionUtils.getPlayer(); try { Class<?> propertyType = PropertyUtils.getPropertyType(player, propertyName); if (propertyType == null) { // Not found property throw new IllegalArgumentException("Not found property[" + propertyName + "]"); } if (propertyType == Byte.class || propertyType == Byte.TYPE) { BeanUtils.setProperty(player, propertyName, Byte.valueOf(val)); } else if (propertyType == Character.class || propertyType == Character.TYPE) { BeanUtils.setProperty(player, propertyName, val.charAt(0)); } else if (propertyType == Boolean.class || propertyType == Boolean.TYPE) { BeanUtils.setProperty(player, propertyName, Boolean.valueOf(val)); } else if (propertyType == Integer.class || propertyType == Integer.TYPE) { BeanUtils.setProperty(player, propertyName, Integer.valueOf(val)); } else if (propertyType == Long.class || propertyType == Long.TYPE) { BeanUtils.setProperty(player, propertyName, Long.valueOf(val)); } else if (propertyType == Float.class || propertyType == Float.TYPE) { BeanUtils.setProperty(player, propertyName, Float.valueOf(val)); } else if (propertyType == Double.class || propertyType == Double.TYPE) { BeanUtils.setProperty(player, propertyName, Double.valueOf(val)); } else { BeanUtils.setProperty(player, propertyName, val); } } catch (Exception ex) { throw new IllegalArgumentException(ex.getMessage()); } } }); } catch (Exception e) { throw new MBeanException(e, e.getMessage()); } }
From source file:com.ms.commons.summer.web.util.json.JsonNumberMorpher.java
private boolean isDecimalNumber(Class<?> type) { return (Double.class.isAssignableFrom(type) || Float.class.isAssignableFrom(type) || Double.TYPE == type || Float.TYPE == type || BigDecimal.class.isAssignableFrom(type)); }
From source file:com.projity.util.ClassUtils.java
/** * Given a type, return a value that signifies that there are multiple values. This can occur in a dialog which works on multile objects at once. If type is unknown, a new one is constructed * @param clazz/* w w w .j ava 2s . c om*/ * @return */ public static Object getMultipleValueForType(Class clazz) { if (clazz == String.class) return STRING_MULTIPLE_VALUES; else if (clazz == Double.class || clazz == Double.TYPE) return DOUBLE_MULTIPLE_VALUES; else if (clazz == Integer.class || clazz == Integer.TYPE) return INTEGER_MULTIPLE_VALUES; else if (clazz == Long.class || clazz == Long.TYPE) return LONG_MULTIPLE_VALUES; else if (clazz == Float.class || clazz == Float.TYPE) return FLOAT_MULTIPLE_VALUES; else if (clazz == Boolean.class) return BOOLEAN_MULTIPLE_VALUES; else if (clazz == Rate.class) return RATE_MULTIPLE_VALUES; else { try { return clazz.newInstance(); } catch (InstantiationException e) { } catch (IllegalAccessException e) { } return null; } }
From source file:org.kuali.kfs.sys.context.DocumentSerializabilityTest.java
/** * Determines if the given class represents one of the eight Java primitives * @param clazz the class to check//from w w w . j a va 2 s . co m * @return true if the class represents a byte, short, int, long, char, double, float, or boolean; false otherwise */ protected boolean isPrimitive(Class<?> clazz) { return Byte.TYPE.isAssignableFrom(clazz) || Short.TYPE.isAssignableFrom(clazz) || Integer.TYPE.isAssignableFrom(clazz) || Long.TYPE.isAssignableFrom(clazz) || Float.TYPE.isAssignableFrom(clazz) || Double.TYPE.isAssignableFrom(clazz) || Character.TYPE.isAssignableFrom(clazz) || Boolean.TYPE.isAssignableFrom(clazz); }
From source file:candr.yoclip.option.OptionField.java
@Override public void setOption(final T bean, final String value) { final Class<?> fieldType = getField().getType(); try {//from www.jav a2 s. co m if (Boolean.TYPE.equals(fieldType) || Boolean.class.isAssignableFrom(fieldType)) { setBooleanOption(bean, value); } else if (Byte.TYPE.equals(fieldType) || Byte.class.isAssignableFrom(fieldType)) { setByteOption(bean, value); } else if (Short.TYPE.equals(fieldType) || Short.class.isAssignableFrom(fieldType)) { setShortOption(bean, value); } else if (Integer.TYPE.equals(fieldType) || Integer.class.isAssignableFrom(fieldType)) { setIntegerOption(bean, value); } else if (Long.TYPE.equals(fieldType) || Long.class.isAssignableFrom(fieldType)) { setLongOption(bean, value); } else if (Character.TYPE.equals(fieldType) || Character.class.isAssignableFrom(fieldType)) { setCharacterOption(bean, value); } else if (Float.TYPE.equals(fieldType) || Float.class.isAssignableFrom(fieldType)) { setFloatOption(bean, value); } else if (Double.TYPE.equals(fieldType) || Double.class.isAssignableFrom(fieldType)) { setDoubleOption(bean, value); } else if (String.class.isAssignableFrom(fieldType)) { setStringOption(bean, value); } else { final String supportedTypes = "boolean, byte, short, int, long, char, float, double, and String"; throw new OptionsParseException( String.format("OldOptionsParser only support %s types", supportedTypes)); } } catch (NumberFormatException e) { final String error = String.format("Error converting '%s' to %s", value, fieldType); throw new OptionsParseException(error, e); } }
From source file:com.cyclopsgroup.waterview.utils.TypeUtils.java
private static Map getNonePrimitiveTypeMap() { if (nonePrimitiveTypeMap == null) { nonePrimitiveTypeMap = new Hashtable(); nonePrimitiveTypeMap.put(Boolean.TYPE, Boolean.class); nonePrimitiveTypeMap.put(Byte.TYPE, Byte.class); nonePrimitiveTypeMap.put(Character.TYPE, Character.class); nonePrimitiveTypeMap.put(Short.TYPE, Short.class); nonePrimitiveTypeMap.put(Integer.TYPE, Integer.class); nonePrimitiveTypeMap.put(Long.TYPE, Long.class); nonePrimitiveTypeMap.put(Float.TYPE, Float.class); nonePrimitiveTypeMap.put(Double.TYPE, Double.class); }/*from w ww .j a v a2 s. c o m*/ return nonePrimitiveTypeMap; }