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:br.org.indt.ndg.client.Service.java

/**
 * @param username// w w w. j a  v  a2 s.  c  o m
 * @param surveyId
 * @param resultId
 * @return
 * @throws NDGServerException
 */

public ArrayList<SPreview> getPreview(String username, String surveyId, String resultId)
        throws NDGServerException {
    SSurvey survey = this.getSSurvey(username, surveyId, resultId);
    String finalString = "";
    ArrayList<SPreview> list = new ArrayList<SPreview>();

    Set categoryKeys = ((SResult) survey.getResults().get(0)).getCategories().keySet();
    Iterator iCategory = categoryKeys.iterator();
    while (iCategory.hasNext()) {

        SCategory sc = (SCategory) ((SResult) survey.getResults().get(0)).getCategories().get(iCategory.next());
        finalString = "<span id='txt-list-top'><b>" + sc.getId() + " - " + sc.getName().toUpperCase()
                + "</b></span><br>";

        list.add(new SPreview(finalString, false));

        String[] sortedKeys = new String[sc.getSubCategories().keySet().size()];
        sc.getSubCategories().keySet().toArray(sortedKeys);
        java.util.Arrays.sort(sortedKeys, String.CASE_INSENSITIVE_ORDER);

        for (int i = 0; i < sortedKeys.length; i++) {
            String subCatId = sortedKeys[i];
            log.info("SubCategory" + subCatId);
            Vector<SField> fields = sc.getSubCategories().get(subCatId);

            if (sc.getSubCategories().keySet().size() > 1) {
                finalString = "<span id='txt-list-down'><b>" + sc.getId() + "." + subCatId + "</b></span><br>";
                list.add(new SPreview(finalString, false));
            }

            Iterator<SField> iFields = fields.iterator();//sc.getFields().iterator();
            while (iFields.hasNext()) {
                SField sf = (SField) iFields.next();

                if (sc.getSubCategories().keySet().size() > 1) {
                    finalString = "<span id='txt-list-down'><b>" + sc.getId() + "." + subCatId + "."
                            + sf.getId() + " " + sf.getDescription() + "</b></span><br>";
                } else {
                    finalString = "<span id='txt-list-down'><b>" + sc.getId() + "." + sf.getId() + " "
                            + sf.getDescription() + "</b></span><br>";
                }

                list.add(new SPreview(finalString, false));

                if (survey.getResultsSize() > 0) {
                    SResult r = (SResult) survey.getResults().get(0);
                    SCategory rc = (SCategory) r.getCategories().get(sc.getId());

                    SField rf = rc.getField(subCatId, sf.getId());
                    String value = "----";
                    if (rf.getValue() != null && !rf.getValue().trim().equals("")) {
                        value = rf.getValue();
                    }

                    if (sf.getElementName() != null) {
                        if (!sf.getElementName().equals("img_data")) {
                            value = value.trim().replaceAll("\n", "");
                            finalString = "<span id = 'txt-list-answer'><i>" + value + "</i></span><br>";

                            list.add(new SPreview(finalString, false));
                        } else {

                            for (TaggedImage taggedImage : rf.getImages()) {
                                // TODO add GeoTagging preview
                                String imageString = taggedImage.getImageData();
                                finalString = imageString.trim();
                                list.add(new SPreview(finalString, true));
                            }
                        }
                    }
                }
            }
            finalString = "<br>";
            list.add(new SPreview(finalString, false));
        }
        finalString = "<br>";
        list.add(new SPreview(finalString, false));
    }
    return list;
}

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

/**
 * Populate the Attribute types in the combo box.
 *//*from w  ww  . ja  v  a2 s  .c  o m*/
void populateAttributes() {
    Set<String> attributeTypes = scanRulesForAttributes();

    try {
        SleuthkitCase currentCase = Case.getCurrentCase().getSleuthkitCase();
        for (BlackboardAttribute.Type type : currentCase.getAttributeTypes()) {
            attributeTypes.add(type.getTypeName());
            attributeTypeMap.put(type.getTypeName(), type.getValueType());
        }
    } catch (IllegalStateException | TskCoreException ex) {
        // Unable to find and open case or cannot read the database. Use enum.
        for (BlackboardAttribute.ATTRIBUTE_TYPE type : BlackboardAttribute.ATTRIBUTE_TYPE.values()) {
            attributeTypes.add(type.getLabel());
            attributeTypeMap.put(type.getLabel(), type.getValueType());
        }
    }

    List<String> sorted = new ArrayList<>(attributeTypes);
    Collections.sort(sorted, String.CASE_INSENSITIVE_ORDER);
    for (String attribute : sorted) {
        comboBoxAttributeName.addItem(attribute);
    }
}

From source file:pcgen.core.Globals.java

/**
 * Clears all lists of game data./*from w w  w .j  a  va 2 s  . co m*/
 */
public static void emptyLists() {
    // These lists do not need cleared; they are tied to game mode
    // alignmentList
    // checkList
    // gameModeList
    // campaignList
    // statList
    // All other lists should be cleared!!!
    //////////////////////////////////////
    // DO NOT CLEAR THESE HERE!!!
    // They only get loaded once.
    //
    //birthplaceList.clear();
    //cityList.clear();
    //hairStyleList.clear();
    //helpContextFileList.clear();
    //interestsList.clear();
    //locationList.clear();
    //paperInfo.clear();
    //phobiaList.clear();
    //phraseList.clear();
    //schoolsList.clear();
    //sizeAdjustmentList.clear();
    //specialsList.clear();
    //speechList.clear();
    //traitList.clear();
    //unitSet.clear();
    //////////////////////////////////////

    // Clear Maps (not strictly necessary, but done for consistency)
    spellMap = new TreeMap<String, Spell>(String.CASE_INSENSITIVE_ORDER);
    VisionType.clearConstants();

    // Perform other special cleanup
    Equipment.clearEquipmentTypes();
    SettingsHandler.getGame().clearLoadContext();

    RaceType.clearConstants();
    createEmptyRace();
    CNAbilityFactory.reset();
}

From source file:org.forgerock.openidm.repo.jdbc.impl.MappedTableHandler.java

public static Set<String> getColumnNames(ResultSet rs) throws SQLException {
    TreeSet<String> set = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
    for (int i = 1; i <= rs.getMetaData().getColumnCount(); i++) {
        set.add(rs.getMetaData().getColumnName(i));
    }//ww w .  j  av a  2  s  .  c  o  m
    return set;
}

From source file:com.evolveum.midpoint.gui.api.util.WebComponentUtil.java

public static List<QName> createObjectTypeList() {

    List<QName> types = new ArrayList<>(ObjectTypes.values().length);
    for (ObjectTypes t : ObjectTypes.values()) {
        types.add(t.getTypeQName());/*from w  w  w.  j  ava  2s  .c  o m*/
    }

    return types.stream().sorted((type1, type2) -> {
        Validate.notNull(type1);
        Validate.notNull(type2);

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

    }).collect(Collectors.toList());

}

From source file:weave.utils.SQLUtils.java

/**
 * @param conn An existing SQL Connection
 * @return A List of schema names/*from w  w w. j a  v  a  2  s  . c  om*/
 * @throws SQLException If the query fails.
 */
public static List<String> getSchemas(Connection conn) throws SQLException {
    List<String> schemas = new Vector<String>();
    ResultSet rs = null;
    try {
        DatabaseMetaData md = conn.getMetaData();

        // MySQL "doesn't support schemas," so use catalogs.
        if (conn.getMetaData().getDatabaseProductName().equalsIgnoreCase(MYSQL)) {
            rs = md.getCatalogs();
            // use column index instead of name because sometimes the names are lower case, sometimes upper.
            while (rs.next())
                schemas.add(rs.getString(1)); // table_catalog
        } else {
            rs = md.getSchemas();
            // use column index instead of name because sometimes the names are lower case, sometimes upper.
            while (rs.next())
                schemas.add(rs.getString(1)); // table_schem
        }

        Collections.sort(schemas, String.CASE_INSENSITIVE_ORDER);
    } finally {
        SQLUtils.cleanup(rs);
    }
    return schemas;
}

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

protected Boolean refreshColumnTypeCache(final String tableName) {
    return jdbc.query(sqlGenerator.constructSelect(schema, tableName, null, "1=0", null, null, -1),
            new ResultSetExtractor<Boolean>() {
                @Override//from   w  w w  .  j  a v  a 2  s  . com
                public Boolean extractData(ResultSet rs) throws SQLException, DataAccessException {
                    ResultSetMetaData rsmd = rs.getMetaData();
                    Map<String, Integer> columnType = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
                    for (int i = 1; i <= rsmd.getColumnCount(); i++) {
                        columnType.put(rsmd.getColumnLabel(i), rsmd.getColumnType(i));
                    }
                    cache.putColumnTypes(tableName, columnType);
                    return true;
                }
            });
}

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

private void updateDoesNotRemovePropertyWhenIdIsInteger(final String property) throws Throwable {

    final String tableName = "MyTableName";

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

    MobileServiceClient client = null;//  ww w. j a  v a 2 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"));
            assertTrue(properties.containsKey(property));

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

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

    JsonObject obj = new JsonParser()
            .parse("{\"id\":5,\"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:org.intermine.web.logic.results.ReportObject.java

/**
 * Create the Maps and Lists returned by the getters in this class.
 *//*from  w w w.  j  a  va2 s. c  o  m*/
private void initialise() {
    // TODO don't initialise replaced collections!  Work this out first.

    long startTime = System.currentTimeMillis();
    // combined Map of References & Collections
    refsAndCollections = new TreeMap<String, DisplayField>(String.CASE_INSENSITIVE_ORDER);

    /** InlineLists **/
    inlineListsHeader = (inlineListsHeader != null) ? inlineListsHeader : new ArrayList<InlineList>();
    inlineListsNormal = (inlineListsNormal != null) ? inlineListsNormal : new ArrayList<InlineList>();

    Type type = webConfig.getTypes().get(getClassDescriptor().getName());
    // init lists from WebConfig Type
    List<InlineListConfig> inlineListsWebConfig = type.getInlineListConfig();
    // a map of inlineList object names so we do not include them elsewhere
    HashMap<String, Boolean> bagOfInlineListNames = new HashMap<String, Boolean>();
    // fill up
    for (InlineListConfig listConfig : inlineListsWebConfig) {
        initialiseInlineList(listConfig, bagOfInlineListNames);
    }

    /** Attributes, References, Collections through FieldDescriptors **/
    nullRefsCols = im.getObjectStoreSummary().getNullReferencesAndCollections(getClassDescriptor().getName());

    Set<String> replacedFields = getReplacedFieldExprs();
    for (FieldDescriptor fd : getClassDescriptor().getAllFieldDescriptors()) {
        // only continue if we have not included this object in an inline list
        if (!bagOfInlineListNames.containsKey(fd.getName()) && !replacedFields.contains(fd.getName())) {
            if (fd.isAttribute() && !"id".equals(fd.getName())) {
                /** Attribute **/
                initialiseAttribute(fd);
            } else if (fd.isReference()) {
                /** Reference **/
                initialiseReference(fd);
            } else if (fd.isCollection()) {
                /** Collection **/
                initialiseCollection(fd);
            }
        } else {
            /** InlineList (cont...) **/
            // assign Descriptor from FieldDescriptors to the InlineList
            setDescriptorOnInlineList(fd.getName(), fd);
        }
    }

    // make a combined Map
    if (references != null) {
        refsAndCollections.putAll(references);
    }
    if (collections != null) {
        refsAndCollections.putAll(collections);
    }
    long endTime = System.currentTimeMillis();
    LOG.info("TIME initialise took: " + (endTime - startTime) + "ms");
}

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

private void getDims(ArrayList<Set<String>> dimsList, Set<String> dims, String[][] stringSets) {
    if (stringSets != null) {
        for (String[] ss : stringSets) {
            Set<String> temp = new TreeSet<>(String.CASE_INSENSITIVE_ORDER);
            for (String s : ss) {
                temp.add(s);//from   ww  w  .  ja  va2s .  co m
                dims.add(s);
            }
            dimsList.add(temp);
        }
    }
}