Example usage for java.lang Double intValue

List of usage examples for java.lang Double intValue

Introduction

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

Prototype

public int intValue() 

Source Link

Document

Returns the value of this Double as an int after a narrowing primitive conversion.

Usage

From source file:Util.PacketGenerator.java

public void GenerateGraphGnuplot() {
    try {//  ww  w  .  ja va 2  s  .co  m
        for (int j = 6; j <= 6; j++) {
            File real = new File("D:\\Mestrado\\SketchMatrix\\trunk\\Simulations\\Analise\\Scenario1\\Topology"
                    + j + "\\Real.csv");
            for (int k = 1; k <= 4; k++) {
                File simu = new File(
                        "D:\\Mestrado\\SketchMatrix\\trunk\\Simulations\\Analise\\Scenario1\\Topology" + j
                                + "\\SimulacaoInstancia" + k + ".csv");
                File dat = new File(
                        "D:\\Mestrado\\SketchMatrix\\trunk\\Simulations\\Analise\\Scenario1\\Topology" + j
                                + "\\SimulacaoInstancia" + k + ".txt");

                FileInputStream simuFIS = new FileInputStream(simu);
                DataInputStream simuDIS = new DataInputStream(simuFIS);
                BufferedReader simuBR = new BufferedReader(new InputStreamReader(simuDIS));

                FileInputStream realFIS = new FileInputStream(real);
                DataInputStream realDIS = new DataInputStream(realFIS);
                BufferedReader realBR = new BufferedReader(new InputStreamReader(realDIS));

                PrintWriter datPW = new PrintWriter(dat);

                String lineSimu = simuBR.readLine();
                String lineReal = realBR.readLine();

                double maxX = 0.0;
                double maxY = 0.0;

                HashMap<Double, Double> map = new HashMap<>();

                while (lineSimu != null && lineReal != null) {

                    lineSimu = lineSimu.replaceAll(",", ".");
                    String[] simuMatriz = lineSimu.split(";");
                    String[] realMatriz = lineReal.split(";");

                    for (int i = 0; i < simuMatriz.length; i++) {
                        try {
                            Integer valorReal = Integer.parseInt(realMatriz[i]);
                            Double valorSimu = Double.parseDouble(simuMatriz[i]);
                            if (map.containsKey(valorReal) && map.containsValue(valorSimu)) {
                                continue;
                            }
                            map.put(valorReal.doubleValue(), valorSimu);
                            datPW.write(valorReal.doubleValue() + "\t");
                            datPW.write(valorReal.doubleValue() + "\t");
                            datPW.write(valorSimu.doubleValue() + "\t");
                            datPW.write(valorReal.doubleValue() * 1.2 + "\t");
                            datPW.write(valorReal.doubleValue() * 0.8 + "\n");
                            if (valorReal > maxX) {
                                maxX = valorReal;
                            }
                            if (valorSimu > maxY) {
                                maxY = valorSimu;
                            }
                        } catch (NumberFormatException ex) {

                        }
                    }
                    lineSimu = simuBR.readLine();
                    lineReal = realBR.readLine();
                }

                simuFIS.close();
                simuDIS.close();
                simuBR.close();

                realFIS.close();
                realDIS.close();
                realBR.close();

                datPW.close();

                Double max = Math.max(maxX, maxY);
                max *= 1.05;

                Process p = Runtime.getRuntime().exec("cmd");
                new Thread(new SyncPipe(p.getErrorStream(), System.err)).start();
                new Thread(new SyncPipe(p.getInputStream(), System.out)).start();
                PrintWriter stdin = new PrintWriter(p.getOutputStream());
                stdin.println("gnuplot");
                stdin.println("cd 'D:\\Mestrado\\SketchMatrix\\trunk\\Simulations\\Analise\\Scenario1\\Topology"
                        + j + "'");
                stdin.println("set terminal postscript eps enhanced \"Times\" 20");
                stdin.println("set output \"SimulacaoInstancia" + k + ".eps\"");
                stdin.println("unset title");
                stdin.println("unset style line");
                stdin.println("set style line 1 pt 7 lc 7 lw 1");
                stdin.println("set style line 2 lt 1 lc 7 lw 1");
                stdin.println("set style line 3 lt 4 lc 7 lw 1");
                stdin.println("set style line 4 lt 4 lc 7 lw 1");
                stdin.println("set style line 5 lt 5 lc 5 lw 3");
                stdin.println("set style line 6 lt 6 lc 6 lw 3");
                stdin.println("set style line 7 pt 7 lc 7 lw 3");
                if (k == 4) {
                    stdin.println("set ylabel \"CMO-MT\"");
                    stdin.println("set xlabel \"Real\"");
                } else {
                    stdin.println("set ylabel \"Zhao\"");
                    stdin.println("set xlabel \"CMO-MT\"");
                }
                stdin.println("set key top left");
                stdin.println("set xrange [0:" + max.intValue() + "]");
                stdin.println("set yrange [0:" + max.intValue() + "]");
                stdin.println("set grid ytics lc rgb \"#bbbbbb\" lw 1 lt 0");
                stdin.println("set grid xtics lc rgb \"#bbbbbb\" lw 1 lt 0");
                stdin.println("plot " + "x title \"Referencia\"      ls 2," + "\"SimulacaoInstancia" + k
                        + ".txt\" using 1:3 title \"Matriz\"          ls 7,"
                        + "1.2*x title \"Superior 20%\"    ls 4," + "0.8*x title \"Inferior 20%\"    ls 4");

                stdin.println("exit");
                stdin.println("exit");
                // write any other commands you want here
                stdin.close();
                int returnCode = p.waitFor();
                System.out.println("Return code = " + returnCode);
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:org.medici.bia.service.user.UserServiceImpl.java

/**
 * {@inheritDoc}// w  w  w  .j a  v a2s .  c om
 */
@Override
public void cropPortraitUser(String account, Double x, Double y, Double x2, Double y2, Double width,
        Double height) throws ApplicationThrowable {
    try {
        User user = getUserDAO().findUser(account);

        if ((user != null) && (user.getPortrait())) {
            String portraitPath = ApplicationPropertyManager.getApplicationProperty("portrait.user.path");
            File portraitFile = new File(portraitPath + "/" + user.getPortraitImageName());
            BufferedImage bufferedImage = ImageIO.read(portraitFile);
            //here code for cropping... TO BE TESTED...
            BufferedImage croppedBufferedImage = bufferedImage.getSubimage(x.intValue(), y.intValue(),
                    width.intValue(), height.intValue());
            ImageIO.write(croppedBufferedImage, "jpg", portraitFile);
        }
    } catch (Throwable th) {
        throw new ApplicationThrowable(th);
    }

}

From source file:gov.anl.cue.arcane.engine.matrix.MatrixModel.java

/**
 * Imports the dimensions for a matrix model from a
 * template spreadsheet.//w  w w.  j av a2s.c  o m
 *
 * @param fileName            the file name
 * @return the matrix dimensions
 */
public static HashMap<Integer, Integer> importTemplateDimensions(String fileName) {

    // Create the results holder.
    HashMap<Integer, Integer> nodeCounts = new HashMap<Integer, Integer>();

    // Try to read the spreadsheet.
    try {

        // Attempt to open the template spreadsheet.
        XSSFWorkbook workbook = new XSSFWorkbook(new FileInputStream(new File(fileName)));

        // Scan the sheets.
        Iterator<XSSFSheet> sheets = workbook.iterator();

        // Ignore the first sheet.
        XSSFSheet sheet = sheets.next();
        sheet = sheets.next();

        // Prepare to scan the node count column.
        Iterator<Row> rowIterator = sheet.rowIterator();

        // Skip the header row.
        rowIterator.next();

        // Find the total number of nodes requested.
        int rowIndex = 0;
        Double nextCellValue = Util.getSpreadsheetNumber(sheet, rowIterator.next().getRowNum(), 2);
        while (!Double.isNaN(nextCellValue)) {

            // Store the results.
            nodeCounts.put(rowIndex++, nextCellValue.intValue());

            // Get the next node count.
            nextCellValue = Util.getSpreadsheetNumber(sheet, rowIterator.next().getRowNum(), 2);

        }

        // Close the workbook.
        workbook.close();

        // Catch errors.
    } catch (Exception e) {

        // Note an error.
        nodeCounts = null;

    }

    // Return the results.
    return nodeCounts;

}

From source file:org.plos.crepo.integration.ContentRepoTest.java

public void creationAndMetadataTest() {

    File file = null;/* www. ja  v a2s  . c o m*/
    try {
        file = new File("testFile.txt");
        BufferedWriter output = new BufferedWriter(new FileWriter(file));
        output.write(testData1);
        output.close();
    } catch (IOException e) {
        e.printStackTrace();
    }

    // create object 1
    RepoObjectInput repoObjectInput = RepoObjectInput.builder(BUCKET_NAME, repoObjKey1)
            .setCreationDate(creationDateTime).setFileContent(file).setDownloadName("dowloadNameTest1").build();

    Map<String, Object> repoObj1 = contentRepoService.createRepoObject(repoObjectInput).getMapView();
    assertNotNull(repoObj1);
    String fileUuid = (String) repoObj1.get("uuid");
    Double versionNumber = (Double) repoObj1.get("versionNumber");

    // version object 1 ---> object 2
    RepoObjectInput repoObjectInput2 = RepoObjectInput.builder(BUCKET_NAME, repoObjKey1).setFileContent(file)
            .setDownloadName("dowloadNameTest2").build();

    Map<String, Object> repoObj2 = contentRepoService.versionRepoObject(repoObjectInput2).getMapView();
    assertNotNull(repoObj2);
    String fileUuid2 = (String) repoObj2.get("uuid");
    Double versionNumber2 = (Double) repoObj2.get("versionNumber");

    //get versions
    List<Map<String, Object>> versions = asRawList(
            contentRepoService.getRepoObjectVersions(RepoId.create(BUCKET_NAME, repoObjKey1)));
    assertNotNull(versions);
    assertEquals(2, versions.size());
    assertEquals(fileUuid, versions.get(0).get("uuid"));
    assertEquals(fileUuid2, versions.get(1).get("uuid"));

    // get object 1 by version UUID
    Map<String, Object> repoObj3 = contentRepoService
            .getRepoObjectMetadata(RepoVersion.create(BUCKET_NAME, repoObjKey1, fileUuid)).getMapView();
    // get object 1 by version number
    Map<String, Object> repoObj4 = contentRepoService
            .getRepoObjectMetadata(RepoVersionNumber.create(BUCKET_NAME, repoObjKey1, versionNumber.intValue()))
            .getMapView();

    assertNotNull(repoObj3);
    assertNotNull(repoObj4);
    assertEquals(repoObj1, repoObj3);
    assertEquals(repoObj3, repoObj4);

    // get latest version with key 'testData1Key' ---> object 2
    Map<String, Object> repoObj5 = contentRepoService
            .getLatestRepoObjectMetadata(RepoId.create(BUCKET_NAME, repoObjKey1)).getMapView();
    assertNotNull(repoObj5);
    assertEquals(repoObj2, repoObj5);

    // delete using version UUID ---> object 1
    contentRepoService.deleteRepoObject(RepoVersion.create(BUCKET_NAME, repoObjKey1, fileUuid));

    Map<String, Object> repoObj6 = null;
    try {
        // get object 1 by version UUID ----> must be null
        repoObj6 = contentRepoService
                .getRepoObjectMetadata(RepoVersion.create(BUCKET_NAME, repoObjKey1, fileUuid)).getMapView();
        fail(EXCEPTION_EXPECTED);
    } catch (ContentRepoException fe) {
        assertNull(repoObj6);
        assertEquals(fe.getErrorType(), ErrorType.ErrorFetchingObjectMeta);
        assertTrue(fe.getMessage().contains("not found"));
    }

    // delete using version number ---> object 2
    contentRepoService
            .deleteRepoObject(RepoVersionNumber.create(BUCKET_NAME, repoObjKey1, versionNumber2.intValue()));

    try {
        // get object 2 by version UUID ----> must be null
        repoObj6 = contentRepoService
                .getRepoObjectMetadata(RepoVersion.create(BUCKET_NAME, repoObjKey1, fileUuid2)).getMapView();
        fail(EXCEPTION_EXPECTED);
    } catch (ContentRepoException fe) {
        assertNull(repoObj6);
        assertEquals(fe.getErrorType(), ErrorType.ErrorFetchingObjectMeta);
        assertTrue(fe.getMessage().contains("not found"));
    }

}

From source file:org.plos.crepo.integration.ContentRepoTest.java

public void autoCreationObjectTest() {

    File file = null;//w w  w .  j ava 2  s. c  o m
    try {
        file = new File("testFile.txt");
        BufferedWriter output = new BufferedWriter(new FileWriter(file));
        output.write(testData1);
        output.close();
    } catch (IOException e) {
        e.printStackTrace();
    }

    // auto - create object 1
    RepoObjectInput repoObjectInput = RepoObjectInput.builder(BUCKET_NAME, repoObjKey10)
            .setCreationDate(creationDateTime).setFileContent(file).setDownloadName("dowloadNameTest1").build();

    Map<String, Object> repoObj1 = contentRepoService.autoCreateRepoObject(repoObjectInput).getMapView();
    assertNotNull(repoObj1);
    String fileUuid = (String) repoObj1.get("uuid");
    Double versionNumber = (Double) repoObj1.get("versionNumber");

    // auto create object 1, creates new version
    RepoObjectInput repoObjectInput2 = RepoObjectInput.builder(BUCKET_NAME, repoObjKey10).setFileContent(file)
            .setDownloadName("dowloadNameTest2").build();

    Map<String, Object> repoObj2 = contentRepoService.autoCreateRepoObject(repoObjectInput2).getMapView();
    assertNotNull(repoObj2);
    String fileUuid2 = (String) repoObj2.get("uuid");
    Double versionNumber2 = (Double) repoObj2.get("versionNumber");

    assertTrue(versionNumber2 > versionNumber);

    //get versions
    List<Map<String, Object>> versions = asRawList(
            contentRepoService.getRepoObjectVersions(RepoId.create(BUCKET_NAME, repoObjKey10)));
    assertNotNull(versions);
    assertEquals(2, versions.size());
    assertEquals(fileUuid, versions.get(0).get("uuid"));
    assertEquals(fileUuid2, versions.get(1).get("uuid"));

    // delete using version UUID ---> object 1
    contentRepoService.deleteRepoObject(RepoVersion.create(BUCKET_NAME, repoObjKey10, fileUuid));

    Map<String, Object> repoObj6 = null;
    try {
        // get object 1 by version UUID ----> must be null
        repoObj6 = contentRepoService
                .getRepoObjectMetadata(RepoVersion.create(BUCKET_NAME, repoObjKey10, fileUuid)).getMapView();
        fail(EXCEPTION_EXPECTED);
    } catch (ContentRepoException fe) {
        assertNull(repoObj6);
        assertEquals(fe.getErrorType(), ErrorType.ErrorFetchingObjectMeta);
        assertTrue(fe.getMessage().contains("not found"));
    }

    // delete using version number ---> object 2
    contentRepoService
            .deleteRepoObject(RepoVersionNumber.create(BUCKET_NAME, repoObjKey10, versionNumber2.intValue()));

    try {
        // get object 2 by version UUID ----> must be null
        repoObj6 = contentRepoService
                .getRepoObjectMetadata(RepoVersion.create(BUCKET_NAME, repoObjKey10, fileUuid2)).getMapView();
        fail(EXCEPTION_EXPECTED);
    } catch (ContentRepoException fe) {
        assertNull(repoObj6);
        assertEquals(fe.getErrorType(), ErrorType.ErrorFetchingObjectMeta);
        assertTrue(fe.getMessage().contains("not found"));
    }

}

From source file:de.otto.mongodb.profiler.web.OpProfileController.java

@RequestMapping(value = "/{id:.+}/stats", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public HttpEntity<String> getStatsData(@PathVariable("connectionId") final String connectionId,
        @PathVariable("databaseName") final String databaseName, @PathVariable("id") final String id,
        @RequestParam(value = "datum", required = false) final List<String> datum,
        @RequestParam(value = "from", required = false) final Long from,
        @RequestParam(value = "to", required = false) final Long to,
        @RequestParam(value = "min", required = false) final Double min,
        @RequestParam(value = "max", required = false) final Double max,
        @RequestParam(value = "limit", required = false) final Integer limit) throws Exception {

    final ProfiledDatabase database = requireDatabase(connectionId, databaseName);

    final OpProfile profile = requireProfile(database, id);

    final JsonObject json = new JsonObject();
    final JsonObject outliersJson = new JsonObject();

    final JsonObject params = new JsonObject();
    outliersJson.add("params", params);

    final JsonArray datumParamValues = new JsonArray();
    params.add("datum", datumParamValues);
    if (datum != null) {
        for (String datumValue : datum) {
            datumParamValues.add(new JsonPrimitive(datumValue));
        }// w ww  . ja  va2  s.c om
    }

    final DateTime lowerTimeBound = from != null ? new DateTime(from.longValue()) : null;
    final DateTime upperTimeBound = to != null ? new DateTime(to.longValue()) : null;

    if (lowerTimeBound != null && upperTimeBound != null && !upperTimeBound.isAfter(lowerTimeBound)) {
        throw new IllegalArgumentException("'to' must not be lower than or equal to 'from'");
    }

    params.add("from", from != null ? new JsonPrimitive(from.longValue()) : null);
    params.add("to", to != null ? new JsonPrimitive(to.longValue()) : null);

    if (min != null && max != null && !(max.longValue() > min.longValue())) {
        throw new IllegalArgumentException("'max' must not be lower than or equal to 'min'");
    }

    params.add("min", min != null ? new JsonPrimitive(min.intValue()) : null);
    params.add("max", max != null ? new JsonPrimitive(max.intValue()) : null);

    if (limit != null && limit.intValue() < 1) {
        throw new IllegalArgumentException("'limit' must not be lower than 1");
    }

    final int maximumValues = limit != null && limit.intValue() > 0 ? limit.intValue() : maximumGraphValues;

    params.add("limit", new JsonPrimitive(maximumValues));

    if (profile.getOutlierConfiguration() != null && profile.getOutlierConfiguration().captureOutliers()) {

        final OutlierGraphDataBuilder builder = new OutlierGraphDataBuilder(datum, maximumValues,
                lowerTimeBound, upperTimeBound, min, max);

        builder.add("executionTimeOutliers", "Execution time outliers", profile.getAverageMillisOutliers());
        builder.add("readLockAcquisitionTimeOutliers", "Read lock acquisition time outliers",
                profile.getAverageAcquireReadLockMicrosOutliers());
        builder.add("writeLockAcquisitionTimeOutliers", "Write lock acquisition time outliers",
                profile.getAverageAcquireWriteLockMicrosOutliers());
        builder.add("readLockTimeOutliers", "Read lock time outliers",
                profile.getAverageLockedReadMicrosOutliers());
        builder.add("writeLockTimeOutliers", "Write lock time outliers",
                profile.getAverageLockedWriteMicrosOutliers());

        outliersJson.add("data", builder.getGroups());
        outliersJson.add("lowestTime", new JsonPrimitive(builder.getLowestTime()));
        outliersJson.add("highestTime", new JsonPrimitive(builder.getHighestTime()));

        final JsonArray warningJson = new JsonArray();

        if (!builder.getKeysWithTooMuchData().isEmpty()) {
            final StringBuilder warning = new StringBuilder();
            final JsonArray tooMuchDataFor = new JsonArray();
            for (String key : builder.getKeysWithTooMuchData()) {
                tooMuchDataFor.add(new JsonPrimitive(key));
                if (warning.length() > 0) {
                    warning.append(", ");
                }
                warning.append(key);
            }
            warningJson.add(new JsonPrimitive(String.format(
                    "The maximum amount of %d values has been exceeded. "
                            + "The following data could not be (completely) returned: %s. "
                            + "Please narrow your filter to get applicable results.",
                    maximumValues, warning.toString())));
        }

        if (warningJson.size() > 0) {
            outliersJson.add("warnings", warningJson);
        }
    }

    json.add("outliers", outliersJson);

    return new HttpEntity<>(json.toString());
}

From source file:slash.navigation.mapview.browser.BrowserMapView.java

@SuppressWarnings("unchecked")
private BaseRoute parseRoute(List<String> parameters, NavigationPosition before, NavigationPosition after) {
    BaseRoute route = new NavigatingPoiWarnerFormat().createRoute(Waypoints, null,
            new ArrayList<NavigationPosition>());
    // count backwards as inserting at position 0
    CompactCalendar time = after.getTime();
    for (int i = parameters.size() - 1; i > 0; i -= 5) {
        String instructions = trim(parameters.get(i));
        Double seconds = parseSeconds(parameters.get(i - 1));
        // Double meters = parseDouble(parameters.get(i - 2));
        NavigationPosition coordinates = parsePosition(parameters.get(i - 4), parameters.get(i - 3));
        if (seconds != null && time != null) {
            Calendar calendar = time.getCalendar();
            calendar.add(SECOND, -seconds.intValue());
            time = fromCalendar(calendar);
        }// ww  w . j  a  v a2  s  .  c o m
        BaseNavigationPosition position = route.createPosition(coordinates.getLongitude(),
                coordinates.getLatitude(), null, null, seconds != null ? time : null, instructions);
        if (!isDuplicate(before, position) && !isDuplicate(after, position)) {
            route.add(0, position);
        }
    }
    return route;
}

From source file:com.tao.realweb.util.StringUtil.java

/** 
* ? //from  w w w.jav a  2 s .  co m
*  
* @param money 
* @param style 
*            ? [default]???? such as #.00, #.# 
* @return 
*/

public static String moneyToString(Object money, String style) {
    if (money != null && style != null && (money instanceof Double || money instanceof Float)) {
        Double num = (Double) money;

        if (style.equalsIgnoreCase("default")) {
            // ?? 0 ? ,???.0  
            if (num == 0) {
                // ?0  
                return "";
            } else if ((num * 10 % 10) == 0) {
                // ?  
                return Integer.toString((int) num.intValue());
            } else {
                // ?  
                return num.toString();
            }

        } else {
            DecimalFormat df = new DecimalFormat(style);
            return df.format(num);
        }
    }
    return null;
}

From source file:com.smartitengineering.dao.impl.hibernate.AbstractDAOTest.java

private void performTestReadOtherSingle(MethodInvocationType type) {
    AbstractDAO<Publisher> publisherInstance = getDaoInstance();
    QueryParameter<Void> param;
    /**//w w  w  .  jav  a  2 s.  c  o m
     * Test average
     */
    {
        param = getAvgEmployeesParam();
        Double average;
        switch (type) {
        case HASH_TABLE: {
            average = (Double) publisherInstance.readOther(Publisher.class, getQueryParamHashtable(param));
            break;
        }
        case LIST: {
            average = (Double) publisherInstance.readOther(Publisher.class, getQueryParamList(param));
            break;
        }
        case VAR_ARGS:
        default: {
            average = (Double) publisherInstance.readOther(Publisher.class, param);
            break;
        }
        }
        int expectedAverage = getTotalNumOfEmployeesFromPubs() / getAllPublishers().length;
        assertEquals(expectedAverage, average.intValue());
    }
    /**
     * Test count
     */
    {
        param = getCountIdParam();
        Integer count;
        switch (type) {
        case HASH_TABLE: {
            count = (Integer) publisherInstance.readOther(Publisher.class, getQueryParamHashtable(param));
            break;
        }
        case LIST: {
            count = (Integer) publisherInstance.readOther(Publisher.class, getQueryParamList(param));
            break;
        }
        case VAR_ARGS:
        default: {
            count = (Integer) publisherInstance.readOther(Publisher.class, param);
            break;
        }
        }
        int expectedCount = getAllPublishers().length;
        assertEquals(expectedCount, count.intValue());
    }
    /**
     * Test count distinct
     */
    {
        param = getCountDistinctNumOfEmployeeParam();
        Integer distinctCount;
        switch (type) {
        case HASH_TABLE: {
            distinctCount = (Integer) publisherInstance.readOther(Publisher.class,
                    getQueryParamHashtable(param));
            break;
        }
        case LIST: {
            distinctCount = (Integer) publisherInstance.readOther(Publisher.class, getQueryParamList(param));
            break;
        }
        case VAR_ARGS:
        default: {
            distinctCount = (Integer) publisherInstance.readOther(Publisher.class, param);
            break;
        }
        }
        int expectedDistinctCount = getDistinctNumOfEmployeeNum();
        assertEquals(expectedDistinctCount, distinctCount.intValue());
    }
    /**
     * Test Max
     */
    {
        param = getMaxNumOfEmployeeParam();
        Integer max = (Integer) publisherInstance.readOther(Publisher.class, param);
        switch (type) {
        case HASH_TABLE: {
            max = (Integer) publisherInstance.readOther(Publisher.class, getQueryParamHashtable(param));
            break;
        }
        case LIST: {
            max = (Integer) publisherInstance.readOther(Publisher.class, getQueryParamList(param));
            break;
        }
        case VAR_ARGS:
        default: {
            max = (Integer) publisherInstance.readOther(Publisher.class, param);
            break;
        }
        }
        int expectedMax = getMaxEmployeesFromPubs();
        assertEquals(expectedMax, max.intValue());
    }
    /**
     * Test Min
     */
    {
        param = getMinNumOfEmployeeParam();
        Integer min;
        switch (type) {
        case HASH_TABLE: {
            min = (Integer) publisherInstance.readOther(Publisher.class, getQueryParamHashtable(param));
            break;
        }
        case LIST: {
            min = (Integer) publisherInstance.readOther(Publisher.class, getQueryParamList(param));
            break;
        }
        case VAR_ARGS:
        default: {
            min = (Integer) publisherInstance.readOther(Publisher.class, param);
            break;
        }
        }
        int expectedMin = getMinEmployeesFromPubs();
        assertEquals(expectedMin, min.intValue());
    }
    /**
     * Test Sum
     */
    {
        param = getTotalNumOfEmployeesParam();
        Integer sum;
        switch (type) {
        case HASH_TABLE: {
            sum = (Integer) publisherInstance.readOther(Publisher.class, getQueryParamHashtable(param));
            break;
        }
        case LIST: {
            sum = (Integer) publisherInstance.readOther(Publisher.class, getQueryParamList(param));
            break;
        }
        case VAR_ARGS:
        default: {
            sum = (Integer) publisherInstance.readOther(Publisher.class, param);
            break;
        }
        }
        int expectedSum = getTotalNumOfEmployeesFromPubs();
        assertEquals(expectedSum, sum.intValue());
    }
}

From source file:pcgen.core.SettingsHandler.java

public static Dimension getOptionsFromProperties(final PlayerCharacter aPC) {
    Dimension d = new Dimension(0, 0);

    final String tempBrowserPath = getPCGenOption("browserPath", ""); //$NON-NLS-1$ //$NON-NLS-2$

    if (!"".equals(tempBrowserPath)) //$NON-NLS-1$
    {/*w w  w.ja  va2  s.c o m*/
        setBrowserPath(tempBrowserPath);
    } else {
        setBrowserPath(null);
    }

    setLeftUpperCorner(new Point(getPCGenOption("windowLeftUpperCorner.X", -1.0).intValue(), //$NON-NLS-1$
            getPCGenOption("windowLeftUpperCorner.Y", -1.0).intValue())); //$NON-NLS-1$

    setWindowState(getPCGenOption("windowState", Frame.NORMAL)); //$NON-NLS-1$

    Double dw = getPCGenOption("windowWidth", 0.0); //$NON-NLS-1$
    Double dh = getPCGenOption("windowHeight", 0.0); //$NON-NLS-1$

    if (!CoreUtility.doublesEqual(dw.doubleValue(), 0.0) && !CoreUtility.doublesEqual(dh.doubleValue(), 0.0)) {
        final int width = Integer.parseInt(
                dw.toString().substring(0, Math.min(dw.toString().length(), dw.toString().lastIndexOf('.'))));
        final int height = Integer.parseInt(
                dh.toString().substring(0, Math.min(dh.toString().length(), dh.toString().lastIndexOf('.'))));
        d = new Dimension(width, height);
    }

    setCustomizerLeftUpperCorner(
            new Point(getPCGenOption("customizer.windowLeftUpperCorner.X", -1.0).intValue(), //$NON-NLS-1$
                    getPCGenOption("customizer.windowLeftUpperCorner.Y", -1.0).intValue())); //$NON-NLS-1$
    dw = getPCGenOption("customizer.windowWidth", 0.0); //$NON-NLS-1$
    dh = getPCGenOption("customizer.windowHeight", 0.0); //$NON-NLS-1$

    if (!CoreUtility.doublesEqual(dw.doubleValue(), 0.0) && !CoreUtility.doublesEqual(dh.doubleValue(), 0.0)) {
        setCustomizerDimension(new Dimension(dw.intValue(), dh.intValue()));
    }

    setKitSelectorLeftUpperCorner(
            new Point(getPCGenOption("kitSelector.windowLeftUpperCorner.X", -1.0).intValue(), //$NON-NLS-1$
                    getPCGenOption("kitSelector.windowLeftUpperCorner.Y", -1.0).intValue())); //$NON-NLS-1$
    dw = getPCGenOption("kitSelector.windowWidth", 0.0); //$NON-NLS-1$
    dh = getPCGenOption("kitSelector.windowHeight", 0.0); //$NON-NLS-1$

    if (!CoreUtility.doublesEqual(dw.doubleValue(), 0.0) && !CoreUtility.doublesEqual(dh.doubleValue(), 0.0)) {
        setKitSelectorDimension(new Dimension(dw.intValue(), dh.intValue()));
    }

    //
    // Read in the buy/sell percentages for the gear tab
    // If not in the .ini file and ignoreCost is set, then use 0%
    // Otherwise set buy to 100% and sell to %50
    //
    int buyRate = getPCGenOption("GearTab.buyRate", -1); //$NON-NLS-1$
    int sellRate = getPCGenOption("GearTab.sellRate", -1); //$NON-NLS-1$

    if ((buyRate < 0) || (sellRate < 0)) {
        if (getPCGenOption("GearTab.ignoreCost", false)) //$NON-NLS-1$
        {
            buyRate = 0;
            sellRate = 0;
        } else {
            buyRate = 100;
            sellRate = 50;
        }
    }

    Globals.initCustColumnWidth(CoreUtility.split(getOptions().getProperty("pcgen.options.custColumnWidth", ""), //$NON-NLS-1$//$NON-NLS-2$
            ','));

    loadURLs = getPCGenOption("loadURLs", false); //$NON-NLS-1$

    Globals.setSourceDisplay(
            SourceFormat.values()[getPCGenOption("sourceDisplay", SourceFormat.LONG.ordinal())]); //$NON-NLS-1$

    setAlwaysOverwrite(getPCGenOption("alwaysOverwrite", false)); //$NON-NLS-1$
    setAutoFeatsRefundable(getPCGenOption("autoFeatsRefundable", false)); //$NON-NLS-1$
    setAutogenExoticMaterial(getPCGenOption("autoGenerateExoticMaterial", false)); //$NON-NLS-1$
    setAutogenMagic(getPCGenOption("autoGenerateMagic", false)); //$NON-NLS-1$
    setAutogenMasterwork(getPCGenOption("autoGenerateMasterwork", false)); //$NON-NLS-1$
    setAutogenRacial(getPCGenOption("autoGenerateRacial", false)); //$NON-NLS-1$
    setChaTabPlacement(getOptionTabPlacement("chaTabPlacement", SwingConstants.TOP)); //$NON-NLS-1$
    setCreatePcgBackup(getPCGenOption("createPcgBackup", true));
    setCustomizerSplit1(getPCGenOption("customizer.split1", -1)); //$NON-NLS-1$
    setCustomizerSplit2(getPCGenOption("customizer.split2", -1)); //$NON-NLS-1$
    setDefaultOSType(getPCGenOption("defaultOSType", null)); //$NON-NLS-1$
    setEnforceSpendingBeforeLevelUp(getPCGenOption("enforceSpendingBeforeLevelUp", false)); //$NON-NLS-1$
    setGearTab_AllowDebt(getPCGenOption("GearTab.allowDebt", false)); //$NON-NLS-1$
    setGearTab_AutoResize(getPCGenOption("GearTab.autoResize", false)); //$NON-NLS-1$
    setGearTab_BuyRate(buyRate);
    setGearTab_IgnoreCost(getPCGenOption("GearTab.ignoreCost", false)); //$NON-NLS-1$
    setGearTab_SellRate(sellRate);
    setGrimHPMode(getPCGenOption("grimHPMode", false)); //$NON-NLS-1$
    setGrittyACMode(getPCGenOption("grittyACMode", false)); //$NON-NLS-1$
    setGUIUsesOutputNameEquipment(getPCGenOption("GUIUsesOutputNameEquipment", false)); //$NON-NLS-1$
    setGUIUsesOutputNameSpells(getPCGenOption("GUIUsesOutputNameSpells", false)); //$NON-NLS-1$
    setHideMonsterClasses(getPCGenOption("hideMonsterClasses", false)); //$NON-NLS-1$
    setHPMaxAtFirstLevel(getPCGenOption("hpMaxAtFirstLevel", true)); //$NON-NLS-1$
    setHPMaxAtFirstClassLevel(getPCGenOption("hpMaxAtFirstClassLevel", false)); //$NON-NLS-1$
    setHPMaxAtFirstPCClassLevelOnly(getPCGenOption("hpMaxAtFirstPCClassLevelOnly", false)); //$NON-NLS-1$
    setHPPercent(getPCGenOption("hpPercent", 100)); //$NON-NLS-1$
    setHPRollMethod(getPCGenOption("hpRollMethod", Constants.HP_STANDARD)); //$NON-NLS-1$
    setIgnoreMonsterHDCap(getPCGenOption("ignoreMonsterHDCap", false)); //$NON-NLS-1$
    setInvalidDmgText(getPCGenOption("invalidDmgText", //$NON-NLS-1$
            LanguageBundle.getString("SettingsHandler.114"))); //$NON-NLS-1$
    setInvalidToHitText(getPCGenOption("invalidToHitText", //$NON-NLS-1$
            LanguageBundle.getString("SettingsHandler.114"))); //$NON-NLS-1$
    setLastTipShown(getPCGenOption("lastTipOfTheDayTipShown", -1)); //$NON-NLS-1$
    setLookAndFeel(getPCGenOption("looknFeel", 1)); //$NON-NLS-1$
    setMaxPotionSpellLevel(getPCGenOption("maxPotionSpellLevel", 3)); //$NON-NLS-1$
    setMaxWandSpellLevel(getPCGenOption("maxWandSpellLevel", 4)); //$NON-NLS-1$
    setMetamagicAllowedInEqBuilder(getPCGenOption("allowMetamagicInCustomizer", false)); //$NON-NLS-1$
    setPccFilesLocation(new File(expandRelativePath(getPCGenOption("pccFilesLocation", //$NON-NLS-1$
            System.getProperty("user.dir") + File.separator + "data")))); //$NON-NLS-1$ //$NON-NLS-2$
    setPcgenOutputSheetDir(
            new File(expandRelativePath(getOptions().getProperty("pcgen.files.pcgenOutputSheetDir", //$NON-NLS-1$
                    System.getProperty("user.dir") + File.separator + "outputsheets")))); //$NON-NLS-1$ //$NON-NLS-2$
    setPcgenPreviewDir(new File(expandRelativePath(getOptions().getProperty("pcgen.files.pcgenPreviewDir", //$NON-NLS-1$
            System.getProperty("user.dir") + File.separator + "preview")))); //$NON-NLS-1$ //$NON-NLS-2$
    setGmgenPluginDir(new File(expandRelativePath(getOptions().getProperty("gmgen.files.gmgenPluginDir", //$NON-NLS-1$
            System.getProperty("user.dir") + File.separator + "plugins")))); //$NON-NLS-1$ //$NON-NLS-2$
    setBackupPcgPath(
            new File(expandRelativePath(getOptions().getProperty("pcgen.files.characters.backup", "")))); //$NON-NLS-1$
    setPortraitsPath(new File(expandRelativePath(getOptions().getProperty("pcgen.files.portraits", //$NON-NLS-1$
            Globals.getDefaultPcgPath()))));
    setPostExportCommandStandard(getPCGenOption("postExportCommandStandard", "")); //$NON-NLS-1$ //$NON-NLS-2$
    setPostExportCommandPDF(getPCGenOption("postExportCommandPDF", "")); //$NON-NLS-1$ //$NON-NLS-2$
    setPrereqFailColor(getPCGenOption("prereqFailColor", Color.red.getRGB())); //$NON-NLS-1$
    setPrereqQualifyColor(getPCGenOption("prereqQualifyColor", SystemColor.text.getRGB())); //$NON-NLS-1$
    setPreviewTabShown(getPCGenOption("previewTabShown", true)); //$NON-NLS-1$
    setROG(getPCGenOption("isROG", false)); //$NON-NLS-1$
    setSaveCustomInLst(getPCGenOption("saveCustomInLst", false)); //$NON-NLS-1$
    setSaveOutputSheetWithPC(getPCGenOption("saveOutputSheetWithPC", false)); //$NON-NLS-1$
    setPrintSpellsWithPC(getPCGenOption("printSpellsWithPC", true)); //$NON-NLS-1$
    setSelectedSpellSheet(
            expandRelativePath(getOptions().getProperty("pcgen.files.selectedSpellOutputSheet", ""))); //$NON-NLS-1$ //$NON-NLS-2$
    setSelectedCharacterHTMLOutputSheet(
            expandRelativePath(getOptions().getProperty("pcgen.files.selectedCharacterHTMLOutputSheet", //$NON-NLS-1$
                    "")), //$NON-NLS-1$
            aPC);
    setSelectedCharacterPDFOutputSheet(
            expandRelativePath(getOptions().getProperty("pcgen.files.selectedCharacterPDFOutputSheet", //$NON-NLS-1$
                    "")), //$NON-NLS-1$
            aPC);
    setSelectedEqSetTemplate(
            expandRelativePath(getOptions().getProperty("pcgen.files.selectedEqSetTemplate", ""))); //$NON-NLS-1$ //$NON-NLS-2$
    setSelectedPartyHTMLOutputSheet(
            expandRelativePath(getOptions().getProperty("pcgen.files.selectedPartyHTMLOutputSheet", //$NON-NLS-1$
                    ""))); //$NON-NLS-1$
    setSelectedPartyPDFOutputSheet(
            expandRelativePath(getOptions().getProperty("pcgen.files.selectedPartyPDFOutputSheet", //$NON-NLS-1$
                    ""))); //$NON-NLS-1$
    setShowFeatDialogAtLevelUp(getPCGenOption("showFeatDialogAtLevelUp", true)); //$NON-NLS-1$
    setShowHPDialogAtLevelUp(getPCGenOption("showHPDialogAtLevelUp", true)); //$NON-NLS-1$
    setShowImagePreview(getPCGenOption("showImagePreview", true)); //$NON-NLS-1$
    setShowSingleBoxPerBundle(getPCGenOption("showSingleBoxPerBundle", false)); //$NON-NLS-1$
    setOutputDeprecationMessages(getPCGenOption("outputDeprecationMessages", true));
    setInputUnconstructedMessages(getPCGenOption("inputUnconstructedMessages", false));
    setShowStatDialogAtLevelUp(getPCGenOption("showStatDialogAtLevelUp", true)); //$NON-NLS-1$
    setShowTipOfTheDay(getPCGenOption("showTipOfTheDay", true)); //$NON-NLS-1$
    setShowToolBar(getPCGenOption("showToolBar", true)); //$NON-NLS-1$
    setShowSkillModifier(getPCGenOption("showSkillModifier", true)); //$NON-NLS-1$
    setShowSkillRanks(getPCGenOption("showSkillRanks", true)); //$NON-NLS-1$
    setShowWarningAtFirstLevelUp(getPCGenOption("showWarningAtFirstLevelUp", true)); //$NON-NLS-1$
    setSkinLFThemePack(getPCGenOption("skinLFThemePack", "")); //$NON-NLS-1$ //$NON-NLS-2$
    setSpellMarketPriceAdjusted(getPCGenOption("spellMarketPriceAdjusted", false)); //$NON-NLS-1$
    setTabPlacement(getOptionTabPlacement("tabPlacement", SwingConstants.BOTTOM)); //$NON-NLS-1$
    setUseHigherLevelSlotsDefault(getPCGenOption("useHigherLevelSlotsDefault", false)); //$NON-NLS-1$
    setUseWaitCursor(getPCGenOption("useWaitCursor", true)); //$NON-NLS-1$
    setWantToLoadMasterworkAndMagic(getPCGenOption("loadMasterworkAndMagicFromLst", false)); //$NON-NLS-1$
    setWeaponProfPrintout(getPCGenOption("weaponProfPrintout", Constants.DEFAULT_PRINTOUT_WEAPONPROF));

    // Load up all the RuleCheck stuff from the options.ini file
    // It's stored as:
    //   pcgen.options.rulechecks=aKey:Y|bKey:N|cKey:Y
    parseRuleChecksFromOptions(getPCGenOption("ruleChecks", "")); //$NON-NLS-1$ //$NON-NLS-2$

    return d;
}