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.vanita5.twittnuker.activity.support.ComposeActivity.java

private boolean handleReplyIntent(final ParcelableStatus status) {
    if (status == null || status.id <= 0)
        return false;
    final String myScreenName = getAccountScreenName(this, status.account_id);
    if (isEmpty(myScreenName))
        return false;
    mEditText.append("@" + status.user_screen_name + " ");
    final int selectionStart = mEditText.length();
    if (!isEmpty(status.retweeted_by_screen_name)) {
        mEditText.append("@" + status.retweeted_by_screen_name + " ");
    }//from w  w  w  .j a  va  2  s .  c o m
    final Collection<String> mentions = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
    mentions.addAll(mExtractor.extractMentionedScreennames(status.text_plain));
    for (final String mention : mentions) {
        if (mention.equalsIgnoreCase(status.user_screen_name) || mention.equalsIgnoreCase(myScreenName)
                || mention.equalsIgnoreCase(status.retweeted_by_screen_name)) {
            continue;
        }
        mEditText.append("@" + mention + " ");
    }
    final int selectionEnd = mEditText.length();
    mEditText.setSelection(selectionStart, selectionEnd);
    mSendAccountIds = new long[] { status.account_id };
    return true;
}

From source file:org.springframework.extensions.webscripts.AbstractWebScript.java

/**
 * Create a map of headers from Web Script Request (for scripting)
 * //from   w  ww.j av  a2s .  c o m
 * @param req  Web Script Request
 * @return  header map
 */
final protected Map<String, String> createHeaders(WebScriptRequest req) {
    // NOTE: headers names are case-insensitive according to HTTP Spec
    Map<String, String> headers = new TreeMap<String, String>(String.CASE_INSENSITIVE_ORDER);
    String[] names = req.getHeaderNames();
    for (String name : names) {
        headers.put(name, req.getHeader(name));
    }
    return headers;
}

From source file:org.apereo.portal.portlets.portletadmin.PortletAdministrationHelper.java

/**
 * Retreive the list of portlet application contexts currently available in
 * this portlet container./*from w  w  w  . j ava  2s. c  o  m*/
 *
 * @return list of portlet context
 */
public List<PortletApplicationDefinition> getPortletApplications() {
    final PortletRegistryService portletRegistryService = portalDriverContainerServices
            .getPortletRegistryService();
    final List<PortletApplicationDefinition> contexts = new ArrayList<PortletApplicationDefinition>();

    for (final Iterator<String> iter = portletRegistryService.getRegisteredPortletApplicationNames(); iter
            .hasNext();) {
        final String applicationName = iter.next();
        final PortletApplicationDefinition applicationDefninition;
        try {
            applicationDefninition = portletRegistryService.getPortletApplication(applicationName);
        } catch (PortletContainerException e) {
            throw new RuntimeException(
                    "Failed to load PortletApplicationDefinition for '" + applicationName + "'");
        }

        final List<? extends PortletDefinition> portlets = applicationDefninition.getPortlets();
        Collections.sort(portlets,
                new ComparableExtractingComparator<PortletDefinition, String>(String.CASE_INSENSITIVE_ORDER) {
                    @Override
                    protected String getComparable(PortletDefinition o) {
                        final List<? extends DisplayName> displayNames = o.getDisplayNames();
                        if (displayNames != null && displayNames.size() > 0) {
                            return displayNames.get(0).getDisplayName();
                        }

                        return o.getPortletName();
                    }
                });

        contexts.add(applicationDefninition);
    }

    Collections.sort(contexts, new ComparableExtractingComparator<PortletApplicationDefinition, String>(
            String.CASE_INSENSITIVE_ORDER) {
        @Override
        protected String getComparable(PortletApplicationDefinition o) {
            final String portletContextName = o.getName();
            if (portletContextName != null) {
                return portletContextName;
            }

            final String applicationName = o.getContextPath();
            if ("/".equals(applicationName)) {
                return "ROOT";
            }

            if (applicationName.startsWith("/")) {
                return applicationName.substring(1);
            }

            return applicationName;
        }
    });
    return contexts;
}

From source file:org.springframework.extensions.webscripts.AbstractWebScript.java

/**
 * Create a map of (array) headers from Web Script Request (for scripting)
 * //from  w ww  .j  a  v  a 2  s . c  o  m
 * @param req  Web Script Request
 * @return  argument map
 */
final protected Map<String, String[]> createHeadersM(WebScriptRequest req) {
    // NOTE: headers names are case-insensitive according to HTTP Spec
    Map<String, String[]> headers = new TreeMap<String, String[]>(String.CASE_INSENSITIVE_ORDER);
    String[] names = req.getHeaderNames();
    for (String name : names) {
        headers.put(name, req.getHeaderValues(name));
    }
    return headers;
}

From source file:weave.utils.SQLUtils.java

/**
 * This function is for use with an Oracle connection
 * @param conn An existing Oracle SQL Connection
 * @param schemaName A schema name accessible through the given connection
 * @return A List of sequence names in the given schema
 * @throws SQLException If the query fails.
 *//*from w  w w . j  a v  a2 s. c o  m*/
private static List<String> getSequences(Connection conn, String schemaName) throws SQLException {
    List<String> sequences = new Vector<String>();
    ResultSet rs = null;
    try {
        DatabaseMetaData md = conn.getMetaData();
        String[] types = new String[] { "SEQUENCE" };

        rs = md.getTables(null, schemaName.toUpperCase(), null, types);

        // use column index instead of name because sometimes the names are lower case, sometimes upper.
        // column indices: 1=sequence_cat,2=sequence_schem,3=sequence_name,4=sequence_type,5=remarks
        while (rs.next())
            sequences.add(rs.getString(3)); // sequence_name

        Collections.sort(sequences, String.CASE_INSENSITIVE_ORDER);
    } finally {
        // close everything in reverse order
        cleanup(rs);
    }
    //System.out.println(sequences);
    return sequences;
}

From source file:eu.apenet.dpt.standalone.gui.ead2edm.EdmOptionsPanel.java

public String[] getAllLanguages() {
    String[] isoLanguages = Locale.getISOLanguages();
    Map<String, String> languagesTemp = new LinkedHashMap<String, String>(isoLanguages.length);
    languages = new LinkedHashMap<String, String>(isoLanguages.length);
    for (String isoLanguage : isoLanguages) {
        languagesTemp.put(new Locale(isoLanguage).getDisplayLanguage(Locale.ENGLISH), isoLanguage);
    }/*from   w  w w .j  ava  2s  . c o  m*/

    List<String> tempList = new LinkedList<String>(languagesTemp.keySet());
    Collections.sort(tempList, String.CASE_INSENSITIVE_ORDER);

    for (String tempLanguage : tempList) {
        languages.put(tempLanguage, languagesTemp.get(tempLanguage));
    }

    return languages.keySet().toArray(new String[] {});
}

From source file:org.gcaldaemon.gui.config.MainConfig.java

public final String[] getCalendarPaths() {
    try {//from w  w  w .j  ava2s .  c o  m
        HashSet set = new HashSet();
        FileSync[] configs = getFileSyncConfigs();

        // Scan directories
        HashSet dirs = new HashSet();
        int i;
        FileSync config;
        File file, dir;
        for (i = 0; i < configs.length; i++) {
            config = configs[i];
            if (config.icalPath != null && config.icalPath.endsWith(".ics")) {
                if (config.icalPath.indexOf("*.ics") != -1) {
                    continue;
                }
                if (config.icalPath.indexOf("Application Support") != -1) {
                    continue;
                }
                file = new File(config.icalPath);
                dir = file.getParentFile();
                if (dir.isDirectory() && dir.canRead() && !dirs.contains(dir)) {
                    dirs.add(dir);
                    getCalendarPaths(set, dir, true);
                }
            }
        }

        // Scan folders of iCal3
        getICalendar3Paths(set, dirs);

        // Scan folders of iCal4
        getICalendar4Paths(set, dirs);

        // Scan folders of Evolution
        getEvolutionPaths(set, dirs);

        // Add configured paths
        for (i = 0; i < configs.length; i++) {
            config = configs[i];
            if (config.icalPath != null && config.icalPath.endsWith(".ics")
                    && !containsPath(set, config.icalPath)) {
                set.add(config.icalPath);
            }
        }
        String[] array = new String[set.size()];
        set.toArray(array);
        Arrays.sort(array, String.CASE_INSENSITIVE_ORDER);
        return array;
    } catch (Exception anyException) {
    }
    return null;
}

From source file:com.microsoft.tfs.core.clients.versioncontrol.Workstation.java

private Workspace[] updateWorkspaceInfoCache(final String key, final VersionControlClient client,
        String ownerName) {/*  w  w  w . j a  v a 2 s.c  om*/
    // Do not allow null for owner name. We do not want to put the
    // workspaces for every owner
    // into the cache. The machine may be a server with many different users
    // having workspaces
    // on it.
    Check.notNullOrEmpty(ownerName, "ownerName"); //$NON-NLS-1$

    // Make sure we have the fully qualified owner name.
    ownerName = client.resolveUserUniqueName(ownerName);

    // We do this *before* removing the workspaces from cache in case it
    // throws.
    Workspace[] workspaces = null;

    if (client.isAuthorizedUser(ownerName)) {
        // Only add the permissions filter when ownerName is the
        // AuthenticatedUser.
        workspaces = client.queryWorkspaces(null, ownerName, getName(),
                WorkspacePermissions.READ.combine(WorkspacePermissions.USE));
    } else {
        workspaces = client.queryWorkspaces(null, ownerName, getName());
    }

    // Refresh the server GUID in case it changed somehow
    client.refreshServerGUID();

    final List<InternalWorkspaceConflictInfo> warningList = new ArrayList<InternalWorkspaceConflictInfo>();
    final List<KeyValuePair<Exception, Workspace>> errorList = new ArrayList<KeyValuePair<Exception, Workspace>>();

    final Set<String> keysUpdated = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER);

    // Make sure to add the key passed in. This way if no workspaces are
    // found at least we can record that nothing was found for this key.
    keysUpdated.add(key);

    synchronized (cacheMutex) {
        // Remove all workspaces for the specified repository.
        final List<WorkspaceInfo> infoRemovedList = removeCachedWorkspaceInfo(client, workspaces, false);
        infoRemovedList.addAll(removeCachedWorkspaceInfo(client, ownerName, false));

        // Add all workspaces that are local and are owned by the specified
        // owner.
        for (final Workspace workspace : workspaces) {
            try {
                final AtomicReference<InternalWorkspaceConflictInfo[]> cws1 = new AtomicReference<InternalWorkspaceConflictInfo[]>();

                final WorkspaceInfo info = getCache().insertWorkspace(workspace, cws1);

                for (final InternalWorkspaceConflictInfo iwci : cws1.get()) {
                    warningList.add(iwci);
                }

                // For each workspace info that was removed, we want to copy
                // its local metadata (e.g., LastSavedCheckin) to the new
                // object.
                copyLocalMetadata(info, infoRemovedList);

                keysUpdated.addAll(createLoadWorkspacesTableKeys(client, workspace));
            } catch (final VersionControlException exception) {
                // Skip the workspace if there's a mapping conflict, etc.
                errorList.add(new KeyValuePair<Exception, Workspace>(exception, workspace));
            }
        }

        final AtomicReference<InternalWorkspaceConflictInfo[]> cws2 = new AtomicReference<InternalWorkspaceConflictInfo[]>();

        InternalCacheLoader.saveConfigIfDirty(getCache(), cws2, cacheMutex, workspaceCacheFile);

        for (final InternalWorkspaceConflictInfo iwci : cws2.get()) {
            warningList.add(iwci);
        }

        // Record for EnsureUpdateWorkspaceInfoCache() the fact that we have
        // already queried the server for the user's workspaces.
        final Long now = System.currentTimeMillis();
        for (final String updatedKey : keysUpdated) {
            workspacesLoadedTable.put(updatedKey, now);
        }
    }

    // Raise all of the error events after releasing the lock.
    for (final InternalWorkspaceConflictInfo iwci : warningList) {
        onNonFatalError(new WorkstationNonFatalErrorEvent(EventSource.newFromHere(), iwci));
    }
    for (final KeyValuePair<Exception, Workspace> error : errorList) {
        onNonFatalError(
                new WorkstationNonFatalErrorEvent(EventSource.newFromHere(), error.getKey(), error.getValue()));
    }

    return workspaces;
}

From source file:org.apache.directory.fortress.core.ldap.ApacheDsDataProvider.java

/**
 * Method wraps ldap client to return multi-occurring attribute values by name within a given entry and returns
 * as a set of strings./* ww  w  .j a  v a 2  s .  c om*/
 *
 * @param entry         contains the target ldap entry.
 * @param attributeName name of ldap attribute to retrieve.
 * @return List of type string containing attribute values.
 * @throws LdapException in the event of ldap client error.
 */
protected Set<String> getAttributeSet(Entry entry, String attributeName) {
    // create Set with case insensitive comparator:
    Set<String> attrValues = new TreeSet<>(String.CASE_INSENSITIVE_ORDER);

    if (entry != null && entry.containsAttribute(attributeName)) {
        for (Value<?> value : entry.get(attributeName)) {
            attrValues.add(value.getString());
        }
    }

    return attrValues;
}

From source file:org.usergrid.persistence.Schema.java

private Map<String, Set<CollectionInfo>> addDynamicApplicationCollectionAsContainer(
        Map<String, Set<CollectionInfo>> containers, String entityType) {

    Map<String, Set<CollectionInfo>> copy = new TreeMap<String, Set<CollectionInfo>>(
            String.CASE_INSENSITIVE_ORDER);
    if (containers != null) {
        copy.putAll(containers);//from  w ww  . j a  va2 s .c  o m
    }
    containers = copy;

    if (!containers.containsKey(Application.ENTITY_TYPE)) {
        MapUtils.addMapSet(containers, true, Application.ENTITY_TYPE,
                getCollection(Application.ENTITY_TYPE, defaultCollectionName(entityType)));
    }

    return containers;
}