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:com.nesscomputing.httpclient.factory.httpclient4.InternalResponse.java

@Override
@Nonnull/* w w  w  .  j  av  a 2 s.  c om*/
public Map<String, List<String>> getAllHeaders() {
    Map<String, List<String>> headerMap = new TreeMap<String, List<String>>(String.CASE_INSENSITIVE_ORDER);

    Header[] headers = httpResponse.getAllHeaders();

    for (Header header : headers) {
        String name = header.getName();
        String value = header.getValue();

        List<String> valuesForThisHeader = headerMap.get(name);

        if (valuesForThisHeader == null) {
            valuesForThisHeader = Lists.newLinkedList();
            headerMap.put(name, valuesForThisHeader);
        }
        valuesForThisHeader.add(value);
    }

    return headerMap;
}

From source file:org.apache.syncope.core.util.ContentExporter.java

private List<String> sortByForeignKeys(final Connection conn, final Set<String> tableNames)
        throws SQLException {

    Set<MultiParentNode<String>> roots = new HashSet<MultiParentNode<String>>();

    final DatabaseMetaData meta = conn.getMetaData();

    final Map<String, MultiParentNode<String>> exploited = new TreeMap<String, MultiParentNode<String>>(
            String.CASE_INSENSITIVE_ORDER);

    final Set<String> pkTableNames = new HashSet<String>();

    for (String tableName : tableNames) {
        MultiParentNode<String> node = exploited.get(tableName);
        if (node == null) {
            node = new MultiParentNode<String>(tableName);
            roots.add(node);/*w w  w.  j a v a  2s  .co m*/
            exploited.put(tableName, node);
        }

        pkTableNames.clear();

        ResultSet rs = null;
        try {
            rs = meta.getImportedKeys(conn.getCatalog(), dbSchema, tableName);

            // this is to avoid repetition
            while (rs.next()) {
                pkTableNames.add(rs.getString("PKTABLE_NAME"));
            }
        } finally {
            if (rs != null) {
                try {
                    rs.close();
                } catch (SQLException e) {
                    LOG.error("While closing tables result set", e);
                }
            }
        }

        for (String pkTableName : pkTableNames) {
            if (!tableName.equalsIgnoreCase(pkTableName)) {
                MultiParentNode<String> pkNode = exploited.get(pkTableName);
                if (pkNode == null) {
                    pkNode = new MultiParentNode<String>(pkTableName);
                    roots.add(pkNode);
                    exploited.put(pkTableName, pkNode);
                }

                pkNode.addChild(node);

                if (roots.contains(node)) {
                    roots.remove(node);
                }
            }
        }
    }

    final List<String> sortedTableNames = new ArrayList<String>(tableNames.size());
    MultiParentNodeOp.traverseTree(roots, sortedTableNames);

    // remove from sortedTableNames any table possibly added during lookup 
    // but matching some item in this.tablePrefixesToBeExcluded
    sortedTableNames.retainAll(tableNames);

    LOG.debug("Tables after retainAll {}", sortedTableNames);

    Collections.reverse(sortedTableNames);

    return sortedTableNames;
}

From source file:org.caleydo.view.domino.internal.ui.SelectionInfo.java

private static String getLabel(Set<Integer> elements, IDType idType) {
    String label = idType.getIDCategory().getCategoryName();
    IDMappingManager manager = IDMappingManagerRegistry.get().getIDMappingManager(idType);
    IIDTypeMapper<Integer, String> id2label = manager.getIDTypeMapper(idType,
            idType.getIDCategory().getHumanReadableIDType());
    if (id2label != null) {
        Set<String> r = id2label.apply(elements);
        if (r != null) {
            ImmutableSortedSet<String> b = ImmutableSortedSet.orderedBy(String.CASE_INSENSITIVE_ORDER).addAll(r)
                    .build();//from   w  w  w .  j a v  a 2 s.  c  o  m
            if (b.size() < 3) {
                label = StringUtils.join(b, ", ");
            } else {
                label = StringUtils.join(b.asList().subList(0, 3), ", ") + " ...";
            }
        }
    }
    return label;
}

From source file:clientapi.util.ClientAPIUtils.java

/**
 * Gets the categories that are represented by a manager containing modules.
 *
 * @param sort Whether or not to sort alphabetically
 * @return The categories/*  w w  w .  j  a  v  a 2 s .c  om*/
 */
public static Collection<Class<?>> getCategories(Manager<Module> moduleManager, boolean sort) {
    LinkedHashSet<Class<?>> categories = new LinkedHashSet<>();
    moduleManager.stream().map(Module::getType).forEach(categories::add);

    if (sort) {
        List<Class<?>> sorted = new ArrayList<>(categories);
        sorted.sort((c1, c2) -> String.CASE_INSENSITIVE_ORDER.compare(c1.getAnnotation(Category.class).name(),
                c2.getAnnotation(Category.class).name()));
        return sorted;
    }

    return categories;
}

From source file:org.gcaldaemon.gui.Messages.java

public static final String[][] getTranslatorTable(Locale locale) {
    Enumeration keyEnumerator = DEFAULT_RESOURCE_BUNDLE.getKeys();
    LinkedList list = new LinkedList();
    while (keyEnumerator.hasMoreElements()) {
        list.addLast(keyEnumerator.nextElement());
    }/*from  ww  w.  j  a  v a2s.  c  o  m*/
    String[] keys = new String[list.size()];
    list.toArray(keys);
    Arrays.sort(keys, String.CASE_INSENSITIVE_ORDER);
    String[][] data = new String[keys.length][3];
    PropertyResourceBundle localeBundle = null;
    try {
        String programDir = System.getProperty("gcaldaemon.program.dir", "/Progra~1/GCALDaemon");
        File langDir = new File(programDir, "lang");
        if (!langDir.isDirectory()) {
            langDir.mkdir();
        } else {
            File msgFile = new File(langDir, "messages-" + locale.getLanguage().toLowerCase() + ".txt");
            if (msgFile.isFile()) {
                InputStream in = new BufferedInputStream(new FileInputStream(msgFile));
                localeBundle = new PropertyResourceBundle(in);
                in.close();
            }
        }
    } catch (Exception ignored) {
        log.warn("Unable to load messages!", ignored);
    }
    for (int i = 0; i < keys.length; i++) {
        data[i][0] = keys[i];
        data[i][1] = DEFAULT_RESOURCE_BUNDLE.getString(keys[i]);
        if (localeBundle != null) {
            try {
                data[i][2] = localeBundle.getString(keys[i]);
            } catch (Exception ignored) {
            }
        }
        if (data[i][2] == null) {
            data[i][2] = data[i][1];
        }
    }
    return data;
}

From source file:org.openhim.mediator.fhir.FhirProxyHandler.java

private Map<String, String> copyHeaders(Map<String, String> headers) {
    Map<String, String> copy = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
    for (String header : headers.keySet()) {
        if ("Content-Type".equalsIgnoreCase(header) || "Content-Length".equalsIgnoreCase(header)
                || "Host".equalsIgnoreCase(header)) {
            continue;
        }/*from w w  w  .  j av  a2s  . co m*/

        copy.put(header, headers.get(header));
    }
    return copy;
}

From source file:com.acceleratedio.pac_n_zoom.SaveAnmActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_save_anm);
    EventBus.getDefault().register(this);
    crt_ctx = this;
    tagText = (EditText) findViewById(R.id.sav_tags);

    tagText.addTextChangedListener(new TextWatcher() {

        @Override//from   w  w  w.j av  a 2s  . c o m
        public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {
        }

        @Override
        public void onTextChanged(CharSequence key_sqnc, int start, int before, int count) {

            final StringBuilder strBldr = new StringBuilder(key_sqnc.length());
            strBldr.append(key_sqnc);
            srch_str = strBldr.toString();
            dsply_tags();
        }

        @Override
        public void afterTextChanged(Editable s) {
        }
    });

    tagText.setOnEditorActionListener(new TextView.OnEditorActionListener() {

        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {

            boolean handled = false;
            tags_str = tagText.getText().toString();

            if (actionId == EditorInfo.IME_ACTION_SEND) {

                progress = ProgressDialog.show(crt_ctx, "Saving the animation", "dialog message", true);
                MakePostRequest savAnimation = new MakePostRequest();
                savAnimation.execute();
                handled = true;
            }

            return handled;
        }
    });

    fil_tags = PickAnmActivity.orgnl_tags.split("(\\s*,\\s*)|(\\s* \\s*)");
    Arrays.sort(fil_tags, String.CASE_INSENSITIVE_ORDER);
    dsply_tags();
}

From source file:org.springframework.cloud.stream.config.BindingServiceProperties.java

@Override
public void setEnvironment(Environment environment) {
    if (environment instanceof ConfigurableEnvironment) {
        // override the bindings store with the environment-initializing version if in
        // a Spring context
        Map<String, BindingProperties> delegate = new TreeMap<String, BindingProperties>(
                String.CASE_INSENSITIVE_ORDER);
        delegate.putAll(this.bindings);
        this.bindings = new EnvironmentEntryInitializingTreeMap<>((ConfigurableEnvironment) environment,
                BindingProperties.class, "spring.cloud.stream.default", delegate);
    }//from  w ww  .  jav  a 2s . co m
}

From source file:org.apache.hawq.pxf.api.utilities.ProfilesConf.java

private void loadMap(XMLConfiguration conf) {
    String[] profileNames = conf.getStringArray("profile.name");
    if (profileNames.length == 0) {
        LOG.warn("Profile file: " + conf.getFileName() + " is empty");
        return;//ww  w  . jav a 2 s . com
    }
    Map<String, Map<String, String>> profileMap = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
    for (int profileIdx = 0; profileIdx < profileNames.length; profileIdx++) {
        String profileName = profileNames[profileIdx];
        if (profileMap.containsKey(profileName)) {
            LOG.warn("Duplicate profile definition found in " + conf.getFileName() + " for: " + profileName);
            continue;
        }
        Configuration profileSubset = conf.subset("profile(" + profileIdx + ").plugins");
        profileMap.put(profileName, getProfilePluginMap(profileSubset));
    }
    profilesMap.putAll(profileMap);
}