Example usage for java.util TreeMap putAll

List of usage examples for java.util TreeMap putAll

Introduction

In this page you can find the example usage for java.util TreeMap putAll.

Prototype

public void putAll(Map<? extends K, ? extends V> map) 

Source Link

Document

Copies all of the mappings from the specified map to this map.

Usage

From source file:com.mirth.connect.donkey.util.ActionTimer.java

public String getLog() {
    long totalTime = getTotalTime();

    StringBuilder log = new StringBuilder();
    LongComparator longComparator = new LongComparator(times);
    TreeMap<String, Long> sortedTimes = new TreeMap<String, Long>(longComparator);
    sortedTimes.putAll(times);

    for (Entry<String, Long> logEntry : sortedTimes.entrySet()) {
        String eventName = logEntry.getKey();
        Integer count = counts.get(eventName);
        Long time = logEntry.getValue();

        long pct = (totalTime > 0) ? ((time * 100) / totalTime) : 0;
        log.append(StringUtils.rightPad(eventName + ":", 40)
                + StringUtils.rightPad(count + " occurrence" + ((count != 1) ? "s" : ""), 20)
                + StringUtils.rightPad(time + "ms", 12) + pct + "%\n");
    }//from  w w w . jav  a 2 s . c o m

    int totalCount = getTotalCount();
    log.append(StringUtils.rightPad("Totals:", 40)
            + StringUtils.rightPad(totalCount + " occurrence" + ((totalCount != 1) ? "s" : ""), 20) + totalTime
            + "ms\n");
    return log.toString();
}

From source file:org.sonatype.enunciate.modules.wink.DeploymentModuleImpl.java

@Override
protected void doBuild() throws EnunciateException, IOException {
    super.doBuild();

    File webappDir = getBuildDir();
    //noinspection ResultOfMethodCallIgnored
    webappDir.mkdirs();//from www .jav a2 s . c o m
    File webinf = new File(webappDir, "WEB-INF");
    getEnunciate().copyFile(new File(getGenerateDir(), "application"), new File(webinf, "application"));

    BaseWebAppFragment webappFragment = new BaseWebAppFragment(getName());
    webappFragment.setBaseDir(webappDir);
    WebAppComponent servletComponent = new WebAppComponent();
    servletComponent.setName("wink");
    servletComponent.setClassname(RestServlet.class.getName());
    TreeMap<String, String> initParams = new TreeMap<String, String>();
    initParams.putAll(getServletInitParams());
    initParams.put("applicationConfigLocation", "/WEB-INF/application");
    //        initParams.put("propertiesLocation", "/WEB-INF/application.properties");
    //        initParams.put("javax.ws.rs.Application", "some.package.ApplicationImpl");
    servletComponent.setInitParams(initParams);

    // TODO: Setup wink-admin servlet

    // TODO: Setup mapping

    webappFragment.setServlets(Arrays.asList(servletComponent));
    getEnunciate().addWebAppFragment(webappFragment);
}

From source file:blusunrize.immersiveengineering.api.ApiUtils.java

public static Map<String, Integer> sortMap(Map<String, Integer> map, boolean inverse) {
    TreeMap<String, Integer> sortedMap = new TreeMap<String, Integer>(new ValueComparator(map, inverse));
    sortedMap.putAll(map);
    return sortedMap;
}

From source file:com.acc.storefront.interceptors.beforeview.DebugInfoBeforeViewHandler.java

@Override
public void beforeView(final HttpServletRequest request, final HttpServletResponse response,
        final ModelAndView modelAndView) {
    final boolean showDebug = Config.getBoolean(SHOW_STOREFRONT_DEBUG_INFO_PROPERTY_KEY, false);

    // Store the show debug flag in a request attribute
    request.setAttribute(SHOW_STOREFRONT_DEBUG_INFO, Boolean.valueOf(showDebug));

    if (showDebug) {
        final JaloSession currentSession = JaloSession.getCurrentSession();

        final TreeMap<String, Object> attributeMap = new TreeMap<String, Object>();
        // Build up the session attributes as a request attribute
        attributeMap.putAll(currentSession.getAttributes());
        // Add the session id as an attribute
        attributeMap.put("JaloSession ID", currentSession.getSessionID());

        request.setAttribute(JALO_SESSION_ATTRIBUTES, mapToString(attributeMap));
    }//from  w  w w . jav  a  2 s. c  o  m
}

From source file:jenkins.plugins.publish_over.BPPlugin.java

private TreeMap<String, String> getEnvironmentVariables(final AbstractBuild<?, ?> build,
        final TaskListener listener) {
    try {/* w ww . j a  v a2  s  .  c o m*/
        final TreeMap<String, String> env = build.getEnvironment(listener);
        env.putAll(build.getBuildVariables());
        return env;
    } catch (Exception e) {
        throw new RuntimeException(Messages.exception_failedToGetEnvVars(), e);
    }
}

From source file:nl.uva.mlc.eurovoc.featureextractor.KFCPropagator.java

public void propagator() {
    this.fp = new FeaturePropagator();
    for (int i = 0; i < k; i++) {
        Map<String, HashMap<String, Double>> scores = new HashMap<>();
        try {//from  ww  w. j  a va  2 s  .c om
            File file2 = new File(KFoldPath + "/fold" + (i + 1) + "/judg.txt");
            if (file2.exists())
                FileUtils.forceDelete(file2);
            file2.createNewFile();
            FileWriter fw2;
            fw2 = new FileWriter(file2);
            BufferedWriter judg = new BufferedWriter(fw2);

            BufferedReader testFile = new BufferedReader(
                    new FileReader(new File(KFoldPath + "/fold" + (i + 1) + "/test.txt")));
            BufferedReader scoresFile = new BufferedReader(
                    new FileReader(new File(KFoldPath + "/fold" + (i + 1) + "/scores.txt")));

            String str, str2;
            while ((str = testFile.readLine()) != null) {
                String[] parts = str.split(" # ")[1].split(" ");
                if (str.split(" ")[0].equals("1"))
                    judg.write(parts[0] + " 0 " + parts[1] + " 1" + "\n");
                str2 = scoresFile.readLine();
                Double score = Double.valueOf(str2.split("\\s+")[2]);
                if (scores.containsKey(parts[0]))
                    scores.get(parts[0]).put(parts[1], score);
                else {
                    HashMap<String, Double> temp = new HashMap<>();
                    temp.put(parts[1], score);
                    scores.put(parts[0], temp);
                }
            }
            judg.close();
            for (int itr : itNums) {
                if (itr == 0)
                    continue;
                for (double alpha : this.alphas) {
                    if (alpha == 0D)
                        continue;
                    this.fp.alpha = alpha;
                    this.fp.numIteration = itr;
                    File f = new File(KFoldPath + "/fold" + (i + 1) + "/anal");
                    if (f.exists())
                        f.delete();
                    else
                        FileUtils.forceMkdir(f);
                    File file = new File(KFoldPath + "/fold" + (i + 1) + "/anal/propagatedRes_" + "alpha"
                            + alpha + "_itrNum" + itr + ".txt");
                    if (file.exists())
                        FileUtils.forceDelete(file);
                    file.createNewFile();

                    FileWriter fw;
                    fw = new FileWriter(file);
                    BufferedWriter propRes = new BufferedWriter(fw);
                    for (Entry<String, HashMap<String, Double>> ent : scores.entrySet()) {
                        FileUtils.forceMkdir(f);
                        HashMap<String, Double> propScores = fp.finalScorePropagator(ent.getValue());
                        MyValueComparator bvc = new MyValueComparator(propScores);
                        TreeMap<String, Double> sorted_map = new TreeMap<>(bvc);
                        sorted_map.putAll(propScores);
                        int rank = 1;
                        for (Entry<String, Double> ent2 : propScores.entrySet()) {
                            String line = ent.getKey() + " 0 " + ent2.getKey() + " " + rank++ + " "
                                    + ent2.getValue();
                            propRes.write(line + " RUN" + "\n");
                        }
                    }
                    log.info("alpha:" + alpha + "iteration:" + itr + " is finished");
                    propRes.close();
                }
            }

        } catch (IOException ex) {
            log.error(ex);
        }
        log.info("------------- Fold " + (i + 1) + " is finished--------------");
    }
}

From source file:my.mavenproject10.FileuploadController.java

public TreeMap sortByValue(Map unsortedMap) {
    TreeMap sortedMap = new TreeMap(new ValueComparator(unsortedMap));
    sortedMap.putAll(unsortedMap);
    return sortedMap;
}

From source file:com.opengamma.analytics.math.interpolation.GridInterpolator2D.java

private Map<Double, Interpolator1DDataBundle> testData(final Map<DoublesPair, Double> data) {
    final Map<Double, Interpolator1DDataBundle> result = new TreeMap<Double, Interpolator1DDataBundle>();
    final TreeMap<DoublesPair, Double> sorted = new TreeMap<DoublesPair, Double>(_comparator);
    sorted.putAll(data);
    final Iterator<Map.Entry<DoublesPair, Double>> iterator = sorted.entrySet().iterator();
    final Map.Entry<DoublesPair, Double> firstEntry = iterator.next();
    double x = firstEntry.getKey().first;
    Map<Double, Double> yzValues = new TreeMap<Double, Double>();
    yzValues.put(firstEntry.getKey().second, firstEntry.getValue());
    while (iterator.hasNext()) {
        final Map.Entry<DoublesPair, Double> nextEntry = iterator.next();
        final double newX = nextEntry.getKey().first;
        if (Double.doubleToLongBits(newX) != Double.doubleToLongBits(x)) {
            final Interpolator1DDataBundle interpolatorData = _yInterpolator.getDataBundle(yzValues);
            result.put(x, interpolatorData);
            yzValues = new TreeMap<Double, Double>();
            yzValues.put(nextEntry.getKey().second, nextEntry.getValue());
            x = newX;/*w w w  .  j a v a  2 s .  c  o  m*/
        } else {
            yzValues.put(nextEntry.getKey().second, nextEntry.getValue());
        }
        if (!iterator.hasNext()) {
            yzValues.put(nextEntry.getKey().second, nextEntry.getValue());
            final Interpolator1DDataBundle interpolatorData = _yInterpolator.getDataBundle(yzValues);
            result.put(x, interpolatorData);
        }
    }
    return result;
}

From source file:com.opengamma.analytics.financial.provider.sensitivity.inflation.MultipleCurrencyInflationSensitivity.java

/**
 * Create a new multiple currency sensitivity by adding another multiple currency sensitivity.
 * For each currency in the other multiple currency sensitivity, the currency and its associated sensitivity are added.
 * @param other The multiple currency sensitivity. Not null.
 * @return The new multiple currency sensitivity.
 *///from  w ww .  j  av a 2  s .  co m
public MultipleCurrencyInflationSensitivity plus(final MultipleCurrencyInflationSensitivity other) {
    ArgumentChecker.notNull(other, "Sensitivity");
    final TreeMap<Currency, InflationSensitivity> map = new TreeMap<>();
    map.putAll(_sensitivity);
    MultipleCurrencyInflationSensitivity result = new MultipleCurrencyInflationSensitivity(map);
    for (final Currency loopccy : other._sensitivity.keySet()) {
        result = result.plus(loopccy, other.getSensitivity(loopccy));
    }
    return result;
}

From source file:com.opengamma.analytics.financial.forex.method.MultipleCurrencyInterestRateCurveSensitivity.java

/**
 * Create a new multiple currency sensitivity by adding another multiple currency sensitivity.
 * For each currency in the other multiple currency sensitivity, the currency and its associated sensitivity are added.
 * @param other The multiple currency sensitivity. Not null.
 * @return The new multiple currency sensitivity.
 *///from w w  w .j a v a2 s  . c  o  m
public MultipleCurrencyInterestRateCurveSensitivity plus(
        final MultipleCurrencyInterestRateCurveSensitivity other) {
    ArgumentChecker.notNull(other, "Sensitivity");
    final TreeMap<Currency, InterestRateCurveSensitivity> map = new TreeMap<>();
    map.putAll(_sensitivity);
    MultipleCurrencyInterestRateCurveSensitivity result = new MultipleCurrencyInterestRateCurveSensitivity(map);
    for (final Currency loopccy : other._sensitivity.keySet()) {
        result = result.plus(loopccy, other.getSensitivity(loopccy));
    }
    return result;
}