Example usage for java.util LinkedHashMap get

List of usage examples for java.util LinkedHashMap get

Introduction

In this page you can find the example usage for java.util LinkedHashMap get.

Prototype

public V get(Object key) 

Source Link

Document

Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.

Usage

From source file:hydrograph.ui.graph.controller.ComponentEditPart.java

/**
 * updates version and validity status icon of subjob component
 * @param figure/*w  w w. j ava 2  s  .com*/
 */
public void updateSubjobComponent(IFigure figure) {
    LinkedHashMap<String, Object> properties = getCastedModel().getProperties();
    if (StringUtils.equals(getCastedModel().getComponentName(), Constants.SUBJOB_COMPONENT)) {

        if (null == getCastedModel().getSubJobContainer().get(Constants.SUBJOB_CONTAINER)
                && getCastedModel().getSubJobContainer().size() == 0) {
            if (StringUtils.isNotBlank((String) (getCastedModel().getProperties().get(Constants.JOB_PATH)))) {

                reloadSubjobContainer();

            }
        }
        SubJobUtility graphUtility = new SubJobUtility();
        graphUtility.updateSubjobCompVersion(getCastedModel());
    }
    String status = (String) properties.get(Component.Props.VALIDITY_STATUS.getValue());
    ((ComponentFigure) figure).setPropertyStatus(status);
}

From source file:com.opengamma.analytics.financial.provider.sensitivity.multicurve.ParameterSensitivityMulticurveUnderlyingMatrixCalculator.java

/**
 * Computes the sensitivity with respect to the parameters from the point sensitivities to the continuously compounded rate.
 * @param sensitivity The point sensitivity.
 * @param multicurves The multi-curve provider. Not null.
 * @param curvesSet The set of curves for which the sensitivity will be computed. Not null.
 * @return The sensitivity (as a ParameterSensitivity). ??The order of the sensitivity is by curve as provided by the curvesSet??
 *//*from w ww .  j  a  v  a  2s  .co  m*/
@Override
public DoubleMatrix1D pointToParameterSensitivity(final MulticurveSensitivity sensitivity,
        final MulticurveProviderInterface multicurves, final Set<String> curvesSet) {
    // TODO: The first part depends only of the multicurves and curvesSet, not the sensitivity. Should it be refactored and done only once?
    final Set<String> curveNamesSet = multicurves.getAllNames(); // curvesSet; //
    final int nbCurve = curveNamesSet.size();
    final String[] curveNamesArray = new String[nbCurve];
    int loopname = 0;
    final LinkedHashMap<String, Integer> curveNum = new LinkedHashMap<>();
    for (final String name : curveNamesSet) { // loop over all curves (by name)
        curveNamesArray[loopname] = name;
        curveNum.put(name, loopname++);
    }
    final int[] nbNewParameters = new int[nbCurve];
    // Implementation note: nbNewParameters - number of new parameters in the curve, parameters not from an underlying curve which is another curve of the bundle.
    final int[][] indexOther = new int[nbCurve][];
    // Implementation note: indexOther - the index of the underlying curves, if any.
    loopname = 0;
    for (final String name : curveNamesSet) { // loop over all curves (by name)
        nbNewParameters[loopname] = multicurves.getNumberOfParameters(name);
        loopname++;
    }
    loopname = 0;
    for (final String name : curveNamesSet) { // loop over all curves (by name)
        final List<String> underlyingCurveNames = multicurves.getUnderlyingCurvesNames(name);
        final IntArrayList indexOtherList = new IntArrayList();
        for (final String u : underlyingCurveNames) {
            final Integer i = curveNum.get(u);
            if (i != null) {
                indexOtherList.add(i);
                nbNewParameters[loopname] -= nbNewParameters[i]; // Only one level: a curve used as an underlying can not have an underlying itself.
            }
        }
        indexOther[loopname] = indexOtherList.toIntArray();
        loopname++;
    }
    final int nbSensiCurve = curvesSet.size();
    //    for (final String name : curveNamesSet) { // loop over all curves (by name)
    //      if (curvesSet.contains(name)) {
    //        nbSensiCurve++;
    //      }
    //    }
    final int[] nbNewParamSensiCurve = new int[nbSensiCurve];
    // Implementation note: nbNewParamSensiCurve
    final int[][] indexOtherSensiCurve = new int[nbSensiCurve][];
    // Implementation note: indexOtherSensiCurve -
    final int[] startCleanParameter = new int[nbSensiCurve];
    // Implementation note: startCleanParameter - for each curve for which the sensitivity should be computed, the index in the total sensitivity vector at which that curve start.
    final int[][] startDirtyParameter = new int[nbSensiCurve][];
    // Implementation note: startDirtyParameter - for each curve for which the sensitivity should be computed, the indexes of the underlying curves.
    int nbSensitivityCurve = 0;
    int nbCleanParameters = 0;
    int currentDirtyStart = 0;
    for (final String name : curvesSet) { // loop over all curves (by name)
        //      if (curvesSet.contains(name)) {
        final int num = curveNum.get(name);
        final IntArrayList startDirtyParameterList = new IntArrayList();
        final List<String> underlyingCurveNames = multicurves.getUnderlyingCurvesNames(name);
        for (final String u : underlyingCurveNames) {
            final Integer i = curveNum.get(u);
            if (i != null) {
                startDirtyParameterList.add(currentDirtyStart);
                currentDirtyStart += nbNewParameters[i];
            }
        }
        startDirtyParameterList.add(currentDirtyStart);
        currentDirtyStart += nbNewParameters[num];
        startDirtyParameter[nbSensitivityCurve] = startDirtyParameterList.toIntArray();
        nbNewParamSensiCurve[nbSensitivityCurve] = nbNewParameters[num];
        indexOtherSensiCurve[nbSensitivityCurve] = indexOther[num];
        startCleanParameter[nbSensitivityCurve] = nbCleanParameters;
        nbCleanParameters += nbNewParamSensiCurve[nbSensitivityCurve];
        nbSensitivityCurve++;
        //      }
    }
    // Implementation note: Compute the "dirty" sensitivity, i.e. the sensitivity where the underlying curves are not taken into account.
    double[] sensiDirty = new double[0];
    final Map<String, List<DoublesPair>> sensitivityDsc = sensitivity.getYieldDiscountingSensitivities();
    final Map<String, List<ForwardSensitivity>> sensitivityFwd = sensitivity.getForwardSensitivities();
    for (final String name : curvesSet) { // loop over all curves (by name)
        //      if (curvesSet.contains(name)) {
        final int nbParam = multicurves.getNumberOfParameters(name);
        final double[] s1Name = new double[nbParam];
        final double[] sDsc1Name = multicurves.parameterSensitivity(name, sensitivityDsc.get(name));
        final double[] sFwd1Name = multicurves.parameterForwardSensitivity(name, sensitivityFwd.get(name));
        //        if ((sDsc1Name != null) && (sFwd1Name == null)) {
        //          s1Name = sDsc1Name;
        //        }
        //        if ((sDsc1Name == null) && (sFwd1Name != null)) {
        //          s1Name = sFwd1Name;
        //        }
        //        if ((sDsc1Name != null) && (sFwd1Name != null)) {
        for (int loopp = 0; loopp < nbParam; loopp++) {
            s1Name[loopp] = sDsc1Name[loopp] + sFwd1Name[loopp];
        }
        //        }
        sensiDirty = ArrayUtils.addAll(sensiDirty, s1Name);
        //      }
    }
    // Implementation note: "clean" the sensitivity, i.e. add the underlying curve parts.
    final double[] sensiClean = new double[nbCleanParameters];
    for (int loopcurve = 0; loopcurve < nbSensiCurve; loopcurve++) {
        for (int loopo = 0; loopo < indexOtherSensiCurve[loopcurve].length; loopo++) {
            if (curvesSet.contains(curveNamesArray[indexOtherSensiCurve[loopcurve][loopo]])) {
                for (int loops = 0; loops < nbNewParamSensiCurve[indexOtherSensiCurve[loopcurve][loopo]]; loops++) {
                    sensiClean[startCleanParameter[indexOtherSensiCurve[loopcurve][loopo]]
                            + loops] += sensiDirty[startDirtyParameter[loopcurve][loopo] + loops];
                }
            }
        }
        for (int loops = 0; loops < nbNewParamSensiCurve[loopcurve]; loops++) {
            sensiClean[startCleanParameter[loopcurve]
                    + loops] += sensiDirty[startDirtyParameter[loopcurve][indexOtherSensiCurve[loopcurve].length]
                            + loops];
        }
    }
    return new DoubleMatrix1D(sensiClean);
}

From source file:at.ac.htlstp.app.iic.ui.activity.MainActivity.java

@Override
public void onChangePassword(final LinkedHashMap<String, Object> passwordData,
        final MaterialDialog passwordDialog) {
    final MaterialDialog dialog = new MaterialDialog.Builder(this).content(R.string.refreshing_user_data)
            .progress(true, 0).cancelable(false).show();

    Runnable tryAgainAction = new Runnable() {
        @Override/*from  w w w .j  av  a 2  s.  c  o m*/
        public void run() {
            onChangePassword(passwordData, passwordDialog);
        }
    };

    mUserController.changePassword(passwordData)
            .setResultHandler(new IICResultHandler<String>(this, tryAgainAction) {
                @Override
                public void onSuccess(String param) {
                    Toast.makeText(MainActivity.this, param, Toast.LENGTH_LONG).show();

                    /**
                     * UPDATE local stored password to new changed password
                     */
                    mRealm.beginTransaction();
                    mCurrentUser.setPassword(passwordData.get("NewPassword").toString());
                    mRealm.commitTransaction();

                    dialog.dismiss();
                    passwordDialog.dismiss();
                }

                @Override
                public boolean onError(IICError error) {
                    dialog.dismiss();

                    if (error.getErrorId().equals(IICError.E_API_ERROR)) {
                        ErrorHandler.showCustomErrorDialog(MainActivity.this, getString(R.string.error),
                                error.getMessage());

                        return true;
                    }

                    return false;
                }
            });
}

From source file:gate.util.reporting.PRTimeReporter.java

/**
 * Generates a tree like structure made up of LinkedHashMap containing the
 * processing elements and time taken by each element totaled at leaf level
 * over corpus.//from   w  w w.j ava  2s. c o m
 *
 * @param store
 *          An Object of type LinkedHashMap<String, Object> containing the
 *          processing elements (with time in milliseconds) in hierarchical
 *          structure.
 * @param tokens
 *          An array consisting of remaining benchmarkID tokens except the one
 *          being processed.
 * @param bTime
 *          time(in milliseconds) of the benchmarkID token being processed.
 */
@SuppressWarnings("unchecked")
private void organizeEntries(LinkedHashMap<String, Object> store, String[] tokens, String bTime) {
    if (tokens.length > 0 && store.containsKey(tokens[0])) {
        if (tokens.length > 1) {
            String[] tempArr = new String[tokens.length - 1];
            System.arraycopy(tokens, 1, tempArr, 0, tokens.length - 1);
            if (store.get(tokens[0]) instanceof LinkedHashMap) {
                organizeEntries((LinkedHashMap<String, Object>) (store.get(tokens[0])), tempArr, bTime);
            } else {
                if (store.get(tokens[0]) != null) {
                    store.put(tokens[0], new LinkedHashMap<String, Object>());
                } else {
                    store.put(tokens[0], bTime);
                }
            }
        } else {
            if (store.get(tokens[0]) != null) {
                if (!(store.get(tokens[0]) instanceof LinkedHashMap)) {
                    int total = Integer.parseInt((String) (store.get(tokens[0]))) + Integer.parseInt(bTime);
                    store.put(tokens[0], Integer.toString(total));
                } else {
                    int total = Integer.parseInt(bTime);
                    if (((java.util.LinkedHashMap<String, Object>) (store.get(tokens[0])))
                            .get("systotal") != null) {
                        total = total + Integer.parseInt(
                                (String) ((java.util.LinkedHashMap<String, Object>) (store.get(tokens[0])))
                                        .get("systotal"));
                    }
                    ((java.util.LinkedHashMap<String, Object>) (store.get(tokens[0]))).put("systotal",
                            Integer.toString(total));
                }
            }
        }
    } else {
        if (tokens.length - 1 == 0) {
            store.put(tokens[0], bTime);
        } else {
            store.put(tokens[0], new LinkedHashMap<String, Object>());
            String[] tempArr = new String[tokens.length - 1];
            System.arraycopy(tokens, 1, tempArr, 0, tokens.length - 1);
            organizeEntries((LinkedHashMap<String, Object>) (store.get(tokens[0])), tempArr, bTime);
        }
    }
}

From source file:com.tesora.dve.common.catalog.CatalogDAO.java

public PersistentGroup buildAllSitesGroup() throws PEException {
    List<PersistentSite> sites = findAllPersistentSites();
    final LinkedHashMap<String, PersistentSite> uniqueURLS = new LinkedHashMap<String, PersistentSite>();
    for (PersistentSite ps : sites) {
        String key = ps.getMasterUrl();
        PersistentSite already = uniqueURLS.get(key);
        if (already == null)
            uniqueURLS.put(key, ps);//  ww w  .j a v a 2 s. c  o m
    }
    return new PersistentGroup(uniqueURLS.values());
}

From source file:geogebra.io.MyI2GHandler.java

private void startElements(String eName, LinkedHashMap attrs) {
    debug("startElements", eName);
    switch (subMode) {
    case MODE_INVALID:
        // TODO -> extend to further objects
        if (!eName.equals("line") && !eName.equals("line_segment") && !eName.equals("point")) {
            Application.debug("unknown tag in <elements>: " + eName);
            break;
        }/*from  w w w.j  a v  a 2s  .co  m*/

        String label = (String) attrs.get("id");
        if (label == null) {
            Application.debug("attribute id missing in <" + eName + ">");
            break;
        }

        // does a geo element with this label exist?
        geo = kernel.lookupLabel(label);
        if (geo != null) {
            geo = null;
            Application.debug("an element with id \"" + label + "\" already exists");
            break;
        }

        if (eName.equals("line_segment")) {
            eName = "segment";
            segment = true;
            segmentStart = new GeoPoint(cons);
            segmentEnd = new GeoPoint(cons);
            segmentVia = new GeoPoint(cons);
        } else {
            segment = false;
        }

        geo = kernel.createGeoElement(cons, eName);
        geo.setLoadedLabel(label);
        subMode = MODE_ELEMENTS;
        cmdName = eName;
        break;

    case MODE_ELEMENTS:
        String[] tags;
        if (cmdName.equals("point")) {
            tags = new String[] { "homogeneous_coordinates", "euclidean_coordinates", "polar_coordinates" };
        } else {
            tags = new String[] { "homogeneous_coordinates" };
        }
        int i;
        for (i = 0; i < tags.length; i++) {
            if (eName.equals(tags[i])) {
                break;
            }
        }
        if (i >= tags.length) {
            Application.debug("unknown tag in <" + geo.getI2GtypeString() + ">: " + eName);
            break;
        } else if (!(geo instanceof GeoVec3D)) {
            Application.debug("wrong element type for coordinates: " + geo.getI2GtypeString());
            break;
        }

        if (eName.equals("homogeneous_coordinates")) {
            coord = 0;
            coords = new Complex[] { Complex.NaN, Complex.NaN, Complex.NaN };
        } else if (eName.equals("euclidean_coordinates") || eName.equals("polar_coordinates")) {
            coord = 0;
            coords = new Complex[] { Complex.NaN, Complex.NaN };
        }
        subMode = MODE_COORDINATES;
        cmdName = eName;
        break;

    case MODE_COORDINATES:
        if (eName.equals("double")) {
            subMode = MODE_COORDINATES_REAL_DOUBLE;
        } else if (cmdName.equals("homogeneous_coordinates") && eName.equals("complex")) {
            subMode = MODE_COORDINATES_COMPLEX;
        } else {
            Application.debug("unknown tag in <" + cmdName + ">: " + eName);
            break;
        }
        if (coord >= coords.length) {
            break;
        }
        for (coord = 0; coord < coords.length; coord++) {
            if (coords[coord].isNaN()) {
                break;
            }
        }
        if (coord >= coords.length) {
            String tag = "<double>";
            if (cmdName.equals("homogeneous_coordinates")) {
                tag = "<double> or <complex>";
            }
            Application.debug("more than " + coords.length + " " + tag + " specified for <" + cmdName + ">");
        }
        break;

    case MODE_COORDINATES_COMPLEX:
        if (eName.equals("double")) {
            subMode = MODE_COORDINATES_COMPLEX_DOUBLE;
        } else {
            Application.debug("unknown tag in <complex>: " + eName);
        }
        break;

    case MODE_COORDINATES_REAL_DOUBLE:
    case MODE_COORDINATES_COMPLEX_DOUBLE:
        Application.debug("unknown tag in <double>: " + eName);
        break;
    }
}

From source file:com.espertech.esper.regression.support.PatternTestHarness.java

private void checkResults(PatternTestStyle testStyle, String eventId) {
    // For each test descriptor, make sure the listener has received exactly the events expected
    int index = 0;
    log.debug(".checkResults Checking results for event " + eventId);

    for (EventExpressionCase descriptor : caseList.getResults()) {
        String expressionText = expressions[index].getText();

        LinkedHashMap<String, LinkedList<EventDescriptor>> allExpectedResults = descriptor.getExpectedResults();
        EventBean[] receivedResults = listeners[index].getLastNewData();
        index++;/*www.  jav a 2 s. com*/

        // If nothing at all was expected for this event, make sure nothing was received
        if (!(allExpectedResults.containsKey(eventId))) {
            if ((receivedResults != null) && (receivedResults.length > 0)) {
                log.debug(".checkResults Incorrect result for style " + testStyle + " expression : "
                        + expressionText);
                log.debug(".checkResults Expected no results for event " + eventId + ", but received "
                        + receivedResults.length + " events");
                log.debug(".checkResults Received, have " + receivedResults.length + " entries");
                printList(receivedResults);
                TestCase.assertFalse(true);
            }
            continue;
        }

        LinkedList<EventDescriptor> expectedResults = allExpectedResults.get(eventId);

        // Compare the result lists, not caring about the order of the elements
        try {
            if (!(compareLists(receivedResults, expectedResults))) {
                log.debug(".checkResults Incorrect result for style " + testStyle + " expression : "
                        + expressionText);
                log.debug(".checkResults Expected size=" + expectedResults.size() + " received size="
                        + (receivedResults == null ? 0 : receivedResults.length));

                log.debug(".checkResults Expected, have " + expectedResults.size() + " entries");
                printList(expectedResults);
                log.debug(".checkResults Received, have "
                        + (receivedResults == null ? 0 : receivedResults.length) + " entries");
                printList(receivedResults);

                TestCase.assertFalse(true);
            }
        } catch (Exception ex) {
            ex.printStackTrace();
            Assert.fail("For statement '" + expressionText + "' failed to assert: " + ex.getMessage());
        }
    }
}

From source file:gate.util.reporting.PRTimeReporter.java

/**
 * Prints a processing elements structure in a tree like format with time
 * taken by each element in milliseconds and in %.
 *
 * @param gStore/*  w  ww  .ja  v a  2 s  .c om*/
 *          An Object of type LinkedHashMap<String, Object> containing the
 *          processing elements (with time in milliseconds) in hierarchical
 *          structure.
 * @param separator
 *          A String separator to indent the processing elements in tree like
 *          structure.
 * @param suppressZeroTimeEntries
 *          Indicate whether or not to show 0 millisecond entries.
 */
@SuppressWarnings("unchecked")
private void prettyPrint(LinkedHashMap<String, Object> gStore, String separator,
        boolean suppressZeroTimeEntries) {

    Iterator<String> i = gStore.keySet().iterator();
    while (i.hasNext()) {
        Object key = i.next();
        if (globalTotal.containsKey(key))
            globalValue = Integer.parseInt(globalTotal.get(key));
        if (gStore.get(key) instanceof LinkedHashMap) {
            int systotal = 0;
            if (((LinkedHashMap<String, Object>) gStore.get(key)).containsKey("systotal")) {
                systotal = Integer
                        .parseInt((String) ((LinkedHashMap<String, Object>) (gStore.get(key))).get("systotal"));
            }
            if (suppressZeroTimeEntries) {
                if (systotal > 0)
                    printLines.add(separator + key + " (" + systotal / 1000.0 + ") ["
                            + Math.round(((systotal / globalValue) * 100) * 10) / 10.0 + "%]");
            } else {
                printLines.add(separator + key + " (" + systotal / 1000.0 + ") ["
                        + Math.round(((systotal / globalValue) * 100) * 10) / 10.0 + "%]");
            }

            prettyPrint((LinkedHashMap<String, Object>) (gStore.get(key)), separator + "\t",
                    suppressZeroTimeEntries);
        } else {
            if (!(key.equals("total") || key.equals("systotal"))) {
                if (suppressZeroTimeEntries) {
                    if (Integer.parseInt((String) (gStore.get(key))) != 0) {
                        printLines.add(separator + key + " ("
                                + Integer.parseInt((String) (gStore.get(key))) / 1000.0 + ") ["
                                + Math.round(
                                        ((Integer.parseInt((String) (gStore.get(key))) / globalValue) * 100)
                                                * 10)
                                        / 10.0
                                + "%]");
                    }
                } else {
                    printLines.add(separator + key + " ("
                            + Integer.parseInt((String) (gStore.get(key))) / 1000.0 + ") ["
                            + Math.round(
                                    ((Integer.parseInt((String) (gStore.get(key))) / globalValue) * 100) * 10)
                                    / 10.0
                            + "%]");
                }
            }
        }
    }
}

From source file:gate.util.reporting.PRTimeReporter.java

/**
 * Creates three tree like ul/li structures 1. A tree to represent processing
 * elements 2. A tree to represent time taken by processing elements 3. A tree
 * to represent time taken by processing elements in %.
 *
 * @param gStore/*from   w w w.  j a va2s . c o  m*/
 *          An Object of type LinkedHashMap<String, Object> containing the
 *          processing elements (with time in milliseconds) in hierarchical
 *          structure.
 * @param suppressZeroTimeEntries
 *          Indicate whether or not to show 0 millisecond entries.
 */
@SuppressWarnings("unchecked")
private void generateCollapsibleHTMLTree(LinkedHashMap<String, Object> gStore,
        boolean suppressZeroTimeEntries) {
    Iterator<String> i = gStore.keySet().iterator();
    while (i.hasNext()) {
        Object key = i.next();
        if (globalTotal.containsKey(key))
            globalValue = Integer.parseInt(globalTotal.get(key));

        if (gStore.get(key) instanceof LinkedHashMap) {
            int systotal = 0;
            if (((LinkedHashMap<String, Object>) gStore.get(key)).containsKey("systotal")) {
                systotal = Integer
                        .parseInt((String) ((LinkedHashMap<String, Object>) (gStore.get(key))).get("systotal"));
            }

            if (suppressZeroTimeEntries) {
                if (systotal > 0) {
                    htmlElementTree += "<li id=\"level" + level + "\">"
                            + "<a href=\"#\"  onclick=\"expandCollapseTree(this)\">[+]</a>" + "&nbsp;" + key
                            + "<ul style=\"display:none\">" + NL;
                    htmlTimeTree += "<div id=level" + level + ".1>" + NL + systotal / 1000.0 + NL
                            + "<div style=\"display:none\">" + NL;
                    htmlTimeInPercentTree += "<div id=level" + level + ".2>" + NL
                            + Math.round(((systotal / globalValue) * 100) * 10) / 10.0
                            + "<div style=\"display:none\">" + NL;
                    level++;
                    generateCollapsibleHTMLTree((LinkedHashMap<String, Object>) (gStore.get(key)),
                            suppressZeroTimeEntries);
                    htmlElementTree += "</ul></li>" + NL;
                    htmlTimeTree += "</div></div>" + NL;
                    htmlTimeInPercentTree += "</div></div>" + NL;
                }
            } else {
                htmlElementTree += "<li id=level" + level + ">"
                        + "<a href=\"#\" onclick=\"expandCollapseTree(this)\">[+]</a>" + "&nbsp;" + key
                        + "<ul style=\"display:none\">" + NL;
                htmlTimeTree += "<div id=level" + level + ".1>" + NL + systotal / 1000.0
                        + "<div style=\"display:none\">" + NL;
                htmlTimeInPercentTree += "<div id=level" + level + ".2>" + NL
                        + Math.round(((systotal / globalValue) * 100) * 10) / 10.0
                        + "<div style=\"display:none\">" + NL;
                level++;
                generateCollapsibleHTMLTree((LinkedHashMap<String, Object>) (gStore.get(key)),
                        suppressZeroTimeEntries);
                htmlElementTree += "</ul></li>" + NL;
                htmlTimeTree += "</div></div>" + NL;
                htmlTimeInPercentTree += "</div></div>" + NL;
            }
        } else {
            if (!(key.equals("total") || key.equals("systotal"))) {
                if (suppressZeroTimeEntries) {
                    if (Integer.parseInt((String) (gStore.get(key))) != 0) {
                        htmlElementTree += "<li>&nbsp;&nbsp;&nbsp;" + key + "</li>" + NL;
                        htmlTimeTree += "<div>" + NL + Integer.parseInt((String) (gStore.get(key))) / 1000.0
                                + "</div>" + NL;
                        htmlTimeInPercentTree += "<div>" + NL + Math.round(
                                ((Integer.parseInt((String) (gStore.get(key))) / globalValue) * 100) * 10)
                                / 10.0 + "</div>" + NL;
                    }
                } else {
                    htmlElementTree += "<li>&nbsp;&nbsp;&nbsp;" + key + "</li>" + NL;
                    htmlTimeTree += "<div>" + NL + Integer.parseInt((String) (gStore.get(key))) / 1000.0
                            + "</div>" + NL;
                    htmlTimeInPercentTree += "<div>" + NL
                            + Math.round(
                                    ((Integer.parseInt((String) (gStore.get(key))) / globalValue) * 100) * 10)
                                    / 10.0
                            + "</div>" + NL;
                }
            }
        }
    }
}

From source file:com.aliyun.odps.local.common.WareHouse.java

/**
 * copy resource from warehouse/__resources__/ to temp/resource/
 *
 * @param projName//  w ww  .j  a  v a2  s .c  o  m
 * @param resourceName
 * @param resourceRootDir
 * @param limitDownloadRecordCount
 * @param inputColumnSeperator
 * @throws IOException
 * @throws OdpsException
 */
public void copyResource(String projName, String resourceName, File resourceRootDir,
        int limitDownloadRecordCount, char inputColumnSeperator) throws IOException, OdpsException {
    if (StringUtils.isBlank(projName) || StringUtils.isBlank(resourceName) || resourceRootDir == null) {
        return;
    }

    if (!resourceRootDir.exists()) {
        resourceRootDir.mkdirs();
    }

    LOG.info("Start to copy resource: " + projName + "." + resourceName + "-->"
            + resourceRootDir.getAbsolutePath());

    if (!existsResource(projName, resourceName)) {
        DownloadUtils.downloadResource(getOdps(), projName, resourceName, limitDownloadRecordCount,
                inputColumnSeperator);
    }

    File file = getReourceFile(projName, resourceName);

    // table resource
    if (file.isDirectory()) {
        File tableResourceDir = new File(resourceRootDir, resourceName);

        TableInfo refTableInfo = getReferencedTable(projName, resourceName);
        LinkedHashMap<String, String> partitions = refTableInfo.getPartSpec();

        if (partitions != null && partitions.size() > 0) {
            PartitionSpec partSpec = new PartitionSpec();
            for (String key : partitions.keySet()) {
                partSpec.set(key, partitions.get(key));
            }
            copyTable(refTableInfo.getProjectName(), refTableInfo.getTableName(), partSpec, null,
                    tableResourceDir, limitDownloadRecordCount, inputColumnSeperator);
        } else {
            copyTable(refTableInfo.getProjectName(), refTableInfo.getTableName(), null, null, tableResourceDir,
                    limitDownloadRecordCount, inputColumnSeperator);
        }

    } else {
        // not table resource
        if (!existsResource(projName, resourceName)) {

            DownloadUtils.downloadResource(getOdps(), projName, resourceName, limitDownloadRecordCount,
                    inputColumnSeperator);
        }
        FileUtils.copyFileToDirectory(file, resourceRootDir);
    }

    LOG.info("Finished copy resource: " + projName + "." + resourceName + "-->"
            + resourceRootDir.getAbsolutePath());
}