Example usage for java.text Collator getClass

List of usage examples for java.text Collator getClass

Introduction

In this page you can find the example usage for java.text Collator getClass.

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:dk.statsbiblioteket.util.CachedCollator.java

private static Collator fixCollator(Collator collator, boolean check) {
    if (!(collator instanceof RuleBasedCollator)) {
        log.warn(String.format("fixCollator expected a RuleBasedCollator but got %s. Unable to update Collator",
                collator.getClass()));
        return collator;
    }/*  w  w  w.j  ava 2  s .c  o  m*/
    String rules = ((RuleBasedCollator) collator).getRules();
    if (check && !rules.contains("<' '<'\u005f'")) {
        log.debug("fixCollator: The received Collator already sorts spaces first");
        return collator;
    }
    try {
        RuleBasedCollator newCollator = new RuleBasedCollator(rules.replace("<'\u005f'", "<' '<'\u005f'"));
        log.trace("Successfully updated Collator to prioritize spaces before other characters");
        return newCollator;
    } catch (ParseException e) {
        throw new RuntimeException("ParseException while parsing\n" + rules, e);
    }
}