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.microsoft.windowsazure.mobileservices.sdk.testapp.test.SystemPropertiesTests.java

public void testInsertRemovesVersionSerializedNameStringId() throws Throwable {

    final String responseContent = "{\"id\":\"an id\"}";

    MobileServiceClient client = null;/*from w  w  w . ja v a  2s.  com*/

    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"));
            assertFalse(properties.containsKey("__version"));

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

    // Create get the MobileService table
    MobileServiceTable<VersionType> msTable = client.getTable(VersionType.class);

    VersionType element = new VersionType();
    element.Id = "an id";
    element.Version = "a version";

    try {
        // Call the insert method
        VersionType entity = msTable.insert(element).get();

        if (entity == null) {
            fail("Expected result");
        }

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

From source file:org.apache.hadoop.hive.ql.QTestUtil.java

private static void ensureQvFileList(String queryDir) {
    if (cachedQvFileList != null)
        return;/*www . j a va2 s . c om*/
    // Not thread-safe.
    System.out.println("Getting versions from " + queryDir);
    cachedQvFileList = (new File(queryDir)).list(new FilenameFilter() {
        @Override
        public boolean accept(File dir, String name) {
            return name.toLowerCase().endsWith(".qv");
        }
    });
    if (cachedQvFileList == null)
        return; // no files at all
    Arrays.sort(cachedQvFileList, String.CASE_INSENSITIVE_ORDER);
    List<String> defaults = getVersionFilesInternal("default");
    cachedDefaultQvFileList = (defaults != null) ? ImmutableList.copyOf(defaults) : ImmutableList.<String>of();
}

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

public void testInsertRemovesAllSystemSerializedNameStringId() throws Throwable {

    final String responseContent = "{\"id\":\"an id\"}";
    MobileServiceClient client = null;//from  www  .j  ava2  s .  c  om

    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"));
            assertFalse(properties.containsKey("__createdAt"));
            assertFalse(properties.containsKey("__updatedAt"));
            assertFalse(properties.containsKey("__version"));

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

    // Create get the MobileService table
    MobileServiceTable<AllSystemPropertiesType> msTable = client.getTable(AllSystemPropertiesType.class);

    AllSystemPropertiesType element = new AllSystemPropertiesType();
    element.Id = "an id";
    element.CreatedAt = new GregorianCalendar(2012, 00, 18).getTime();
    element.UpdatedAt = new GregorianCalendar(2012, 00, 18).getTime();
    element.Version = "a version";

    try {
        // Call the insert method
        AllSystemPropertiesType entity = msTable.insert(element).get();

        if (entity == null) {
            fail("Expected result");
        }

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

From source file:org.apache.hadoop.hive.ql.QTestUtil.java

private static List<String> getVersionFilesInternal(String tname) {
    if (cachedQvFileList == null) {
        return new ArrayList<String>();
    }//from   w w  w .  jav a 2s . c o  m
    int pos = Arrays.binarySearch(cachedQvFileList, tname, String.CASE_INSENSITIVE_ORDER);
    if (pos >= 0) {
        throw new BuildException("Unexpected file list element: " + cachedQvFileList[pos]);
    }
    List<String> result = null;
    for (pos = (-pos - 1); pos < cachedQvFileList.length; ++pos) {
        String candidate = cachedQvFileList[pos];
        if (candidate.length() <= tname.length()
                || !tname.equalsIgnoreCase(candidate.substring(0, tname.length()))
                || !qvSuffix.matcher(candidate.substring(tname.length())).matches()) {
            break;
        }
        if (result == null) {
            result = new ArrayList<String>();
        }
        result.add(candidate);
    }
    return result;
}

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

public void testInsertDoesNotRemoveNonSystemCreatedAtPropertyNameStringId() throws Throwable {

    final String responseContent = "{\"id\":\"an id\"}";

    MobileServiceClient client = null;//  w ww  .j  a va  2s  .co 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("CreatedAt"));

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

    // Create get the MobileService table
    MobileServiceTable<NotSystemPropertyCreatedAtType> msTable = client
            .getTable(NotSystemPropertyCreatedAtType.class);

    NotSystemPropertyCreatedAtType element = new NotSystemPropertyCreatedAtType();
    element.Id = "an id";
    element.CreatedAt = new GregorianCalendar(2012, 00, 18).getTime();

    try {
        // Call the insert method
        NotSystemPropertyCreatedAtType entity = msTable.insert(element).get();

        if (entity == null) {
            fail("Expected result");
        }

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

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

public void testInsertDoesNotRemoveNonSystemUpdatedAtPropertyNameStringId() throws Throwable {

    final String responseContent = "{\"id\":\"an id\"}";

    MobileServiceClient client = null;//  w w  w .  j  a  va2  s. com

    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("_UpdatedAt"));

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

    // Create get the MobileService table
    MobileServiceTable<NotSystemPropertyUpdatedAtType> msTable = client
            .getTable(NotSystemPropertyUpdatedAtType.class);

    NotSystemPropertyUpdatedAtType element = new NotSystemPropertyUpdatedAtType();
    element.Id = "an id";
    element._UpdatedAt = new GregorianCalendar(2012, 00, 18).getTime();

    try {
        // Call the insert method
        NotSystemPropertyUpdatedAtType entity = msTable.insert(element).get();

        if (entity == null) {
            fail("Expected result");
        }

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

From source file:dentex.youtube.downloader.DashboardActivity.java

private static int parseJson(Context context) {
    // read existing/init new JSON 
    String previousJson = Json.readJsonDashboardFile(context);

    JSONObject jV = null;//from   w  ww  .j av a  2  s .  co  m
    try {
        jV = new JSONObject(previousJson);
        //Utils.logger("v", "current json:\n" + previousJson, DEBUG_TAG);
        @SuppressWarnings("unchecked")
        Iterator<Object> ids = jV.keys();
        while (ids.hasNext()) {
            String id = (String) ids.next();
            JSONObject jO = new JSONObject();
            jO = jV.getJSONObject(id);
            idEntries.add(id);
            typeEntries.add(jO.getString(YTD.JSON_DATA_TYPE));
            linkEntries.add(jO.getString(YTD.JSON_DATA_YTID));
            posEntries.add(jO.getInt(YTD.JSON_DATA_POS));
            statusEntries.add(jO.getString(YTD.JSON_DATA_STATUS));
            pathEntries.add(jO.getString(YTD.JSON_DATA_PATH));
            filenameEntries.add(jO.getString(YTD.JSON_DATA_FILENAME));
            basenameEntries.add(jO.getString(YTD.JSON_DATA_BASENAME));
            audioExtEntries.add(jO.getString(YTD.JSON_DATA_AUDIO_EXT));
            sizeEntries.add(jO.getString(YTD.JSON_DATA_SIZE));
        }
    } catch (JSONException e) {
        Log.e(DEBUG_TAG, "JSONException @ parseJson: " + e.getMessage());
        Toast.makeText(sDashboard, sDashboard.getString(R.string.invalid_data), Toast.LENGTH_LONG).show();
        YTD.JSON_FILE.delete();
    }

    // do sort by filenames
    List<String> oldFilenameEntries = new ArrayList<String>(filenameEntries);
    List<String> oldIdEntries = new ArrayList<String>(idEntries);
    List<String> oldTypeEntries = new ArrayList<String>(typeEntries);
    List<String> oldLinkEntries = new ArrayList<String>(linkEntries);
    List<Integer> oldPosEntries = new ArrayList<Integer>(posEntries);
    List<String> oldStatusEntries = new ArrayList<String>(statusEntries);
    List<String> oldPathEntries = new ArrayList<String>(pathEntries);
    List<String> oldBasenameEntries = new ArrayList<String>(basenameEntries);
    List<String> oldAudioExtEntries = new ArrayList<String>(audioExtEntries);
    List<String> oldSizeEntries = new ArrayList<String>(sizeEntries);

    idEntries.clear();
    typeEntries.clear();
    linkEntries.clear();
    posEntries.clear();
    statusEntries.clear();
    pathEntries.clear();
    basenameEntries.clear();
    audioExtEntries.clear();
    sizeEntries.clear();

    Collections.sort(filenameEntries, String.CASE_INSENSITIVE_ORDER);

    for (int i = 0; i < filenameEntries.size(); i++) {
        for (int j = 0; j < oldFilenameEntries.size(); j++) {
            if (oldFilenameEntries.get(j) == filenameEntries.get(i)) {
                idEntries.add(oldIdEntries.get(j));
                typeEntries.add(oldTypeEntries.get(j));
                linkEntries.add(oldLinkEntries.get(j));
                posEntries.add(oldPosEntries.get(j));
                statusEntries.add(oldStatusEntries.get(j));
                pathEntries.add(oldPathEntries.get(j));
                basenameEntries.add(oldBasenameEntries.get(j));
                audioExtEntries.add(oldAudioExtEntries.get(j));
                sizeEntries.add(oldSizeEntries.get(j));
            }
        }
    }
    return idEntries.size();
}

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

public void testInsertDoesNotRemoveNonSystemVersionPropertyNameStringId() throws Throwable {

    final String responseContent = "{\"id\":\"an id\"}";

    MobileServiceClient client = null;//from  w w  w.jav  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("version"));

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

    // Create get the MobileService table
    MobileServiceTable<NotSystemPropertyVersionType> msTable = client
            .getTable(NotSystemPropertyVersionType.class);

    NotSystemPropertyVersionType element = new NotSystemPropertyVersionType();
    element.Id = "an id";
    element.version = "a version";

    try {
        // Call the insert method
        NotSystemPropertyVersionType entity = msTable.insert(element).get();

        if (entity == null) {
            fail("Expected result");
        }

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

From source file:com.ah.ui.actions.BaseAction.java

public EnumItem[] getStrCountry() {
    int strLeng = UserRegInfoForLs.USER_COUNTRY.length;
    EnumItem[] enumItems = new EnumItem[strLeng + 3];

    List<String> countryLs = Arrays.asList(UserRegInfoForLs.USER_COUNTRY);
    Collections.sort(countryLs, String.CASE_INSENSITIVE_ORDER);

    enumItems[0] = new EnumItem(0, UserRegInfoForLs.USER_COUNTRY_0);
    enumItems[1] = new EnumItem(1, UserRegInfoForLs.USER_COUNTRY_1);

    for (int k = 0; k < countryLs.size(); k++) {
        enumItems[k + 2] = new EnumItem(k + 2, countryLs.get(k));
    }//w ww . j  a v a  2s.  co m
    enumItems[strLeng + 2] = new EnumItem(strLeng + 2, UserRegInfoForLs.USER_COUNTRY_LAST);
    return enumItems;
}

From source file:org.mdc.chess.MDChess.java

private String[] findFilesInDirectory(String dirName, final FileNameFilter filter) {
    File extDir = Environment.getExternalStorageDirectory();
    String sep = File.separator;
    File dir = new File(extDir.getAbsolutePath() + sep + dirName);
    File[] files = dir.listFiles(new FileFilter() {
        public boolean accept(File pathname) {
            return pathname.isFile() && ((filter == null) || filter.accept(pathname.getAbsolutePath()));
        }//from   w  w  w .ja v a2s  .  com
    });
    if (files == null) {
        files = new File[0];
    }
    final int numFiles = files.length;
    String[] fileNames = new String[numFiles];
    for (int i = 0; i < files.length; i++) {
        fileNames[i] = files[i].getName();
    }
    Arrays.sort(fileNames, String.CASE_INSENSITIVE_ORDER);
    return fileNames;
}