Example usage for java.util TreeMap TreeMap

List of usage examples for java.util TreeMap TreeMap

Introduction

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

Prototype

public TreeMap(SortedMap<K, ? extends V> m) 

Source Link

Document

Constructs a new tree map containing the same mappings and using the same ordering as the specified sorted map.

Usage

From source file:com.opengamma.financial.analytics.cashflow.FixedPaymentMatrix.java

public FixedPaymentMatrix(final Map<LocalDate, MultipleCurrencyAmount> values) {
    ArgumentChecker.notNull(values, "values");
    _values = new TreeMap<LocalDate, MultipleCurrencyAmount>(values);
    int count = 0;
    for (final MultipleCurrencyAmount mca : values.values()) {
        if (mca.size() > count) {
            count = mca.size();//  w w w  .ja  v a2 s  .  c  om
        }
    }
    _maxCurrencyAmounts = count;
}

From source file:com.thinkbiganalytics.servicemonitor.support.ServiceMonitorCheckUtil.java

/**
 * get a map of the Service and any components that should be checked within that service.
 *//*  w w w . j  av  a 2s .co m*/
public static Map<String, List<String>> getMapOfServiceAndComponents(String services) {
    Map<String, List<String>> map = new TreeMap<String, List<String>>(String.CASE_INSENSITIVE_ORDER);
    if (StringUtils.isNotBlank(services)) {
        String finalServiceString = services;
        if (services.contains("/")) {
            int i = 1;
            String serviceName = null;
            for (String servicePart : StringUtils.split(services, "/")) {
                //service name is the first string before the /

                if (serviceName == null) {
                    if (servicePart.contains(",")) {
                        serviceName = StringUtils.substringAfterLast(servicePart, ",");
                    } else {
                        serviceName = servicePart;
                    }
                } else {
                    String components = "";
                    String origComponents = "";
                    if (servicePart.contains("]")) {
                        components = StringUtils.substringBeforeLast(servicePart, "]");
                        components = StringUtils.substringAfter(components, "[");
                        origComponents = "[" + components + "]";
                    } else {
                        components = StringUtils.substringBefore(servicePart, ",");
                        origComponents = components;
                    }
                    String[] componentsArr = StringUtils.split(components, ",");
                    map.put(serviceName, Arrays.asList(componentsArr));

                    //now remove these from the finalServiceString
                    finalServiceString = StringUtils.replace(finalServiceString,
                            serviceName + "/" + origComponents, "");

                    //reset serviceName
                    serviceName = StringUtils.substringAfterLast(servicePart, ",");

                }
                i++;
            }
        }

        for (String service : StringUtils.split(finalServiceString, ",")) {
            String serviceName = service;
            map.put(serviceName, Arrays.asList(new String[] { ALL_COMPONENTS }));
        }
    }
    return map;
}

From source file:com.roncoo.pay.trade.utils.MerchantApiUtil.java

/**
 * ??// www  .ja va  2 s .c  o  m
 * @param paramMap
 * @return
 */
public static String getParamStr(Map<String, Object> paramMap) {
    SortedMap<String, Object> smap = new TreeMap<String, Object>(paramMap);
    StringBuffer stringBuffer = new StringBuffer();
    for (Map.Entry<String, Object> m : smap.entrySet()) {
        Object value = m.getValue();
        if (value != null && StringUtils.isNotBlank(String.valueOf(value))) {
            stringBuffer.append(m.getKey()).append("=").append(value).append("&");
        }
    }
    stringBuffer.delete(stringBuffer.length() - 1, stringBuffer.length());

    return stringBuffer.toString();
}

From source file:com.opengamma.financial.analytics.cashflow.FloatingPaymentMatrix.java

public FloatingPaymentMatrix(final Map<LocalDate, List<Pair<CurrencyAmount, String>>> values) {
    ArgumentChecker.notNull(values, "values");
    _values = new TreeMap<LocalDate, List<Pair<CurrencyAmount, String>>>(values);
    int count = 0;
    for (final List<Pair<CurrencyAmount, String>> pairs : values.values()) {
        if (pairs.size() > count) {
            count = pairs.size();/*from ww w.  j  a  v  a 2s.  com*/
        }
    }
    _maxEntries = count;
}

From source file:net.sf.gazpachoquest.domain.core.QuestionnaireAnswers.java

public Map<String, Object> getAnswers() {
    if (answers == null) {
        answers = new TreeMap<String, Object>(String.CASE_INSENSITIVE_ORDER);
    }//from w w  w.j a v a2  s  .  com
    return answers;
}

From source file:eu.trentorise.smartcampus.mobility.processor.alerts.ParkingChecker.java

public static AlertsSent cleanOldAlerts(AlertsSent sent) {
    AlertsSent newSent = new AlertsSent(sent);
    newSent.setParkings(new TreeMap<String, String>(sent.getParkings()));

    String delay = buildDate();/*from ww w.  ja  v  a2 s. c  o  m*/
    for (String key : sent.getParkings().keySet()) {
        if (!sent.getParkings().get(key).startsWith(delay)) {
            newSent.getParkings().remove(key);
        }
    }
    return newSent;
}

From source file:CollectionUtils.java

/**
 * Create a map optimized for case insensitive search for keys.
 * The case insensitive rules are simplified to ASCII chars for performance reasons.
 *
 * @return case insensitive map./*from ww  w . j a v a2s .c o m*/
 */
public static <V> Map<String, V> newCaseInsensitiveAsciiMap() {
    return new TreeMap<String, V>(ASCII_CASE_INSENSITIVE_ORDER);
}

From source file:com.kku.apps.pricesearch.util.SignedHelper.java

/**
 * ??l???B/*w ww.j  a  v a 2  s. c om*/
 * 
 * @param secretKey
 *            API?B
 * @param url
 *            http://api.7netshopping.jp/ws/affiliate/[rest|soap]/[
 *            NGXg?bZ?[W] `URL?B
 * @param params
 *            NGXgp??[^(Signature?)?B
 * @return ??l?B
 * @throws Exception
 *             ??????O??B
 */
public static String createSignatureValue(String secretKey, String url, Map<String, String> params)
        throws Exception {
    params.put("Timestamp", timestamp());
    String targetString = createTargetString(url, params);
    String sig = sign(secretKey, targetString);
    SortedMap<String, String> sortedParamMap = new TreeMap<String, String>(params);
    String canonicalQS = canonicalize(sortedParamMap);
    String rUrl = url + "?" + canonicalQS + "&Signature=" + sig;
    return rUrl;
}

From source file:com.michellemay.mappings.LanguageTagsMapping.java

/**
 * Instantiates a new Language tags mapping.
 *///  w w w. j a  va 2  s .co m
public LanguageTagsMapping() {
    super(NAME);
    this.withCaseSensitive(false);

    // Build reverse map.  Use a tree map to offer case insensitiveness while preserving keys case (useful for extending)
    TreeMap<String, Locale> map = new TreeMap<String, Locale>(
            this.getCaseSensitive() ? null : String.CASE_INSENSITIVE_ORDER);
    for (Locale loc : LocaleUtils.availableLocaleList()) {
        String isoCode = loc.getLanguage();
        if (isoCode.length() > 0) {
            String displayValue = loc.toLanguageTag();
            if (!map.containsKey(displayValue)) {
                // Also add variant with underscores
                map.put(displayValue, loc);
                map.put(displayValue.replace('-', '_'), loc);
            }
        }
    }
    this.withMapping(map);
}

From source file:io.fabric8.mq.controller.util.BrokerJmxUtils.java

public static String getOrderedProperties(Hashtable<String, String> properties) {
    TreeMap<String, String> map = new TreeMap<>(properties);
    String result = "";
    String separator = "";
    for (Map.Entry<String, String> entry : map.entrySet()) {
        result += separator;/*from   w  w w  . ja v a2 s.co m*/
        result += entry.getKey() + "=" + entry.getValue();
        separator = ",";
    }
    return result;
}