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.consol.citrus.admin.service.FileBrowserService.java

/**
 * Gets all sub-folder names in give directory.
 * @param directory/*from  w  ww . ja va2  s.c o  m*/
 * @return
 */
public String[] getFolders(File directory) {
    if (directory.exists()) {
        String[] files = directory.list(new FilenameFilter() {
            public boolean accept(File dir, String name) {
                return name.charAt(0) != '.' && new File(dir, name).isDirectory();
            }
        });

        if (files != null) {
            Arrays.sort(files, String.CASE_INSENSITIVE_ORDER);
            return files;
        } else {
            return new String[] {};
        }
    } else {
        throw new ApplicationRuntimeException(
                "Could not open directory because it does not exist: " + directory);
    }
}

From source file:info.magnolia.module.imaging.tools.ImageIOPluginsPage.java

/**
 * Removes duplicates and returns a sorted set of all entries in lowercase.
 *///  w w w.j  av  a2s . co m
protected static Collection<String> filter(String... formats) {
    final TreeSet<String> set = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
    set.addAll(Arrays.asList(formats));
    CollectionUtils.transform(set, new Transformer() {
        @Override
        public Object transform(Object input) {
            return ((String) input).toLowerCase();
        }
    });
    return set;
}

From source file:uk.org.rbc1b.roms.db.common.MergeUtilTest.java

@Test
public void testMergeSingleStrings() {
    final List<Pair<String, String>> outputs = new ArrayList<Pair<String, String>>();

    MergeUtil.merge(Arrays.asList("foo"), Arrays.asList("foo"), String.CASE_INSENSITIVE_ORDER,
            new MergeUtil.Callback<String, String>() {
                @Override//w  w  w.  j  a v  a  2s  . c  om
                public void output(String leftValue, String rightValue) {
                    outputs.add(new ImmutablePair<String, String>(leftValue, rightValue));
                }
            });

    assertEquals(Arrays.asList(new ImmutablePair<String, String>("foo", "foo")), outputs);
}

From source file:org.apache.accumulo.core.util.shell.commands.GetAuthsCommand.java

@Override
public int execute(final String fullCommand, final CommandLine cl, final Shell shellState)
        throws AccumuloException, AccumuloSecurityException, IOException {
    final String user = cl.getOptionValue(userOpt.getOpt(), shellState.getConnector().whoami());
    // Sort authorizations
    Authorizations auths = shellState.getConnector().securityOperations().getUserAuthorizations(user);
    SortedSet<String> set = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
    for (byte[] auth : auths) {
        set.add(new String(auth));
    }//from www  .  j a  va2s  . com
    shellState.getReader().println(StringUtils.join(set, ','));
    return 0;
}

From source file:org.kuali.rice.core.api.util.ConcreteKeyValue.java

@Override
public int compareTo(KeyValue o) {
    if (o == null) {
        throw new NullPointerException("o is null");
    }// ww  w  .  j  a va2s.c o m

    return new CompareToBuilder().append(this.getValue(), o.getValue(), String.CASE_INSENSITIVE_ORDER)
            .append(this.getKey(), o.getKey(), String.CASE_INSENSITIVE_ORDER).toComparison();
}

From source file:org.apache.hawq.pxf.service.rest.RestResource.java

/**
 * Converts the request headers multivalued map to a case-insensitive
 * regular map by taking only first values and storing them in a
 * CASE_INSENSITIVE_ORDER TreeMap. All values are converted from ISO_8859_1
 * (ISO-LATIN-1) to UTF_8./*  w w  w  . java 2  s.  c  o  m*/
 *
 * @param requestHeaders request headers multi map.
 * @return a regular case-insensitive map.
 * @throws UnsupportedEncodingException if the named charsets ISO_8859_1 and
 *             UTF_8 are not supported
 */
public Map<String, String> convertToCaseInsensitiveMap(MultivaluedMap<String, String> requestHeaders)
        throws UnsupportedEncodingException {
    Map<String, String> result = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
    for (Map.Entry<String, List<String>> entry : requestHeaders.entrySet()) {
        String key = entry.getKey();
        List<String> values = entry.getValue();
        if (values != null) {
            String value = values.get(0);
            if (value != null) {
                // converting to value UTF-8 encoding
                value = new String(value.getBytes(CharEncoding.ISO_8859_1), CharEncoding.UTF_8);
                LOG.trace("key: " + key + ". value: " + value);
                result.put(key, value.replace("\\\"", "\""));
            }
        }
    }
    return result;
}

From source file:com.intuit.tank.admin.LogViewer.java

@PostConstruct
public void init() {
    logFiles = new ArrayList<String>();
    String fileRoot = "logs";
    File f = new File(fileRoot);
    LOG.info("Log file dir is " + f.getAbsolutePath());
    if (!f.exists()) {
        f = new File("/opt/tomcat6/logs");
    }// w w w  .  j  ava2 s  .co  m
    try {
        File[] list = f.listFiles();
        for (File file : list) {
            if (file.isFile()) {
                logFiles.add(file.getName());
            }
        }
    } catch (Exception e) {
        LOG.error("Error getting log files: " + e, e);
    }
    Collections.sort(logFiles, String.CASE_INSENSITIVE_ORDER);
}

From source file:org.carewebframework.ui.mockup.MockupTypeEnumerator.java

/**
 * Returns an alphabetically sorted iterator of recognized mockup framework types.
 *///w  w w  . ja v a  2 s  . c o  m
@Override
public Iterator<String> iterator() {
    List<String> list = new ArrayList<String>(mockupTypes.stringPropertyNames());
    Collections.sort(list, String.CASE_INSENSITIVE_ORDER);
    return list.iterator();
}

From source file:com.evolveum.midpoint.web.component.wizard.resource.dto.ObjectClassDto.java

@Override
public int compareTo(ObjectClassDto o) {
    if (o == null) {
        return 0;
    }//  w  ww.j av a 2s .  c o m

    return String.CASE_INSENSITIVE_ORDER.compare(getName(), o.getName());
}

From source file:kr.co.bitnine.octopus.postgres.utils.misc.PostgresConfiguration.java

public PostgresConfiguration() {
    super(String.CASE_INSENSITIVE_ORDER);

    put(PARAM_INTEGER_DATETIMES, "on");
    put(PARAM_EXTRA_FLOAT_DIGITS, "0");
    put(PARAM_DATESTYLE, "ISO");
    put(PARAM_CLIENT_ENCODING, "UTF8");
    put(PARAM_SERVER_ENCODING, "UTF8");
    put(PARAM_SERVER_VERSION, ProtocolConstants.POSTGRES_VERSION);
    put(PARAM_TIMEZONE, "GMT");
}