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.libreplan.business.resources.entities.Resource.java

public static List<Resource> sortByName(List<Resource> resources) {
    Collections.sort(resources, new Comparator<Resource>() {

        @Override/*  ww  w  .  j  av  a 2s .c  o m*/
        public int compare(Resource o1, Resource o2) {
            return String.CASE_INSENSITIVE_ORDER.compare(o1.getName(), o2.getName());
        }
    });
    return resources;
}

From source file:org.apache.pulsar.functions.utils.io.ConnectorUtils.java

public static Connectors searchForConnectors(String connectorsDirectory) throws IOException {
    Path path = Paths.get(connectorsDirectory).toAbsolutePath();
    log.info("Searching for connectors in {}", path);

    Connectors connectors = new Connectors();

    if (!path.toFile().exists()) {
        log.warn("Connectors archive directory not found");
        return connectors;
    }//from  w w  w .j a va2  s  .co  m

    try (DirectoryStream<Path> stream = Files.newDirectoryStream(path, "*.nar")) {
        for (Path archive : stream) {
            try {
                ConnectorDefinition cntDef = ConnectorUtils.getConnectorDefinition(archive.toString());
                log.info("Found connector {} from {}", cntDef, archive);

                if (!StringUtils.isEmpty(cntDef.getSourceClass())) {
                    connectors.sources.put(cntDef.getName(), archive);
                }

                if (!StringUtils.isEmpty(cntDef.getSinkClass())) {
                    connectors.sinks.put(cntDef.getName(), archive);
                }

                connectors.connectors.add(cntDef);
            } catch (Throwable t) {
                log.warn("Failed to load connector from {}", archive, t);
            }
        }
    }

    Collections.sort(connectors.connectors,
            (c1, c2) -> String.CASE_INSENSITIVE_ORDER.compare(c1.getName(), c2.getName()));

    return connectors;
}

From source file:org.openhim.mediator.engine.connectors.HTTPConnector.java

private MediatorHTTPResponse buildResponseFromOpenHIMJSONContent(MediatorHTTPRequest req,
        CloseableHttpResponse apacheResponse) throws IOException, CoreResponse.ParseException {
    String content = IOUtils.toString(apacheResponse.getEntity().getContent());
    CoreResponse parsedContent = CoreResponse.parse(content);
    if (parsedContent.getResponse() == null) {
        throw new CoreResponse.ParseException(
                new Exception("No response object found in application/json+openhim content"));
    }//from  w  w w  .  j a v a2s  . c  o  m

    int status = apacheResponse.getStatusLine().getStatusCode();
    if (parsedContent.getResponse().getStatus() != null) {
        status = parsedContent.getResponse().getStatus();
    }

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

    if (parsedContent.getResponse().getHeaders() != null) {
        for (String hdr : parsedContent.getResponse().getHeaders().keySet()) {
            headers.put(hdr, parsedContent.getResponse().getHeaders().get(hdr));
        }
    }

    if (parsedContent.getOrchestrations() != null) {
        for (CoreResponse.Orchestration orch : parsedContent.getOrchestrations()) {
            req.getRequestHandler().tell(new AddOrchestrationToCoreResponse(orch), getSelf());
        }
    }

    if (parsedContent.getProperties() != null) {
        for (String prop : parsedContent.getProperties().keySet()) {
            req.getRequestHandler().tell(
                    new PutPropertyInCoreResponse(prop, parsedContent.getProperties().get(prop)), getSelf());
        }
    }

    return new MediatorHTTPResponse(req, parsedContent.getResponse().getBody(), status, headers);
}

From source file:rapternet.irc.bots.wheatley.listeners.DefListener2.java

@Override
public void onMessage(MessageEvent event) throws FileNotFoundException, InterruptedException {
    String message = Colors.removeFormattingAndColors(event.getMessage());
    String[] msgSplit = message.split(" ");

    if (message.equalsIgnoreCase("!randef") || message.equalsIgnoreCase("!randdef")) {
        String word = defs.getRandomWord();
        event.getBot().sendIRC().message(event.getChannel().getName(),
                Colors.BOLD + defs.getWordWithCase(word) + ": " + Colors.NORMAL + defs.getDefOfWord(word));
    } else if (msgSplit[0].equalsIgnoreCase("!whodef")) {
        String word = message.split(" ", 2)[1];
        if (defs.containsDef(word)) {

            event.getBot().sendIRC().message(event.getChannel().getName(), Colors.BOLD
                    + defs.getWordWithCase(word) + Colors.NORMAL + " was defined by " + defs.getOriginator(word)
                    + " at "
                    + IRCUtils.getTimestamp(String.valueOf(Long.parseLong(defs.getTimeOfDef(word)) * 1000)));
        } else if (!event.getBot().getUserChannelDao()
                .getChannels(event.getBot().getUserChannelDao().getUser("theTardis"))
                .contains(event.getChannel())) {
            event.getBot().sendIRC().notice(event.getUser().getNick(),
                    Colors.BOLD + "WhoDef: " + Colors.NORMAL + "Definition not found");
        }/* w w  w.  j a  v  a  2s. co  m*/
    }

    if (message.endsWith("?") && message.split("\\?", 2)[0].length() > 0 && message.split("\\?").length == 1
            && StringUtils.countMatches(message, "?") == 1) {
        if (defs.containsDef(message.split("\\?")[0])) {
            String word = message.split("\\?")[0];
            //                int index = indexOfIgnoreCase(words,message.split("\\?")[0]);
            event.getBot().sendIRC().message(event.getChannel().getName(),
                    Colors.BOLD + defs.getWordWithCase(word) + Colors.NORMAL + ": " + defs.getDefOfWord(word));
        }
    }
    //Global.getTimestamp(Long.toString(rs.getLong("TIME")*1000))
    //event.getTimestamp() / 1000

    if (message.equalsIgnoreCase("!list defs")) {

        ArrayList<String> sortedWords = defs.getDefList();
        //            sortedWords.addAll(words);
        Collections.sort(sortedWords, String.CASE_INSENSITIVE_ORDER);

        String wordList = "";
        for (int i = 0; i < sortedWords.size(); i++) {
            wordList = wordList + sortedWords.get(i) + ", ";
        }
        event.getBot().sendIRC().message(event.getUser().getNick(), wordList);
    }

    if (msgSplit.length > 3 && msgSplit[0].equalsIgnoreCase("tell") && msgSplit[2].equalsIgnoreCase("about")) {
        String user = message.split(" ")[1];
        if (event.getBot().getUserChannelDao().getAllUsers()
                .contains(event.getBot().getUserChannelDao().getUser(user))) {

            //If the user is in the same channel as the summon
            String defWord = message.split("(?i)about(?-i)")[1].trim();//.split(" ",2)[2];
            if (defs.containsDef(defWord)) {
                String def = defs.getDefOfWord(defWord);
                event.getBot().sendIRC().notice(event.getUser().getNick(), user + " has been PMed");
                event.getBot().sendIRC().message(event.getBot().getUserChannelDao().getUser(user).getNick(),
                        event.getUser().getNick() + " wants me to tell you about: " + Colors.BOLD
                                + defs.getWordWithCase(defWord) + Colors.NORMAL + ": " + Colors.NORMAL + def);
            } else if (!event.getBot().getUserChannelDao()
                    .getChannels(event.getBot().getUserChannelDao().getUser("theTardis"))
                    .contains(event.getChannel())) {
                event.getBot().sendIRC().notice(event.getUser().getNick(),
                        Colors.BOLD + "tell " + Colors.NORMAL + "definition not found");
            }
        } else if (!event.getBot().getUserChannelDao()
                .getChannels(event.getBot().getUserChannelDao().getUser("theTardis"))
                .contains(event.getChannel())) {
            event.getBot().sendIRC().notice(event.getUser().getNick(),
                    Colors.BOLD + "tell " + Colors.NORMAL + "user not in channel");
        }
    }

    //        if(msgSplit[0].equalsIgnoreCase("!load")){
    //            
    //            if (event.getUser().getNick().equalsIgnoreCase(Global.botOwner)&&event.getUser().isVerified()){
    //                
    //                addDefsFromFile("definitions.txt", String.valueOf(event.getTimestamp()/1000));
    //                addDefLogFromFile("definitionLog.txt", String.valueOf(event.getTimestamp()/1000));
    //            }
    //        }

    // ADDING DEFINITIONS
    if (msgSplit[0].equalsIgnoreCase("!mkdef")) {//||msgSplit[0].equalsIgnoreCase("!addef")

        if (event.getUser().getNick().equalsIgnoreCase(Global.botOwner) && event.getUser().isVerified()) {

            if (message.split("@").length != 2) {
                event.getBot().sendIRC().notice(event.getUser().getNick(),
                        "Improperly formed defintion add command: !mkdef word or phrase @ definition phrase");
            }

            else if (StringUtils.countMatches(message.split("@")[0], "?") > 0) {
                event.getBot().sendIRC().notice(event.getUser().getNick(),
                        "Improperly formed defintion add command: Definition terms may not contain a \"?\"");
            }

            else if (defs.containsDef(message.split(" ", 2)[1].split("@")[0].trim())) {
                event.getBot().sendIRC().notice(event.getUser().getNick(), "Definition already exists");
            }

            else {
                String word = message.split(" ", 2)[1].split("@")[0].trim();
                String def = message.split("@")[1].trim();
                String user = event.getUser().getNick();
                String time = String.valueOf(event.getTimestamp() / 1000);
                defs.createDef(word, def, user, time);
                event.getBot().sendIRC().notice(event.getUser().getNick(),
                        "Success: " + word + " was added to the definitions file");
            }
        } else
            event.getBot().sendIRC().notice(event.getUser().getNick(),
                    "You do not have access to this function");
    }

    // REMOVING DEFINITIONS
    if (msgSplit[0].equalsIgnoreCase("!rmdef")) {//||msgSplit[0].equalsIgnoreCase("!deletedef")

        if (event.getUser().getNick().equalsIgnoreCase(Global.botOwner) && event.getUser().isVerified()) {
            String word = message.split(" ", 2)[1];
            if (!defs.containsDef(word)) {
                event.getBot().sendIRC().notice(event.getUser().getNick(), "Definition not found");
            } else {
                String logWord = defs.getWordWithCase(word);
                int i = 0;
                while (defsLog.containsDef(logWord)) {
                    logWord = word + String.valueOf(i);
                    i++;
                }
                defsLog.createDef(logWord, defs.getDefOfWord(word), defs.getOriginator(word),
                        defs.getTimeOfDef(word));

                boolean success = defs.deleteDef(word);
                if (success)
                    event.getBot().sendIRC().notice(event.getUser().getNick(),
                            "Success: " + word + " was removed from the definitions file");
                else
                    event.getBot().sendIRC().notice(event.getUser().getNick(),
                            "SOMETHING BROKE: DEF NOT DELETED");

            }
        } else
            event.getBot().sendIRC().notice(event.getUser().getNick(),
                    "You do not have access to this function");
    }

    // Updating definitions already in the db

    if (msgSplit[0].equalsIgnoreCase("!overdef")) {//||msgSplit[0].equalsIgnoreCase("!updef")

        if (event.getUser().getNick().equalsIgnoreCase(Global.botOwner) && event.getUser().isVerified()) {

            if (!(message.split("@").length == 2)) {
                event.getBot().sendIRC().notice(event.getUser().getNick(),
                        "Improperly formed update command: !overdef word phrase @ definition phrase");
            }

            else if (!defs.containsDef(message.split(" ", 2)[1].split("@")[0].trim())) {
                event.getBot().sendIRC().notice(event.getUser().getNick(),
                        "Def currently does not exist, please use !adddef");
            }

            else {

                String word = message.split(" ", 2)[1].split("@")[0].trim();
                System.out.println(word);
                String logWord = defs.getWordWithCase(word);
                int i = 0;
                while (defsLog.containsDef(logWord)) {
                    logWord = word + String.valueOf(i);
                    i++;
                }
                defsLog.createDef(logWord, defs.getDefOfWord(word), defs.getOriginator(word),
                        defs.getTimeOfDef(word));
                boolean success = defs.deleteDef(word);
                defs.createDef(word, message.split("@")[1], event.getUser().getNick(),
                        String.valueOf(event.getTimestamp() / 1000));

                if (success)
                    event.getBot().sendIRC().notice(event.getUser().getNick(),
                            "Success: " + message.split(" ", 2)[1].split("@")[0].trim()
                                    + " was updated in the definitions file");
                else
                    event.getBot().sendIRC().notice(event.getUser().getNick(),
                            "SOMETHING BROKE: FILE NOT UPDATED");

            }
        } else
            event.getBot().sendIRC().notice(event.getUser().getNick(),
                    "You do not have access to this function");
    }
}

From source file:org.kuali.rice.kew.docsearch.SearchableAttributeStringValue.java

@Override
public Boolean isRangeValid(String lowerValue, String upperValue, boolean caseSensitive) {
    if (allowsRangeSearches()) {
        return StringUtils.isBlank(lowerValue) || StringUtils.isBlank(upperValue)
                || (caseSensitive ? ObjectUtils.compare(lowerValue, upperValue) <= 0
                        : String.CASE_INSENSITIVE_ORDER.compare(lowerValue, upperValue) <= 0);
    }//w w w  . j  a v  a  2s  .co  m
    return null;
}

From source file:forge.deck.io.OldDeckParser.java

private void convertConstructedAndSealed() {
    boolean allowDeleteUnsupportedConstructed = false;
    final Map<String, Pair<DeckGroup, MutablePair<File, File>>> sealedDecks = new TreeMap<String, Pair<DeckGroup, MutablePair<File, File>>>(
            String.CASE_INSENSITIVE_ORDER);

    for (final File f : this.deckDir.listFiles(DeckStorage.DCK_FILE_FILTER)) {
        boolean importedOk = false;

        final List<String> fileLines = FileUtil.readFile(f);
        final Map<String, List<String>> sections = FileSection.parseSections(fileLines);
        final DeckFileHeader dh = DeckSerializer.readDeckMetadata(sections);
        String name = dh.getName();

        if (dh.isCustomPool()) {
            try {
                this.cube.add(DeckSerializer.fromSections(sections));
                importedOk = true;//from www  .j av  a2s.c  o  m
            } catch (final NoSuchElementException ex) {
                if (!allowDeleteUnsupportedConstructed) {
                    final String msg = String.format(
                            "Can not convert deck '%s' for some unsupported cards it contains. %n%s%n%nMay Forge delete all such decks?",
                            name, ex.getMessage());
                    allowDeleteUnsupportedConstructed = SOptionPane.showConfirmDialog(msg,
                            "Problem converting decks");
                }
            }
            if (importedOk || allowDeleteUnsupportedConstructed) {
                f.delete();
            }
            continue;
        }

        switch (dh.getDeckType()) {
        case Constructed:
            try {
                this.constructed.add(DeckSerializer.fromSections(sections));
                importedOk = true;
            } catch (final NoSuchElementException ex) {
                if (!allowDeleteUnsupportedConstructed) {
                    final String msg = String.format(
                            "Can not convert deck '%s' for some unsupported cards it contains. %n%s%n%nMay Forge delete all such decks?",
                            name, ex.getMessage());
                    allowDeleteUnsupportedConstructed = SOptionPane.showConfirmDialog(msg,
                            "Problem converting decks");
                }
            }
            if (importedOk || allowDeleteUnsupportedConstructed) {
                f.delete();
            }
            break;

        case Limited:
            name = name.startsWith("AI_") ? name.replace("AI_", "") : name;

            Pair<DeckGroup, MutablePair<File, File>> stored = sealedDecks.get(name);
            if (null == stored) {
                stored = ImmutablePair.of(new DeckGroup(name), MutablePair.of((File) null, (File) null));
            }

            final Deck deck = DeckSerializer.fromSections(sections);
            if (dh.isIntendedForAi()) {
                stored.getLeft().addAiDeck(deck);
                stored.getRight().setRight(f);
            } else {
                stored.getLeft().setHumanDeck(deck);
                stored.getRight().setLeft(f);
            }

            if ((stored.getLeft().getHumanDeck() != null) && !stored.getLeft().getAiDecks().isEmpty()) {
                // have both parts of sealed deck, may convert
                this.sealed.add(stored.getLeft());
                stored.getRight().getLeft().delete();
                stored.getRight().getRight().delete();

                // there stay only orphans
                sealedDecks.remove(name);
            } else {
                sealedDecks.put(name, stored);
            }
            break;
        default:
            break;
        }
    }

    // advise to kill orphaned decks
    if (!sealedDecks.isEmpty()) {
        final StringBuilder sb = new StringBuilder();
        for (final Pair<DeckGroup, MutablePair<File, File>> s : sealedDecks.values()) {
            final String missingPart = s.getRight().getLeft() == null ? "human" : "computer";
            sb.append(String.format("Sealed deck '%s' has no matching '%s' deck.%n", s.getKey().getName(),
                    missingPart));
        }
        sb.append(System.getProperty("line.separator"));
        sb.append("May Forge delete these decks?");
        if (SOptionPane.showConfirmDialog(sb.toString(), "Some of your sealed decks are orphaned")) {
            for (final Pair<DeckGroup, MutablePair<File, File>> s : sealedDecks.values()) {
                if (s.getRight().getLeft() != null) {
                    s.getRight().getLeft().delete();
                }
                if (s.getRight().getRight() != null) {
                    s.getRight().getRight().delete();
                }
            }
        }
    }
}

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

private void init(LoggingConfigurationType config) {
    if (config == null) {
        return;/*w ww. j av  a 2s .  co  m*/
    }
    rootLevel = config.getRootLoggerLevel();
    rootAppender = config.getRootLoggerAppender();

    for (SubSystemLoggerConfigurationType logger : config.getSubSystemLogger()) {
        filters.add(new FilterConfiguration(logger));
    }

    AuditingConfigurationType auditing = config.getAuditing();
    if (auditing != null) {
        setAuditLog(auditing.isEnabled());
        setAuditDetails(auditing.isDetails());
        setAuditAppender(auditing.getAppender() != null && auditing.getAppender().size() > 0
                ? auditing.getAppender().get(0)
                : null);
    }

    for (ClassLoggerConfigurationType logger : config.getClassLogger()) {

        if (ProfilingDto.LOGGER_PROFILING.equals(logger.getPackage())) {
            continue;
        }
        if (componentMap.containsKey(logger.getPackage())) {
            loggers.add(new ComponentLogger(logger));
        } else if (StandardLogger.isStandardLogger(logger.getPackage())) {
            loggers.add(new StandardLogger(logger));
        } else {
            loggers.add(new ClassLogger(logger));
        }
    }

    Collections.sort(loggers, new Comparator<LoggerConfiguration>() {

        @Override
        public int compare(LoggerConfiguration l1, LoggerConfiguration l2) {
            return String.CASE_INSENSITIVE_ORDER.compare(l1.getName(), l2.getName());
        }
    });
    Collections.sort(filters, new Comparator<FilterConfiguration>() {

        @Override
        public int compare(FilterConfiguration f1, FilterConfiguration f2) {
            return String.CASE_INSENSITIVE_ORDER.compare(f1.getName(), f2.getName());
        }
    });
}

From source file:org.eclipse.sw360.licenseinfo.outputGenerators.OutputGenerator.java

@NotNull
protected static List<LicenseNameWithText> getSortedLicenseNameWithTexts(
        Collection<LicenseInfoParsingResult> projectLicenseInfoResults) {
    Set<LicenseNameWithText> licenseNamesWithText = projectLicenseInfoResults.stream()
            .map(LicenseInfoParsingResult::getLicenseInfo).filter(Objects::nonNull)
            .map(LicenseInfo::getLicenseNamesWithTexts).filter(Objects::nonNull).reduce(Sets::union)
            .orElse(Collections.emptySet());

    return licenseNamesWithText.stream()
            .filter(licenseNameWithText -> !LicenseNameWithTextUtils.isEmpty(licenseNameWithText))
            .sorted(Comparator.comparing(LicenseNameWithText::getLicenseName, String.CASE_INSENSITIVE_ORDER))
            .collect(Collectors.toList());
}

From source file:de.tor.tribes.util.VillageUtils.java

public static String[] getContinents(Village[] pVillages) {
    List<String> continents = new ArrayList<>();

    for (Village v : pVillages) {
        int cont = v.getContinent();
        String sCont = "K" + ((cont < 10) ? "0" + cont : cont);
        if (!continents.contains(sCont)) {
            continents.add(sCont);/*from  ww w.j  a  v a  2  s .c o  m*/
        }
    }
    Collections.sort(continents, String.CASE_INSENSITIVE_ORDER);
    return continents.toArray(new String[continents.size()]);
}

From source file:org.eclipse.mylyn.internal.bugzilla.core.RepositoryConfiguration.java

/**
 * Returns an array of names of current products.
 *//*from  ww  w  .  j a v  a2  s.  co m*/
public List<String> getProducts() {
    ArrayList<String> productList = new ArrayList<String>(products.keySet());
    Collections.sort(productList, String.CASE_INSENSITIVE_ORDER);
    return productList;
}