Example usage for java.util Locale getCountry

List of usage examples for java.util Locale getCountry

Introduction

In this page you can find the example usage for java.util Locale getCountry.

Prototype

public String getCountry() 

Source Link

Document

Returns the country/region code for this locale, which should either be the empty string, an uppercase ISO 3166 2-letter code, or a UN M.49 3-digit code.

Usage

From source file:com.haulmont.cuba.core.sys.FormatStringsRegistryImpl.java

@Override
public void setFormatStrings(Locale locale, FormatStrings formatStrings) {
    formatStringsMap.put(locale, formatStrings);
    if (!StringUtils.isEmpty(locale.getCountry()) || !StringUtils.isEmpty(locale.getVariant()))
        useLocaleLanguageOnly = false;/*from w w  w . j a va  2s. c o  m*/
}

From source file:com.puppycrawl.tools.checkstyle.filters.SuppressWarningsFilterTest.java

@Override
protected Checker createChecker(Configuration checkConfig) throws Exception {
    final DefaultConfiguration checkerConfig = new DefaultConfiguration("configuration");
    final DefaultConfiguration checksConfig = createCheckConfig(TreeWalker.class);
    final DefaultConfiguration holderConfig = createCheckConfig(SuppressWarningsHolder.class);
    holderConfig.addAttribute("aliasList",
            "com.puppycrawl.tools.checkstyle.checks.sizes." + "ParameterNumberCheck=paramnum");
    checksConfig.addChild(holderConfig);
    checksConfig.addChild(createCheckConfig(MemberNameCheck.class));
    checksConfig.addChild(createCheckConfig(ConstantNameCheck.class));
    checksConfig.addChild(createCheckConfig(ParameterNumberCheck.class));
    checksConfig.addChild(createCheckConfig(IllegalCatchCheck.class));
    checkerConfig.addChild(checksConfig);
    if (checkConfig != null) {
        checkerConfig.addChild(checkConfig);
    }//from www . j a va2s.  c o  m
    final Checker checker = new Checker();
    final Locale locale = Locale.ROOT;
    checker.setLocaleCountry(locale.getCountry());
    checker.setLocaleLanguage(locale.getLanguage());
    checker.setModuleClassLoader(Thread.currentThread().getContextClassLoader());
    checker.configure(checkerConfig);
    checker.addListener(new BriefLogger(stream));
    return checker;
}

From source file:org.sakaiproject.tool.assessment.ui.bean.shared.PersonBean.java

public String getLocaleCountry() {
    ResourceLoader r = new ResourceLoader();
    Locale locale = r.getLocale();
    return locale.getCountry();
}

From source file:com.evolveum.midpoint.web.component.menu.top.LocaleDescriptor.java

@Override
public int compareTo(LocaleDescriptor o) {
    if (o == null) {
        return 0;
    }//from  w ww  .  j ava  2 s.com

    Locale other = o.getLocale();

    int val = compareStrings(locale.getCountry(), other.getCountry());
    if (val != 0) {
        return val;
    }

    val = compareStrings(locale.getLanguage(), other.getLanguage());
    if (val != 0) {
        return val;
    }

    val = compareStrings(locale.getVariant(), other.getVariant());
    if (val != 0) {
        return val;
    }

    return 0;
}

From source file:net.sourceforge.atunes.kernel.modules.state.LocaleBean.java

/**
 * Constructs LocaleBean from a given java.util.Locale
 * /* w  w  w  . j a  v  a2s .  co  m*/
 * @param locale
 *            locale
 */
public LocaleBean(final Locale locale) {
    this.language = locale.getLanguage();
    this.country = locale.getCountry();
}

From source file:org.apache.struts2.config.PropertiesConfigurationProviderTest.java

public void testRegister_DifferentLocale() {

    ContainerBuilder builder = new ContainerBuilder();
    builder.constant("foo", "bar");
    builder.constant("struts.locale", "de_DE");

    PropertiesConfigurationProvider prov = new PropertiesConfigurationProvider();
    prov.register(builder, new LocatableProperties());

    Container container = builder.create(true);

    String localeStr = container.getInstance(String.class, StrutsConstants.STRUTS_LOCALE);
    Locale locale = LocaleUtils.toLocale(localeStr);

    assertNotNull(locale);//from www  .  j av a  2  s  .c om
    assertEquals("DE", locale.getCountry());
    assertEquals("de", locale.getLanguage());

}

From source file:org.opencommercesearch.service.localeservice.FeedLocaleService.java

public boolean isSupportedLocale(String language, String country) {
    for (Locale locale : supportedLocales) {
        if (locale.getLanguage().equals(language) && locale.getCountry().equals(country)) {
            return true;
        }/*  ww  w. j a  v a2s.c  o m*/
    }
    return false;
}

From source file:com.puppycrawl.tools.checkstyle.checks.FileSetCheckLifecycleTest.java

@Test
public void testProcessCallsFinishBeforeCallingDestroy() throws Exception {

    DefaultConfiguration dc = new DefaultConfiguration("configuration");
    DefaultConfiguration twConf = createCheckConfig(TreeWalker.class);
    dc.addAttribute("charset", "UTF-8");
    dc.addChild(twConf);/*from   www  .  j a va  2 s.  co  m*/
    twConf.addChild(new DefaultConfiguration(FileContentsHolder.class.getName()));
    twConf.addChild(new DefaultConfiguration(AvoidStarImportCheck.class.getName()));

    final Checker checker = new Checker();
    final Locale locale = Locale.ROOT;
    checker.setLocaleCountry(locale.getCountry());
    checker.setLocaleLanguage(locale.getLanguage());
    checker.setModuleClassLoader(Thread.currentThread().getContextClassLoader());
    checker.configure(dc);
    checker.addListener(new BriefLogger(stream));

    checker.addFileSetCheck(new TestFileSetCheck());

    final String[] expected = ArrayUtils.EMPTY_STRING_ARRAY;

    verify(checker, getPath("InputIllegalTokens.java"), expected);

    assertTrue("FileContent should be available during finishProcessing() call",
            TestFileSetCheck.isFileContentAvailable());
}

From source file:cn.remex.core.util.StringUtils.java

/**
 *  HTTP  RFC 3306??/*from   www  .j  a  v  a  2s .c  o  m*/
 * Determine the RFC 3066 compliant language tag,
 * as used for the HTTP "Accept-Language" header.
 * @param locale the Locale to transform to a language tag 
 * @return the RFC 3066 compliant language tag as String  RFC 3306??
 */
public static String toLanguageTag(final Locale locale) {
    return locale.getLanguage() + (hasText(locale.getCountry()) ? "-" + locale.getCountry() : "");
}

From source file:org.apache.cocoon.forms.datatype.convertor.LocaleMap.java

private final String getKey(Locale locale) {
    boolean hasLanguage = !locale.getLanguage().equals("");
    boolean hasCountry = !locale.getCountry().equals("");
    boolean hasVariant = !locale.getVariant().equals("");

    if (hasLanguage && hasCountry && hasVariant)
        return locale.getLanguage() + '-' + locale.getCountry() + '-' + locale.getVariant();
    else if (hasLanguage && hasCountry)
        return locale.getLanguage() + '-' + locale.getCountry();
    else if (hasLanguage)
        return locale.getLanguage();
    else// w w w.  ja va  2  s .c o  m
        return "";
}