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.trenako.entities.WishList.java

@Override
public int compareTo(WishList other) {
    int ret = 0;//from  w  w w  .  j av  a 2 s. co m

    if (this.equals(other)) {
        return 0;
    }

    ret = String.CASE_INSENSITIVE_ORDER.compare(this.getOwner(), other.getOwner());
    if (ret != 0)
        return ret;

    ret = String.CASE_INSENSITIVE_ORDER.compare(this.getName(), other.getName());
    if (ret != 0)
        return ret;

    return 0;
}

From source file:org.ebayopensource.turmeric.eclipse.errorlibrary.ui.views.ErrorRegistryView.java

/**
 * Create toolbar./*  www  . j  a  va  2  s .  c o m*/
 */
private void createToolbar() throws Exception {
    IToolBarManager mgr = getViewSite().getActionBars().getToolBarManager();
    RefreshErrRegistry refreshAction = new RefreshErrRegistry(errorLibraryViewer);

    mgr.add(refreshAction);
    final ErrLibComparator errLibComparator = new ErrLibComparator();
    final ViewerComparator comparator = new ViewerComparator(errLibComparator) {
        @Override
        public int compare(Viewer viewer, Object e1, Object e2) {
            if (e1 instanceof ISOAError && e2 instanceof ISOAError) {
                return errLibComparator.compare((ISOAError) e1, (ISOAError) e2);
            }
            return String.CASE_INSENSITIVE_ORDER.compare(e1.toString(), e2.toString());
        }

    };

    mgr.add(new SortRegistry(errorLibraryViewer, comparator));

    ErrorLibraryProviderFactory factory = ErrorLibraryProviderFactory.getInstance();
    IErrorRegistryViewProvider vProvider = factory.getPreferredProvider().getErrorRegistryViewProvider();
    if (vProvider != null) {
        vProvider.createToolBar(mgr, this.errorLibraryViewer);
    }
}

From source file:au.com.domain.AccountsAutoCompleteTextView.java

private List<String> getGoogleAccountEmails(Context context) {
    List<String> emails = new ArrayList<>();
    if (isPermissionGranted()) {
        //noinspection MissingPermission isPermission() is doing the check required by lint
        Account[] accounts = AccountManager.get(context).getAccountsByType(GoogleAuthUtil.GOOGLE_ACCOUNT_TYPE);
        for (Account account : accounts) {
            if (android.util.Patterns.EMAIL_ADDRESS.matcher(account.name).matches()) {
                emails.add(account.name);
            }/*from ww w . ja  v a2  s.  co m*/
        }
        Collections.sort(emails, String.CASE_INSENSITIVE_ORDER);
    }
    return emails;
}

From source file:com.volley.air.toolbox.BasicNetwork.java

/**
 * Converts Headers[] to Map<String, String>.
 *//*from   w w w  .ja v a  2 s  .c om*/

private static Map<String, String> convertHeaders(Header[] headers) {
    Map<String, String> result = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
    for (int i = 0; i < headers.length; i++) {
        result.put(headers[i].getName(), headers[i].getValue());
    }
    return result;
}

From source file:com.androidex.volley.toolbox.BasicNetwork.java

/**
 * Converts Headers[] to Map<String, String>.
 *//*from www.  j  a v a 2  s .c  om*/

private static Map<String, String> convertHeaders(Header[] headers) {
    Map<String, String> result = new TreeMap<String, String>(String.CASE_INSENSITIVE_ORDER);
    for (int i = 0; i < headers.length; i++) {
        result.put(headers[i].getName(), headers[i].getValue());
    }
    return result;
}

From source file:org.springframework.jdbc.repo.impl.jdbc.RawPropertiesRepoImpl.java

@Override
@SuppressWarnings("synthetic-access")
public void setProperties(final String id, final Map<String, ?> props) {
    if (StringUtils.isEmpty(id)) {
        throw new IllegalArgumentException(
                "setProperties(" + getEntityClass().getSimpleName() + ") no identifier");
    }/*from  w  w  w .  j a va  2 s .  com*/

    if (ExtendedMapUtils.isEmpty(props)) {
        throw new IllegalArgumentException(
                "setProperties(" + getEntityClass().getSimpleName() + ")[" + id + "] no properties");
    }

    validatePropertyValues(id, props);

    Object internalId = findInternalId(id);
    if (internalId == null) {
        internalId = createEntityEntry(id);
    }

    removeEntityProperties(id);

    Class<?> idType = internalId.getClass();
    InternalIdSetter idSetter = InternalIdSetter.SETTERS_MAP.get(idType);
    if (idSetter == null) {
        throw new UnsupportedOperationException("setProperties(" + getEntityClass().getSimpleName() + ")[" + id
                + "]" + " no identifier setter for type " + idType.getSimpleName());
    }

    @SuppressWarnings("unchecked")
    Map<String, Object>[] batchValues = new Map[props.size()];
    int batchIndex = 0;
    final Object assignedId = internalId;
    for (Map.Entry<String, ?> pe : props.entrySet()) {
        final String propName = pe.getKey();
        Object orgValue = pe.getValue();
        final Class<?> propType = JdbcOperationsUtils.resolveEffectivePropertyType(orgValue);
        final Object propValue = JdbcOperationsUtils.resolveEffectivePropertyValue(orgValue);
        batchValues[batchIndex] = new TreeMap<String, Object>(String.CASE_INSENSITIVE_ORDER) {
            private static final long serialVersionUID = 1L;

            {
                if (!conversionService.canConvert(propType, String.class)) {
                    throw new UnsupportedOperationException(
                            "setProperties(" + id + ")" + " cannot convert " + propName + "["
                                    + propType.getSimpleName() + "]" + " to string for value=" + propValue);
                }

                put(PROP_OWNER_COL, assignedId);
                put(PROP_NAME_COL, propName);
                put(PROP_TYPE_COL, propType.getName());
                put(PROP_VALUE_COL, conversionService.convert(propValue, String.class));
            }
        };
        batchIndex++;
    }

    try {
        int[] changeSet = jdbcAccessor.batchUpdate(
                "INSERT INTO " + ENTITY_PROPERTIES_TABLE + " (" + PROP_OWNER_COL + "," + PROP_NAME_COL + ","
                        + PROP_TYPE_COL + "," + PROP_VALUE_COL + ")" + " VALUES(:" + PROP_OWNER_COL + ",:"
                        + PROP_NAME_COL + ",:" + PROP_TYPE_COL + ",:" + PROP_VALUE_COL + ")",
                batchValues);
        if (logger.isDebugEnabled()) {
            logger.debug("setProperties(" + getEntityClass().getSimpleName() + ")[" + id + "] batch size="
                    + ExtendedArrayUtils.length(changeSet));
        }
    } catch (RuntimeException e) {
        logger.warn("setProperties(" + getEntityClass().getSimpleName() + ")[" + id + "]" + " failed ("
                + e.getClass().getSimpleName() + ") to insert props=" + props + ": " + e.getMessage());
        throw e;
    }
}

From source file:com.evolveum.midpoint.web.page.admin.configuration.PageDebugList.java

private List<ObjectViewDto> loadResources() {
    List<ObjectViewDto> objects = new ArrayList<>();

    try {//from   www .  j a  v a  2 s .c  o  m
        OperationResult result = new OperationResult(OPERATION_LOAD_RESOURCES);
        List<PrismObject<ResourceType>> list = WebModelUtils.searchObjects(ResourceType.class, null,
                SelectorOptions.createCollection(GetOperationOptions.createRaw()), result, this, null);

        for (PrismObject obj : list) {
            ObjectViewDto dto = new ObjectViewDto(obj.getOid(), WebMiscUtil.getName(obj));
            objects.add(dto);
        }
    } catch (Exception ex) {
        // todo implement error handling
    }

    Collections.sort(objects, new Comparator<ObjectViewDto>() {

        @Override
        public int compare(ObjectViewDto o1, ObjectViewDto o2) {
            return String.CASE_INSENSITIVE_ORDER.compare(o1.getName(), o2.getName());
        }
    });

    return objects;
}

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

/**
 *
 * @param roles//w w  w.  ja va 2s  .  co  m
 * @param contextId maps to sub-tree in DIT, for example ou=contextId, dc=jts, dc = com.
 * @return set of descendant roles associated with this entry.
 */
static Set<String> getDescendantRoles(Set<String> roles, String contextId) {
    // create Set with case insensitive comparator:
    Set<String> iRoles = new TreeSet<>(String.CASE_INSENSITIVE_ORDER);
    if (CollectionUtils.isNotEmpty(roles)) {
        for (String role : roles) {
            iRoles.add(role);
            Set<String> children = HierUtil.getDescendants(role, getGraph(contextId));
            if (CollectionUtils.isNotEmpty(children)) {
                iRoles.addAll(children);
            }
        }
    }
    return iRoles;
}

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

public void fullScan() throws CoreCancelException {
    final long start = System.currentTimeMillis();
    int firstPassItems = 0;

    // First, set the Scanned bit for each item in the local version table
    // to false/*  ww w .  j a  va2s.  c  o m*/
    for (final WorkspaceLocalItem lvEntry : lv.queryByLocalItem(null, RecursionType.FULL, null)) {
        lvEntry.setScanned(false);
    }

    final TaskMonitor taskMonitor = TaskMonitorService.getTaskMonitor();
    final WorkingFolder[] workingFolders = this.wp.getWorkingFolders();

    int candidateAddsCount = 0;
    int enumeratedItemsCount = 0;

    // For each item in the mapped local space of the workspace (first pass)
    PassOne: for (final LocalItemEnumerator localItemEnum : LocalItemEnumerable
            .getEnumeratorsForWorkingFolders(workingFolders)) {
        final LocalItemExclusionEvaluator ignoreFileStack = new LocalItemExclusionEvaluator(this.wp,
                localItemEnum.getStartPath());

        while (localItemEnum.hasNext()) {
            if (taskMonitor.isCanceled()) {
                throw new CoreCancelException();
            }

            final EnumeratedLocalItem fromDisk = localItemEnum.next();

            if (candidateAddsCount >= s_candidateAddsLimit || enumeratedItemsCount >= s_enumeratedItemsLimit) {
                // We're done walking mapped local space. Finish up the
                // items that are actually in the local version
                // table by skipping directly to pass two.

                // No goto in Java, break the PassOne loop
                break PassOne;
            }

            enumeratedItemsCount++;

            final WorkspaceLocalItem lvEntry = lv.getByLocalItem(fromDisk.getFullPath());

            if (null != lvEntry) {
                // We've hit this item in the first pass and will not
                // need
                // to check it again
                // in the second.
                lvEntry.setScanned(true);
                firstPassItems++;

                diffItem(fromDisk, lvEntry);
            } else if (!fromDisk.isDirectory() || fromDisk.isSymbolicLink()) {
                // Check to see if this is a candidate add.
                if (!ignoreFileStack.isExcluded(fromDisk.getFullPath())) {
                    final WorkingFolder closestMapping = (WorkingFolder) localItemEnum.getTag();
                    fromDisk.setServerItem(
                            closestMapping.translateLocalItemToServerItem(fromDisk.getFullPath()));

                    // Check for illegal characters or a $ at the
                    // beginning of a path part
                    if (ServerPath.isServerPath(fromDisk.getServerItem())) {
                        if (addCandidateAdd(fromDisk)) {
                            candidateAddsCount++;
                        }
                    }
                }
            }
        }
    }

    // PassTwo starts here

    // If we hit everything in the first pass (common case) then there's no
    // additional work to do here.
    if (firstPassItems != lv.getLocalItemsCount()) {
        // For each item in the local version table that we missed (second
        // pass)
        for (final WorkspaceLocalItem lvEntry : lv.queryByLocalItem(null, RecursionType.FULL, null)) {
            if (lvEntry.isScanned()) {
                // We already hit this item
                continue;
            }

            final File localFile = new File(lvEntry.getLocalItem());
            final FileSystemAttributes attrs = FileSystemUtils.getInstance().getAttributes(localFile);

            if (!attrs.exists()) {
                // Missing on disk, and candidate delete
                markForRemoval.add(lvEntry);
                continue;
            }

            final EnumeratedLocalItem fromDisk = new EnumeratedLocalItem(localFile, attrs);

            diffItem(fromDisk, lvEntry);
        }
    }

    scanPartTwo();

    // Remove from the pending changes table those candidates which we don't
    // have in our list.
    final Set<String> candidatesToRemove = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER);

    for (final LocalPendingChange candidateChange : pc.queryCandidatesByTargetServerItem(ServerPath.ROOT,
            RecursionType.FULL, null)) {
        if (!candidateChanges.contains(candidateChange.getTargetServerItem())) {
            candidatesToRemove.add(candidateChange.getTargetServerItem());
        }
    }

    for (final String candidateToRemove : candidatesToRemove) {
        pc.removeCandidateByTargetServerItem(candidateToRemove);
    }

    if (candidatesToRemove.size() > 0) {
        LocalWorkspaceTransaction.getCurrent().setRaisePendingChangeCandidatesChanged(true);
    }

    fireChangedByScanEvent();

    log.debug(
            MessageFormat.format("Full scan took {0} ms ({1} enum items, {2} fp items, {3} adds, {4} removes)", //$NON-NLS-1$
                    (System.currentTimeMillis() - start), enumeratedItemsCount, firstPassItems,
                    candidateAddsCount, candidatesToRemove.size()));
}

From source file:org.jvnet.hudson.update_center.MavenRepositoryImpl.java

public Collection<PluginHistory> listHudsonPlugins() throws PlexusContainerException, ComponentLookupException,
        IOException, UnsupportedExistingLuceneIndexException, AbstractArtifactResolutionException {
    BooleanQuery q = new BooleanQuery();
    q.add(indexer.constructQuery(ArtifactInfo.PACKAGING, "hpi"), Occur.MUST);

    FlatSearchRequest request = new FlatSearchRequest(q);
    FlatSearchResponse response = indexer.searchFlat(request);

    Map<String, PluginHistory> plugins = new TreeMap<String, PluginHistory>(String.CASE_INSENSITIVE_ORDER);

    for (ArtifactInfo a : response.getResults()) {
        if (a.version.contains("SNAPSHOT"))
            continue; // ignore snapshots
        if (IGNORE.containsKey(a.artifactId) || IGNORE.containsKey(a.artifactId + "-" + a.version))
            continue; // artifactIds or particular versions to omit

        PluginHistory p = plugins.get(a.artifactId);
        if (p == null)
            plugins.put(a.artifactId, p = new PluginHistory(a.artifactId));
        p.addArtifact(createHpiArtifact(a, p));
        p.groupId.add(a.groupId);//from  w  w  w .ja  v  a  2  s .co m
    }
    return plugins.values();
}