Example usage for java.lang Double TYPE

List of usage examples for java.lang Double TYPE

Introduction

In this page you can find the example usage for java.lang Double TYPE.

Prototype

Class TYPE

To view the source code for java.lang Double TYPE.

Click Source Link

Document

The Class instance representing the primitive type double .

Usage

From source file:com.bedatadriven.rebar.persistence.mapping.PrimitiveMapping.java

public PrimitiveMapping(MethodInfo getter) {
    super(getter);

    TypeInfo type = getter.getReturnType();
    Class primitive = type.isPrimitive();

    this.boxed = (primitive == null);

    if (primitive != null) {
        this.nullable = false;
    }/*from  w w w . j a  v a2 s  . c o  m*/

    if (primitive == Integer.TYPE || type.getQualifiedName().equals(Integer.class.getName())
            || primitive == Short.TYPE || type.getQualifiedName().equals(Short.class.getName())
            || primitive == Long.TYPE || type.getQualifiedName().equals(Long.class.getName())
            || primitive == Byte.TYPE || type.getQualifiedName().equals(Byte.class.getName())
            || primitive == Boolean.TYPE || type.getQualifiedName().equals(Boolean.class.getName())) {

        sqlTypeName = SqliteTypes.integer;

    } else if (primitive == Float.TYPE || type.getQualifiedName().equals(Float.class.getName())
            || primitive == Double.TYPE || type.getQualifiedName().equals(Double.class.getName())) {

        sqlTypeName = SqliteTypes.real;

    } else if (primitive == Character.TYPE || type.getQualifiedName().equals(Character.class.getName())) {

        sqlTypeName = SqliteTypes.text;
    }

    String suffix = type.getSimpleName();

    if (suffix.equals("Integer")) {
        suffix = "Int";
    } else if (suffix.equals("Character")) {
        suffix = "Char";
    }
    suffix = suffix.substring(0, 1).toUpperCase() + suffix.substring(1);

    readerName = "Readers.read" + suffix;
    stmtSetter = "set" + suffix;

}

From source file:org.exolab.castor.xml.parsing.primitive.objects.PrimitiveObjectFactory.java

private PrimitiveObjectFactory() {
    typeHandlers.put(String.class, PrimitiveString.class);

    typeHandlers.put(Enum.class, PrimitiveEnum.class);

    typeHandlers.put(Integer.TYPE, PrimitiveInteger.class);
    typeHandlers.put(Integer.class, PrimitiveInteger.class);

    typeHandlers.put(Boolean.TYPE, PrimitiveBoolean.class);
    typeHandlers.put(Boolean.class, PrimitiveBoolean.class);

    typeHandlers.put(Double.TYPE, PrimitiveDouble.class);
    typeHandlers.put(Double.class, PrimitiveDouble.class);

    typeHandlers.put(Long.TYPE, PrimitiveLong.class);
    typeHandlers.put(Long.class, PrimitiveLong.class);

    typeHandlers.put(Character.TYPE, PrimitiveChar.class);
    typeHandlers.put(Character.class, PrimitiveChar.class);

    typeHandlers.put(Short.TYPE, PrimitiveShort.class);
    typeHandlers.put(Short.class, PrimitiveShort.class);

    typeHandlers.put(Float.TYPE, PrimitiveFloat.class);
    typeHandlers.put(Float.class, PrimitiveFloat.class);

    typeHandlers.put(Byte.TYPE, PrimitiveByte.class);
    typeHandlers.put(Byte.class, PrimitiveByte.class);

    typeHandlers.put(BigInteger.class, PrimitiveBigInteger.class);

    typeHandlers.put(BigDecimal.class, PrimitiveBigDecimal.class);
}

From source file:Main.java

/**
 * <p>Inserts the specified element at the specified position in the array. 
 * Shifts the element currently at that position (if any) and any subsequent
 * elements to the right (adds one to their indices).</p>
 *
 * <p>This method returns a new array with the same elements of the input
 * array plus the given element on the specified position. The component 
 * type of the returned array is always the same as that of the input 
 * array.</p>//from  w w  w  . j  a v  a2s.  c  o m
 *
 * <p>If the input array is <code>null</code>, a new one element array is returned
 *  whose component type is the same as the element.</p>
 * 
 * <pre>
 * ArrayUtils.add([1.1], 0, 2.2)              = [2.2, 1.1]
 * ArrayUtils.add([2.3, 6.4], 2, 10.5)        = [2.3, 6.4, 10.5]
 * ArrayUtils.add([2.6, 6.7], 0, -4.8)        = [-4.8, 2.6, 6.7]
 * ArrayUtils.add([2.9, 6.0, 0.3], 2, 1.0)    = [2.9, 6.0, 1.0, 0.3]
 * </pre>
 * 
 * @param array  the array to add the element to, may be <code>null</code>
 * @param index  the position of the new object
 * @param element  the object to add
 * @return A new array containing the existing elements and the new element
 * @throws IndexOutOfBoundsException if the index is out of range 
 * (index < 0 || index > array.length).
 */
public static double[] add(double[] array, int index, double element) {
    return (double[]) add(array, index, new Double(element), Double.TYPE);
}

From source file:org.fhcrc.cpl.viewer.util.ConvertHelper.java

protected void register() {
    super.register();

    ConvertUtils.register(new MyBooleanConverter(), Boolean.TYPE);
    ConvertUtils.register(new NullSafeConverter(new MyBooleanConverter()), Boolean.class);
    ConvertUtils.register(new NullSafeConverter(new ByteArrayConverter()), byte[].class);
    ConvertUtils.register(new PercentWrapper(new DoubleConverter()), Double.TYPE);
    ConvertUtils.register(new NullSafeConverter(new PercentWrapper(new DoubleConverter())), Double.class);
    ConvertUtils.register(new PercentWrapper(new FloatConverter()), Float.TYPE);
    ConvertUtils.register(new NullSafeConverter(new PercentWrapper(new FloatConverter())), Float.class);
    ConvertUtils.register(new ChargeWrapper(new IntegerConverter()), Integer.TYPE);
    ConvertUtils.register(new NullSafeConverter(new ChargeWrapper(new IntegerConverter())), Integer.class);
    ConvertUtils.register(new NullSafeConverter(new DateFriendlyStringConverter()), String.class);
    ConvertUtils.register(new LenientTimestampConverter(), java.sql.Timestamp.class);
    ConvertUtils.register(new LenientDateConverter(), java.util.Date.class);
}

From source file:org.apache.lens.ml.AlgoArgParser.java

/**
 * Extracts feature names. If the algo has any parameters associated with @AlgoParam annotation, those are set
 * as well.//from w  w w.ja va2 s  .  c  om
 *
 * @param algo the algo
 * @param args    the args
 * @return List of feature column names.
 */
public static List<String> parseArgs(MLAlgo algo, String[] args) {
    List<String> featureColumns = new ArrayList<String>();
    Class<? extends MLAlgo> algoClass = algo.getClass();
    // Get param fields
    Map<String, Field> fieldMap = new HashMap<String, Field>();

    for (Field fld : algoClass.getDeclaredFields()) {
        fld.setAccessible(true);
        AlgoParam paramAnnotation = fld.getAnnotation(AlgoParam.class);
        if (paramAnnotation != null) {
            fieldMap.put(paramAnnotation.name(), fld);
        }
    }

    for (int i = 0; i < args.length; i += 2) {
        String key = args[i].trim();
        String value = args[i + 1].trim();

        try {
            if ("feature".equalsIgnoreCase(key)) {
                featureColumns.add(value);
            } else if (fieldMap.containsKey(key)) {
                Field f = fieldMap.get(key);
                if (String.class.equals(f.getType())) {
                    f.set(algo, value);
                } else if (Integer.TYPE.equals(f.getType())) {
                    f.setInt(algo, Integer.parseInt(value));
                } else if (Double.TYPE.equals(f.getType())) {
                    f.setDouble(algo, Double.parseDouble(value));
                } else if (Long.TYPE.equals(f.getType())) {
                    f.setLong(algo, Long.parseLong(value));
                } else {
                    // check if the algo provides a deserializer for this param
                    String customParserClass = algo.getConf().getProperties().get("lens.ml.args." + key);
                    if (customParserClass != null) {
                        Class<? extends CustomArgParser<?>> clz = (Class<? extends CustomArgParser<?>>) Class
                                .forName(customParserClass);
                        CustomArgParser<?> parser = clz.newInstance();
                        f.set(algo, parser.parse(value));
                    } else {
                        LOG.warn("Ignored param " + key + "=" + value + " as no parser found");
                    }
                }
            }
        } catch (Exception exc) {
            LOG.error("Error while setting param " + key + " to " + value + " for algo " + algo);
        }
    }
    return featureColumns;
}

From source file:org.kordamp.ezmorph.object.NumberMorpher.java

/**
 * Creates a new morpher for the target type.
 *
 * @param type must be a primitive or wrapper type. BigDecimal and BigInteger
 *             are also supported./*  w w  w . ja  va 2 s .  co  m*/
 */
public NumberMorpher(Class<?> type) {
    super(false);

    if (type == null) {
        throw new MorphException("Must specify a type");
    }

    if (type != Byte.TYPE && type != Short.TYPE && type != Integer.TYPE && type != Long.TYPE
            && type != Float.TYPE && type != Double.TYPE && !Byte.class.isAssignableFrom(type)
            && !Short.class.isAssignableFrom(type) && !Integer.class.isAssignableFrom(type)
            && !Long.class.isAssignableFrom(type) && !Float.class.isAssignableFrom(type)
            && !Double.class.isAssignableFrom(type) && !BigInteger.class.isAssignableFrom(type)
            && !BigDecimal.class.isAssignableFrom(type)) {
        throw new MorphException("Must specify a Number subclass");
    }

    this.type = type;
}

From source file:org.apache.lens.ml.TrainerArgParser.java

/**
 * Extracts feature names. If the trainer has any parameters associated with @TrainerParam annotation, those are set
 * as well.//from  w  w  w.j a v  a  2 s  .com
 *
 * @param trainer
 *          the trainer
 * @param args
 *          the args
 * @return List of feature column names.
 */
public static List<String> parseArgs(MLTrainer trainer, String[] args) {
    List<String> featureColumns = new ArrayList<String>();
    Class<? extends MLTrainer> trainerClass = trainer.getClass();
    // Get param fields
    Map<String, Field> fieldMap = new HashMap<String, Field>();

    for (Field fld : trainerClass.getDeclaredFields()) {
        fld.setAccessible(true);
        TrainerParam paramAnnotation = fld.getAnnotation(TrainerParam.class);
        if (paramAnnotation != null) {
            fieldMap.put(paramAnnotation.name(), fld);
        }
    }

    for (int i = 0; i < args.length; i += 2) {
        String key = args[i].trim();
        String value = args[i + 1].trim();

        try {
            if ("feature".equalsIgnoreCase(key)) {
                featureColumns.add(value);
            } else if (fieldMap.containsKey(key)) {
                Field f = fieldMap.get(key);
                if (String.class.equals(f.getType())) {
                    f.set(trainer, value);
                } else if (Integer.TYPE.equals(f.getType())) {
                    f.setInt(trainer, Integer.parseInt(value));
                } else if (Double.TYPE.equals(f.getType())) {
                    f.setDouble(trainer, Double.parseDouble(value));
                } else if (Long.TYPE.equals(f.getType())) {
                    f.setLong(trainer, Long.parseLong(value));
                } else {
                    // check if the trainer provides a deserializer for this param
                    String customParserClass = trainer.getConf().getProperties().get("lens.ml.args." + key);
                    if (customParserClass != null) {
                        Class<? extends CustomArgParser<?>> clz = (Class<? extends CustomArgParser<?>>) Class
                                .forName(customParserClass);
                        CustomArgParser<?> parser = clz.newInstance();
                        f.set(trainer, parser.parse(value));
                    } else {
                        LOG.warn("Ignored param " + key + "=" + value + " as no parser found");
                    }
                }
            }
        } catch (Exception exc) {
            LOG.error("Error while setting param " + key + " to " + value + " for trainer " + trainer);
        }
    }
    return featureColumns;
}

From source file:org.kuali.rice.krad.util.DataTypeUtil.java

/**
 * Determines if the given class is enough like a Float to store values of it as a SearchableAttributeFloatValue
 * @param type the class to determine of the type of
 * @return true if it is like a "float", false otherwise
 *///from  w  w  w  .  j av a  2s .co m
public static boolean isDecimaltastic(Class<?> type) {
    return java.lang.Double.class.isAssignableFrom(type) || java.lang.Float.class.isAssignableFrom(type)
            || type.equals(Double.TYPE) || type.equals(Float.TYPE)
            || java.math.BigDecimal.class.isAssignableFrom(type)
            || org.kuali.rice.core.api.util.type.KualiDecimal.class.isAssignableFrom(type);
}

From source file:loon.LGame.java

private static Class<?> getType(Object o) {
    if (o instanceof Integer) {
        return Integer.TYPE;
    } else if (o instanceof Float) {
        return Float.TYPE;
    } else if (o instanceof Double) {
        return Double.TYPE;
    } else if (o instanceof Long) {
        return Long.TYPE;
    } else if (o instanceof Short) {
        return Short.TYPE;
    } else if (o instanceof Short) {
        return Short.TYPE;
    } else if (o instanceof Boolean) {
        return Boolean.TYPE;
    } else {/*from  w  ww . j a  v  a2s. c o m*/
        return o.getClass();
    }
}

From source file:com.csipsimple.backup.Columns.java

public Columns(String[] names, Class<?>[] classes) {
    this.names = new ArrayList<String>(Arrays.asList(names));
    types = new ArrayList<Type>(names.length);
    for (int i = 0; i < names.length; i++) {

        if (classes[i] == String.class) {
            types.add(i, Type.STRING);
        } else if (classes[i] == Integer.TYPE || classes[i] == Integer.class) {
            types.add(i, Type.INT);
        } else if (classes[i] == Long.TYPE || classes[i] == Long.class) {
            types.add(i, Type.LONG);
        } else if (classes[i] == Float.TYPE || classes[i] == Float.class) {
            types.add(i, Type.FLOAT);
        } else if (classes[i] == Double.TYPE || classes[i] == Double.class) {
            types.add(i, Type.DOUBLE);
        } else if (classes[i] == Boolean.TYPE || classes[i] == Boolean.class) {
            types.add(i, Type.BOOLEAN);
        }/*  w w w  .ja v  a  2 s  .  co m*/
    }
}