本文整理汇总了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);
}
示例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;
}
示例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 ());
}
示例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
}
}
示例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")));
}
示例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 ();
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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);
});
}
示例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;
}
示例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));
}
示例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"));
}