Locale getCountry - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Locale getCountry method.

This code example shows how to use the following methods:getCountry, getLanguage, getVariant
	 *  
	 * @param locale the locale for which a resource bundle is desired 
	 * @return a <code>List</code> of candidate <code>Locale</code>s for the given <code>locale</code> 
	 * @exception NullPointerException if <code>locale</code> is <code>null</code> */ 
	private static List<Locale> getCandidateLocales (Locale locale) {
		String language = locale.getLanguage();
		String country = locale.getCountry();
		String variant = locale.getVariant();
 
		List<Locale> locales = new ArrayList<Locale>(4);
		if (variant.length() > 0) {
			locales.add(locale);
		} 
		if (country.length() > 0) {
			locales.add((locales.size() == 0) ? locale : new Locale(language, country));
		} 
		if (language.length() > 0) {
			locales.add((locales.size() == 0) ? locale : new Locale(language));
		} 
		locales.add(Locale.ROOT);

7
CodeRank
This code example shows how to use the following methods:getCountry, getLanguage, getVariant
		Assert.notNull(extension, "Extension must not be null");
 
		Resource resource = null;
 
		if (locale != null) {
			String lang = locale.getLanguage();
			String country = locale.getCountry();
			String variant = locale.getVariant();
 
			// Check for file with language, country and variant localization. 
			if (variant.length() > 0) {
				String location =
						name + this.separator + lang + this.separator + country + this.separator + variant + extension;
				resource = this.resourceLoader.getResource(location);
			} 
 
			// Check for file with language and country localization. 
			if ((resource == null || !resource.exists()) && country.length() > 0) {
				String location = name + this.separator + lang + this.separator + country + extension;
				resource = this.resourceLoader.getResource(location);
7
CodeRank
This code example shows how to use the following methods:getCountry, getLanguage, getVariant
		} 
 
		try { 
			Locale locale = (Locale)object;
 
			localeJSONObject.put("country", locale.getCountry());
			localeJSONObject.put("language", locale.getLanguage());
			localeJSONObject.put("variant", locale.getVariant());
		} 
		catch (Exception e) {
			throw new MarshallException( 
				"Unable to put country, language, and variant", e);
		} 
		finally { 
			serializerState.pop();
		} 
 
		return jsonObject;
	} 
 
7
CodeRank
This code example shows how to use the following methods:getCountry, getLanguage
 
  @Test(dependsOnMethods = { "testDbOpenWithBackSlash" }) 
  public void testChangeLocale() throws IOException { 
    database = new OObjectDatabaseTx(url);
    database.open("admin", "admin");
    database.getStorage().getConfiguration().setLocaleLanguage(Locale.ENGLISH.getLanguage());
    database.getStorage().getConfiguration().setLocaleCountry(Locale.ENGLISH.getCountry());
    database.getStorage().getConfiguration().update();
    database.close();
  } 
 
  @Test(dependsOnMethods = { "testChangeLocale" }) 
  public void testRoles() throws IOException { 
    database = new OObjectDatabaseTx(url);
    database.open("admin", "admin");
    database.query(new OSQLSynchQuery<ORole>("select from ORole where name = 'admin'"));
    database.close();
  } 
 
  @Test(dependsOnMethods = { "testChangeLocale" }) 
7
CodeRank
This code example shows how to use the following methods:getCountry
                      String productID,
                      HistoryManager historyManager,
                      Context context) {
    super(textView, historyManager);
    String country = LocaleManager.getCountry(context);
    if ("ISBN".equals(type) && !Locale.US.getCountry().equals(country)) {
      type = "EAN";
    } 
    this.type = type;
    this.productID = productID;
    this.country = country;
  } 
 
  @Override 
  void retrieveSupplementalInfo() throws IOException { 
 
    CharSequence contents =  
        HttpHelper.downloadViaHttp("https://bsplus.srowen.com/ss?c=" + country + "&t=" + type + "&i=" + productID,
                                   HttpHelper.ContentType.XML); 
 
7
CodeRank
This code example shows how to use the following methods:getCountry, getLanguage, getVariant
	} 
 
	@AfterClass 
	public static void tearDownClass() { 
		LocaleUtil.setDefault( 
			_defaultLocale.getLanguage(), _defaultLocale.getCountry(),
			_defaultLocale.getVariant());
	} 
 
	@Test
	public void testCustomPortalLocaleAlternateURL() throws Exception {
		testAlternateURL("localhost", null, null, LocaleUtil.SPAIN, "/es"); 
	} 
 
	@Test
	public void testDefaultPortalLocaleAlternateURL() throws Exception {
		testAlternateURL( 
			"localhost", null, null, LocaleUtil.US, StringPool.BLANK); 
	} 
 
7
CodeRank
This code example shows how to use the following methods:getCountry, getDisplayLanguage, getLanguage
	} 
 
	private String _getShortDisplayName(
		Locale locale, Set<String> duplicateLanguages) {
 
		String language = locale.getDisplayLanguage(locale);
 
		if (language.length() > 3) {
			language = locale.getLanguage();
			language = StringUtil.toUpperCase(language);
		} 
 
		String country = locale.getCountry();
 
		return _getDisplayName( 
			language, StringUtil.toUpperCase(country), locale,
			duplicateLanguages);
	} 
 
	private Locale _getSiteDefault() {
6
CodeRank
This code example shows how to use the following methods:getCountry, getLanguage
    @Override 
    public String toString(Locale header) {
 
        throwIllegalArgumentExceptionIfNull(header, LocalizationMessages.LOCALE_IS_NULL());
 
        if (header.getCountry().length() == 0) {
            return header.getLanguage();
        } else { 
            StringBuilder sb = new StringBuilder(header.getLanguage());
            return sb.append('-').append(header.getCountry()).toString();
        } 
    } 
 
    @Override 
    public Locale fromString(String header) {
 
        throwIllegalArgumentExceptionIfNull(header, LocalizationMessages.LOCALE_IS_NULL());
 
        try { 
            LanguageTag lt = new LanguageTag(header);
7
CodeRank
This code example shows how to use the following methods:getCountry, getLanguage, getVariant
     * @param locale the message locale to use 
     * @param <T> the bundle type 
     * @return the bundle 
     */ 
    public static <T> T getBundle(Class<T> type, Locale locale) {
        String language = locale.getLanguage();
        String country = locale.getCountry();
        String variant = locale.getVariant();
 
        Class<? extends T> bundleClass = null;
        if (variant != null && variant.length() > 0)
            try { 
                bundleClass = Class.forName(join(type.getName(), "$bundle", language, country, variant), true,
                        type.getClassLoader()).asSubclass(type);
            } catch (ClassNotFoundException e) {
                // ignore 
            } 
        if (bundleClass == null && country != null && country.length() > 0)
            try { 
                bundleClass = Class.forName(join(type.getName(), "$bundle", language, country, null), true,
7
CodeRank
This code example shows how to use the following methods:getCountry, getLanguage, getVariant
	} 
 
	@AfterClass 
	public static void tearDownClass() { 
		LocaleUtil.setDefault( 
			_defaultLocale.getLanguage(), _defaultLocale.getCountry(),
			_defaultLocale.getVariant());
	} 
 
	@Before 
	public void setUp() throws Exception {
		StringBundler sb = new StringBundler();
 
		sb.append("<?xml version='1.0' encoding='UTF-8'?>");
 
		sb.append("<root available-locales=\"en_US,es_ES\" ");
		sb.append("default-locale=\"en_US\">");
		sb.append("<static-content language-id=\"es_ES\">");
		sb.append("foo&amp;bar");
		sb.append("</static-content>");
7
CodeRank

Related Locale getCountry Questions & Answers:

getCountry Method Overview
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.
See Code Examples for other Java 8 Locale Methods: