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:de.zib.scalaris.examples.wikipedia.bliki.WikiServlet.java

/**
 * Shows a page containing a list of article names.
 * //from   ww  w .  j ava2  s  .  c  om
 * @param request
 *            the request of the current operation
 * @param response
 *            the response of the current operation
 * @param result
 *            result from reading the page list
 * @param connection
 *            connection to the database
 * @param page
 *            the bean for the page
 * 
 * @throws IOException
 * @throws ServletException
 */
private void handleViewSpecialPageList(HttpServletRequest request, HttpServletResponse response,
        ValueResult<List<NormalisedTitle>> result, Connection connection, WikiPageListBean page)
        throws ServletException, IOException {
    if (result.success) {
        final TreeSet<String> pageList = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
        MyWikiModel.denormalisePageTitles(result.value, namespace, pageList);
        page.setNotice(getParam_notice(request));
        String nsPrefix = namespace.getNamespaceByNumber(page.getNamespaceId());
        if (!nsPrefix.isEmpty()) {
            nsPrefix += ":";
        }
        final String prefix = nsPrefix + page.getPrefix();
        final String from = page.getFromPage();
        final String fullFrom = nsPrefix + page.getFromPage();
        final String to = page.getToPage();
        final String fullTo = nsPrefix + page.getToPage();
        final String search = page.getSearch().toLowerCase();
        final String searchTitle = MyWikiModel.normaliseName(page.getSearch());
        boolean foundMatch = false;
        if (!prefix.isEmpty() || !from.isEmpty() || !to.isEmpty() || !search.isEmpty()) {
            // only show pages with this prefix:
            for (Iterator<String> it = pageList.iterator(); it.hasNext();) {
                final String cur = it.next();
                // case-insensitive "startsWith" check:
                if (!cur.regionMatches(true, 0, prefix, 0, prefix.length())) {
                    it.remove();
                } else if (!from.isEmpty() && cur.compareToIgnoreCase(fullFrom) <= 0) {
                    it.remove();
                } else if (!to.isEmpty() && cur.compareToIgnoreCase(fullTo) > 0) {
                    it.remove();
                } else if (!search.isEmpty() && !cur.toLowerCase().contains(search)) {
                    it.remove();
                } else if (!search.isEmpty() && cur.equals(searchTitle)) {
                    foundMatch = true;
                }
            }
        }
        page.setPages(pageList);
        page.setFoundFullMatch(foundMatch);
        page.setWikiTitle(siteinfo.getSitename());
        page.setWikiNamespace(namespace);

        forwardToPageJsp(request, response, connection, page, "pageSpecial_pagelist.jsp");
    } else {
        if (result.connect_failed) {
            setParam_error(request, "ERROR: DB connection failed");
        } else {
            setParam_error(request, "ERROR: page list unavailable");
            addToParam_notice(request, "error: unknown error getting page list for " + page.getTitle()
                    + ": <pre>" + result.message + "</pre>");
        }
        showEmptyPage(request, response, connection, page);
        return;
    }
    page.setError(getParam_error(request));
    page.setTitle(page.getTitle());
}

From source file:com.mirth.connect.cli.CommandLineInterface.java

private void commandExportMap(Token[] arguments) throws ClientException {
    if (hasInvalidNumberOfArguments(arguments, 1)) {
        return;/*  ww  w .j a v a 2  s  . c om*/
    }

    // file path
    String path = arguments[1].getText();
    File file = new File(path);

    if (file != null) {
        try {
            PropertiesConfiguration properties = new PropertiesConfiguration(file);
            properties.clear();
            PropertiesConfigurationLayout layout = properties.getLayout();

            Map<String, ConfigurationProperty> configurationMap = client.getConfigurationMap();
            Map<String, ConfigurationProperty> sortedMap = new TreeMap<String, ConfigurationProperty>(
                    String.CASE_INSENSITIVE_ORDER);
            sortedMap.putAll(configurationMap);

            for (Entry<String, ConfigurationProperty> entry : sortedMap.entrySet()) {
                String key = entry.getKey();
                String value = entry.getValue().getValue();
                String comment = entry.getValue().getComment();

                if (StringUtils.isNotBlank(key)) {
                    properties.setProperty(key, value);
                    layout.setComment(key, StringUtils.isBlank(comment) ? null : comment);
                }
            }

            properties.save();

            out.println("Configuration map export complete.");
        } catch (ConfigurationException e) {
            error("Unable to export configuration map.", e);
        }
    }
}

From source file:org.forester.archaeopteryx.ControlPanel.java

public void setSequenceRelationQueries(final Collection<Sequence> sequenceRelationQueries) {
    final JComboBox box = getSequenceRelationBox();
    while (box.getItemCount() > 1) {
        box.removeItemAt(1);//from  w ww .j ava  2 s.co m
    }
    final HashMap<String, Sequence> sequencesByName = new HashMap<String, Sequence>();
    final SequenceRelation.SEQUENCE_RELATION_TYPE relationType = (SequenceRelation.SEQUENCE_RELATION_TYPE) _sequence_relation_type_box
            .getSelectedItem();
    if (relationType == null) {
        return;
    }
    final ArrayList<String> sequenceNamesToAdd = new ArrayList<String>();
    for (final Sequence seq : sequenceRelationQueries) {
        if (seq.hasSequenceRelations()) {
            boolean fFoundForCurrentType = false;
            for (final SequenceRelation sq : seq.getSequenceRelations()) {
                if (sq.getType().equals(relationType)) {
                    fFoundForCurrentType = true;
                    break;
                }
            }
            if (fFoundForCurrentType) {
                sequenceNamesToAdd.add(seq.getName());
                sequencesByName.put(seq.getName(), seq);
            }
        }
    }
    // sort sequences by name before adding them to the combo
    final String[] sequenceNameArray = sequenceNamesToAdd.toArray(new String[sequenceNamesToAdd.size()]);
    Arrays.sort(sequenceNameArray, String.CASE_INSENSITIVE_ORDER);
    for (final String seqName : sequenceNameArray) {
        box.addItem(seqName);
    }
    for (final ItemListener oldItemListener : box.getItemListeners()) {
        box.removeItemListener(oldItemListener);
    }
    box.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(final ItemEvent e) {
            _selected_query_seq = sequencesByName.get(e.getItem());
            _mainpanel.getCurrentTreePanel().repaint();
        }
    });
}

From source file:lcmc.cluster.ui.ClusterBrowser.java

/**
 * Adds ServiceInfo in the name to ServiceInfo hash. Id and name
 * are taken from serviceInfo object. nameToServiceInfoHash
 * contains a hash with id as a key and ServiceInfo as a value.
 *//*from   w w w .ja v  a 2 s  .co  m*/
public void addNameToServiceInfoHash(final ServiceInfo serviceInfo) {
    /* add to the hash with service name and id as keys */
    final Service service = serviceInfo.getService();
    lockNameToServiceInfo();
    Map<String, ServiceInfo> idToInfoHash = nameToServiceInfoHash.get(service.getName());
    String csPmId = null;
    final ServiceInfo cs = serviceInfo.getContainedService();
    if (cs != null) {
        csPmId = cs.getService().getName() + '_' + cs.getService().getId();
    }
    if (idToInfoHash == null) {
        idToInfoHash = new TreeMap<String, ServiceInfo>(String.CASE_INSENSITIVE_ORDER);
        if (service.getId() == null) {
            if (csPmId == null) {
                service.setId("1");
            } else {
                service.setIdAndCrmId(csPmId);
            }
        }
    } else {
        if (service.getId() == null) {
            int index = 0;
            for (final String id : idToInfoHash.keySet()) {
                final Pattern p;
                if (csPmId == null) {
                    p = Pattern.compile("^(\\d+)$");
                } else {
                    /* ms */
                    p = Pattern.compile('^' + csPmId + "_(\\d+)$");
                    if (csPmId.equals(id)) {
                        index++;
                    }
                }

                final Matcher m = p.matcher(id);
                if (m.matches()) {
                    try {
                        final int i = Integer.parseInt(m.group(1));
                        if (i > index) {
                            index = i;
                        }
                    } catch (final NumberFormatException nfe) {
                        LOG.appWarning("addNameToServiceInfoHash: could not parse: " + m.group(1));
                    }
                }
            }

            if (csPmId == null) {
                service.setId(Integer.toString(index + 1));
            } else {
                /* ms */
                if (index == 0) {
                    service.setIdAndCrmId(csPmId);
                } else {
                    service.setIdAndCrmId(csPmId + '_' + Integer.toString(index + 1));
                }
            }
        }
    }
    idToInfoHash.put(service.getId(), serviceInfo);
    nameToServiceInfoHash.put(service.getName(), idToInfoHash);
    unlockNameToServiceInfo();
}

From source file:com.microsoft.windowsazure.mobileservices.sdk.testapp.test.SystemPropertiesTests.java

public void testInsertRemovesCreatedAtSerializedNameStringId() throws Throwable {

    final String responseContent = "{\"id\":\"an id\"}";

    MobileServiceClient client = null;//ww  w. j av a 2 s. c om

    try {
        client = new MobileServiceClient(appUrl, appKey, getInstrumentation().getTargetContext());
    } catch (MalformedURLException e) {
        e.printStackTrace();
    }

    // Add a filter to handle the request and create a new json
    // object with an id defined
    client = client.withFilter(getTestFilter(responseContent));

    client = client.withFilter(new ServiceFilter() {
        @Override
        public ListenableFuture<ServiceFilterResponse> handleRequest(ServiceFilterRequest request,
                NextServiceFilterCallback nextServiceFilterCallback) {
            String content = request.getContent();
            JsonObject obj = new JsonParser().parse(content).getAsJsonObject();

            Map<String, JsonElement> properties = new TreeMap<String, JsonElement>(
                    String.CASE_INSENSITIVE_ORDER);

            for (Entry<String, JsonElement> entry : obj.entrySet()) {
                properties.put(entry.getKey(), entry.getValue());
            }

            assertTrue(properties.containsKey("id"));
            assertFalse(properties.containsKey("__createdAt"));

            return nextServiceFilterCallback.onNext(request);
        }
    });

    // Create get the MobileService table
    MobileServiceTable<CreatedAtType> msTable = client.getTable(CreatedAtType.class);

    CreatedAtType element = new CreatedAtType();
    element.Id = "an id";
    element.CreatedAt = new GregorianCalendar(2012, 00, 18).getTime();

    try {
        // Call the insert method
        CreatedAtType entity = msTable.insert(element).get();

        if (entity == null) {
            fail("Expected result");
        }

    } catch (Exception exception) {
        fail(exception.getMessage());
    }
}

From source file:lcmc.gui.ClusterBrowser.java

/**
 * Adds ServiceInfo in the name to ServiceInfo hash. Id and name
 * are taken from serviceInfo object. nameToServiceInfoHash
 * contains a hash with id as a key and ServiceInfo as a value.
 *//* ww  w .  j  a  v a 2 s  .co m*/
public void addNameToServiceInfoHash(final ServiceInfo serviceInfo) {
    /* add to the hash with service name and id as keys */
    final Service service = serviceInfo.getService();
    lockNameToServiceInfo();
    Map<String, ServiceInfo> idToInfoHash = nameToServiceInfoHash.get(service.getName());
    String csPmId = null;
    final ServiceInfo cs = serviceInfo.getContainedService();
    if (cs != null) {
        csPmId = cs.getService().getName() + "_" + cs.getService().getId();
    }
    if (idToInfoHash == null) {
        idToInfoHash = new TreeMap<String, ServiceInfo>(String.CASE_INSENSITIVE_ORDER);
        if (service.getId() == null) {
            if (csPmId == null) {
                service.setId("1");
            } else {
                service.setIdAndCrmId(csPmId);
            }
        }
    } else {
        if (service.getId() == null) {
            final Iterator<String> it = idToInfoHash.keySet().iterator();
            int index = 0;
            while (it.hasNext()) {
                final String id = idToInfoHash.get(it.next()).getService().getId();
                Pattern p;
                if (csPmId == null) {
                    p = Pattern.compile("^(\\d+)$");
                } else {
                    p = Pattern.compile("^" + csPmId + "_(\\d+)$");
                    if (csPmId.equals(id)) {
                        index++;
                    }
                }

                final Matcher m = p.matcher(id);
                if (m.matches()) {
                    try {
                        final int i = Integer.parseInt(m.group(1));
                        if (i > index) {
                            index = i;
                        }
                    } catch (NumberFormatException nfe) {
                        Tools.appWarning("could not parse: " + m.group(1));
                    }
                }
            }
            if (csPmId == null) {
                service.setId(Integer.toString(index + 1));
            } else {
                if (index == 0) {
                    service.setIdAndCrmId(csPmId);
                } else {
                    service.setIdAndCrmId(csPmId + "_" + Integer.toString(index + 1));
                }
            }
        }
    }
    idToInfoHash.put(service.getId(), serviceInfo);
    nameToServiceInfoHash.put(service.getName(), idToInfoHash);
    unlockNameToServiceInfo();
}

From source file:com.microsoft.windowsazure.mobileservices.sdk.testapp.test.SystemPropertiesTests.java

public void testInsertRemovesCreatedAtPropertyNameStringId() throws Throwable {

    final String responseContent = "{\"id\":\"an id\"}";

    MobileServiceClient client = null;/*  www.ja v a2 s  .  c  o  m*/

    try {
        client = new MobileServiceClient(appUrl, appKey, getInstrumentation().getTargetContext());
    } catch (MalformedURLException e) {
        e.printStackTrace();
    }

    // Add a filter to handle the request and create a new json
    // object with an id defined
    client = client.withFilter(getTestFilter(responseContent));

    client = client.withFilter(new ServiceFilter() {
        @Override
        public ListenableFuture<ServiceFilterResponse> handleRequest(ServiceFilterRequest request,
                NextServiceFilterCallback nextServiceFilterCallback) {
            String content = request.getContent();
            JsonObject obj = new JsonParser().parse(content).getAsJsonObject();

            Map<String, JsonElement> properties = new TreeMap<String, JsonElement>(
                    String.CASE_INSENSITIVE_ORDER);

            for (Entry<String, JsonElement> entry : obj.entrySet()) {
                properties.put(entry.getKey(), entry.getValue());
            }

            assertTrue(properties.containsKey("id"));
            assertFalse(properties.containsKey("__createdAt"));

            return nextServiceFilterCallback.onNext(request);
        }
    });

    // Create get the MobileService table
    MobileServiceTable<NamedSystemPropertiesType> msTable = client.getTable(NamedSystemPropertiesType.class);

    NamedSystemPropertiesType element = new NamedSystemPropertiesType();
    element.Id = "an id";
    element.__createdAt = new GregorianCalendar(2012, 00, 18).getTime();

    try {
        // Call the insert method
        NamedSystemPropertiesType entity = msTable.insert(element).get();

        if (entity == null) {
            fail("Expected result");
        }

    } catch (Exception exception) {
        fail(exception.getMessage());
    }
}

From source file:com.microsoft.windowsazure.mobileservices.sdk.testapp.test.SystemPropertiesTests.java

public void testInsertRemovesUpdatedAtSerializedNameStringId() throws Throwable {

    final String responseContent = "{\"id\":\"an id\"}";

    MobileServiceClient client = null;/*  ww  w.jav  a 2s . c om*/

    try {
        client = new MobileServiceClient(appUrl, appKey, getInstrumentation().getTargetContext());
    } catch (MalformedURLException e) {
        e.printStackTrace();
    }

    // Add a filter to handle the request and create a new json
    // object with an id defined
    client = client.withFilter(getTestFilter(responseContent));

    client = client.withFilter(new ServiceFilter() {
        @Override
        public ListenableFuture<ServiceFilterResponse> handleRequest(ServiceFilterRequest request,
                NextServiceFilterCallback nextServiceFilterCallback) {
            String content = request.getContent();
            JsonObject obj = new JsonParser().parse(content).getAsJsonObject();

            Map<String, JsonElement> properties = new TreeMap<String, JsonElement>(
                    String.CASE_INSENSITIVE_ORDER);

            for (Entry<String, JsonElement> entry : obj.entrySet()) {
                properties.put(entry.getKey(), entry.getValue());
            }

            assertTrue(properties.containsKey("id"));
            assertFalse(properties.containsKey("__updatedAt"));

            return nextServiceFilterCallback.onNext(request);
        }
    });

    // Create get the MobileService table
    MobileServiceTable<UpdatedAtType> msTable = client.getTable(UpdatedAtType.class);

    UpdatedAtType element = new UpdatedAtType();
    element.Id = "an id";
    element.UpdatedAt = new GregorianCalendar(2012, 00, 18).getTime();

    try {
        // Call the insert method
        UpdatedAtType entity = msTable.insert(element).get();

        if (entity == null) {
            fail("Expected result");
        }

    } catch (Exception exception) {
        fail(exception.getMessage());
    }
}

From source file:pcgen.gui2.facade.Gui2InfoFactory.java

/**
 * @see pcgen.facade.core.InfoFactory#getPantheons(DeityFacade)
 *///from ww w.  j  a v a  2  s.  com
@Override
public String getPantheons(DeityFacade deityFacade) {
    if (deityFacade == null || !(deityFacade instanceof Deity)) {
        return EMPTY_STRING;
    }
    Deity deity = (Deity) deityFacade;
    Set<String> set = new TreeSet<>(String.CASE_INSENSITIVE_ORDER);
    FactSetKey<String> fk = FactSetKey.valueOf("Pantheon");
    for (Indirect<String> indirect : deity.getSafeSetFor(fk)) {
        set.add(indirect.get());
    }
    final StringBuilder piString = new StringBuilder(100);
    piString.append(StringUtil.joinToStringBuilder(set, ",")); //$NON-NLS-1$
    return piString.toString();

}

From source file:com.wso2telco.dep.reportingservice.northbound.NbHostObjectUtils.java

/**
 * Gets the all subscribers.//from   w ww .  ja  va 2 s  .co m
 *
 * @return the all subscribers
 * @throws Exception 
 */
public static List<String> getAllSubscribers() throws Exception {
    BillingDAO billingDAO = new BillingDAO();
    List<String> subscriptions = billingDAO.getAllSubscriptions();
    Collections.sort(subscriptions, String.CASE_INSENSITIVE_ORDER);
    return subscriptions;
}