Example usage for java.util SortedMap get

List of usage examples for java.util SortedMap get

Introduction

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

Prototype

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:org.opennaas.extensions.genericnetwork.capability.circuitstatistics.CircuitStatisticsCapability.java

@Override
public void reportStatistics(String csvStatistics) throws CapabilityException {

    log.info("Circuit Statistics report received.");

    try {//w w w  .j ava 2s. c om
        SortedMap<Long, List<CircuitStatistics>> circuitStatistics = parseCSV(csvStatistics);
        GenericNetworkModel model = (GenericNetworkModel) resource.getModel();

        SortedMap<Long, List<CircuitStatistics>> modelStatistics = model.getCircuitStatistics();
        for (Long timestamp : circuitStatistics.keySet()) {
            if (modelStatistics.keySet().contains(timestamp))
                modelStatistics.get(timestamp).addAll(circuitStatistics.get(timestamp));
            else
                modelStatistics.put(timestamp, circuitStatistics.get(timestamp));
        }

    } catch (Exception e) {
        log.info("Error parsing received CSV", e);
        throw new CapabilityException(e);
    }

    log.info("Circuits statistics stored.");

}

From source file:eu.trentorise.opendata.josman.test.GitTest.java

@Test
public void testEgit() throws IOException {
    List<RepositoryTag> tags = Josmans.fetchTags("opendatatrentino", "josman");
    SortedMap<String, RepositoryTag> filteredTags = Josmans.versionTags("josman", tags);
    for (String tagName : filteredTags.keySet()) {
        RepositoryTag tag = filteredTags.get(tagName);
        LOG.info(tag.getName());/*w  w  w .j  a  v  a2 s. co m*/
        LOG.info(tag.getCommit().getSha());
    }
}

From source file:com.kixeye.chassis.support.metrics.aws.MetricsCloudWatchReporter.java

private void addTimers(SortedMap<String, Timer> timers, LinkedList<PutMetricDataRequest> requests,
        Date timestamp) {//from   w  w  w .  ja  v a  2  s  .c o m
    logger.debug("Adding Timers...");
    for (String name : timers.keySet()) {
        Timer timer = timers.get(name);
        checkAndAddDatum(MetricFilter.Stat.COUNT, name, timer.getCount(), requests, timestamp);
        addMetered(name, timer, requests, timestamp);
    }
}

From source file:com.kixeye.chassis.support.metrics.aws.MetricsCloudWatchReporter.java

private void addMeters(SortedMap<String, Meter> meters, LinkedList<PutMetricDataRequest> requests,
        Date timestamp) {//from  w  ww.j av a2s  .  com
    logger.debug("Adding Meters...");
    for (String name : meters.keySet()) {
        addMetered(name, meters.get(name), requests, timestamp);
    }
}

From source file:org.libreplan.web.common.components.finders.CriterionMultipleFiltersFinder.java

@Override
public List<FilterPair> getFirstTenFilters() {
    getListMatching().clear();//from ww w  .  j  a v a  2s .c  o m
    SortedMap<CriterionType, List<Criterion>> criterionsMap = getCriterionsMap();
    Iterator<CriterionType> iteratorCriterionType = criterionsMap.keySet().iterator();
    while (iteratorCriterionType.hasNext() && getListMatching().size() < 10) {
        CriterionType type = iteratorCriterionType.next();
        for (int i = 0; getListMatching().size() < 10 && i < criterionsMap.get(type).size(); i++) {
            Criterion criterion = criterionsMap.get(type).get(i);
            addCriterion(type, criterion);
        }
    }
    return getListMatching();
}

From source file:com.haulmont.cuba.web.sys.WebJarResourceResolver.java

protected SortedMap<String, String> filterPathIndexByPrefix(SortedMap<String, String> pathIndex,
        String prefix) {/*from   w  w  w.  j a v  a  2  s.  co m*/
    SortedMap<String, String> filteredPathIndex = new TreeMap<>();
    for (String key : pathIndex.keySet()) {
        String value = pathIndex.get(key);
        if (value.startsWith(prefix)) {
            filteredPathIndex.put(key, value);
        }
    }
    return filteredPathIndex;
}

From source file:edu.brown.statistics.AbstractStatistics.java

protected String debug(Database catalog_db, Enum<?> elements[]) {
    Map<String, Object> m = new ListOrderedMap<String, Object>();
    try {//  w  w  w  . j a va  2 s  .  c om
        Class<?> statsClass = this.getClass();
        for (Enum<?> element : elements) {
            Field field = statsClass.getDeclaredField(element.toString().toLowerCase());
            Object value = field.get(this);

            if (field.getClass().isAssignableFrom(SortedMap.class)) {
                SortedMap<?, ?> orig_value = (SortedMap<?, ?>) value;
                Map<String, Object> inner_m = new ListOrderedMap<String, Object>();
                for (Object inner_key : orig_value.keySet()) {
                    Object inner_val = orig_value.get(inner_key);
                    if (inner_val instanceof AbstractStatistics<?>) {
                        inner_val = ((AbstractStatistics<?>) inner_val).debug(catalog_db);
                    }
                    inner_m.put(inner_key.toString(), inner_val);
                } // FOR
                value = StringUtil.formatMaps(inner_m);
            }
            m.put(element.toString(), value);
        } // FOR
    } catch (Exception ex) {
        ex.printStackTrace();
        System.exit(1);
    }
    return (String.format("%s\n%s", this.getCatalogItem(catalog_db),
            StringUtil.prefix(StringUtil.formatMaps(m), DEBUG_SPACER)));
}

From source file:com.kixeye.chassis.support.metrics.aws.MetricsCloudWatchReporter.java

@SuppressWarnings("rawtypes")
private void addGauges(SortedMap<String, Gauge> gauges, LinkedList<PutMetricDataRequest> requests,
        Date timestamp) {//  w  w  w  .ja  v a 2 s  . c o  m
    logger.debug("Adding Gauges...");
    for (String name : gauges.keySet()) {
        Gauge<?> gauge = gauges.get(name);
        if (!(gauge.getValue() instanceof Number)) {
            logger.warn("Encountered Gauge with non-numeric value. Gauge:{}, Value:{}", name, gauge.getValue());
            continue;
        }
        Double value = ((Number) gauge.getValue()).doubleValue();
        addDatum(filter.getMatchingMetricDescriptor(name, Stat.ALL).getAlias(), value, requests, timestamp);
    }
}

From source file:com.kixeye.chassis.support.metrics.aws.MetricsCloudWatchReporter.java

private void addCounters(SortedMap<String, Counter> counters, LinkedList<PutMetricDataRequest> requests,
        Date timestamp) {/*from w  ww. j  av  a2 s. c om*/
    logger.debug("Adding Counters...");
    for (String name : counters.keySet()) {
        Counter counter = counters.get(name);
        addDatum(filter.getMatchingMetricDescriptor(name, Stat.ALL).getAlias(), counter.getCount(), requests,
                timestamp);
    }
}

From source file:org.motrice.jmx.BasicAppManagement.java

/**
 * Set the level of a named logger./*from  w w w . j  a va  2 s.  c  o m*/
 * All loggers ending with the name are chosen.
 */
@ManagedOperation(description = "Set the log level of a specific logger", currencyTimeLimit = 10)
@ManagedOperationParameters({
        @ManagedOperationParameter(name = "logger", description = "(Last part of) logger name"),
        @ManagedOperationParameter(name = "level", description = "The new Log4j log level") })
public void setLogLevel(String logger, String level) {
    // Note that getLogger returns a new logger if the name is undefined
    SortedMap<String, Logger> map = doGetLoggers();
    // The level is set to DEBUG if it does not match any known level
    Level newLevel = Level.toLevel(level.toUpperCase());
    if (notBlank(logger)) {
        for (String key : map.keySet()) {
            if (key.endsWith(logger.trim())) {
                Logger log = map.get(key);
                if (log != null)
                    log.setLevel(newLevel);
            }
        }
    }
}