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.evolveum.midpoint.web.page.admin.users.component.OrgMemberPanel.java

@Override
protected void initSearch(Form form) {

    /// TODO: move to utils class??
    List<ObjectTypes> objectTypes = new ArrayList<>(Arrays.asList(ObjectTypes.values()));
    //fix for MID-3629 (we don't know the resource to search shadows on)
    objectTypes.remove(ObjectTypes.SHADOW);
    Collections.sort(objectTypes, new Comparator<ObjectTypes>() {

        @Override//from w w  w. jav  a2 s.c o m
        public int compare(ObjectTypes o1, ObjectTypes o2) {
            Validate.notNull(o1);
            Validate.notNull(o2);

            String type1 = o1.getValue();
            String type2 = o2.getValue();

            return String.CASE_INSENSITIVE_ORDER.compare(type1, type2);

        }
    });

    DropDownChoice<ObjectTypes> objectType = new DropDownChoice<>(ID_SEARCH_BY_TYPE,
            Model.of(OBJECT_TYPES_DEFAULT), objectTypes, new EnumChoiceRenderer<>());
    objectType.add(new OnChangeAjaxBehavior() {
        private static final long serialVersionUID = 1L;

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            refreshSearch();
            refreshTable(target);
        }
    });
    objectType.setOutputMarkupId(true);
    form.add(objectType);

    DropDownChoice<String> seachScrope = new DropDownChoice<>(ID_SEARCH_SCOPE, Model.of(SEARCH_SCOPE_SUBTREE),
            SEARCH_SCOPE_VALUES, new StringResourceChoiceRenderer("TreeTablePanel.search.scope"));
    seachScrope.add(new OnChangeAjaxBehavior() {
        private static final long serialVersionUID = 1L;

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            refreshTable(target);
        }
    });
    seachScrope.setOutputMarkupId(true);
    form.add(seachScrope);

    DropDownChoicePanel<RelationTypes> relationSelector = WebComponentUtil.createEnumPanel(RelationTypes.class,
            ID_SEARCH_BY_RELATION, WebComponentUtil.createReadonlyModelFromEnum(RelationTypes.class),
            new IModel<RelationTypes>() {
                @Override
                public RelationTypes getObject() {
                    return relationValue;
                }

                @Override
                public void setObject(RelationTypes relationTypes) {
                    relationValue = relationTypes;
                }

                @Override
                public void detach() {

                }
            }, this, true, createStringResource("RelationTypes.ANY").getString());

    relationSelector.getBaseFormComponent().add(new EmptyOnChangeAjaxFormUpdatingBehavior());
    relationSelector.setOutputMarkupId(true);
    relationSelector.setOutputMarkupPlaceholderTag(true);
    relationSelector.getBaseFormComponent().add(new OnChangeAjaxBehavior() {
        private static final long serialVersionUID = 1L;

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            refreshTable(target);
        }
    });
    form.add(relationSelector);

}

From source file:com.mirth.connect.client.ui.SettingsPanelMap.java

public void doExportMap() {
    if (isSaveEnabled()) {
        int option = JOptionPane.showConfirmDialog(this, "Would you like to save the settings first?");

        if (option == JOptionPane.YES_OPTION) {
            if (!doSave()) {
                return;
            }//  w w w .j  a  v a 2s.  c o  m
        } else if (option == JOptionPane.CANCEL_OPTION || option == JOptionPane.CLOSED_OPTION) {
            return;
        }
    }

    final String workingId = getFrame().startWorking("Exporting " + getTabName() + " settings...");

    SwingWorker<Void, Void> worker = new SwingWorker<Void, Void>() {

        private Map<String, ConfigurationProperty> configurationMap;

        public Void doInBackground() {
            try {
                File file = getFrame().createFileForExport(null, "PROPERTIES");
                if (file != null) {
                    PropertiesConfiguration properties = new PropertiesConfiguration();
                    properties.setDelimiterParsingDisabled(true);
                    properties.setListDelimiter((char) 0);
                    properties.clear();
                    PropertiesConfigurationLayout layout = properties.getLayout();

                    configurationMap = getFrame().mirthClient.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(file);
                }
            } catch (Exception e) {
                getFrame().alertThrowable(getFrame(), e);
            }

            return null;
        }

        @Override
        public void done() {
            getFrame().stopWorking(workingId);
        }
    };

    worker.execute();
}

From source file:org.eclipse.hudson.plugins.UpdateSiteManager.java

private Map<String, AvailablePluginInfo> parseJson(String jsonString) throws IOException {
    Map<String, AvailablePluginInfo> pluginInfos = new TreeMap<String, AvailablePluginInfo>(
            String.CASE_INSENSITIVE_ORDER);
    try {//from  ww  w  .ja  va  2  s.  c  o  m
        JSONObject jsonObject = JSONObject.fromObject(jsonString);
        for (Map.Entry<String, JSONObject> e : (Set<Map.Entry<String, JSONObject>>) jsonObject
                .getJSONObject("plugins").entrySet()) {
            AvailablePluginInfo pluginInfo = new AvailablePluginInfo(e.getValue());
            if (!"disabled".equals(pluginInfo.getType())) {
                pluginInfos.put(e.getKey(), pluginInfo);
            }
        }
    } catch (Exception exc) {
        System.out.println(jsonString);
        throw new IOException("Incorrect Update Center JSON. " + exc.getLocalizedMessage());
    }
    return pluginInfos;

}

From source file:nz.govt.natlib.adapter.warc.WarcAdapter.java

public void adapt(File file, ParserContext ctx) throws IOException {
    WarcReader warcReader = null;/*from  w ww . ja va2s  . c  o  m*/
    try {
        // Get the reader (either compressed or uncompressed)
        warcReader = getWarcReader(file);
        // Get an iterator over the warc records
        Iterator<WarcRecord> iter = warcReader.iterator();
        // Reference to the first record which is the "archive metadata record"
        WarcMetadata warcMetadata = null;
        // Map to hold the mime type statistics
        HashMap<String, Integer> mimeMap = new HashMap<String, Integer>();
        HashMap<String, Integer> warcTypeMap = new HashMap<String, Integer>();
        // Iterate over the warc records
        try {
            while (iter != null && iter.hasNext()) {
                WarcRecord record = iter.next();
                /*
                 * Get required information from the retrieved WARC record
                 */
                String warcType = getWarcType(record);
                addContentToMap(warcType, warcTypeMap);
                /*
                 * Extract the warc metadata from the warcinfo record. Extract the mime type info from "response" and other
                 * specific types of warc records.
                 */
                if ("warcinfo".equals(warcType) && warcMetadata == null) {
                    // Extract the metadata from this warc record
                    warcMetadata = parseWarcMetadataRecord(record);
                } else if (WARC_TYPES_OF_INTEREST.contains(warcType)) {
                    // Add logic later if we ever need to get metadata out of other
                    // WARC types.
                }
                addMimeTypeToMimeMap(record, mimeMap);
                record.close();
            }
        } catch (Exception ex) {
            System.out.println("Exception while iterating through WARC records: " + ex);
            ex.printStackTrace();
        }

        ctx.fireStartParseEvent("WARC");
        writeFileInfo(file, ctx);

        // Write the <WARCMETADATA> element
        if (warcMetadata != null) {
            ctx.fireStartParseEvent("WARCMETADATA");
            ctx.fireParseEvent("SOFTWARE", warcMetadata.software);
            ctx.fireParseEvent("HOSTNAME", warcMetadata.hostname);
            ctx.fireParseEvent("IP", warcMetadata.ip);
            ctx.fireParseEvent("OPERATOR", warcMetadata.operator);
            ctx.fireParseEvent("CREATEDDATE", warcMetadata.createdDate);
            ctx.fireParseEvent("ROBOTPOLICY", warcMetadata.robotPolicy);
            ctx.fireParseEvent("WARCFORMAT", warcMetadata.warcFormat);
            ctx.fireParseEvent("CONFORMSTO", warcMetadata.conformsTo);
            ctx.fireParseEvent("WARCDATE", warcMetadata.warcDate);
            ctx.fireEndParseEvent("WARCMETADATA");
        }

        // Write the <WARCINFO> element
        ctx.fireStartParseEvent("WARCINFO");
        ctx.fireParseEvent("COMPRESSED", warcReader.isCompressed());

        ctx.fireStartParseEvent("CONTENTSUMMARY");

        if (warcTypeMap.size() > 0) {
            Set<String> keys = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
            keys.addAll(warcTypeMap.keySet());
            Iterator<String> keyIterator = keys.iterator();
            while (keyIterator != null && keyIterator.hasNext()) {
                String warctype = keyIterator.next();
                ctx.fireStartParseEvent("WARCTYPEREPORT");
                ctx.fireParseEvent("WARCTYPE", warctype);
                ctx.fireParseEvent("COUNT", warcTypeMap.get(warctype));
                ctx.fireEndParseEvent("WARCTYPEREPORT");
            }
        }
        if (mimeMap.size() > 0) {
            Set<String> keys = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
            keys.addAll(mimeMap.keySet());
            Iterator<String> keyIterator = keys.iterator();
            StringBuffer mimeSummary = new StringBuffer();
            boolean first = true;
            while (keyIterator != null && keyIterator.hasNext()) {
                String mimetype = (String) keyIterator.next();
                if (first == false) {
                    mimeSummary.append(", ");
                }
                first = false;
                mimeSummary.append(mimetype).append(":").append(mimeMap.get(mimetype));
            }
            ctx.fireParseEvent("MIMEREPORT", mimeSummary.toString());
        }
        ctx.fireEndParseEvent("CONTENTSUMMARY");
        ctx.fireEndParseEvent("WARCINFO");
        ctx.fireEndParseEvent("WARC");
    } catch (Throwable ex) {
        System.out.println("Exception: " + ex);
        ex.printStackTrace();
    } finally {
        if (warcReader != null)
            warcReader.close();
    }
}

From source file:com.foilen.smalltools.spring.messagesource.UsageMonitoringMessageSource.java

private void init() {

    // Check the base folder
    File basenameFile = new File(basename);
    logger.info("Base name is {}", basename);
    File directory = basenameFile.getParentFile();
    logger.info("Base directory is {}", directory.getAbsoluteFile());
    if (!directory.exists()) {
        throw new SmallToolsException("Directory: " + directory.getAbsolutePath() + " does not exists");
    }//ww  w .  j a  v a  2 s . c om

    tmpUsed = new File(directory.getAbsolutePath() + File.separatorChar + "_messages_usage.txt");

    // Check the files in it
    String startswith = basenameFile.getName() + "_";
    String endswith = ".properties";
    for (File file : directory.listFiles(
            (FilenameFilter) (dir, name) -> name.startsWith(startswith) && name.endsWith(endswith))) {
        // Create the locale
        logger.info("Found messages file {}", directory.getAbsoluteFile());
        String filename = file.getName();
        String localePart = filename.substring(startswith.length(), filename.length() - endswith.length());
        Locale locale = new Locale(localePart);
        logger.info("Locale is {} -> {}", localePart, locale);
        filePerLocale.put(locale, file);

        // Load the file
        Properties properties = new Properties();
        try (FileInputStream inputStream = new FileInputStream(file)) {
            properties.load(new InputStreamReader(inputStream, CharsetTools.UTF_8));
        } catch (IOException e) {
            logger.error("Problem reading the property file {}", file.getAbsoluteFile(), e);
            throw new SmallToolsException("Problem reading the file", e);
        }

        // Check codes and save values
        Map<String, String> messages = new HashMap<>();
        messagesPerLocale.put(locale, messages);
        for (Object key : properties.keySet()) {
            String name = (String) key;
            String value = properties.getProperty(name);
            allCodesInFiles.add(name);
            messages.put(name, value);
        }

    }

    // Add missing codes in all the maps (copy one that has it)
    for (Locale locale : filePerLocale.keySet()) {
        Set<String> missingCodes = new HashSet<>();
        Map<String, String> messagesForCurrentLocale = messagesPerLocale.get(locale);

        // Get the ones missing
        missingCodes.addAll(allCodesInFiles);
        missingCodes.removeAll(messagesForCurrentLocale.keySet());

        for (String missingCode : missingCodes) {
            logger.info("Locale {} was missing code {}", locale, missingCode);

            String codeValue = findAnyValue(missingCode);
            messagesForCurrentLocale.put(missingCode, codeValue);
        }
    }

    // Load the already known codes
    if (tmpUsed.exists()) {
        for (String line : FileTools.readFileLinesIteration(tmpUsed.getAbsolutePath())) {
            knownUsedCodes.add(line);
        }
    }

    smoothTrigger = new SmoothTrigger(() -> {

        synchronized (lock) {

            logger.info("Begin saving locale files");

            // Go through each locale
            for (Entry<Locale, File> entry : filePerLocale.entrySet()) {
                Map<String, String> messages = messagesPerLocale.get(entry.getKey());

                try (PrintWriter printWriter = new PrintWriter(entry.getValue(),
                        CharsetTools.UTF_8.toString())) {

                    // Save the known used (sorted) at the top
                    for (String code : knownUsedCodes.stream().sorted(String.CASE_INSENSITIVE_ORDER)
                            .collect(Collectors.toList())) {
                        printWriter.println(code + "=" + messages.get(code));
                    }
                    printWriter.println();

                    // Save the others (sorted) at the bottom
                    Set<String> unknownCodes = new HashSet<>();
                    unknownCodes.addAll(messages.keySet());
                    unknownCodes.removeAll(knownUsedCodes);
                    if (!unknownCodes.isEmpty()) {
                        printWriter.println("# Unknown");
                        printWriter.println();

                        for (String code : unknownCodes.stream().sorted(String.CASE_INSENSITIVE_ORDER)
                                .collect(Collectors.toList())) {
                            printWriter.println(code + "=" + messages.get(code));
                        }
                        printWriter.println();
                    }
                } catch (Exception e) {
                    logger.error("Could not write the file", e);
                }
            }

            // Save the known
            FileTools.writeFile(Joiner.on('\n').join(
                    knownUsedCodes.stream().sorted(String.CASE_INSENSITIVE_ORDER).collect(Collectors.toList())),
                    tmpUsed);

            logger.info("Done saving locale files");
        }

    }) //
            .setDelayAfterLastTriggerMs(5000) //
            .setMaxDelayAfterFirstRequestMs(10000) //
            .setFirstPassThrough(true) //
            .start();

    smoothTrigger.request();
}

From source file:pt.lunacloud.auth.AWS4Signer.java

private String getCanonicalizedHeaderString(Request<?> request) {
    List<String> sortedHeaders = new ArrayList<String>();
    sortedHeaders.addAll(request.getHeaders().keySet());
    Collections.sort(sortedHeaders, String.CASE_INSENSITIVE_ORDER);

    StringBuilder buffer = new StringBuilder();
    for (String header : sortedHeaders) {
        buffer.append(header.toLowerCase().replaceAll("\\s+", " ") + ":"
                + request.getHeaders().get(header).replaceAll("\\s+", " "));
        buffer.append("\n");
    }//  w  w  w.j a v a 2 s .c  o  m

    return buffer.toString();
}

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

/**
 * @param id The entity ID//from  ww w.  jav a2s  . com
 * @return A {@link Pair} whose left hand holds the internal identifier
 * and left hand the properties {@link Map} - <code>null</code> if cannot
 * locate internal identifier value
 */
Pair<Object, Map<String, Serializable>> resolveProperties(String id) {
    Object internalId = findInternalId(id);
    if (internalId == null) {
        return null;
    }

    List<Pair<String, Serializable>> propVals = jdbcAccessor.query(
            "SELECT * FROM " + ENTITY_PROPERTIES_TABLE + " WHERE " + PROP_OWNER_COL + " = :" + INTERNAL_ID_COL,
            Collections.singletonMap(INTERNAL_ID_COL, internalId), valueMapper);
    if (ExtendedCollectionUtils.isEmpty(propVals)) {
        return Pair.of(internalId, Collections.<String, Serializable>emptyMap());
    }

    Map<String, Serializable> propsMap = new TreeMap<String, Serializable>(String.CASE_INSENSITIVE_ORDER);
    for (Pair<String, Serializable> p : propVals) {
        String propName = p.getKey();
        Serializable propValue = p.getValue();
        if (propValue == null) {
            continue; // ignore null(s)
        }

        Serializable prevValue = propsMap.put(propName, propValue);
        if (prevValue != null) {
            throw new IllegalStateException("getProperties(" + getEntityClass().getSimpleName() + ")[" + id
                    + "]" + " multiple values for property=" + propName + ": " + propValue + ", " + prevValue);
        }
    }

    return Pair.of(internalId, propsMap);
}

From source file:com.blackducksoftware.tools.idcopier.service.ProjectService.java

/**
 * Gets the tree with all its paths and pending counts.
 *
 * @param projectID//  www  . j a v  a  2  s . co m
 * @param path
 * @return
 */
public String getProjectCodeTreeNodesWithCount(String projectID, String path) {
    String json = "";

    try {
        int pendingCount = 0;

        CodeTreeNodeRequest ctrRequest = new CodeTreeNodeRequest();
        ctrRequest.setDepth(CodeTreeUtilities.DIRECT_CHILDREN);
        ctrRequest.setIncludeParentNode(false);
        ctrRequest.getIncludedNodeTypes().addAll(CodeTreeUtilities.ALL_CODE_TREE_NODE_TYPES);
        ctrRequest.getCounts().add(NodeCountType.PENDING_ID_ALL);

        List<CodeTreeNode> nodes = proxy.getCodeTreeApi().getCodeTreeNodes(projectID, path, ctrRequest);

        log.debug("Got nodes for '" + path + "' (count: " + nodes.size() + ")");

        List<String> folderNodes = new ArrayList<String>();
        List<String> fileNodes = new ArrayList<String>();

        HashMap<String, CodeTreeNode> folderLookup = new HashMap<String, CodeTreeNode>();
        HashMap<String, CodeTreeNode> fileLookup = new HashMap<String, CodeTreeNode>();

        for (CodeTreeNode codeTreeNode : nodes) {
            String name = codeTreeNode.getName();
            pendingCount += getCounts(codeTreeNode.getNodeCounts());

            if (codeTreeNode.getNodeType() == CodeTreeNodeType.FILE) {
                fileNodes.add(name);
                fileLookup.put(name, codeTreeNode);
            } else {
                folderNodes.add(name);
                folderLookup.put(name, codeTreeNode);
            }
        }

        Collections.sort(folderNodes, String.CASE_INSENSITIVE_ORDER);
        Collections.sort(fileNodes, String.CASE_INSENSITIVE_ORDER);

        List<IDCTree> treeNodes = new ArrayList<IDCTree>();

        CodeTreeNode currentTreeNode;
        String name;
        String filePath;

        for (String currentNodeString : folderNodes) {
            currentTreeNode = folderLookup.get(currentNodeString);
            name = currentTreeNode.getName();
            filePath = name;
            int count = getCounts(currentTreeNode.getNodeCounts());

            treeNodes.add(new IDCTree(filePath, name, true, count));
        }

        for (String currentNodeString : fileNodes) {
            currentTreeNode = fileLookup.get(currentNodeString);
            name = currentTreeNode.getName();
            filePath = name;
            int count = getCounts(currentTreeNode.getNodeCounts());

            treeNodes.add(new IDCTree(filePath, name, false, count));
        }

        Gson gson = new Gson();

        if (path.equals("/")) {
            List<IDCTree> projectNodes = new ArrayList<IDCTree>();

            IDCTree rootNode = new IDCTree("", getProjectName(projectID), true, pendingCount);
            rootNode.setExpand(true);
            rootNode.addChildren(treeNodes);
            projectNodes.add(rootNode);
            json = gson.toJson(projectNodes);
        } else {
            json = gson.toJson(treeNodes);
        }
    } catch (Exception e) {
        // log.error("Could not convert project tree to JSON", e);

        List<IDCTree> projectNodes = new ArrayList<IDCTree>();
        IDCTree rootNode = new IDCTree("", getProjectName(projectID), true, 0);
        projectNodes.add(rootNode);

        return new Gson().toJson(projectNodes);
    }

    return json;
}

From source file:com.opengamma.financial.analytics.ircurve.CurveSpecificationBuilderConfiguration.java

private static List<String> getCurveSpecBuilderConfigurationNames() {
    final List<String> list = new ArrayList<>();
    for (final Field field : CurveSpecificationBuilderConfigurationFudgeBuilder.class.getDeclaredFields()) {
        if (Modifier.isStatic(field.getModifiers()) && field.isSynthetic() == false) {
            field.setAccessible(true);//from ww w  . j a  v  a  2s  . c o  m
            try {
                list.add((String) field.get(null));
            } catch (final Exception ex) {
                // Ignore
            }
        }
    }
    Collections.sort(list, String.CASE_INSENSITIVE_ORDER);
    return ImmutableList.copyOf(list);
}

From source file:com.stimulus.archiva.presentation.ConfigBean.java

public List<String> getFields() {

    ArrayList<String> fieldList = new ArrayList<String>();
    EmailFields emailFields = Config.getConfig().getEmailFields();
    for (EmailField ef : emailFields.getAvailableFields().values()) {
        fieldList.add(ef.getName());/* www  .j  a  va 2 s . c o  m*/
    }
    fieldList.add("all");
    fieldList.add("addresses");
    Collections.sort(fieldList, String.CASE_INSENSITIVE_ORDER);
    return fieldList;
}