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:MethodHashing.java
static String getTypeString(Class cl) { if (cl == Byte.TYPE) { return "B"; } else if (cl == Character.TYPE) { return "C"; } else if (cl == Double.TYPE) { return "D"; } else if (cl == Float.TYPE) { return "F"; } else if (cl == Integer.TYPE) { return "I"; } else if (cl == Long.TYPE) { return "J"; } else if (cl == Short.TYPE) { return "S"; } else if (cl == Boolean.TYPE) { return "Z"; } else if (cl == Void.TYPE) { return "V"; } else if (cl.isArray()) { return "[" + getTypeString(cl.getComponentType()); } else {// w ww. j av a 2s. co m return "L" + cl.getName().replace('.', '/') + ";"; } }
From source file:demo.config.PropertyConverter.java
/** * Converts the specified value to the target class. If the class is a * primitive type (Integer.TYPE, Boolean.TYPE, etc) the value returned will * use the wrapper type (Integer.class, Boolean.class, etc). * /* ww w .ja va 2 s .co m*/ * @param cls * the target class of the converted value * @param value * the value to convert * @param params * optional parameters used for the conversion * @return the converted value * @throws ConversionException * if the value is not compatible with the requested type * * @since 1.5 */ static Object to(Class<?> cls, Object value, Object[] params) throws ConversionException { if (cls.isInstance(value)) { return value; // no conversion needed } if (Boolean.class.equals(cls) || Boolean.TYPE.equals(cls)) { return toBoolean(value); } else if (Character.class.equals(cls) || Character.TYPE.equals(cls)) { return toCharacter(value); } else if (Number.class.isAssignableFrom(cls) || cls.isPrimitive()) { if (Integer.class.equals(cls) || Integer.TYPE.equals(cls)) { return toInteger(value); } else if (Long.class.equals(cls) || Long.TYPE.equals(cls)) { return toLong(value); } else if (Byte.class.equals(cls) || Byte.TYPE.equals(cls)) { return toByte(value); } else if (Short.class.equals(cls) || Short.TYPE.equals(cls)) { return toShort(value); } else if (Float.class.equals(cls) || Float.TYPE.equals(cls)) { return toFloat(value); } else if (Double.class.equals(cls) || Double.TYPE.equals(cls)) { return toDouble(value); } else if (BigInteger.class.equals(cls)) { return toBigInteger(value); } else if (BigDecimal.class.equals(cls)) { return toBigDecimal(value); } } else if (Date.class.equals(cls)) { return toDate(value, (String) params[0]); } else if (Calendar.class.equals(cls)) { return toCalendar(value, (String) params[0]); } else if (URL.class.equals(cls)) { return toURL(value); } else if (Locale.class.equals(cls)) { return toLocale(value); } else if (isEnum(cls)) { return convertToEnum(cls, value); } else if (Color.class.equals(cls)) { return toColor(value); } else if (cls.getName().equals(INTERNET_ADDRESS_CLASSNAME)) { return toInternetAddress(value); } else if (InetAddress.class.isAssignableFrom(cls)) { return toInetAddress(value); } throw new ConversionException("The value '" + value + "' (" + value.getClass() + ")" + " can't be converted to a " + cls.getName() + " object"); }
From source file:org.wrml.runtime.syntax.DefaultSyntaxLoader.java
@Override @SuppressWarnings({ "unchecked", "rawtypes" }) public final <T> T parseSyntacticText(final String text, final java.lang.reflect.Type targetType) { if (text == null) { return null; }/* w ww .j a v a 2 s. c o m*/ if (targetType == null || targetType.equals(String.class)) { return (T) text; } if (targetType.equals(Integer.TYPE) || targetType.equals(Integer.class)) { return (T) new Integer(text); } if (targetType.equals(Boolean.TYPE) || targetType.equals(Boolean.class)) { return (T) (text.equals("true") ? Boolean.TRUE : Boolean.FALSE); } if (targetType.equals(Long.TYPE) || targetType.equals(Long.class)) { return (T) new Long(text); } if (targetType.equals(Double.TYPE) || targetType.equals(Double.class)) { return (T) new Double(text); } if (TypeUtils.isAssignable(targetType, Enum.class)) { return (T) Enum.valueOf((Class<Enum>) targetType, text); } if (targetType instanceof Class<?>) { final SyntaxHandler<?> syntaxHandler = getSyntaxHandler((Class<?>) targetType); if (syntaxHandler != null) { return (T) syntaxHandler.parseSyntacticText(text); } } throw new SyntaxRegistryException( "Failed to transform text: \"" + text + "\" value to target type: " + targetType, null, this); }
From source file:io.openmessaging.rocketmq.utils.BeanUtils.java
public static void setProperties(Class<?> clazz, Object obj, String methodName, Object value) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { Class<?> parameterClass = getMethodClass(clazz, methodName); Method setterMethod = clazz.getMethod(methodName, parameterClass); if (parameterClass == Boolean.TYPE) { setterMethod.invoke(obj, Boolean.valueOf(value.toString())); } else if (parameterClass == Integer.TYPE) { setterMethod.invoke(obj, Integer.valueOf(value.toString())); } else if (parameterClass == Double.TYPE) { setterMethod.invoke(obj, Double.valueOf(value.toString())); } else if (parameterClass == Float.TYPE) { setterMethod.invoke(obj, Float.valueOf(value.toString())); } else if (parameterClass == Long.TYPE) { setterMethod.invoke(obj, Long.valueOf(value.toString())); } else/*ww w .j a v a 2 s. com*/ setterMethod.invoke(obj, value); }
From source file:net.sf.json.JSONDynaBean.java
/** * DOCUMENT ME!//from w ww . ja va 2s.c o m * * @param name DOCUMENT ME! * * @return DOCUMENT ME! */ public Object get(String name) { Object value = dynaValues.get(name); if (value != null) { return value; } Class type = getDynaProperty(name).getType(); if (type == null) { throw new NullPointerException("Unspecified property type for " + name); } if (!type.isPrimitive()) { return value; } if (type == Boolean.TYPE) { return Boolean.FALSE; } else if (type == Byte.TYPE) { return new Byte((byte) 0); } else if (type == Character.TYPE) { return new Character((char) 0); } else if (type == Short.TYPE) { return new Short((short) 0); } else if (type == Integer.TYPE) { return new Integer(0); } else if (type == Long.TYPE) { return new Long(0); } else if (type == Float.TYPE) { return new Float(0.0); } else if (type == Double.TYPE) { return new Double(0); } return null; }
From source file:org.hyperic.hq.plugin.jboss.MBeanUtil.java
private static void initConverters() { addConverter(Object.class, new Converter() { public Object convert(String param) { return param; }/*w ww. j a v a2s. c o m*/ }); addConverter(Short.class, new Converter() { public Object convert(String param) { return Short.valueOf(param); } }); addConverter(Integer.class, new Converter() { public Object convert(String param) { return Integer.valueOf(param); } }); addConverter(Long.class, new Converter() { public Object convert(String param) { return Long.valueOf(param); } }); addConverter(Double.class, new Converter() { public Object convert(String param) { return Double.valueOf(param); } }); addConverter(Boolean.class, new Converter() { public Object convert(String param) { return Boolean.valueOf(param); } }); addConverter(File.class, new Converter() { public Object convert(String param) { return new File(param); } }); addConverter(URL.class, new Converter() { public Object convert(String param) { try { return new URL(param); } catch (MalformedURLException e) { throw invalid(param, e); } } }); addConverter(ObjectName.class, new Converter() { public Object convert(String param) { try { return new ObjectName(param); } catch (MalformedObjectNameException e) { throw invalid(param, e); } } }); addConverter(List.class, new ListConverter() { public Object convert(String[] params) { return Arrays.asList(params); } }); addConverter(String[].class, new ListConverter() { public Object convert(String[] params) { return params; } }); Class[][] aliases = { { String.class, Object.class }, { Short.TYPE, Short.class }, { Integer.TYPE, Integer.class }, { Long.TYPE, Long.class }, { Double.TYPE, Double.class }, { Boolean.TYPE, Boolean.class }, }; for (int i = 0; i < aliases.length; i++) { addConverter(aliases[i][0], aliases[i][1]); } }
From source file:edu.wisc.commons.httpclient.HttpParamsBean.java
public double getDoubleParameter(final String name, double defaultValue) { return getTypedParameter(name, defaultValue, Double.TYPE, new Function<Object, Double>() { public Double apply(Object value) { final Double doubleValue = Double.valueOf(value.toString()); //If this parameter is supposed to be a double store it as such to save future parsing work delegate.setDoubleParameter(name, doubleValue); return doubleValue; }//from ww w. j av a 2s .co m }); }
From source file:com.l2jfree.config.L2Properties.java
@SuppressWarnings("unchecked") public Object getProperty(Class<?> expectedType, ConfigProperty configProperty) { final String name = configProperty.name(); final String defaultValue = configProperty.value(); if (expectedType == Boolean.class || expectedType == Boolean.TYPE) { return getBool(name, defaultValue); } else if (expectedType == Long.class || expectedType == Long.TYPE) { return getLong(name, defaultValue); } else if (expectedType == Integer.class || expectedType == Integer.TYPE) { return getInteger(name, defaultValue); } else if (expectedType == Short.class || expectedType == Short.TYPE) { return getShort(name, defaultValue); } else if (expectedType == Byte.class || expectedType == Byte.TYPE) { return getByte(name, defaultValue); } else if (expectedType == Double.class || expectedType == Double.TYPE) { return getDouble(name, defaultValue); } else if (expectedType == Float.class || expectedType == Float.TYPE) { return getFloat(name, defaultValue); } else if (expectedType == String.class) { return getString(name, defaultValue); } else if (expectedType.isEnum()) { return getEnum(name, (Class<? extends Enum>) expectedType, defaultValue); } else {/* w ww. j a va 2 s . c o m*/ throw new IllegalStateException(); } }
From source file:org.spring4gwt.server.RpcHelper.java
private static String printTypeName(Class<?> type) { // Primitives ////from w w w. ja v a2s . co m if (type.equals(Integer.TYPE)) { return "int"; } else if (type.equals(Long.TYPE)) { return "long"; } else if (type.equals(Short.TYPE)) { return "short"; } else if (type.equals(Byte.TYPE)) { return "byte"; } else if (type.equals(Character.TYPE)) { return "char"; } else if (type.equals(Boolean.TYPE)) { return "boolean"; } else if (type.equals(Float.TYPE)) { return "float"; } else if (type.equals(Double.TYPE)) { return "double"; } // Arrays // if (type.isArray()) { Class<?> componentType = type.getComponentType(); return printTypeName(componentType) + "[]"; } // Everything else // return type.getName().replace('$', '.'); }
From source file:com.twitter.elephantbird.pig.piggybank.Invoker.java
private static Class<?> unPrimitivize(Class<?> klass) { if (klass.equals(Integer.TYPE)) { return Integer.class; }/*ww w. j a va 2 s . c o m*/ if (klass.equals(Long.TYPE)) { return Long.class; } else if (klass.equals(Float.TYPE)) { return Float.class; } else if (klass.equals(Double.TYPE)) { return Double.class; } else if (klass.equals(DOUBLE_ARRAY_CLASS)) { return DOUBLE_ARRAY_CLASS; } else { return klass; } }