當前位置: 首頁>>代碼示例>>Java>>正文


Java CountryCache類代碼示例

本文整理匯總了Java中com.helger.commons.locale.country.CountryCache的典型用法代碼示例。如果您正苦於以下問題:Java CountryCache類的具體用法?Java CountryCache怎麽用?Java CountryCache使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


CountryCache類屬於com.helger.commons.locale.country包,在下文中一共展示了CountryCache類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: VATINStructure

import com.helger.commons.locale.country.CountryCache; //導入依賴的package包/類
public VATINStructure (@Nonnull final String sCountry,
                       @Nonnull @RegEx final String sRegEx,
                       @Nonnull final Collection <String> aExamples)
{
  ValueEnforcer.notNull (sCountry, "Country");
  ValueEnforcer.notNull (sRegEx, "RegEx");
  ValueEnforcer.notEmpty (aExamples, "Example");

  m_aCountry = CountryCache.getInstance ().getCountry (sCountry);
  if (m_aCountry == null)
    throw new IllegalArgumentException ("country");
  m_sPattern = sRegEx;
  m_aPattern = RegExCache.getPattern (sRegEx);
  m_aExamples = new CommonsArrayList <> (aExamples);

  if (GlobalDebug.isDebugMode ())
    for (final String s : m_aExamples)
      if (!isValid (s))
        throw new IllegalArgumentException ("Example VATIN " + s + " does not match " + sRegEx);
}
 
開發者ID:phax,項目名稱:ph-masterdata,代碼行數:21,代碼來源:VATINStructure.java

示例2: getSingleVehicleSign

import com.helger.commons.locale.country.CountryCache; //導入依賴的package包/類
@Nullable
public static String getSingleVehicleSign (@Nullable final String sCountry)
{
  final Locale aRealCountry = CountryCache.getInstance ().getCountry (sCountry);
  final ICommonsOrderedSet <String> aSigns = s_aCountryToSign.get (aRealCountry);
  if (aSigns != null)
  {
    if (aSigns.size () == 1)
      return aSigns.getFirst ();
    throw new IllegalArgumentException ("Multiple vehicle signs are assigned to the country locale '" +
                                        sCountry +
                                        "': " +
                                        aSigns);
  }
  return null;
}
 
開發者ID:phax,項目名稱:ph-masterdata,代碼行數:17,代碼來源:VehicleSigns.java

示例3: testValidity

import com.helger.commons.locale.country.CountryCache; //導入依賴的package包/類
@Test
public void testValidity ()
{
  final VATManager aVATMgr = VATManager.getDefaultInstance ();
  final Map <String, IVATItem> aData = aVATMgr.getAllVATItemsForCountry (CountryCache.getInstance ()
                                                                                     .getCountry ("hu"));
  assertNotNull (aData);

  IVATItem aItem = aData.get ("hu.v25");
  assertNotNull (aItem);
  assertEquals (BigDecimal.valueOf (25), aItem.getPercentage ());
  assertNull (aItem.getPeriod ().getStart ());
  assertEquals (PDTFactory.createLocalDate (2011, Month.DECEMBER, 31), aItem.getPeriod ().getEnd ());

  aItem = aData.get ("hu.v27");
  assertNotNull (aItem);
  assertEquals (PDTFactory.createLocalDate (2012, Month.JANUARY, 1), aItem.getPeriod ().getStart ());
  assertNull (aItem.getPeriod ().getEnd ());
}
 
開發者ID:phax,項目名稱:ph-masterdata,代碼行數:20,代碼來源:VATManagerTest.java

示例4: testGetSingleCountryFromVehicleSign

import com.helger.commons.locale.country.CountryCache; //導入依賴的package包/類
@Test
public void testGetSingleCountryFromVehicleSign ()
{
  final CountryCache aCC = CountryCache.getInstance ();
  assertEquals (aCC.getCountry ("AT"), VehicleSigns.getSingleCountryFromVehicleSign ("A"));
  assertNull (VehicleSigns.getSingleCountryFromVehicleSign ("XYZ"));
  try
  {
    // Has 2 countries
    VehicleSigns.getSingleCountryFromVehicleSign ("ROK");
    fail ();
  }
  catch (final IllegalArgumentException ex)
  {
    // expected
  }
}
 
開發者ID:phax,項目名稱:ph-masterdata,代碼行數:18,代碼來源:VehicleSignsTest.java

示例5: testDefault

import com.helger.commons.locale.country.CountryCache; //導入依賴的package包/類
@Test
public void testDefault ()
{
  final DeprecatedLocaleHandler x = DeprecatedLocaleHandler.getDefaultInstance ();
  assertNotNull (x);
  assertEquals (1, x.getAllDeprecatedLocales ().size ());

  // Deprecated one
  assertTrue (x.isDeprecatedLocale (CountryCache.getInstance ().getCountry ("CS")));

  // This locale is only implicitly deprecated
  assertFalse (x.isDeprecatedLocale (LocaleCache.getInstance ().getLocale ("cs", "CS")));

  // This country is not deprecated
  assertFalse (x.isDeprecatedLocale (CountryCache.getInstance ().getCountry ("AT")));

  // Deprecated one with fallback
  assertTrue (x.isDeprecatedLocaleWithFallback (CountryCache.getInstance ().getCountry ("CS")));

  // This locale is implicitly also deprecated
  assertTrue (x.isDeprecatedLocaleWithFallback (LocaleCache.getInstance ().getLocale ("cs", "CS")));

  // This country is not deprecated
  assertFalse (x.isDeprecatedLocaleWithFallback (CountryCache.getInstance ().getCountry ("AT")));
}
 
開發者ID:phax,項目名稱:ph-masterdata,代碼行數:26,代碼來源:DeprecatedLocaleHandlerTest.java

示例6: cleanup

import com.helger.commons.locale.country.CountryCache; //導入依賴的package包/類
/**
 * Cleanup all custom caches contained in this library. Loaded SPI
 * implementations are not affected by this method!
 */
public static void cleanup ()
{
  // Reinitialize singletons to the default values
  if (LocaleCache.isInstantiated ())
    LocaleCache.getInstance ().reinitialize ();
  if (CountryCache.isInstantiated ())
    CountryCache.getInstance ().reinitialize ();
  if (SerializationConverterRegistry.isInstantiated ())
    SerializationConverterRegistry.getInstance ().reinitialize ();
  if (MimeTypeDeterminator.isInstantiated ())
    MimeTypeDeterminator.getInstance ().reinitialize ();
  if (ThirdPartyModuleRegistry.isInstantiated ())
    ThirdPartyModuleRegistry.getInstance ().reinitialize ();
  if (TypeConverterRegistry.isInstantiated ())
    TypeConverterRegistry.getInstance ().reinitialize ();
  if (URLProtocolRegistry.isInstantiated ())
    URLProtocolRegistry.getInstance ().reinitialize ();
  if (EqualsImplementationRegistry.isInstantiated ())
    EqualsImplementationRegistry.getInstance ().reinitialize ();
  if (HashCodeImplementationRegistry.isInstantiated ())
    HashCodeImplementationRegistry.getInstance ().reinitialize ();

  // Clear caches
  if (DefaultTextResolver.isInstantiated ())
    DefaultTextResolver.getInstance ().clearCache ();
  EnumHelper.clearCache ();
  ResourceBundleHelper.clearCache ();
  if (RegExCache.isInstantiated ())
    RegExCache.getInstance ().clearCache ();
  CollatorHelper.clearCache ();
  LocaleHelper.clearCache ();
  StatisticsManager.clearCache ();
  SystemProperties.clearWarnedPropertyNames ();
  if (ImageDataManager.isInstantiated ())
    ImageDataManager.getInstance ().clearCache ();

  // Clean this one last as it is used in equals and hashCode implementations!
  ClassHierarchyCache.clearCache ();
}
 
開發者ID:phax,項目名稱:ph-commons,代碼行數:44,代碼來源:CommonsCleanup.java

示例7: getVATCountryData

import com.helger.commons.locale.country.CountryCache; //導入依賴的package包/類
/**
 * Get the VAT data of the passed country.
 *
 * @param aLocale
 *        The locale to use. May not be <code>null</code>.
 * @return <code>null</code> if no such country data is present.
 */
@Nullable
public VATCountryData getVATCountryData (@Nonnull final Locale aLocale)
{
  ValueEnforcer.notNull (aLocale, "Locale");
  final Locale aCountry = CountryCache.getInstance ().getCountry (aLocale);
  return m_aVATItemsPerCountry.get (aCountry);
}
 
開發者ID:phax,項目名稱:ph-masterdata,代碼行數:15,代碼來源:VATManager.java

示例8: VATItem

import com.helger.commons.locale.country.CountryCache; //導入依賴的package包/類
public VATItem (@Nonnull @Nonempty final String sID,
                @Nullable final Locale aCountry,
                @Nonnull final EVATType eType,
                @Nonnull @Nonnegative final BigDecimal aPercentage,
                final boolean bDeprecated,
                @Nullable final LocalDate aValidFrom,
                @Nullable final LocalDate aValidTo)
{
  ValueEnforcer.notEmpty (sID, "ID");
  ValueEnforcer.notNull (eType, "Type");
  ValueEnforcer.notNull (aPercentage, "Percentage");
  ValueEnforcer.isBetweenInclusive (aPercentage, "Percentage", BigDecimal.ZERO, CGlobal.BIGDEC_100);
  // Simply not true
  if (false)
    if (MathHelper.isNE0 (aPercentage))
      ValueEnforcer.notNull (aCountry, "If a percentage is present a country must be present!");
  if (aValidFrom != null && aValidTo != null && aValidTo.isBefore (aValidFrom))
    throw new IllegalArgumentException ("ValidFrom date must be <= validTo date");

  m_sID = sID;
  m_aCountry = CountryCache.getInstance ().getCountry (aCountry);
  m_eType = eType;
  m_aPercentage = aPercentage;
  m_aPercentageFactor = m_aPercentage.divide (CGlobal.BIGDEC_100);
  m_aMultiplicationFactorNetToGross = BigDecimal.ONE.add (m_aPercentageFactor);
  m_bDeprecated = bDeprecated;
  m_aPeriod = new LocalDatePeriod (aValidFrom, aValidTo);
}
 
開發者ID:phax,項目名稱:ph-masterdata,代碼行數:29,代碼來源:VATItem.java

示例9: _add

import com.helger.commons.locale.country.CountryCache; //導入依賴的package包/類
private static void _add (@Nonnull final String sCountryCode, @Nonnull final String sSign)
{
  final Locale aCountry = CountryCache.getInstance ().getCountry (sCountryCode);
  if (s_aCountryToSign.putSingle (aCountry, sSign).isUnchanged ())
    throw new InitializationException ("Locale " + aCountry + " already contains sign '" + sSign + "'");
  if (s_aSignToCountry.putSingle (sSign, aCountry).isUnchanged ())
    throw new InitializationException ("Sign '" + sSign + "' already contains country " + aCountry);
}
 
開發者ID:phax,項目名稱:ph-masterdata,代碼行數:9,代碼來源:VehicleSigns.java

示例10: getAllVehicleSigns

import com.helger.commons.locale.country.CountryCache; //導入依賴的package包/類
@Nonnull
@ReturnsMutableCopy
public static ICommonsOrderedSet <String> getAllVehicleSigns (@Nullable final String sCountry)
{
  final Locale aRealCountry = CountryCache.getInstance ().getCountry (sCountry);
  final ICommonsOrderedSet <String> aSigns = s_aCountryToSign.get (aRealCountry);
  return new CommonsLinkedHashSet <> (aSigns);
}
 
開發者ID:phax,項目名稱:ph-masterdata,代碼行數:9,代碼來源:VehicleSigns.java

示例11: getContinentsOfCountry

import com.helger.commons.locale.country.CountryCache; //導入依賴的package包/類
/**
 * Get all continents for the specified country ID
 *
 * @param aLocale
 *        The locale to be used. May be <code>null</code>.
 * @return <code>null</code> if no continent data is defined. Otherwise a non-
 *         <code>null</code> Set with all continents, without
 *         <code>null</code> elements.
 */
@Nullable
@ReturnsMutableCopy
public static ICommonsNavigableSet <EContinent> getContinentsOfCountry (@Nullable final Locale aLocale)
{
  final Locale aCountry = CountryCache.getInstance ().getCountry (aLocale);
  if (aCountry != null)
  {
    final ICommonsNavigableSet <EContinent> ret = s_aMap.get (aCountry);
    if (ret != null)
      return ret.getClone ();
  }
  return null;
}
 
開發者ID:phax,項目名稱:ph-masterdata,代碼行數:23,代碼來源:ContinentHelper.java

示例12: addCountry

import com.helger.commons.locale.country.CountryCache; //導入依賴的package包/類
public void addCountry (@Nonnull final IPostalCodeCountry aPostalCountry)
{
  ValueEnforcer.notNull (aPostalCountry, "PostalCountry");

  // Unify ISO code
  final Locale aCountry = CountryCache.getInstance ().getCountry (aPostalCountry.getISO ());

  m_aRWLock.writeLocked ( () -> {
    if (m_aMap.containsKey (aCountry))
      throw new IllegalArgumentException ("A country with code '" + aCountry + "' was already regsitered!");
    m_aMap.put (aCountry, aPostalCountry);
  });
}
 
開發者ID:phax,項目名稱:ph-masterdata,代碼行數:14,代碼來源:PostalCodeManager.java

示例13: getCountryLocale

import com.helger.commons.locale.country.CountryCache; //導入依賴的package包/類
@Nullable
public Locale getCountryLocale ()
{
  Locale ret = m_aCountry;
  if (ret == null && m_sCountry != null)
  {
    m_aCountry = ret = CountryCache.getInstance ().getCountry (m_sCountry);
  }
  return ret;
}
 
開發者ID:phax,項目名稱:ph-masterdata,代碼行數:11,代碼來源:PostalAddress.java

示例14: testGetFromCountry

import com.helger.commons.locale.country.CountryCache; //導入依賴的package包/類
@Test
public void testGetFromCountry ()
{
  // The following countries have multiple currencies:
  final Locale aLocCuba = CountryCache.getInstance ().getCountry ("CU");

  for (final ECurrency e : ECurrency.values ())
    if (!e.isDeprecated ())
      for (final Locale aLocale : e.getAllMatchingLocales ())
        if (!EqualsHelper.equals (aLocale, aLocCuba))
          assertSame (e, ECurrency.getFromLocaleOrNull (aLocale));
}
 
開發者ID:phax,項目名稱:ph-masterdata,代碼行數:13,代碼來源:ECurrencyTest.java

示例15: testGetAllCountriesFromVehicleSign

import com.helger.commons.locale.country.CountryCache; //導入依賴的package包/類
@Test
public void testGetAllCountriesFromVehicleSign ()
{
  final CountryCache aCC = CountryCache.getInstance ();
  assertEquals (new CommonsLinkedHashSet <> (aCC.getCountry ("AT")),
                VehicleSigns.getAllCountriesFromVehicleSign ("A"));
  assertEquals (new CommonsLinkedHashSet <> (), VehicleSigns.getAllCountriesFromVehicleSign ("XYZ"));
  // Has 2 countries
  assertEquals (new CommonsLinkedHashSet <> (aCC.getCountry ("KP"), aCC.getCountry ("KR")),
                VehicleSigns.getAllCountriesFromVehicleSign ("ROK"));
}
 
開發者ID:phax,項目名稱:ph-masterdata,代碼行數:12,代碼來源:VehicleSignsTest.java


注:本文中的com.helger.commons.locale.country.CountryCache類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。