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.amazonaws.serverless.proxy.internal.servlet.AwsProxyHttpServletRequest.java

private Map<String, Part> getMultipartFormParametersMap() {
    if (!ServletFileUpload.isMultipartContent(this)) { // isMultipartContent also checks the content type
        return new HashMap<>();
    }/*from   ww w .j  ava 2s  .  c om*/

    Map<String, Part> output = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);

    ServletFileUpload upload = new ServletFileUpload();
    try {
        List<FileItem> items = upload.parseRequest(this);
        for (FileItem item : items) {
            AwsProxyRequestPart newPart = new AwsProxyRequestPart(item.get());
            newPart.setName(item.getName());
            newPart.setSubmittedFileName(item.getFieldName());
            newPart.setContentType(item.getContentType());
            newPart.setSize(item.getSize());

            Iterator<String> headerNamesIterator = item.getHeaders().getHeaderNames();
            while (headerNamesIterator.hasNext()) {
                String headerName = headerNamesIterator.next();
                Iterator<String> headerValuesIterator = item.getHeaders().getHeaders(headerName);
                while (headerValuesIterator.hasNext()) {
                    newPart.addHeader(headerName, headerValuesIterator.next());
                }
            }

            output.put(item.getFieldName(), newPart);
        }
    } catch (FileUploadException e) {
        // TODO: Should we swallaw this?
        e.printStackTrace();
    }
    return output;
}

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

private Object findInternalId(final String id) {
    List<?> candidates = jdbcAccessor.query(
            "SELECT " + INTERNAL_ID_COL + " FROM " + IDENTIFIED_ENTITIES_TABLE + " WHERE " + ENTITY_TYPE_COL
                    + " = :" + ENTITY_TYPE_COL + " AND " + ENTITY_ID_COL + " =:" + ENTITY_ID_COL,
            new TreeMap<String, String>(String.CASE_INSENSITIVE_ORDER) {
                private static final long serialVersionUID = 1L;

                {/*from   w ww .j a  va 2  s  . c o m*/
                    put(ENTITY_TYPE_COL, getEntityClass().getSimpleName());
                    put(ENTITY_ID_COL, id);
                }
            }, JdbcOperationsUtils.AS_OBJECT_MAPPER);
    if (ExtendedCollectionUtils.isEmpty(candidates)) {
        return null;
    }

    if (candidates.size() != 1) {
        throw new IllegalStateException("findInternalId(" + getEntityClass().getSimpleName() + ")[" + id
                + "] multiple matches: " + candidates);
    }

    Object internalId = candidates.get(0);
    if (internalId == null) {
        throw new IllegalStateException(
                "findInternalId(" + getEntityClass().getSimpleName() + ")[" + id + "] null/empty internal ID");
    }

    return internalId;
}

From source file:com.bristle.javalib.io.FileUtil.java

/**************************************************************************
* Returns a sorted array of Strings naming the files and directories in
* the specified directory./*from  ww  w.j  av a2s . co  m*/
*@param  directory  The directory to search
*@return            Sorted array of file and directories in the directory.
**************************************************************************/
public static String[] getSortedNames(File directory) {
    String[] arrNames = directory.list();
    if (arrNames != null) {
        Arrays.sort(arrNames, String.CASE_INSENSITIVE_ORDER);
    }
    return arrNames;
}

From source file:org.apache.shindig.gadgets.http.HttpResponse.java

public static Multimap<String, String> newHeaderMultimap() {
    TreeMap<String, Collection<String>> map = Maps.newTreeMap(String.CASE_INSENSITIVE_ORDER);
    return Multimaps.newMultimap(map, HEADER_COLLECTION_SUPPLIER);
}

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

private void updateRemovesPropertyWhenIdIsString(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;/* w w w  . j  a va2 s. 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"));
            assertFalse(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:com.amazonaws.serverless.proxy.internal.servlet.AwsProxyHttpServletRequest.java

private Map<String, List<String>> getFormUrlEncodedParametersMap() {
    String contentType = getContentType();
    if (contentType == null) {
        return new HashMap<>();
    }//from w w w. j a  v a2s . c o  m
    if (!contentType.startsWith(MediaType.APPLICATION_FORM_URLENCODED)
            || !getMethod().toLowerCase().equals("post")) {
        return new HashMap<>();
    }
    String rawBodyContent;
    try {
        rawBodyContent = URLDecoder.decode(request.getBody(), DEFAULT_CHARACTER_ENCODING);
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
        rawBodyContent = request.getBody();
    }

    Map<String, List<String>> output = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
    for (String parameter : rawBodyContent.split(FORM_DATA_SEPARATOR)) {
        String[] parameterKeyValue = parameter.split(HEADER_KEY_VALUE_SEPARATOR);
        if (parameterKeyValue.length < 2) {
            continue;
        }
        List<String> values = new ArrayList<>();
        if (output.containsKey(parameterKeyValue[0])) {
            values = output.get(parameterKeyValue[0]);
        }
        values.add(parameterKeyValue[1]);
        output.put(parameterKeyValue[0], values);
    }

    return output;
}

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

/**
 * Resolve an attribute, part of initialise()
 * @param fd FieldDescriptor//from   w  ww .ja v  a 2s  . co  m
 */
private void initialiseAttribute(FieldDescriptor fd) {
    long startTime = System.currentTimeMillis();
    // bags
    attributes = (attributes != null) ? attributes : new TreeMap<String, Object>(String.CASE_INSENSITIVE_ORDER);
    attributeDescriptors = (attributeDescriptors != null) ? attributeDescriptors
            : new HashMap<String, FieldDescriptor>();

    Object fieldValue = null;
    try {
        fieldValue = object.getFieldValue(fd.getName());
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    }
    if (fieldValue != null) {
        if (fieldValue instanceof ClobAccess) {
            ClobAccess fieldClob = (ClobAccess) fieldValue;
            if (fieldClob.length() > 200) {
                fieldValue = fieldClob.subSequence(0, 200).toString();
            } else {
                fieldValue = fieldClob.toString();
            }
        }

        attributes.put(fd.getName(), fieldValue);
        attributeDescriptors.put(fd.getName(), fd);
    }
    long endTime = System.currentTimeMillis();
    LOG.info("TIME initialiseAttribute " + fd.getName() + " took: " + (endTime - startTime) + "ms");
}

From source file:org.apache.jsp.fileUploader_jsp.java

private String populateMediaTypes(HttpServletRequest request, HttpServletResponse response) {
    String toReturn = "<option> See All </option>";
    String delim = "$$$";
    String json = stringOfUrl(API_ROOT + "social/share/search/", request, response);
    String ext = null;/* w w  w  .j  a va2 s .  c o  m*/
    Object o = request.getParameter("ext");
    if (null != o) {
        ext = o.toString();
    }

    if (json != null) {
        getShare gs = new Gson().fromJson(json, getShare.class);
        if (gs != null && gs.data != null) {
            Set<String> set = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
            for (shareData info : gs.data) {
                if ((showAll == false) && (info.owner != null) && (info.owner.email != null)
                        && !user.equalsIgnoreCase(info.owner.email)) {
                    continue;
                }
                if (info.mediaType != null && !set.contains(info.mediaType)) {
                    set.add(info.mediaType);
                }
                if (info.type != null && !set.contains(info.type)) {
                    set.add("type:" + info.type);
                }
            }

            for (String mt : set) {
                String selected_text = "";
                if ((null != ext) && mt.equalsIgnoreCase(ext)) {
                    selected_text = "selected";
                }

                toReturn += "<option " + selected_text + " value=\"" + mt + "\" > " + mt + "</option>";
            }

        }
    }
    return toReturn;
}

From source file:org.apache.kylin.cube.model.CubeDesc.java

public void validateAggregationGroups() {
    int index = 0;

    for (AggregationGroup agg : getAggregationGroups()) {
        if (agg.getIncludes() == null) {
            logger.error("Aggregation group " + index + " 'includes' field not set");
            throw new IllegalStateException("Aggregation group " + index + " includes field not set");
        }//ww w .  jav  a 2 s . c  o  m

        if (agg.getSelectRule() == null) {
            logger.error("Aggregation group " + index + " 'select_rule' field not set");
            throw new IllegalStateException("Aggregation group " + index + " select rule field not set");
        }

        Set<String> includeDims = new TreeSet<>(String.CASE_INSENSITIVE_ORDER);
        getDims(includeDims, agg.getIncludes());

        Set<String> mandatoryDims = new TreeSet<>(String.CASE_INSENSITIVE_ORDER);
        getDims(mandatoryDims, agg.getSelectRule().mandatoryDims);

        ArrayList<Set<String>> hierarchyDimsList = Lists.newArrayList();
        Set<String> hierarchyDims = new TreeSet<>(String.CASE_INSENSITIVE_ORDER);
        getDims(hierarchyDimsList, hierarchyDims, agg.getSelectRule().hierarchyDims);

        ArrayList<Set<String>> jointDimsList = Lists.newArrayList();
        Set<String> jointDims = new TreeSet<>(String.CASE_INSENSITIVE_ORDER);
        getDims(jointDimsList, jointDims, agg.getSelectRule().jointDims);

        if (!includeDims.containsAll(mandatoryDims) || !includeDims.containsAll(hierarchyDims)
                || !includeDims.containsAll(jointDims)) {
            List<String> notIncluded = Lists.newArrayList();
            final Iterable<String> all = Iterables
                    .unmodifiableIterable(Iterables.concat(mandatoryDims, hierarchyDims, jointDims));
            for (String dim : all) {
                if (includeDims.contains(dim) == false) {
                    notIncluded.add(dim);
                }
            }
            Collections.sort(notIncluded);
            logger.error("Aggregation group " + index
                    + " Include dimensions not containing all the used dimensions");
            throw new IllegalStateException("Aggregation group " + index
                    + " 'includes' dimensions not include all the dimensions:" + notIncluded.toString());
        }

        if (CollectionUtils.containsAny(mandatoryDims, hierarchyDims)) {
            logger.warn(
                    "Aggregation group " + index + " mandatory dimensions overlap with hierarchy dimensions: "
                            + ensureOrder(CollectionUtils.intersection(mandatoryDims, hierarchyDims)));
        }
        if (CollectionUtils.containsAny(mandatoryDims, jointDims)) {
            logger.warn("Aggregation group " + index + " mandatory dimensions overlap with joint dimensions: "
                    + ensureOrder(CollectionUtils.intersection(mandatoryDims, jointDims)));
        }

        if (CollectionUtils.containsAny(hierarchyDims, jointDims)) {
            logger.error("Aggregation group " + index + " hierarchy dimensions overlap with joint dimensions");
            throw new IllegalStateException(
                    "Aggregation group " + index + " hierarchy dimensions overlap with joint dimensions: "
                            + ensureOrder(CollectionUtils.intersection(hierarchyDims, jointDims)));
        }

        if (hasSingleOrNone(hierarchyDimsList)) {
            logger.error("Aggregation group " + index + " require at least 2 dimensions in a hierarchy");
            throw new IllegalStateException(
                    "Aggregation group " + index + " require at least 2 dimensions in a hierarchy.");
        }
        if (hasSingleOrNone(jointDimsList)) {
            logger.error("Aggregation group " + index + " require at least 2 dimensions in a joint");
            throw new IllegalStateException(
                    "Aggregation group " + index + " require at least 2 dimensions in a joint");
        }

        Pair<Boolean, Set<String>> overlap = hasOverlap(hierarchyDimsList, hierarchyDims);
        if (overlap.getFirst() == true) {
            logger.error("Aggregation group " + index + " a dimension exist in more than one hierarchy: "
                    + ensureOrder(overlap.getSecond()));
            throw new IllegalStateException("Aggregation group " + index
                    + " a dimension exist in more than one hierarchy: " + ensureOrder(overlap.getSecond()));
        }

        overlap = hasOverlap(jointDimsList, jointDims);
        if (overlap.getFirst() == true) {
            logger.error("Aggregation group " + index + " a dimension exist in more than one joint: "
                    + ensureOrder(overlap.getSecond()));
            throw new IllegalStateException("Aggregation group " + index
                    + " a dimension exist in more than one joint: " + ensureOrder(overlap.getSecond()));
        }

        index++;
    }
}

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

/**
 * Populate the MIME types in the combo box.
 *///  www. ja  v a 2  s. c o m
void populateMimeTypes() {
    Set<String> mimeTypesCollated = scanRulesForMimetypes();
    for (MediaType mediaType : mediaTypes) {
        mimeTypesCollated.add(mediaType.toString());
    }

    FileTypeDetector fileTypeDetector;
    try {
        fileTypeDetector = new FileTypeDetector();
        List<String> userDefinedFileTypes = fileTypeDetector.getUserDefinedTypes();
        mimeTypesCollated.addAll(userDefinedFileTypes);

    } catch (FileTypeDetector.FileTypeDetectorInitException ex) {
        logger.log(Level.SEVERE, "Unable to get user defined file types", ex);
    }
    List<String> sorted = new ArrayList<>(mimeTypesCollated);
    Collections.sort(sorted, String.CASE_INSENSITIVE_ORDER);
    for (String mime : sorted) {
        comboBoxMimeValue.addItem(mime);
    }
}