Java Code Examples for java.util.Locale.getExtensionKeys()

The following are Jave code examples for showing how to use getExtensionKeys() of the java.util.Locale class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: jdk8u-jdk   File: LocaleEnhanceTest.java   View Source Code Vote up 6 votes
public void testGetExtensionKeys() {
    Locale locale = Locale.forLanguageTag("und-a-xx-yy-b-zz-ww");
    Set<Character> result = locale.getExtensionKeys();
    assertEquals("result size", 2, result.size());
    assertTrue("'a','b'", result.contains('a') && result.contains('b'));

    // result is not mutable
    try {
        result.add('x');
        errln("expected exception on add to extension key set");
    }
    catch (UnsupportedOperationException e) {
        // ok
    }

    // returns empty set if no extensions
    locale = Locale.forLanguageTag("und");
    assertTrue("empty result", locale.getExtensionKeys().isEmpty());
}
 
Example 2
Project: openjdk-jdk10   File: LocaleEnhanceTest.java   View Source Code Vote up 6 votes
public void testGetExtensionKeys() {
    Locale locale = Locale.forLanguageTag("und-a-xx-yy-b-zz-ww");
    Set<Character> result = locale.getExtensionKeys();
    assertEquals("result size", 2, result.size());
    assertTrue("'a','b'", result.contains('a') && result.contains('b'));

    // result is not mutable
    try {
        result.add('x');
        errln("expected exception on add to extension key set");
    }
    catch (UnsupportedOperationException e) {
        // ok
    }

    // returns empty set if no extensions
    locale = Locale.forLanguageTag("und");
    assertTrue("empty result", locale.getExtensionKeys().isEmpty());
}