Example usage for java.lang Double valueOf

List of usage examples for java.lang Double valueOf

Introduction

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

Prototype

@HotSpotIntrinsicCandidate
public static Double valueOf(double d) 

Source Link

Document

Returns a Double instance representing the specified double value.

Usage

From source file:edu.coeia.charts.PieChartPanel.java

private static PieDataset createSampleDataset(final Map<String, Double> map, int factor) {
    final DefaultPieDataset result = new DefaultPieDataset();

    Set set = map.entrySet();//w ww  .  j a v  a2 s  .c  om
    Iterator itr = set.iterator();

    while (itr.hasNext()) {
        Map.Entry me = (Map.Entry) itr.next();

        String str = me.getValue().toString();
        double counts = Double.valueOf(str).doubleValue();

        if (counts < factor)
            continue;

        double per = (counts / map.size()) * 100;

        result.setValue((String) me.getKey(), per);
    }

    return result;
}

From source file:com.nebhale.cyclinglibrary.web.json.PointJsonSerializerTest.java

@Override
protected Point getValue() {
    return new Point(Long.valueOf(0), Long.valueOf(1), Long.valueOf(2), Long.valueOf(3), Double.valueOf(4),
            Double.valueOf(5), Double.valueOf(6));
}

From source file:controllers.FileHandler.java

/**
* brief: read content of a given file to the proper list
* @param strFilePath    - path of given file          e.g. "D:\\EGYETEM\\Szakdolgozat\\Mernoki_tervezes\\update files\\sr28upd\\ADD_NUTR.txt"
* @param strFileType    - type of the given file      e.g. AddFood
* @param TList          - list to fill with data      e.g. List<FileFoodStruct> ListFFS
*///  ww w. j  av  a2  s.  co  m
public static <T> void readFile(String strFilePath, List<T> TList, String strFileType) {
    TList.clear();

    try {

        File file = FileUtils.getFile(strFilePath);
        LineIterator iter = FileUtils.lineIterator(file);

        while (iter.hasNext()) {
            String strLine = iter.next();

            switch (strFileType) {
            case "ADD_FOOD": {
                ArrayList<String> strList = ParseUpdateFile(strLine);
                FileStructFood Object = new FileStructFood(strList.get(0), strList.get(2), strList.get(3),
                        Integer.valueOf(strList.get(8)));
                TList.add((T) Object);
                //System.out.println(Object.toString());
                break;
            }
            case "ADD_NUTR": {
                ArrayList<String> strList = ParseUpdateFile(strLine);
                FileStructNutrient Object = new FileStructNutrient(strList.get(0), strList.get(1),
                        Double.valueOf(strList.get(2)));
                TList.add((T) Object);
                //System.out.println(Object.toString());
                break;
            }
            case "ADD_WGT": {
                ArrayList<String> strList = ParseUpdateFile(strLine);
                FileStructWeight Object = new FileStructWeight(strList.get(0), Double.valueOf(strList.get(2)),
                        strList.get(3), Double.valueOf(strList.get(4)));
                TList.add((T) Object);
                //System.out.println(Object.toString());
                break;
            }
            case "CHG_FOOD": {
                ArrayList<String> strList = ParseUpdateFile(strLine);
                FileStructFood Object = new FileStructFood(strList.get(0), strList.get(2), strList.get(3),
                        Integer.valueOf(strList.get(8)));
                TList.add((T) Object);
                //System.out.println(Object.toString());
                break;
            }
            case "CHG_NUTR": {
                ArrayList<String> strList = ParseUpdateFile(strLine);
                FileStructNutrient Object = new FileStructNutrient(strList.get(0), strList.get(1),
                        Double.valueOf(strList.get(2)));
                TList.add((T) Object);
                //System.out.println(Object.toString());
                break;
            }
            case "CHG_WGT": {
                ArrayList<String> strList = ParseUpdateFile(strLine);
                FileStructWeight Object = new FileStructWeight(strList.get(0), Double.valueOf(strList.get(2)),
                        strList.get(3), Double.valueOf(strList.get(4)));
                TList.add((T) Object);
                //System.out.println(Object.toString());
                break;
            }
            case "DEL_FOOD": {
                ArrayList<String> strList = ParseUpdateFile(strLine);
                FileStructFood Object = new FileStructFood(strList.get(0), strList.get(1));
                TList.add((T) Object);
                //System.out.println(Object.toString());
                break;
            }
            case "DEL_NUTR": {
                ArrayList<String> strList = ParseUpdateFile(strLine);
                FileStructNutrient Object = new FileStructNutrient(strList.get(0), strList.get(1));
                TList.add((T) Object);
                //System.out.println(Object.toString());
                break;
            }
            case "DEL_WGT": {
                ArrayList<String> strList = ParseUpdateFile(strLine);
                FileStructWeight Object = new FileStructWeight(strList.get(0), Double.valueOf(strList.get(2)),
                        strList.get(3), Double.valueOf(strList.get(4)));
                TList.add((T) Object);
                //System.out.println(Object.toString());
                break;
            }
            case "ADD_NDEF": {
                ArrayList<String> strList = ParseUpdateFile(strLine);
                FileStructNutrient Object = new FileStructNutrient(strList.get(0), strList.get(1),
                        strList.get(2), strList.get(3), Integer.valueOf(strList.get(4)));
                TList.add((T) Object);
                System.out.println(strList.get(0) + " " + strList.get(1) + " " + strList.get(2) + " "
                        + strList.get(3) + " " + Integer.valueOf(strList.get(4)));
                break;
            }
            case "CHG_NDEF": {
                ArrayList<String> strList = ParseUpdateFile(strLine);
                FileStructNutrient Object = new FileStructNutrient(strList.get(0), strList.get(1),
                        strList.get(2), strList.get(3), Integer.valueOf(strList.get(4)));
                TList.add((T) Object);
                System.out.println(strList.get(0) + " " + strList.get(1) + " " + strList.get(2) + " "
                        + strList.get(3) + " " + Integer.valueOf(strList.get(4)));
                break;
            }
            case "LOG_FILE": {
                ArrayList<String> strList = ParseLogFile(strLine);
                TraceMessage Object = new TraceMessage(strList.get(0), strList.get(1));
                TList.add((T) Object);
                break;
            }
            }
        }
        iter.close();

    } catch (IOException ex) {
        Logger.getLogger(FileHandler.class.getName()).log(Level.SEVERE, null, ex);
    } finally {
        return;
    }
}

From source file:Main.java

/**
 * Convert a string value to a boxed primitive type.
 *
 * @param type the boxed primitive type//from www .  ja  va  2  s.co m
 * @param value the string value
 * @return a boxed primitive type
 */
public static Object valueOf(final Class<?> type, final String value) {
    if (type == String.class) {
        return value;
    }
    if (type == boolean.class) {
        return Boolean.valueOf(value);
    }
    if (type == int.class) {
        return Integer.valueOf(value);
    }
    if (type == long.class) {
        return Long.valueOf(value);
    }
    if (type == float.class) {
        return Float.valueOf(value);
    }
    if (type == double.class) {
        return Double.valueOf(value);
    }
    throw new IllegalArgumentException("Unsupported type " + type.getName());
}

From source file:net.ceos.project.poi.annotated.bean.cascade.CascadeObjectBuilder.java

/**
 * Create a CascadeObject for tests.//from w  ww  .  j  a  v  a 2s .  c om
 * 
 * @return the {@link CascadeObject}
 */
public static CascadeObject buildCascadeObject(int multiplier) {
    CascadeObject toValidate = new CascadeObject();

    toValidate.setDateAttribute(new Date());
    toValidate.setStringAttribute("some string");
    toValidate.setIntegerAttribute(46 * multiplier);
    toValidate.setDoubleAttribute(Double.valueOf("25.3") * multiplier);
    toValidate.setLongAttribute(Long.valueOf("1234567890") * multiplier);
    toValidate.setBooleanAttribute(Boolean.FALSE);
    /* create sub object Job */
    Job job = new Job();
    job.setJobCode(0005);
    job.setJobFamily("Family Job Name");
    job.setJobName("Job Name");
    toValidate.setJob(job);

    BasicObject bo = BasicObjectBuilder.buildBasicObject();
    List<BasicObject> boList = new ArrayList<>();
    boList.add(bo);
    boList.add(bo);
    boList.add(bo);
    boList.add(bo);
    boList.add(bo);

    toValidate.setBasicObjectList(boList);

    ObjectConfigurable oc = ObjectConfigurableBuilder.buildObjectConfigurable();
    ArrayList<ObjectConfigurable> ocList = new ArrayList<>();
    ocList.add(oc);
    ocList.add(oc);
    ocList.add(oc);

    toValidate.setObjectConfList(ocList);

    CascadeL1 l1 = CascadeL1Builder.buildCascadeL1();
    ArrayList<CascadeL1> objectsList = new ArrayList<>();
    objectsList.add(l1);
    objectsList.add(l1);

    toValidate.setObjectsList(objectsList);
    /*ArrayList<CascadeObject> ownList = new ArrayList<>();
    ownList.add(toValidate);
    ownList.add(toValidate);
            
    toValidate.setObjectsList(ownList);*/
    // TODO add new fields below

    return toValidate;
}

From source file:ca.sqlpower.dao.session.Point2DConverter.java

public Point2D convertToComplexType(String convertFrom) throws ConversionException {
    String[] pieces = PersisterUtils.splitByDelimiter(convertFrom, 2);

    double x = Double.valueOf(pieces[0]);
    double y = Double.valueOf(pieces[1]);

    return (new Point2D.Double(x, y));
}

From source file:com.rackspacecloud.blueflood.io.serializers.astyanax.TimerSerializationTest.java

@Test
public void testV1RoundTrip() throws IOException {
    // build up a Timer
    BluefloodTimerRollup r0 = new BluefloodTimerRollup().withSum(Double.valueOf(42)).withCountPS(23.32d)
            .withAverage(56).withVariance(853.3245d).withMinValue(2).withMaxValue(987).withCount(345);
    r0.setPercentile("foo", 741.32d);
    r0.setPercentile("bar", 0.0323d);

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    //The V1 serialization is artificially constructed for the purposes of this test and should no longer be used.
    baos.write(// w  ww .  j  av  a 2s  .  co m
            Base64.encodeBase64(Serializers.timerRollupInstance.toByteBufferWithV1Serialization(r0).array()));
    baos.write("\n".getBytes());
    baos.close();

    BufferedReader reader = new BufferedReader(
            new InputStreamReader(new ByteArrayInputStream(baos.toByteArray())));
    ByteBuffer bb = ByteBuffer.wrap(Base64.decodeBase64(reader.readLine().getBytes()));
    BluefloodTimerRollup r1 = Serializers.timerRollupInstance.fromByteBuffer(bb);
    Assert.assertEquals(r0, r1);
}

From source file:corner.util.VectorUtils.java

/**
 * ???,???//from   w  w  w. ja v a 2  s . c o  m
 * @param m1 ??1
 * @param m2 ??1
 * @return
 */
public static MatrixRow<String> minus(MatrixRow<String> m1, MatrixRow<String> m2) {
    if (m1 == null || m2 == null || m1.size() != m2.size()) {
        return null;
    }

    MatrixRow<String> newM = new MatrixRow<String>();

    Iterator<String> m1v = m1.iterator();
    Iterator<String> m2v = m2.iterator();

    for (int i = 0; i < m1.size(); i++) {
        newM.add(String.valueOf(CurrencyUtils.minus(Double.valueOf(m1v.next()), Double.valueOf(m2v.next()))));
    }

    return newM;
}

From source file:net.anthonypoon.ngram.correlation.CorrelationReducer.java

@Override
protected void setup(Context context) throws IOException, InterruptedException {
    threshold = Double.valueOf(context.getConfiguration().get("threshold", "0.7"));
    lag = Integer.valueOf(context.getConfiguration().get("lag", "0"));
    lowbound = Integer.valueOf(context.getConfiguration().get("lowbound"));
    upbound = Integer.valueOf(context.getConfiguration().get("upbound"));
    String uri = context.getConfiguration().get("target");
    Path input = new Path(uri);
    // Read data from path to be our compare target
    FileSystem fileSystem = input.getFileSystem(context.getConfiguration());
    BufferedReader br = new BufferedReader(new InputStreamReader(fileSystem.open(input)));
    String line = "";
    while ((line = br.readLine()) != null) {
        String[] strArray = line.split("\t");
        if (Integer.valueOf(strArray[1]) <= upbound && Integer.valueOf(strArray[1]) >= lowbound) {
            if (!corrTargetArray.containsKey(strArray[0])) {
                corrTargetArray.put(strArray[0], new TreeMap());
            }//ww  w .  j av a  2 s .  c  o  m
            TreeMap<String, Double> targetElement = corrTargetArray.get(strArray[0]);
            targetElement.put(strArray[1], Double.valueOf(strArray[2]));
        }
    }

}

From source file:nodeconfig.FinalSuspectLine.java

private DefaultCategoryDataset createDataset() {
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    for (int i = 0; i < suspectline.size(); i++) {
        dataset.addValue((1 - Double.valueOf(suspectline.get(i))) * 100, "Degree Of Suspect", "Node " + i + "");
    }//  w ww  .  j  a  v a2s .co m
    return dataset;
}