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.util.FileHelperImpl.java

/**
 * {@inheritDoc}/*  ww  w.  j  a va 2s . c  o m*/
 */
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 CitrusAdminRuntimeException(
                "Could not open directory because it does not exist: " + directory);
    }
}

From source file:org.usergrid.utils.MapUtils.java

/**
 * @param <A>/*ww  w .j  a  v a2s.c  om*/
 * @param <B>
 * @param map
 * @param ignore_case
 * @param a
 * @param b
 */
@SuppressWarnings("unchecked")
public static <A, B> void addMapSet(Map<A, Set<B>> map, boolean ignore_case, A a, B b) {

    Set<B> set_b = map.get(a);
    if (set_b == null) {
        if (ignore_case && (b instanceof String)) {
            set_b = (Set<B>) new TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
        } else {
            set_b = new LinkedHashSet<B>();
        }
        map.put(a, set_b);
    }
    set_b.add(b);
}

From source file:forge.util.FileSection.java

/**
 * Instantiates a new file section.//from www . j a  v  a 2s .  c om
 */
protected FileSection() {
    this(new TreeMap<String, String>(String.CASE_INSENSITIVE_ORDER));
}

From source file:com.evolveum.midpoint.web.component.prism.ItemWrapperComparator.java

@Override
public int compare(ItemWrapper p1, ItemWrapper p2) {
    ItemDefinition def1 = p1.getItem().getDefinition();
    ItemDefinition def2 = p2.getItem().getDefinition();

    if (isMainContainer(p1)) {
        return -1;
    }//  w w  w. j  av a2s . c  o  m
    if (isMainContainer(p2)) {
        return 1;
    }

    Integer index1 = def1.getDisplayOrder();
    Integer index2 = def2.getDisplayOrder();
    if (index1 != null && index2 != null) {
        return index1 - index2;
    } else if (index1 != null && index2 == null) {
        return -1;
    } else if (index1 == null && index2 != null) {
        return 1;
    }

    return String.CASE_INSENSITIVE_ORDER.compare(getDisplayName(def1), getDisplayName(def2));
}

From source file:com.mothsoft.alexis.web.security.OutboundRestAuthenticationInterceptor.java

@Override
public void handleMessage(Message message) {

    if (!CurrentUserUtil.isAuthenticated()) {
        throw new AuthenticationCredentialsNotFoundException("Unauthenticated user!");
    }/*from w  ww .  j  a v a  2s  . co m*/

    @SuppressWarnings("unchecked")
    Map<String, List<String>> headers = (Map<String, List<String>>) message.get(Message.PROTOCOL_HEADERS);
    if (headers == null) {
        headers = new TreeMap<String, List<String>>(String.CASE_INSENSITIVE_ORDER);
        message.put(Message.PROTOCOL_HEADERS, headers);
    }

    final List<String> header = new ArrayList<String>();

    final String username = CurrentUserUtil.getCurrentUser().getUsername();
    final String apiToken = CurrentUserUtil.getCurrentUser().getApiToken();
    final String usernameToken = String.format("%s:%s", username, apiToken);
    try {
        header.add(String.format("Basic %s", new String(Base64.encodeBase64(usernameToken.getBytes("UTF-8")))));
    } catch (UnsupportedEncodingException e) {
        throw new RuntimeException(e);
    }

    headers.put("Authorization", header);
}

From source file:com.skelril.skree.content.modifier.ModifierNotifier.java

@Listener
public void onPlayerJoin(ClientConnectionEvent.Join event) {
    Optional<ModifierService> optService = Sponge.getServiceManager().provide(ModifierService.class);
    if (!optService.isPresent()) {
        return;/*from   w ww.  j  ava2  s .  co m*/
    }

    ModifierService service = optService.get();

    List<String> messages = new ArrayList<>();
    for (Map.Entry<String, Long> entry : service.getActiveModifiers().entrySet()) {
        String friendlyName = StringUtils.capitalize(entry.getKey().replace("_", " ").toLowerCase());
        String friendlyTime = PrettyText.date(entry.getValue());
        messages.add(" - " + friendlyName + " till " + friendlyTime);
    }
    if (messages.isEmpty())
        return;

    Collections.sort(messages, String.CASE_INSENSITIVE_ORDER);
    messages.add(0, "\n\nThe following donation perks are enabled:");

    Player player = event.getTargetEntity();

    Task.builder().execute(() -> {
        for (String message : messages) {
            player.sendMessage(Text.of(TextColors.GOLD, message));
        }
    }).delay(1, TimeUnit.SECONDS).submit(SkreePlugin.inst());
}

From source file:cn.tata.t2s.ssm.util.AcmeCorpPhysicalNamingStrategy.java

private static Map<String, String> buildAbbreviationMap() {
    TreeMap<String, String> abbreviationMap = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
    abbreviationMap.put("account", "acct");
    abbreviationMap.put("number", "num");
    return abbreviationMap;
}

From source file:org.apache.usergrid.persistence.index.utils.MapUtils.java

@SuppressWarnings("unchecked")
public static <A, B, C> void addMapMapSet(Map<A, Map<B, Set<C>>> map, boolean ignoreCase, A a, B b, C c) {

    Map<B, Set<C>> mapB = map.get(a);
    if (mapB == null) {
        if (ignoreCase && (b instanceof String)) {
            mapB = (Map<B, Set<C>>) new TreeMap<String, Set<C>>(String.CASE_INSENSITIVE_ORDER);
        } else {/*w  w w . ja v  a  2s  .  co m*/
            mapB = new LinkedHashMap<B, Set<C>>();
        }
        map.put(a, mapB);
    }
    addMapSet(mapB, ignoreCase, b, c);
}

From source file:org.kuali.coeus.common.notification.impl.lookup.keyvalue.KeyLabelSortByValue.java

@Override
public int compareTo(KeyValue o) {
    if (o == null) {
        throw new NullPointerException("the object to compare to is null");
    }/*from www .  j a  v a  2  s .  com*/
    CompareToBuilder builder = new CompareToBuilder();
    builder.append(this.getValue(), o.getValue(), String.CASE_INSENSITIVE_ORDER);

    if ((this.getKey() instanceof String) && (o.getKey() instanceof String))
        builder.append(this.getKey(), o.getKey(), String.CASE_INSENSITIVE_ORDER);
    else {
        builder.append(this.getKey(), o.getKey());
    }

    return builder.toComparison();

}

From source file:edu.sdsc.scigraph.services.api.vocabulary.Completion.java

@Override
public int compareTo(Completion o) {
    return String.CASE_INSENSITIVE_ORDER.compare(getCompletion(), o.getCompletion());
}