Example usage for java.lang String CASE_INSENSITIVE_ORDER

List of usage examples for java.lang String CASE_INSENSITIVE_ORDER

Introduction

In this page you can find the example usage for java.lang String CASE_INSENSITIVE_ORDER.

Prototype

Comparator CASE_INSENSITIVE_ORDER

To view the source code for java.lang String CASE_INSENSITIVE_ORDER.

Click Source Link

Document

A Comparator that orders String objects as by compareToIgnoreCase .

Usage

From source file:nl.cyso.vcloud.client.vCloudClient.java

public void listOrganizations() {
    this.vccPreCheck();

    try {/*from   w  w  w .  j  a  va  2s.c o m*/
        Formatter.printInfoLine("Retrieving Organizations...");
        Collection<ReferenceType> orgs = this.vcc.getOrgRefs();

        List<String> o = new ArrayList<String>(orgs.size());
        for (ReferenceType org : orgs) {
            o.add(org.getName());
        }
        Collections.sort(o, String.CASE_INSENSITIVE_ORDER);

        Formatter.printInfoLine("Organizations:");
        for (String p : o) {
            Formatter.printInfoLine("\t" + p);
        }

    } catch (VCloudException e) {
        Formatter.printErrorLine("An error occured while retrieving organizations");
        Formatter.printErrorLine(e.getLocalizedMessage());
        System.exit(1);
    }
}

From source file:org.eclipse.sw360.licenseinfo.outputGenerators.OutputGenerator.java

private static <U> SortedMap<String, U> sortStringKeyedMap(Map<String, U> unsorted) {
    SortedMap<String, U> sorted = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
    sorted.putAll(unsorted);/*  w  w  w  .jav  a 2s. co m*/
    if (sorted.size() != unsorted.size()) {
        // there were key collisions and some data was lost -> throw away the sorted map and sort by case sensitive order
        sorted = new TreeMap<>();
        sorted.putAll(unsorted);
    }
    return sorted;
}

From source file:org.usergrid.utils.MapUtils.java

@SuppressWarnings("unchecked")
public static <A, B, C> void putMapMap(Map<A, Map<B, C>> map, boolean ignore_case, A a, B b, C c) {

    Map<B, C> map_b = map.get(a);
    if (map_b == null) {
        if (ignore_case && (b instanceof String)) {
            map_b = (Map<B, C>) new TreeMap<String, C>(String.CASE_INSENSITIVE_ORDER);
        } else {/*from  w  w w.j  av a2  s  .  co m*/
            map_b = new LinkedHashMap<B, C>();
        }
        map.put(a, map_b);
    }
    map_b.put(b, c);
}

From source file:org.apache.kylin.rest.util.ValidateUtil.java

public void validateTable(String project, String table) throws IOException {
    List<TableDesc> tableDescs = tableService.getTableDescByProject(project, false);
    Set<String> tables = new TreeSet<>(String.CASE_INSENSITIVE_ORDER);
    for (TableDesc tableDesc : tableDescs) {
        tables.add(tableDesc.getDatabase() + "." + tableDesc.getName());
    }//from   w ww  .j  a v  a2  s.  c om

    if (!tables.contains(table)) {
        throw new RuntimeException("Operation failed, table:" + table + " not exists");
    }
}

From source file:com.ignorelist.kassandra.steam.scraper.Tagger.java

public Set<String> getAvailableTags(Set<Path> sharedConfigPaths, Options taggerOptions)
        throws IOException, RecognitionException {
    Set<String> availableTags = new TreeSet<>(String.CASE_INSENSITIVE_ORDER);
    Set<Long> availableGameIds = new HashSet<>();
    for (Path path : sharedConfigPaths) {
        SharedConfig sharedConfig = new SharedConfig(path);
        availableGameIds.addAll(sharedConfig.getGameIds());
        for (Long gameId : sharedConfig.getGameIds()) {
            availableTags.addAll(sharedConfig.getTags(gameId));
        }/*from  ww  w . j a  va2s  . co  m*/
    }
    availableGameIds.addAll(LibraryScanner.findGames(new PathResolver().findAllLibraryDirectories()));
    Map<Long, GameInfo> load = tagLoader.load(availableGameIds, taggerOptions.getTagTypes());
    Iterables.addAll(availableTags, GameInfo.getAllTags(load.values()));
    return availableTags;
}

From source file:forge.util.FileSection.java

/**
 * Parses the sections./*from w  w w. j  a va2 s. c  om*/
 * 
 * @param source
 *            the source
 * @return the map
 */
@SuppressWarnings("unchecked")
public static Map<String, List<String>> parseSections(final List<String> source) {
    final Map<String, List<String>> result = new TreeMap<String, List<String>>(String.CASE_INSENSITIVE_ORDER);
    String currentSection = "";
    List<String> currentList = null;

    for (final String s : source) {
        final String st = s.trim();
        if (st.length() == 0) {
            continue;
        }
        if (st.startsWith("[") && st.endsWith("]")) {
            if ((currentList != null) && (currentList.size() > 0)) {
                final Object oldVal = result.get(currentSection);
                if ((oldVal != null) && (oldVal instanceof List<?>)) {
                    currentList.addAll((List<String>) oldVal);
                }
                result.put(currentSection, currentList);
            }

            final String newSection = st.substring(1, st.length() - 1);
            currentSection = newSection;
            currentList = null;
        } else {
            if (currentList == null) {
                currentList = new ArrayList<String>();
            }
            currentList.add(st);
        }
    }

    // save final block
    if ((currentList != null) && (currentList.size() > 0)) {
        final Object oldVal = result.get(currentSection);
        if ((oldVal != null) && (oldVal instanceof List<?>)) {
            currentList.addAll((List<String>) oldVal);
        }
        result.put(currentSection, currentList);
    }

    return result;
}

From source file:ac.elements.io.Signature.java

/**
 * Calculate String to Sign for SignatureVersion 1.
 * /*from  ww  w.j av  a 2 s  . co  m*/
 * @param parameters
 *            request parameters
 * 
 * @return String to Sign
 * 
 * @throws java.security.SignatureException
 */
private static String calculateStringToSignV1(Map<String, String> parameters) {
    StringBuilder data = new StringBuilder();
    Map<String, String> sorted = new TreeMap<String, String>(String.CASE_INSENSITIVE_ORDER);
    sorted.putAll(parameters);
    Iterator<Entry<String, String>> pairs = sorted.entrySet().iterator();
    while (pairs.hasNext()) {
        Map.Entry<String, String> pair = pairs.next();
        data.append(pair.getKey());
        data.append(pair.getValue());
    }
    return data.toString();
}

From source file:org.mc4j.ems.impl.jmx.connection.bean.DMBean.java

public synchronized void loadSynchronous() {
    if (!loaded) {
        try {/*from   w w  w  .  j av  a  2  s  .com*/
            info = connectionProvider.getMBeanServer().getMBeanInfo(this.objectName);

            if (info.getAttributes().length > 0) {

                this.attributes = new TreeMap<String, EmsAttribute>(String.CASE_INSENSITIVE_ORDER);
                for (MBeanAttributeInfo attributeInfo : info.getAttributes()) {
                    DAttribute attribute = new DAttribute(attributeInfo, this);
                    this.attributes.put(attributeInfo.getName(), attribute);
                }
            }

            if (info.getOperations().length > 0) {
                this.operations = new TreeMap<String, EmsOperation>(String.CASE_INSENSITIVE_ORDER);
                for (MBeanOperationInfo operationInfo : info.getOperations()) {
                    DOperation operation = new DOperation(operationInfo, this);
                    this.operations.put(operationInfo.getName(), operation);
                }
            }

            if (info.getNotifications().length > 0) {
                this.notifications = new TreeMap<String, EmsNotification>(String.CASE_INSENSITIVE_ORDER);
                for (MBeanNotificationInfo notificationInfo : info.getNotifications()) {
                    DNotification notification = new DNotification(notificationInfo, this);
                    this.notifications.put(notificationInfo.getName(), notification);
                }
            }

        } catch (InstanceNotFoundException infe) {
            this.deleted = true;
            this.attributes = null;
            this.operations = null;
            this.notifications = null;

        } catch (Exception e) {
            unsupportedType = true;
            RuntimeException f = new EmsUnsupportedTypeException(
                    "Could not load MBean info, unsupported type on bean " + objectName, e);
            // TODO: Memory Leak below... don't do that
            //registerFailure(f);
            // TODO should we throw this here?
            //throw f;
        } finally {
            loaded = true;
        }
    }
}

From source file:uk.org.rbc1b.roms.db.common.MergeUtilTest.java

@Test
public void testMergeDuplicateStrings() {
    final List<Pair<String, String>> outputs = new ArrayList<Pair<String, String>>();

    MergeUtil.merge(Arrays.asList("bar", "foo", "foo"), Arrays.asList("foo", "quux"),
            String.CASE_INSENSITIVE_ORDER, new MergeUtil.Callback<String, String>() {
                @Override/*from w  w  w .  j  a  v  a  2 s  .  c om*/
                public void output(String leftValue, String rightValue) {
                    outputs.add(new ImmutablePair<String, String>(leftValue, rightValue));
                }
            });

    // note outputs [bar,] [foo,foo] [foo,] [,quux] NOT [bar,] [foo,foo] [foo,foo] [,quux]
    assertEquals(Arrays.asList(new ImmutablePair<String, String>("bar", null),
            new ImmutablePair<String, String>("foo", "foo"), new ImmutablePair<String, String>("foo", null),
            new ImmutablePair<String, String>(null, "quux")), outputs);
}

From source file:com.eucalyptus.auth.login.Hmacv1LoginModule.java

private String makeSubjectString(final Map<String, List<String>> parameters)
        throws UnsupportedEncodingException {
    String paramString = "";
    Set<String> sortedKeys = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
    sortedKeys.addAll(parameters.keySet());
    sortedKeys.remove(SecurityParameter.Signature.parameter());
    for (final String key : sortedKeys) {
        if (parameters.get(key).isEmpty()) {
            paramString = paramString.concat(key).replaceAll("\\+", " ");
        } else/*from  w ww.  j ava 2 s .com*/
            for (final String value : Ordering.natural().sortedCopy(parameters.get(key))) {
                paramString = paramString.concat(key).concat(Strings.nullToEmpty(value).replaceAll("\\+", " "));
            }
    }
    try {
        return new String(URLCodec.decodeUrl(paramString.getBytes()));
    } catch (DecoderException e) {
        return paramString;
    }
}