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.repo.sql.SqlRepositoryServiceImpl.java

@Override
public RepositoryDiag getRepositoryDiag() {
    LOGGER.debug("Getting repository diagnostics.");

    RepositoryDiag diag = new RepositoryDiag();
    diag.setImplementationShortName(IMPLEMENTATION_SHORT_NAME);
    diag.setImplementationDescription(IMPLEMENTATION_DESCRIPTION);

    SqlRepositoryConfiguration config = getConfiguration();

    //todo improve, find and use real values (which are used by sessionFactory) MID-1219
    diag.setDriverShortName(config.getDriverClassName());
    diag.setRepositoryUrl(config.getJdbcUrl());
    diag.setEmbedded(config.isEmbedded());

    Enumeration<Driver> drivers = DriverManager.getDrivers();
    while ((drivers != null && drivers.hasMoreElements())) {
        Driver driver = drivers.nextElement();
        if (!driver.getClass().getName().equals(config.getDriverClassName())) {
            continue;
        }/*from w w  w.j a  va  2 s  .co m*/

        diag.setDriverVersion(driver.getMajorVersion() + "." + driver.getMinorVersion());
    }

    List<LabeledString> details = new ArrayList<>();
    diag.setAdditionalDetails(details);
    details.add(new LabeledString(DETAILS_DATA_SOURCE, config.getDataSource()));
    details.add(new LabeledString(DETAILS_HIBERNATE_DIALECT, config.getHibernateDialect()));
    details.add(new LabeledString(DETAILS_HIBERNATE_HBM_2_DDL, config.getHibernateHbm2ddl()));

    readDetailsFromConnection(diag, config);

    Collections.sort(details, new Comparator<LabeledString>() {

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

    return diag;
}

From source file:com.eucalyptus.ws.util.HmacUtils.java

public static String makeSubjectString(final Map<String, String> parameters) {
    String paramString = "";
    Set<String> sortedKeys = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
    sortedKeys.addAll(parameters.keySet());
    for (String key : sortedKeys)
        paramString = paramString.concat(key).concat(parameters.get(key).replaceAll("\\+", " "));
    try {/*w w  w.  j  a  va  2 s .  c  om*/
        return new String(URLCodec.decodeUrl(paramString.getBytes()));
    } catch (DecoderException e) {
        return paramString;
    }
}

From source file:net.community.chest.gitcloud.facade.frontend.git.GitController.java

private Map<String, String> copyResponseHeadersValues(HttpServletRequest req, HttpMessage response,
        HttpServletResponse rsp) {/*from  ww w  .  j a v  a2 s.  c  o  m*/
    Header[] hdrs = response.getAllHeaders();
    if (ArrayUtils.isEmpty(hdrs)) {
        logger.warn("copyResponseHeadersValues(" + req.getMethod() + ")[" + req.getRequestURI() + "]["
                + req.getQueryString() + "] no headers");
        return Collections.emptyMap();
    }
    Arrays.sort(hdrs, BY_NAME_COMPARATOR);

    // NOTE: map must be case insensitive as per HTTP requirements
    Map<String, String> hdrsMap = new TreeMap<String, String>(String.CASE_INSENSITIVE_ORDER);
    for (Header hdrEntry : hdrs) {
        // TODO add support for multi-valued headers
        String hdrName = ServletUtils.capitalizeHttpHeaderName(hdrEntry.getName()),
                hdrValue = StringUtils.trimToEmpty(hdrEntry.getValue());
        hdrsMap.put(hdrName, hdrValue);
        if (FILTERED_RESPONSE_HEADERS.contains(hdrName)) {
            if (logger.isTraceEnabled()) {
                logger.trace("copyResponseHeadersValues(" + req.getMethod() + ")[" + req.getRequestURI() + "]["
                        + req.getQueryString() + "]" + " filtered " + hdrName + ": " + hdrValue);
            }
            continue;
        }

        if (StringUtils.isEmpty(hdrValue)) {
            logger.warn("copyResponseHeadersValues(" + req.getMethod() + ")[" + req.getRequestURI() + "]["
                    + req.getQueryString() + "]" + " no value for header " + hdrName);
            rsp.setHeader(hdrName, "");
            continue;
        }

        if (logger.isTraceEnabled()) {
            logger.trace("copyResponseHeadersValues(" + req.getMethod() + ")[" + req.getRequestURI() + "]["
                    + req.getQueryString() + "]" + " " + hdrName + ": " + hdrValue);
        }

        rsp.setHeader(hdrName, hdrValue);
    }

    return hdrsMap;
}

From source file:org.sleuthkit.autopsy.experimental.autoingest.FileExporterSettingsPanel.java

/**
 * Populate the Artifact types in the combo box.
 *//* w ww  .j  av a 2  s.  c o  m*/
void populateArtifacts() {
    Set<String> artifactTypes = scanRulesForArtifacts();
    try {
        SleuthkitCase currentCase = Case.getCurrentCase().getSleuthkitCase();
        for (BlackboardArtifact.Type type : currentCase.getArtifactTypes()) {
            artifactTypes.add(type.getTypeName());
        }
    } catch (IllegalStateException | TskCoreException ex) {
        // Unable to find and open case or cannot read the database. Use enum.
        for (BlackboardArtifact.ARTIFACT_TYPE artifact : BlackboardArtifact.ARTIFACT_TYPE.values()) {
            artifactTypes.add(artifact.toString());
        }
    }
    List<String> sorted = new ArrayList<>(artifactTypes);
    Collections.sort(sorted, String.CASE_INSENSITIVE_ORDER);
    for (String artifact : sorted) {
        comboBoxArtifactName.addItem(artifact);
    }
}

From source file:org.intermine.web.logic.results.ReportObject.java

/**
 * Resolve a Reference, part of initialise()
 * @param fd FieldDescriptor// w  ww .ja  v  a  2  s  . c o m
 */
private void initialiseReference(FieldDescriptor fd) {
    long startTime = System.currentTimeMillis();
    // bag
    references = (references != null) ? references
            : new TreeMap<String, DisplayReference>(String.CASE_INSENSITIVE_ORDER);

    ReferenceDescriptor ref = (ReferenceDescriptor) fd;

    String refName = ref.getName();
    // do not bother with 'em if they WILL be size 0
    if (!nullRefsCols.contains(refName)) {
        // check whether reference is null without dereferencing
        Object proxyObject = null;
        ProxyReference proxy = null;
        try {
            proxyObject = object.getFieldProxy(refName);
        } catch (IllegalAccessException e1) {
            e1.printStackTrace();
        }
        if (proxyObject instanceof org.intermine.objectstore.proxy.ProxyReference) {
            proxy = (ProxyReference) proxyObject;
        } else {
            // no go on objects that are not Proxies, ie Tests
        }
        DisplayReference newReference = null;
        try {
            newReference = new DisplayReference(proxy, ref, webConfig, im.getClassKeys(), objectType);
        } catch (Exception e) {
            e.printStackTrace();
        }

        if (newReference != null) {
            references.put(refName, newReference);
        }
    }
    long endTime = System.currentTimeMillis();
    LOG.info("TIME initialiseReference " + fd.getName() + " took: " + (endTime - startTime) + "ms");
}

From source file:com.microsoft.windowsazure.mobileservices.sdk.testapp.test.SystemPropertiesTests.java

private void updateDoesNotRemovePropertyWhenIdIsString(final String property) throws Throwable {

    final String tableName = "MyTableName";

    final String jsonTestSystemProperty = property.replace("\\", "\\\\").replace("\"", "\\\"");
    final String responseContent = "{\"id\":\"an id\",\"String\":\"Hey\"}";

    MobileServiceClient client = null;/*from w w w  .j a va2s.c  o  m*/

    try {
        client = new MobileServiceClient(appUrl, appKey, getInstrumentation().getTargetContext());
    } catch (MalformedURLException e) {
        e.printStackTrace();
    }

    // Add a filter to handle the request and create a new json
    // object with an id defined
    client = client.withFilter(getTestFilter(responseContent));

    client = client.withFilter(new ServiceFilter() {
        @Override
        public ListenableFuture<ServiceFilterResponse> handleRequest(ServiceFilterRequest request,
                NextServiceFilterCallback nextServiceFilterCallback) {
            String content = request.getContent();
            JsonObject obj = new JsonParser().parse(content).getAsJsonObject();

            Map<String, JsonElement> properties = new TreeMap<String, JsonElement>(
                    String.CASE_INSENSITIVE_ORDER);

            for (Entry<String, JsonElement> entry : obj.entrySet()) {
                properties.put(entry.getKey(), entry.getValue());
            }

            assertTrue(properties.containsKey("id"));
            assertTrue(properties.containsKey("String"));
            assertTrue(properties.containsKey(property));

            return nextServiceFilterCallback.onNext(request);
        }
    });

    // Create get the MobileService table
    MobileServiceJsonTable msTable = client.getTable(tableName);

    JsonObject obj = new JsonParser()
            .parse("{\"id\":\"an id\",\"String\":\"what\",\"" + jsonTestSystemProperty + "\":\"a value\"}")
            .getAsJsonObject();

    try {
        // Call the update method
        JsonObject jsonObject = msTable.update(obj).get();

        // Asserts
        if (jsonObject == null) {
            fail("Expected result");
        }

    } catch (Exception exception) {
        fail(exception.getMessage());
    }
}

From source file:forge.gui.ImportSourceAnalyzer.java

private void analyzeSimpleListedDir(final File root, final String listFile, final String targetDir,
        final OpType opType) {
    if (!fileNameDb.containsKey(listFile)) {
        final Map<String, String> fileNames = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
        for (final Pair<String, String> nameurl : FileUtil.readNameUrlFile(listFile)) {
            // we use a map instead of a set since we need to match case-insensitively but still map to the correct case
            fileNames.put(nameurl.getLeft(), nameurl.getLeft());
        }//  w  ww  .  j  a va2 s .  c o m
        fileNameDb.put(listFile, fileNames);
    }

    final Map<String, String> fileDb = fileNameDb.get(listFile);
    analyzeListedDir(root, targetDir, new ListedAnalyzer() {
        @Override
        public String map(final String filename) {
            return fileDb.containsKey(filename) ? fileDb.get(filename) : null;
        }

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

From source file:rapture.repo.jdbc.JDBCStructuredStore.java

private List<Map<String, Object>> getCursorResult(String cursorId, int count, boolean isForward) {
    ResultSet rs = cache.getCursor(cursorId);
    if (rs == null) {
        throw RaptureExceptionFactory.create(
                String.format("Invalid cursorId [%s] provided.  No existing cursor in cache.", cursorId));
    }//from w ww  .  jav  a 2 s  .c o  m
    try {
        int currentCount = 0;
        ResultSetMetaData rsmd = rs.getMetaData();
        int numColumns = rsmd.getColumnCount();
        List<Map<String, Object>> ret = new ArrayList<>();
        while (currentCount++ < count && !rs.isClosed() && (isForward ? rs.next() : rs.previous())) {
            Map<String, Object> row = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
            for (int i = 1; i <= numColumns; i++) {
                row.put(rsmd.getColumnLabel(i), rs.getObject(i));
            }
            ret.add(row);
        }
        return ret.isEmpty() ? null : ret;
    } catch (SQLException e) {
        log.error(ExceptionToString.format(e));
        throw RaptureExceptionFactory
                .create(String.format("SQL Exception while traversing ResultSet: [%s]", e.getMessage()));
    }
}

From source file:com.amazonservices.mws.sellers.MarketplaceWebServiceSellersClient.java

/**
 * Calculate String to Sign for SignatureVersion 1
 * //from  w  ww .  j ava  2  s  .  com
 * @param parameters
 *            request parameters
 * @return String to Sign
 * @throws java.security.SignatureException
 */
@SuppressWarnings("rawtypes")
private String calculateStringToSignV1(Map<String, String> parameters) {
    StringBuilder data = new StringBuilder();
    Map<String, String> sorted = new TreeMap<String, String>(String.CASE_INSENSITIVE_ORDER);
    sorted.putAll(parameters);
    Iterator pairs = sorted.entrySet().iterator();
    while (pairs.hasNext()) {
        Map.Entry pair = (Map.Entry) pairs.next();
        data.append(pair.getKey());
        data.append(pair.getValue());
    }
    return data.toString();
}

From source file:org.intermine.web.logic.results.ReportObject.java

/**
 * Resolve a Collection, part of initialise()
 * @param fd FieldDescriptor//from  ww w  .  jav  a 2 s  .c om
 */
private void initialiseCollection(FieldDescriptor fd) {
    long startTime = System.currentTimeMillis();
    // bag
    collections = (collections != null) ? collections
            : new TreeMap<String, DisplayCollection>(String.CASE_INSENSITIVE_ORDER);

    String colName = fd.getName();
    // do not bother with 'em if they WILL be size 0
    if (!nullRefsCols.contains(colName)) {
        Object fieldValue = null;
        try {
            fieldValue = object.getFieldValue(colName);
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }

        long queryStartTime = System.currentTimeMillis();
        // determine the types in the collection
        List<Class<?>> listOfTypes = PathQueryResultHelper.queryForTypesInCollection(object, colName,
                im.getObjectStore());
        long queryTime = System.currentTimeMillis() - queryStartTime;
        LOG.info("TIME - query for types in collection: " + colName + " took: " + queryTime);

        DisplayCollection newCollection = null;
        try {
            newCollection = new DisplayCollection((Collection<?>) fieldValue, (CollectionDescriptor) fd,
                    webConfig, webProperties, im.getClassKeys(), listOfTypes, objectType);
        } catch (Exception e) {
            e.printStackTrace();
        }

        if (newCollection != null) {
            collections.put(colName, newCollection);
        }
    }
    long endTime = System.currentTimeMillis();
    LOG.info("TIME initialiseCollection " + fd.getName() + " took: " + (endTime - startTime) + "ms");
}