Example usage for java.util SortedMap keySet

List of usage examples for java.util SortedMap keySet

Introduction

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

Prototype

Set<K> keySet();

Source Link

Document

Returns a Set view of the keys contained in this map.

Usage

From source file:org.sonar.test.i18n.BundleSynchronizedMatcherTest.java

@Test
public void testRetrieveMissingKeys() throws Exception {
    InputStream defaultBundleIS = this.getClass()
            .getResourceAsStream(BundleSynchronizedMatcher.L10N_PATH + "myPlugin.properties");
    InputStream frBundleIS = this.getClass()
            .getResourceAsStream(BundleSynchronizedMatcher.L10N_PATH + "myPlugin_fr.properties");
    InputStream qbBundleIS = this.getClass()
            .getResourceAsStream(BundleSynchronizedMatcher.L10N_PATH + "myPlugin_fr_QB.properties");

    try {//from ww w. j av  a 2s  .  c  o m
        SortedMap<String, String> diffs = BundleSynchronizedMatcher.retrieveMissingTranslations(frBundleIS,
                defaultBundleIS);
        assertThat(diffs.size(), is(1));
        assertThat(diffs.keySet(), hasItem("second.prop"));

        diffs = BundleSynchronizedMatcher.retrieveMissingTranslations(qbBundleIS, defaultBundleIS);
        assertThat(diffs.size(), is(0));
    } finally {
        IOUtils.closeQuietly(defaultBundleIS);
        IOUtils.closeQuietly(frBundleIS);
        IOUtils.closeQuietly(qbBundleIS);
    }
}

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

/**
 * @param <T>//  w w w . j  a va  2s .  c  o  m
 * @param map
 * @param name
 * @param stringer
 * @throws JSONException
 */
protected <U> void writeMap(SortedMap<U, ?> map, String name, JSONStringer stringer) throws JSONException {
    stringer.key(name).object();
    for (U key : map.keySet()) {
        String key_name = key.toString();
        if (key instanceof CatalogType) {
            key_name = ((CatalogType) key).getName();
        }
        stringer.key(key_name).value(map.get(key));
    } // FOR
    stringer.endObject();
}

From source file:com.amazonaws.services.sns.util.SignatureChecker.java

protected String stringToSign(SortedMap<String, String> signables) {
    // each key and value is followed by a newline
    StringBuilder sb = new StringBuilder();
    for (String k : signables.keySet()) {
        sb.append(k).append("\n");
        sb.append(signables.get(k)).append("\n");
    }/*from www  .java  2 s.c om*/
    String result = sb.toString();
    return result;
}

From source file:org.archive.settings.file.PrefixFinderTest.java

private void testUrlsNoMatch(SortedMap<String, String> sm) {
    sm.put("http://(com,ilovepauljack,www,", "foo");
    for (int i = 0; i < 10; i++) {
        sm.put("http://" + Math.random(), "foo");
    }//from w  w w .  ja va  2  s  . c o  m
    Set<String> keys = sm.keySet();
    if (!(keys instanceof SortedSet)) {
        keys = new TreeSet<String>(keys);
    }
    List<String> results = PrefixFinder.find((SortedSet<String>) keys, "http://");
    assertTrue(results.isEmpty());
}

From source file:com.tesobe.obp.transport.spi.DefaultResponder.java

@SuppressWarnings("ComparatorMethodParameterNotUsed")
protected Comparator<Map<String, Object>> sorter(Decoder.Pager p) {
    Comparator<Map<String, Object>> equal = (o1, o2) -> 0;

    return p.sorter().map(s -> {
        SortedMap<String, SortOrder> fields = s.fields();

        if (fields != null) {
            Set<String> names = fields.keySet();

            return (Comparator<Map<String, Object>>) (o1, o2) -> {
                for (String name : names) {
                    int delta = 0;
                    Object v1 = o1.get(name);
                    Object v2 = o2.get(name);

                    if (v1 == null) {
                        delta = v2 == null ? 0 : -1;
                    } else if (v2 != null) {
                        SortOrder order = fields.get(name);

                        if (SortOrder.ascending == order) {
                            delta = compare(v1, v2);
                        } else if (SortOrder.descending == order) {
                            delta = compare(v2, v1);
                        }/*from w w w .  j  av a2 s  . com*/
                    } else {
                        return 1;
                    }

                    if (delta != 0) {
                        return delta;
                    }
                }

                return 0;
            };
        }

        return equal;
    }).orElse(equal);
}

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

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

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

/**
 * Set the level of a named logger./*from w ww . j  a  v a  2  s .c  om*/
 * 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);
            }
        }
    }
}

From source file:org.wso2.andes.messageStore.MessageContentRemoverTask.java

public void run() {
    while (running) {
        try {/*from   ww w . jav a 2s  .  c  o m*/
            while (!contentDeletionTasks.isEmpty() && connectionToMessageStore.isLive()) {
                long currentTime = System.nanoTime();

                //remove content for timeout messages
                SortedMap<Long, Long> timedOutContentList = contentDeletionTasks
                        .headMap(currentTime - timeOutPerMessage);
                try {
                    messageStore.deleteMessageParts(new ArrayList<Long>(timedOutContentList.values()));
                    for (Long key : timedOutContentList.keySet()) {
                        contentDeletionTasks.remove(key);
                    }
                } catch (AndesException e) {
                    log.error("Error while deleting message contents", e);
                }
            }
            try {
                Thread.sleep(waitInterval);
            } catch (InterruptedException e) {
                log.error(e);
            }

        } catch (Throwable e) {
            log.error("Erring in removing message content details ", e);
        }
    }
}

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());/*from  w w  w .j  a  v  a  2  s.co m*/
        LOG.info(tag.getCommit().getSha());
    }
}

From source file:net.ripe.rpki.commons.crypto.rfc3779.ResourceExtensionEncoder.java

/**
 * IPAddrBlocks ::= SEQUENCE OF IPAddressFamily
 *///  ww  w  . j  a va  2 s  .c  om
ASN1Object ipAddressBlocksToDer(SortedMap<AddressFamily, IpResourceSet> resources) {
    List<ASN1Encodable> seq = new ArrayList<ASN1Encodable>(2);
    for (AddressFamily addressFamily : resources.keySet()) {
        seq.add(ipAddressFamilyToDer(addressFamily, resources.get(addressFamily)));
    }
    return new DERSequence(seq.toArray(new ASN1Encodable[seq.size()]));
}