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:org.openhim.mediator.engine.connectors.HTTPConnector.java

private MediatorHTTPResponse buildResponseFromContent(MediatorHTTPRequest req,
        CloseableHttpResponse apacheResponse) throws IOException {
    String content = null;//from  www  .jav a2  s. co m
    if (apacheResponse.getEntity() != null && apacheResponse.getEntity().getContent() != null) {
        content = IOUtils.toString(apacheResponse.getEntity().getContent());
    }

    int status = apacheResponse.getStatusLine().getStatusCode();

    Map<String, String> headers = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
    for (Header hdr : apacheResponse.getAllHeaders()) {
        headers.put(hdr.getName(), hdr.getValue());
    }

    return new MediatorHTTPResponse(req, content, status, headers);
}

From source file:com.stimulus.archiva.presentation.SearchBean.java

public List<String> getFields() {

    ArrayList<String> fieldList = new ArrayList<String>();
    EmailFields emailFields = Config.getConfig().getEmailFields();
    for (EmailField ef : emailFields.getAvailableFields().values()) {
        // we dont allow end-users to search using bcc
        if (ef.getName().equals("bcc") && getMailArchivaPrincipal().getRole().equals("user"))
            continue;
        if (ef.getName().equals("deliveredto") && getMailArchivaPrincipal().getRole().equals("user"))
            continue;

        if (ef.getAllowSearch() == EmailField.AllowSearch.SEARCH)
            fieldList.add(ef.getName());
    }/*  ww  w.j  ava  2s .c  o  m*/
    fieldList.add("addresses");
    fieldList.add("all");
    Collections.sort(fieldList, String.CASE_INSENSITIVE_ORDER);
    return fieldList;
}

From source file:annis.gui.flatquerybuilder.ValueField.java

@Override
public void textChange(TextChangeEvent event) {
    ReducingStringComparator rsc = sq.getRSC();
    String fm = sq.getFilterMechanism();
    if (!"generic".equals(fm)) {
        ConcurrentSkipListSet<String> notInYet = new ConcurrentSkipListSet<>();
        String txt = event.getText();
        if (!txt.equals("")) {
            scb.removeAllItems();/*from   w  w  w  .j a va  2 s. c  o m*/
            for (Iterator<String> it = values.keySet().iterator(); it.hasNext();) {
                String s = it.next();
                if (rsc.compare(s, txt, fm) == 0) {
                    scb.addItem(s);
                } else {
                    notInYet.add(s);
                }
            }
            //startsWith
            for (String s : notInYet) {
                if (rsc.startsWith(s, txt, fm)) {
                    scb.addItem(s);
                    notInYet.remove(s);
                }
            }
            //contains
            for (String s : notInYet) {
                if (rsc.contains(s, txt, fm)) {
                    scb.addItem(s);
                }
            }
        } else {
            buildValues(this.vm);
        }
    } else {
        String txt = event.getText();
        HashMap<Integer, Collection> levdistvals = new HashMap<>();
        if (txt.length() > 1) {
            scb.removeAllItems();
            for (String s : values.keySet()) {
                Integer d = StringUtils.getLevenshteinDistance(removeAccents(txt).toLowerCase(),
                        removeAccents(s).toLowerCase());
                if (levdistvals.containsKey(d)) {
                    levdistvals.get(d).add(s);
                }
                if (!levdistvals.containsKey(d)) {
                    Set<String> newc = new TreeSet<>();
                    newc.add(s);
                    levdistvals.put(d, newc);
                }
            }
            SortedSet<Integer> keys = new TreeSet<>(levdistvals.keySet());
            for (Integer k : keys.subSet(0, 10)) {
                List<String> valueList = new ArrayList(levdistvals.get(k));
                Collections.sort(valueList, String.CASE_INSENSITIVE_ORDER);
                for (String v : valueList) {
                    scb.addItem(v);
                }
            }
        }
    }
}

From source file:forge.CardStorageReader.java

/**
 * Starts reading cards into memory until the given card is found.
 *
 * After that, we save our place in the list of cards (on disk) in case we
 * need to load more.// ww  w  . j ava  2s.c  o  m
 *
 * @return the Card or null if it was not found.
 */
public final Iterable<CardRules> loadCards() {

    final Localizer localizer = Localizer.getInstance();

    progressObserver.setOperationName(localizer.getMessage("splash.loading.examining-cards"), true);

    // Iterate through txt files or zip archive.
    // Report relevant numbers to progress monitor model.

    final Set<CardRules> result = new TreeSet<>(new Comparator<CardRules>() {
        @Override
        public int compare(final CardRules o1, final CardRules o2) {
            return String.CASE_INSENSITIVE_ORDER.compare(o1.getName(), o2.getName());
        }
    });

    final List<File> allFiles = collectCardFiles(new ArrayList<File>(), this.cardsfolder);
    if (!allFiles.isEmpty()) {
        int fileParts = zip == null ? NUMBER_OF_PARTS : 1 + NUMBER_OF_PARTS / 3;
        if (allFiles.size() < fileParts * 100) {
            fileParts = allFiles.size() / 100; // to avoid creation of many threads for a dozen of files
        }
        final CountDownLatch cdlFiles = new CountDownLatch(fileParts);
        final List<Callable<List<CardRules>>> taskFiles = makeTaskListForFiles(allFiles, cdlFiles);
        progressObserver.setOperationName(localizer.getMessage("splash.loading.cards-folders"), true);
        progressObserver.report(0, taskFiles.size());
        final StopWatch sw = new StopWatch();
        sw.start();
        executeLoadTask(result, taskFiles, cdlFiles);
        sw.stop();
        final long timeOnParse = sw.getTime();
        System.out.printf("Read cards: %s files in %d ms (%d parts) %s%n", allFiles.size(), timeOnParse,
                taskFiles.size(), useThreadPool ? "using thread pool" : "in same thread");
    }

    if (this.zip != null) {
        final CountDownLatch cdlZip = new CountDownLatch(NUMBER_OF_PARTS);
        List<Callable<List<CardRules>>> taskZip;

        ZipEntry entry;
        final List<ZipEntry> entries = new ArrayList<>();
        // zipEnum was initialized in the constructor.
        final Enumeration<? extends ZipEntry> zipEnum = this.zip.entries();
        while (zipEnum.hasMoreElements()) {
            entry = zipEnum.nextElement();
            if (entry.isDirectory() || !entry.getName().endsWith(CardStorageReader.CARD_FILE_DOT_EXTENSION)) {
                continue;
            }
            entries.add(entry);
        }

        taskZip = makeTaskListForZip(entries, cdlZip);
        progressObserver.setOperationName(localizer.getMessage("splash.loading.cards-archive"), true);
        progressObserver.report(0, taskZip.size());
        final StopWatch sw = new StopWatch();
        sw.start();
        executeLoadTask(result, taskZip, cdlZip);
        sw.stop();
        final long timeOnParse = sw.getTime();
        System.out.printf("Read cards: %s archived files in %d ms (%d parts) %s%n", this.zip.size(),
                timeOnParse, taskZip.size(), useThreadPool ? "using thread pool" : "in same thread");
    }

    return result;
}

From source file:org.gcaldaemon.core.notifier.GmailNotifierWindow.java

final void show(String[] newMails) {
    if (newMails != null && newMails.length != 0) {
        if (clip != null) {
            try {
                clip.play();//  ww  w .  ja v  a 2  s.c  o m
            } catch (Exception soundError) {
                log.error("Unable to play sound!", soundError);
            }
        } else {
            try {
                Toolkit.getDefaultToolkit().beep();
            } catch (Exception ignored) {
            }
        }
        synchronized (RENDER_LOCK) {
            pointer = -1;
            offset = 0;
            dragged = false;
            if (isVisible()) {
                String[] swap = new String[mails.length + newMails.length];
                System.arraycopy(mails, 0, swap, 0, mails.length);
                System.arraycopy(newMails, 0, swap, mails.length, newMails.length);
                Arrays.sort(swap, String.CASE_INSENSITIVE_ORDER);
                mails = swap;
                current = mails[0];
                render();
            } else {
                mails = newMails;
                current = mails[0];
                render();
                super.setVisible(true);
                if (repainter != null && repainter.isAlive()) {
                    repainter.interrupt();
                }
                repainter = new Thread(this);
                repainter.start();
            }
        }
    }
}

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

/**
 * Return Set of {@link org.apache.directory.fortress.core.model.OrgUnit#name}s ascendants contained within {@link org.apache.directory.fortress.core.model.OrgUnit.Type#USER}.
 *
 * @param ous contains list of {@link org.apache.directory.fortress.core.model.OrgUnit}s.
 * @return contains Set of all descendants.
 *//*from   w w w .  ja  v a2 s  .  co  m*/
static Set<String> getInherited(List<OrgUnit> ous, String contextId) {
    // create Set with case insensitive comparator:
    Set<String> iOUs = new TreeSet<>(String.CASE_INSENSITIVE_ORDER);

    if (CollectionUtils.isNotEmpty(ous)) {
        for (OrgUnit ou : ous) {
            String name = ou.getName();
            iOUs.add(name);
            Set<String> parents = HierUtil.getAscendants(name, getGraph(contextId));

            if (CollectionUtils.isNotEmpty(parents)) {
                iOUs.addAll(parents);
            }
        }
    }

    return iOUs;
}

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

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

    MergeUtil.merge(Arrays.asList("bar", "foo"),
            Arrays.asList(new Container("foo", "FooValue"), new Container("quux", "QuuxValue")),
            new MergeUtil.Compare<String, Container>() {
                @Override/* w ww  . j  av a  2  s  . com*/
                public int compare(String left, Container right) {
                    return String.CASE_INSENSITIVE_ORDER.compare(left, right.key);
                }
            }, new MergeUtil.Callback<String, Container>() {
                @Override
                public void output(String left, Container right) {
                    outputs.add(new ImmutablePair<String, Container>(left, right));
                }
            });

    assertEquals(Arrays.asList(new ImmutablePair<String, Container>("bar", null),
            new ImmutablePair<String, Container>("foo", new Container("foo", "FooValue")),
            new ImmutablePair<String, Container>(null, new Container("quux", "QuuxValue"))), outputs);
}

From source file:de.eonas.opencms.portlet.CmsPortletWidget.java

@NotNull
static private ArrayList<String> fetchRegisteredPortlets(@Nullable String selected) {
    String metainfo = null;/* ww  w  .  j  av  a2s. c o m*/
    if (!CmsStringUtil.isEmpty(selected)) {
        PortletWindowConfig selectedConfig = PortletWindowConfig.fromId(selected);
        metainfo = selectedConfig.getMetaInfo();
    }

    if (metainfo == null) {
        metainfo = createPlacementId();
    }

    if (m_context == null) {
        LOG.warn("ServletContext still unset. Maybe the listener is missing?");
        return new ArrayList<String>();
    }
    // Es wird auf die PortletContainer Instanz zugegriffen
    PortletContainer container = (PortletContainer) m_context.getAttribute(AttributeKeys.PORTLET_CONTAINER);

    PortalDriverServicesImpl driverserviceimpl = (PortalDriverServicesImpl) container.getContainerServices();
    Iterator<DriverPortletContext> iter = driverserviceimpl.getPortletContextService().getPortletContexts();

    ArrayList<String> liste = new ArrayList<String>();
    // Das Select Element wird mit Werten der PortletApplikationen gefuellt
    while (iter.hasNext()) {
        DriverPortletContext portletcontext = iter.next();
        PortletApplicationDefinition portletAppDd = portletcontext.getPortletApplicationDefinition();

        String contextPath = portletcontext.getApplicationName();
        if (contextPath.length() > 0) {
            contextPath = "/" + contextPath;
        }

        for (PortletDefinition portlet : portletAppDd.getPortlets()) {
            String portletName = portlet.getPortletName();

            String portletId = PortletWindowConfig.createPortletId(contextPath, portletName, metainfo);

            liste.add(portletId);
        }
    }

    // Pruefung damit ein Portlet, das selektiert ist, aber zur Zeit nicht
    // verfuegbar ist, troztdem in der Liste bleibt
    // und nicht ausgelassen wird.
    if (selected != null && selected.length() > 0 && !liste.contains(selected)) {
        liste.add(selected);
    }

    Collections.sort(liste, String.CASE_INSENSITIVE_ORDER);
    return liste;
}

From source file:com.microsoft.tfs.core.clients.favorites.IdentityFavoritesStore.java

/**
 * Updates/Adds supplied favorite Items//from   w ww  .jav  a 2 s . co m
 */
private static void updateFavorites(final TeamFoundationIdentity identity, final String effectiveNamespace,
        final FavoriteItem[] items) {
    final Map<GUID, FavoriteItem> favorites = new HashMap<GUID, FavoriteItem>();
    for (final FavoriteItem item : getFavorites(identity)) {
        favorites.put(item.getID(), item);
    }

    for (final FavoriteItem favItem : items) {
        if (!GUID.EMPTY.equals(favItem.getParentID())) {
            if (!favorites.containsKey(favItem.getParentID())) {
                throw new FavoritesException(
                        Messages.getString("IdentityFavoritesStore.ParentFavoriteNotFound")); //$NON-NLS-1$
            }
        }

        for (final FavoriteItem f : favorites.values()) {
            if (f.getParentID().equals(favItem.getParentID())) {
                if (!f.getID().equals(favItem.getID())
                        && String.CASE_INSENSITIVE_ORDER.compare(f.getType() + "", favItem.getType() + "") == 0 //$NON-NLS-1$ //$NON-NLS-2$
                        && String.CASE_INSENSITIVE_ORDER.compare(f.getName() + "", favItem.getName() + "") == 0 //$NON-NLS-1$ //$NON-NLS-2$
                        && String.CASE_INSENSITIVE_ORDER.compare(f.getData() + "", favItem.getData() + "") == 0) //$NON-NLS-1$ //$NON-NLS-2$
                {
                    throw new DuplicateFavoritesException(
                            Messages.getString("IdentityFavoritesStore.FavoriteWithSameNameTypeDataExists"), //$NON-NLS-1$
                            favItem);
                }
            }
        }

        setViewProperty(identity, IdentityPropertyScope.LOCAL, effectiveNamespace,
                favItem.getID().getGUIDString(), favItem.serialize());
    }
}

From source file:cn.ctyun.amazonaws.auth.AWS4Signer.java

protected String getSignedHeadersString(Request<?> request) {
    List<String> sortedHeaders = new ArrayList<String>();
    sortedHeaders.addAll(request.getHeaders().keySet());
    Collections.sort(sortedHeaders, String.CASE_INSENSITIVE_ORDER);

    StringBuilder buffer = new StringBuilder();
    for (String header : sortedHeaders) {
        if (buffer.length() > 0)
            buffer.append(";");
        buffer.append(header.toLowerCase());
    }/*from   w  ww .j a va2  s .c o m*/

    return buffer.toString();
}