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.apache.directory.fortress.core.impl.DelAccessMgrImpl.java

/**
 * This helper function processes ARBAC URA "can assign".
 * @param session//from  ww w . ja  v a  2  s . co m
 * @param user
 * @param role
 * @return boolean
 * @throws SecurityException
 */
private boolean checkUserRole(Session session, User user, Role role) throws SecurityException {
    boolean result = false;
    List<UserAdminRole> uaRoles = session.getAdminRoles();
    if (CollectionUtils.isNotEmpty(uaRoles)) {
        // validate user and retrieve user' ou:
        User ue = userP.read(user, false);
        for (UserAdminRole uaRole : uaRoles) {
            if (uaRole.getName().equalsIgnoreCase(SUPER_ADMIN)) {
                result = true;
                break;
            }
            Set<String> osUs = uaRole.getOsU();
            if (CollectionUtils.isNotEmpty(osUs)) {
                // create Set with case insensitive comparator:
                Set<String> osUsFinal = new TreeSet<>(String.CASE_INSENSITIVE_ORDER);
                for (String osU : osUs) {
                    // Add osU children to the set:
                    osUsFinal.add(osU);
                    Set<String> children = UsoUtil.getDescendants(osU, this.contextId);
                    osUsFinal.addAll(children);
                }
                // does the admin role have authority over the user object?
                if (osUsFinal.contains(ue.getOu())) {
                    // Get the Role range for admin role:
                    Set<String> range;
                    if (uaRole.getBeginRange() != null && uaRole.getEndRange() != null
                            && !uaRole.getBeginRange().equalsIgnoreCase(uaRole.getEndRange())) {
                        range = RoleUtil.getAscendants(uaRole.getBeginRange(), uaRole.getEndRange(),
                                uaRole.isEndInclusive(), this.contextId);
                        if (uaRole.isBeginInclusive()) {
                            range.add(uaRole.getBeginRange());
                        }
                        if (CollectionUtils.isNotEmpty(range)) {
                            // Does admin role have authority over a role contained with the allowable role range?
                            if (range.contains(role.getName())) {
                                result = true;
                                break;
                            }
                        }
                    }
                    // Does admin role have authority over the role?
                    else if (uaRole.getBeginRange() != null
                            && uaRole.getBeginRange().equalsIgnoreCase(role.getName())) {
                        result = true;
                        break;
                    }
                }
            }
        }
    }
    return result;
}

From source file:gov.nih.nci.caintegrator.application.lists.UserListBeanHelper.java

public void intersectLists(List<String> listNames, String newListName, ListType listType) {
    List<String> items = new ArrayList<String>();
    List<UserList> lists = new ArrayList<UserList>();
    for (String listName : listNames) {
        UserList list = userListBean.getList(listName);
        lists.add(list);//from   ww w. j ava  2s .  c om
        if (!list.getList().isEmpty()) {
            items.addAll(list.getList());
        }
    }
    Set<String> intersectedList = new HashSet<String>(items);
    for (UserList ul : lists) {
        intersectedList.retainAll(ul.getList());
    }
    items.clear();
    items.addAll(intersectedList);
    Collections.sort(items, String.CASE_INSENSITIVE_ORDER);
    UserList newList = new UserList(newListName, listType, items, new ArrayList<String>(), new Date());
    newList.setListOrigin(ListOrigin.Custom);
    newList.setItemCount(items.size());
    userListBean.addList(newList);
}

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

private void ensureUpdatesFullyPopulated(final ILocalVersionUpdate[] updates) {
    final boolean setFileTimeToCheckin = workspace.getOptions().contains(WorkspaceOptions.SET_FILE_TO_CHECKIN);

    // For the logic for fetching from QueryPendingChanges
    final List<ItemSpec> toFetchFromPendingChanges = new ArrayList<ItemSpec>();
    final Map<String, IPopulatableLocalVersionUpdate> targetServerItemMap = new TreeMap<String, IPopulatableLocalVersionUpdate>(
            String.CASE_INSENSITIVE_ORDER);

    // For the logic for fetching from QueryItems
    final List<IPopulatableLocalVersionUpdate> toFetchFromQueryItems = new ArrayList<IPopulatableLocalVersionUpdate>();

    final LocalWorkspaceTransaction transaction = new LocalWorkspaceTransaction(workspace, wLock);
    try {/*  w  ww .j a va2 s  .c  o m*/
        transaction.execute(new WorkspacePropertiesLocalVersionTransaction() {
            @Override
            public void invoke(final LocalWorkspaceProperties wp, final WorkspaceVersionTable lv) {
                for (final ILocalVersionUpdate update : updates) {
                    // We only care about unpopulated
                    // IPopulatableLocalVersionUpdate objects.
                    if (!(update instanceof IPopulatableLocalVersionUpdate)) {
                        continue;
                    }

                    final IPopulatableLocalVersionUpdate cUpdate = (IPopulatableLocalVersionUpdate) update;
                    final WorkspaceLocalItem lvExisting = lv.getByServerItem(cUpdate.getSourceServerItem(),
                            cUpdate.isCommitted());

                    if (null != lvExisting && lvExisting.getVersion() == cUpdate.getVersionLocal()) {
                        cUpdate.updateFrom(lvExisting);
                    }

                    if (cUpdate.isFullyPopulated(setFileTimeToCheckin)) {
                        continue;
                    }

                    if (null != cUpdate.getPendingChangeTargetServerItem()) {
                        toFetchFromPendingChanges.add(
                                new ItemSpec(cUpdate.getPendingChangeTargetServerItem(), RecursionType.NONE));
                        targetServerItemMap.put(cUpdate.getPendingChangeTargetServerItem(), cUpdate);
                    } else {
                        toFetchFromQueryItems.add(cUpdate);
                    }
                }
            }

        });
    } finally {
        try {
            transaction.close();
        } catch (final IOException e) {
            throw new VersionControlException(e);
        }
    }

    if (toFetchFromPendingChanges.size() > 0) {
        Check.isTrue(options.contains(UpdateLocalVersionQueueOptions.UPDATE_SERVER),
                "Making a server call to fetch missing local version data during an offline operation"); //$NON-NLS-1$

        // We can't call Workspace.GetPendingChanges here, since that's an
        // offline operation. We want *real* PendingChange objects here,
        // from the server.

        final WebServiceLayer webServiceLayer = workspace.getClient().getWebServiceLayer();
        final PendingChange[] pendingChanges = webServiceLayer.queryServerPendingChanges(workspace,
                toFetchFromPendingChanges.toArray(new ItemSpec[toFetchFromPendingChanges.size()]), true,
                workspace.getClient().mergeWithDefaultItemPropertyFilters(null));

        for (final PendingChange pendingChange : pendingChanges) {
            final IPopulatableLocalVersionUpdate cUpdate = targetServerItemMap
                    .get(pendingChange.getServerItem());

            if (cUpdate == null) {
                log.warn("EnsureUpdatesFullyPopulated: Query did not return a PendingChange"); //$NON-NLS-1$
                continue;
            }

            cUpdate.updateFrom(pendingChange);

            Check.isTrue(cUpdate.isFullyPopulated(setFileTimeToCheckin),
                    "cUpdate.isFullyPopulated(setFileTimeToCheckin)"); //$NON-NLS-1$

            // Save off the download URL in case we need it after calling
            // UpdateLocalVersion.
            cUpdate.setDownloadURL(pendingChange.getDownloadURL());
        }
    }

    for (final IPopulatableLocalVersionUpdate update : toFetchFromQueryItems) {
        final GetItemsOptions options = GetItemsOptions.INCLUDE_SOURCE_RENAMES.combine(GetItemsOptions.UNSORTED)
                .combine(GetItemsOptions.DOWNLOAD);

        final ItemSet[] items = workspace.getClient().getItems(
                new ItemSpec[] { new ItemSpec(update.getSourceServerItem(), RecursionType.NONE) },
                new ChangesetVersionSpec(update.getVersionLocal()), DeletedState.ANY, ItemType.ANY, options);

        if (items[0].getItems().length != 1) {
            log.warn("EnsureUpdatesFullyPopulated: Result missing"); //$NON-NLS-1$
        }

        for (final Item item : items[0].getItems()) {
            update.updateFrom(item);

            Check.isTrue(update.isFullyPopulated(setFileTimeToCheckin),
                    "update.isFullyPopulated(setFileTimeToCheckin)"); //$NON-NLS-1$

            // Save off the download URL in case we need it after calling
            // UpdateLocalVersion.
            update.setDownloadURL(item.getDownloadURL());
            break;
        }
    }
}

From source file:forge.gui.ImportSourceAnalyzer.java

private void analyzeIconsPicsDir(final File root) {
    if (null == iconFileNames) {
        iconFileNames = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
        for (final Pair<String, String> nameurl : FileUtil
                .readNameUrlFile(ForgeConstants.IMAGE_LIST_QUEST_OPPONENT_ICONS_FILE)) {
            iconFileNames.put(nameurl.getLeft(), nameurl.getLeft());
        }//w  w w  .j  a va2  s. c  om
    }

    analyzeListedDir(root, ForgeConstants.CACHE_ICON_PICS_DIR, new ListedAnalyzer() {
        @Override
        public String map(final String filename) {
            return iconFileNames.containsKey(filename) ? iconFileNames.get(filename) : null;
        }

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

From source file:acmi.l2.clientmod.l2smr.Controller.java

private void initializeUsx() {
    staticMeshDirProperty().addListener((observable, oldValue, newValue) -> {
        smPane.setDisable(true);// w  w w.  jav  a 2  s .  c  o  m

        usxChooser.getSelectionModel().clearSelection();
        usxChooser.getItems().clear();

        if (newValue == null) {
            return;
        }

        smPane.setDisable(false);
        usxChooser.getItems().addAll(Arrays.stream(newValue.listFiles(STATICMESH_FILE_FILTER))
                .map(File::getName).collect(Collectors.toList()));
        AutoCompleteComboBox.autoCompleteComboBox(usxChooser, AutoCompleteComboBox.AutoCompleteMode.CONTAINING);
    });
    this.usx.bind(Bindings.createObjectBinding(() -> {
        String selected = usxChooser.getSelectionModel().getSelectedItem();
        if (selected == null)
            return null;
        return new File(getStaticMeshDir(), selected);
    }, staticMeshDirProperty(), usxChooser.getSelectionModel().selectedItemProperty()));
    this.usx.addListener((observable, oldValue, newValue) -> {
        smChooser.getSelectionModel().clearSelection();
        smChooser.getItems().clear();
        smChooser.setDisable(true);
        if (newValue == null) {
            return;
        }

        try (UnrealPackage up = new UnrealPackage(newValue, true)) {
            smChooser.getItems().setAll(up.getExportTable().stream()
                    .filter(entry -> entry.getObjectClass().getObjectFullName().equals("Engine.StaticMesh"))
                    .map(UnrealPackage.ExportEntry::getObjectInnerFullName)
                    .sorted(String.CASE_INSENSITIVE_ORDER).collect(Collectors.toList()));
            smChooser.setDisable(false);
            AutoCompleteComboBox.autoCompleteComboBox(smChooser,
                    AutoCompleteComboBox.AutoCompleteMode.CONTAINING);
        } catch (Exception e) {
            onException("Read failed", e);
        }
    });
    this.smView.disableProperty().bind(Bindings.isNull(smChooser.getSelectionModel().selectedItemProperty()));
    ObservableBooleanValue b = Bindings.or(
            Bindings.isNull(unrChooser.getSelectionModel().selectedItemProperty()),
            Bindings.isNull(smChooser.getSelectionModel().selectedItemProperty()));
    this.addToUnr.disableProperty().bind(b);
    this.createNew.disableProperty().bind(b);
}

From source file:org.apache.ctakes.ytex.uima.mapper.DocumentMapperServiceImpl.java

public void initDocKeyMapping() {
    AbstractEntityPersister cm = (AbstractEntityPersister) this.sessionFactory.getClassMetadata(Document.class);
    // figure out which columns are already mapped
    String[] propNames = cm.getPropertyNames();
    Set<String> mappedCols = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
    for (String prop : propNames) {
        String cols[] = cm.getPropertyColumnNames(prop);
        mappedCols.addAll(Arrays.asList(cols));
    }//from  ww  w  . ja v a2  s  . co m
    // this.formattedTableName = DBUtil.formatTableName(cm.getTableName());
    this.formattedTableName = cm.getTableName();
    log.info("document table name = " + formattedTableName);
    final String query = "select * from " + formattedTableName + " where 1=2";
    Connection conn = null;
    Statement stmt = null;
    ResultSet rs = null;
    try {
        conn = dataSource.getConnection();
        stmt = conn.createStatement();
        rs = stmt.executeQuery(query);
        ResultSetMetaData rsmd = rs.getMetaData();
        int nCols = rsmd.getColumnCount();
        for (int i = 1; i <= nCols; i++) {
            String colName = rsmd.getColumnName(i);
            if (!mappedCols.contains(colName)) {
                log.info("document candidate foreign key column: " + colName);
                docTableCols.put(colName, rsmd.getColumnType(i));
            }
        }
        if (log.isDebugEnabled()) {
            log.debug("docTableCols: " + docTableCols);
        }
    } catch (SQLException e) {
        log.error("problem determining document table fields", e);
        throw new RuntimeException(e);
    } finally {
        try {
            if (rs != null)
                rs.close();
        } catch (SQLException e) {
            e.printStackTrace();
        }
        try {
            if (stmt != null)
                stmt.close();
        } catch (SQLException e) {
            e.printStackTrace();
        }
        try {
            if (conn != null)
                conn.close();
        } catch (SQLException e) {
            e.printStackTrace();
        }

    }
}

From source file:net.sourceforge.fenixedu.domain.ExecutionDegree.java

public static List<ExecutionDegree> getAllCoordinatedByTeacher(Person person) {
    List<ExecutionDegree> result = new ArrayList<ExecutionDegree>();

    if (person == null) {
        return result;
    }/* w w w  .  j av a 2  s  . c om*/

    for (Coordinator coordinator : person.getCoordinatorsSet()) {
        result.add(coordinator.getExecutionDegree());
    }

    Comparator<ExecutionDegree> degreNameComparator = new Comparator<ExecutionDegree>() {

        @Override
        public int compare(ExecutionDegree o1, ExecutionDegree o2) {
            String name1 = o1.getDegreeCurricularPlan().getDegree().getName();
            String name2 = o2.getDegreeCurricularPlan().getDegree().getName();

            return String.CASE_INSENSITIVE_ORDER.compare(name1, name2);
        }

    };

    Comparator<ExecutionDegree> yearComparator = new Comparator<ExecutionDegree>() {

        @Override
        public int compare(ExecutionDegree o1, ExecutionDegree o2) {
            String year1 = o1.getExecutionYear().getYear();
            String year2 = o2.getExecutionYear().getYear();

            return String.CASE_INSENSITIVE_ORDER.compare(year1, year2);
        }

    };

    // sort by degreeCurricularPlan.degree.nome ascending,
    // executionYear.year descending
    ComparatorChain comparatorChain = new ComparatorChain();
    comparatorChain.addComparator(degreNameComparator, false);
    comparatorChain.addComparator(yearComparator, true);

    Collections.sort(result, comparatorChain);

    return result;
}

From source file:org.apache.felix.webconsole.internal.compendium.ConfigManager.java

private SortedMap getServices(String inputService, String currServiceFilter, String localeInfo,
        boolean ocdRequired) throws InvalidSyntaxException {
    // sorted map of options
    SortedMap currOptFactory = new TreeMap(String.CASE_INSENSITIVE_ORDER);

    // find all ManagedServiceFactories to get the factoryPIDs
    ServiceReference[] currServRefList = this.getBundleContext().getServiceReferences(inputService,
            currServiceFilter);//from   w w  w .j ava2 s  . c  o m
    for (int i = 0; currServRefList != null && i < currServRefList.length; i++) {
        Object pidObject = currServRefList[i].getProperty(Constants.SERVICE_PID);
        if (pidObject instanceof String) {
            String tempPid = (String) pidObject;
            String workerName;
            final ObjectClassDefinition classDef = this.getObjectClassDefinition(currServRefList[i].getBundle(),
                    tempPid, localeInfo);
            if (classDef != null) {
                workerName = classDef.getName() + " (";
                workerName += tempPid + ")";
            } else {
                workerName = tempPid;
            }

            if (!ocdRequired || classDef != null) {
                currOptFactory.put(tempPid, workerName);
            }
        }
    }

    return currOptFactory;
}

From source file:org.apache.directory.fortress.core.model.Permission.java

/**
 * Add a UserId to list of Users that are valid for this Permission.  This is optional attribute.
 *
 * @param user maps to 'ftUsers' attribute in 'ftOperation' object class.
 *///from   ww  w  .j  a v a2  s  .co m
public void setUser(String user) {
    if (users == null) {
        users = new TreeSet<>(String.CASE_INSENSITIVE_ORDER);
    }

    this.users.add(user);
}

From source file:forge.gui.ImportSourceAnalyzer.java

private void analyzeTokenPicsDir(final File root) {
    if (null == tokenFileNames) {
        tokenFileNames = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
        questTokenFileNames = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
        for (final Pair<String, String> nameurl : FileUtil
                .readNameUrlFile(ForgeConstants.IMAGE_LIST_TOKENS_FILE)) {
            tokenFileNames.put(nameurl.getLeft(), nameurl.getLeft());
        }/*  w w  w  . ja  v  a2 s  .com*/
        for (final Pair<String, String> nameurl : FileUtil
                .readNameUrlFile(ForgeConstants.IMAGE_LIST_QUEST_TOKENS_FILE)) {
            questTokenFileNames.put(nameurl.getLeft(), nameurl.getLeft());
        }
    }

    analyzeListedDir(root, ForgeConstants.CACHE_TOKEN_PICS_DIR, new ListedAnalyzer() {
        @Override
        public String map(final String filename) {
            if (questTokenFileNames.containsKey(filename)) {
                return questTokenFileNames.get(filename);
            }
            if (tokenFileNames.containsKey(filename)) {
                return tokenFileNames.get(filename);
            }
            return null;
        }

        @Override
        public OpType getOpType(final String filename) {
            return questTokenFileNames.containsKey(filename) ? OpType.QUEST_PIC : OpType.TOKEN_PIC;
        }
    });
}