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:forge.gui.ImportSourceAnalyzer.java

private void analyzeCardPicsDir(final File root) {
    if (null == defaultPicNames) {
        defaultPicNames = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
        defaultPicOldNameToCurrentName = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);

        for (final PaperCard c : FModel.getMagicDb().getCommonCards().getAllCards()) {
            addDefaultPicNames(c, false);
            if (ImageUtil.hasBackFacePicture(c)) {
                addDefaultPicNames(c, true);
            }/* w ww.  j  a  va 2s.  co  m*/
        }

        for (final PaperCard c : FModel.getMagicDb().getVariantCards().getAllCards()) {
            addDefaultPicNames(c, false);
            // variants never have backfaces
        }
    }

    analyzeListedDir(root, ForgeConstants.CACHE_CARD_PICS_DIR, new ListedAnalyzer() {
        @Override
        public String map(final String filename) {
            if (defaultPicOldNameToCurrentName.containsKey(filename)) {
                return defaultPicOldNameToCurrentName.get(filename);
            }
            return defaultPicNames.get(filename);
        }

        @Override
        public OpType getOpType(final String filename) {
            return OpType.DEFAULT_CARD_PIC;
        }

        @Override
        boolean onDir(final File dir) {
            if ("icons".equalsIgnoreCase(dir.getName())) {
                analyzeIconsPicsDir(dir);
            } else if ("tokens".equalsIgnoreCase(dir.getName())) {
                analyzeTokenPicsDir(dir);
            } else {
                analyzeCardPicsSetDir(dir);
            }
            return true;
        }
    });
}

From source file:org.infoscoop.gadgets.servlet.HttpRequestHandler.java

/**
 * Extract all unknown keys into a map for extra auth params.
 *///from   w  w w .j ava 2 s  .c  o m
private Map<String, String> getAuthSettings(BaseRequestItem requestItem) {
    // Keys in a request item are always Strings
    @SuppressWarnings("unchecked")
    Set<String> allParameters = requestItem.getTypedRequest(Map.class).keySet();

    //    Map<String, String> authSettings = Maps.newHashMap();
    Map<String, String> authSettings = new TreeMap<String, String>(String.CASE_INSENSITIVE_ORDER);
    for (String paramName : allParameters) {
        if (!HttpApiRequest.KNOWN_PARAMETERS.contains(paramName)) {
            authSettings.put(paramName, requestItem.getParameter(paramName));
        }
    }

    return authSettings;
}

From source file:com.kstenschke.copypastestack.ToolWindow.java

/**
 * Bubble all color-tagged items to the top of the list (groups: yellow, green, reed, untagged)
 *///from   www.j av  a2  s. c  o m
private void sortClipboardListByTags(boolean sortAlphabetically) {
    ListModel<String> listModel = this.form.listClipItems.getModel();
    int amountItems = listModel.getSize();

    if (amountItems > 0) {
        String[] itemsYellow = new String[amountItems + 1];
        int indexYellow = 0;

        String[] itemsGreen = new String[amountItems + 1];
        int indexGreen = 0;

        String[] itemsRed = new String[amountItems + 1];
        int indexRed = 0;

        String[] itemsUntagged = new String[amountItems + 1];
        int indexUntagged = 0;

        // Refill items from listModel into sortable arrays
        for (int i = 0; i < amountItems; i++) {
            String item = listModel.getElementAt(i);
            if (item != null && !item.trim().isEmpty()) {
                switch (TagManager.getIdColorByValue(item)) {
                case StaticValues.ID_COLOR_YELLOW:
                    itemsYellow[indexYellow] = item;
                    indexYellow++;
                    break;

                case StaticValues.ID_COLOR_GREEN:
                    itemsGreen[indexGreen] = item;
                    indexGreen++;
                    break;

                case StaticValues.ID_COLOR_RED:
                    itemsRed[indexRed] = item;
                    indexRed++;
                    break;

                case StaticValues.ID_COLOR_NONE:
                    itemsUntagged[indexUntagged] = item;
                    indexUntagged++;
                    break;
                }
            }
        }

        // Reduce arrays to size of actual content
        itemsYellow = Arrays.copyOfRange(itemsYellow, 0, indexYellow);
        itemsRed = Arrays.copyOfRange(itemsRed, 0, indexRed);
        itemsGreen = Arrays.copyOfRange(itemsGreen, 0, indexGreen);
        itemsUntagged = Arrays.copyOfRange(itemsUntagged, 0, indexUntagged);

        // Sort string items alphabetically
        if (sortAlphabetically) {
            if (itemsYellow.length > 1)
                Arrays.sort(itemsYellow, String.CASE_INSENSITIVE_ORDER);
            if (itemsGreen.length > 1)
                Arrays.sort(itemsGreen, String.CASE_INSENSITIVE_ORDER);
            if (itemsRed.length > 1)
                Arrays.sort(itemsRed, String.CASE_INSENSITIVE_ORDER);
            if (itemsUntagged.length > 1)
                Arrays.sort(itemsUntagged, String.CASE_INSENSITIVE_ORDER);
        }

        // Update list from sorted items
        this.setClipboardListData(ArrayUtils.addAll(
                ArrayUtils.addAll(ArrayUtils.addAll(itemsYellow, itemsGreen), itemsRed), itemsUntagged), false);
    }
}

From source file:org.apache.nifi.web.api.ApplicationResource.java

protected Map<String, String> getHeaders(final Map<String, String> overriddenHeaders) {

    final Map<String, String> result = new HashMap<>();
    final Map<String, String> overriddenHeadersIgnoreCaseMap = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
    if (overriddenHeaders != null) {
        overriddenHeadersIgnoreCaseMap.putAll(overriddenHeaders);
    }/*from  w  w  w  .ja va 2s  .co  m*/

    final Enumeration<String> headerNames = httpServletRequest.getHeaderNames();
    while (headerNames.hasMoreElements()) {

        final String headerName = headerNames.nextElement();
        if (!overriddenHeadersIgnoreCaseMap.isEmpty() && headerName.equalsIgnoreCase("content-length")) {
            continue;
        }
        if (overriddenHeadersIgnoreCaseMap.containsKey(headerName)) {
            result.put(headerName, overriddenHeadersIgnoreCaseMap.get(headerName));
        } else {
            result.put(headerName, httpServletRequest.getHeader(headerName));
        }
    }

    // set the proxy scheme to request scheme if not already set client
    final String proxyScheme = httpServletRequest.getHeader(PROXY_SCHEME_HTTP_HEADER);
    if (proxyScheme == null) {
        result.put(PROXY_SCHEME_HTTP_HEADER, httpServletRequest.getScheme());
    }

    return result;
}

From source file:com.taobao.android.builder.tools.guide.AtlasConfigHelper.java

public static List<AtlasConfigField> readConfig(AtlasExtension atlasExtension, String prefix)
        throws IllegalAccessException, NoSuchMethodException, InvocationTargetException {

    List<AtlasConfigField> configFieldList = new ArrayList<AtlasConfigField>();

    readConfig(atlasExtension, prefix, configFieldList, 0, "");

    Collections.sort(configFieldList, new Comparator<AtlasConfigField>() {
        @Override/*from   w ww  . j a  va  2 s .com*/
        public int compare(AtlasConfigField o1, AtlasConfigField o2) {

            if (o1.groupOrder != o2.groupOrder) {
                return o1.groupOrder - o2.groupOrder;
            }

            int compare = String.CASE_INSENSITIVE_ORDER.compare(o1.group, o2.group);
            if (0 != compare) {
                return compare;
            }

            if (!o1.variantName.equals(o2.variantName)) {
                return o1.variantName.equals("release") ? 1 : -1;
            }

            return o1.order - o2.order;
        }
    });

    return configFieldList;
}

From source file:org.apache.directory.fortress.core.impl.HierUtil.java

/**
 * Recursively traverse the hierarchical graph and return all of the ascendants of a given node.
 *
 * @param childName maps to vertex to determine parentage.
 * @param graph     contains a reference to simple digraph {@code org.jgrapht.graph.SimpleDirectedGraph}.
 * @return Set of names that are parents of given child.
 *//*from   w  w w.j a v  a  2  s  .c  om*/
static Set<String> getAscendants(String childName, SimpleDirectedGraph<String, Relationship> graph) {
    Map<String, String> vx = new HashMap<>();
    // TreeSet will return in sorted order:
    // create Set with case insensitive comparator:
    Set<String> parents = new TreeSet<>(String.CASE_INSENSITIVE_ORDER);
    vx.put(VERTEX, childName.toUpperCase());
    getAscendants(vx, graph, parents);
    return parents;
}

From source file:com.ultramegasoft.flavordex2.dialog.FileSelectorDialog.java

/**
 * Get the list of directories in the given path.
 *
 * @param path The path to a directory to list files from
 * @return An array of directory names// w  ww.  j  a v a  2 s .  c o  m
 */
@NonNull
private String[] getDirList(@NonNull File path) {
    final FilenameFilter dirFilter = new FilenameFilter() {
        public boolean accept(File dir, String filename) {
            final File file = new File(dir, filename);
            return file.canRead() && file.isDirectory() && !filename.startsWith(".");
        }
    };

    final String[] dirList = path.list(dirFilter);
    if (dirList == null) {
        return new String[0];
    }
    Arrays.sort(dirList, String.CASE_INSENSITIVE_ORDER);

    return dirList;
}

From source file:com.dianping.resource.io.util.MimeType.java

/**
 * Compares this {@code MediaType} to another alphabetically.
 * @param other media type to compare to
 * @see MimeTypeUtils#sortBySpecificity(java.util.List)
 *///from w w  w. j av a  2s. c o  m
@Override
public int compareTo(MimeType other) {
    int comp = getType().compareToIgnoreCase(other.getType());
    if (comp != 0) {
        return comp;
    }
    comp = getSubtype().compareToIgnoreCase(other.getSubtype());
    if (comp != 0) {
        return comp;
    }
    comp = getParameters().size() - other.getParameters().size();
    if (comp != 0) {
        return comp;
    }
    TreeSet<String> thisAttributes = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
    thisAttributes.addAll(getParameters().keySet());
    TreeSet<String> otherAttributes = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
    otherAttributes.addAll(other.getParameters().keySet());
    Iterator<String> thisAttributesIterator = thisAttributes.iterator();
    Iterator<String> otherAttributesIterator = otherAttributes.iterator();
    while (thisAttributesIterator.hasNext()) {
        String thisAttribute = thisAttributesIterator.next();
        String otherAttribute = otherAttributesIterator.next();
        comp = thisAttribute.compareToIgnoreCase(otherAttribute);
        if (comp != 0) {
            return comp;
        }
        String thisValue = getParameters().get(thisAttribute);
        String otherValue = other.getParameters().get(otherAttribute);
        if (otherValue == null) {
            otherValue = "";
        }
        comp = thisValue.compareTo(otherValue);
        if (comp != 0) {
            return comp;
        }
    }
    return 0;
}

From source file:com.ebay.erl.mobius.core.model.TupleColumnComparator.java

private static int compare(TreeMap<String, String> m1, TreeMap<String, String> m2) {
    int _COMPARE_RESULT = Integer.MAX_VALUE;

    int m1_size = m1.size();
    int m2_size = m2.size();

    if (m1_size == 0 || m2_size == 0) {
        if (m1_size == m2_size)
            return 0;
        else if (m1_size != 0)
            return 1;
        else//from  w w  w. j  a v a  2s.  c o m
            return -1;
    }

    Iterator<String> k1_it = m1.keySet().iterator();
    Iterator<String> k2_it = m2.keySet().iterator();

    boolean hasDiff = false;

    while (k1_it.hasNext()) {
        String k1 = k1_it.next();

        if (k2_it.hasNext()) {
            String k2 = k2_it.next();

            _COMPARE_RESULT = String.CASE_INSENSITIVE_ORDER.compare(k1, k2);
            if (_COMPARE_RESULT == 0) {
                // same key, check their value
                String v1 = m1.get(k1);
                String v2 = m2.get(k2);

                _COMPARE_RESULT = v1.compareTo(v2);
            }
        } else {
            // m1 has more keys than m2 and m1 has the same
            // values for all the keys in m2
            _COMPARE_RESULT = 1;
        }

        if (_COMPARE_RESULT != 0 && _COMPARE_RESULT != Integer.MAX_VALUE) {
            hasDiff = true;
            break;// has result
        }
    }

    if (!hasDiff) {
        if (k2_it.hasNext()) {
            // m2 has more keys than m1, and m2 has the same
            // values for all the keys in m1
            _COMPARE_RESULT = -1;
        } else {
            // m1 and m2 are the same

        }
    }

    return _COMPARE_RESULT;
}

From source file:org.docrj.smartcard.reader.GroupViewActivity.java

private int addGroup(String name, boolean select, boolean expand) {
    // add to saved hash set
    mUserGroups.add(name);/*from  w  w w  .  ja  v a 2 s .  co m*/
    // add to sorted list
    mSortedAllGroups.add(name);
    Collections.sort(mSortedAllGroups, String.CASE_INSENSITIVE_ORDER);
    // add to member apps
    for (SmartcardApp app : mMemberApps) {
        app.addGroup(name);
    }
    int grpPos = mSortedAllGroups.indexOf(name);
    // adjust selected group position indices as needed
    if (select) {
        mSelectedGrpPos = grpPos;
    } else if (grpPos <= mSelectedGrpPos) {
        mSelectedGrpPos++;
    }
    // adjust expanded group position index as needed
    if (expand) {
        mExpandedGrpPos = grpPos;
    } else if (grpPos <= mExpandedGrpPos) {
        mExpandedGrpPos++;
    }
    return grpPos;
}