本文整理汇总了Java中com.helger.commons.collection.impl.CommonsHashMap类的典型用法代码示例。如果您正苦于以下问题:Java CommonsHashMap类的具体用法?Java CommonsHashMap怎么用?Java CommonsHashMap使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CommonsHashMap类属于com.helger.commons.collection.impl包,在下文中一共展示了CommonsHashMap类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: schedule
import com.helger.commons.collection.impl.CommonsHashMap; //导入依赖的package包/类
/**
* @param aScheduleBuilder
* The schedule builder to be used. May not be <code>null</code>.
* Example:
* <code>SimpleScheduleBuilder.repeatMinutelyForever (1)</code>
* @return The created trigger key for further usage. Never <code>null</code>.
*/
@Nonnull
public static TriggerKey schedule (@Nonnull final SimpleScheduleBuilder aScheduleBuilder)
{
ValueEnforcer.notNull (aScheduleBuilder, "ScheduleBuilder");
final ICommonsMap <String, Object> aJobDataMap = new CommonsHashMap <> ();
return GlobalQuartzScheduler.getInstance ()
.scheduleJob (ReIndexJob.class.getName (),
JDK8TriggerBuilder.newTrigger ()
.startAt (PDTFactory.getCurrentLocalDateTime ()
.plusSeconds (5))
.withSchedule (aScheduleBuilder),
ReIndexJob.class,
aJobDataMap);
}
示例2: testReadBuildInfo
import com.helger.commons.collection.impl.CommonsHashMap; //导入依赖的package包/类
@Test
public void testReadBuildInfo ()
{
final ICommonsMap <String, String> aMap = new CommonsHashMap <> ();
final IReadableResource aRes = new ClassPathResource ("xml/buildinfo.xml");
assertTrue (XMLMapHandler.readMap (aRes, aMap).isSuccess ());
assertNull (XMLMapHandler.readMap (new ClassPathResource ("test1.txt")));
assertTrue (aMap.containsKey ("buildinfo.version"));
assertEquals ("1", aMap.get ("buildinfo.version"));
assertTrue (XMLMapHandler.readMap (aRes).containsKey ("buildinfo.version"));
assertEquals ("1", XMLMapHandler.readMap (aRes).get ("buildinfo.version"));
assertTrue (XMLMapHandler.writeMap (aMap, new ByteArrayOutputStreamProvider ()).isSuccess ());
assertTrue (XMLMapHandler.writeMap (aMap, new NonBlockingByteArrayOutputStream ()).isSuccess ());
}
示例3: testMap
import com.helger.commons.collection.impl.CommonsHashMap; //导入依赖的package包/类
@Test
public void testMap ()
{
final ICommonsMap <String, Object> aMap = new CommonsHashMap<> ();
aMap.put ("foo", "bar");
assertEquals ("{\"foo\":\"bar\"}", JsonConverter.convertToJson (aMap).getAsJsonString ());
final ICommonsNavigableMap <String, Object> aTreeMap = new CommonsTreeMap<> ();
aTreeMap.put ("foo", "bar");
aTreeMap.put ("foo2", Integer.valueOf (5));
assertEquals ("{\"foo\":\"bar\",\"foo2\":5}", JsonConverter.convertToJson (aTreeMap).getAsJsonString ());
final ICommonsOrderedMap <String, Object> aLinkedMap = new CommonsLinkedHashMap<> ();
aLinkedMap.put ("foo", "bar");
aLinkedMap.put ("foo2", Integer.valueOf (5));
assertEquals ("{\"foo\":\"bar\",\"foo2\":5}", JsonConverter.convertToJson (aLinkedMap).getAsJsonString ());
assertEquals ("{foo:\"bar\",foo2:5}",
JsonConverter.convertToJson (aLinkedMap)
.getAsJsonString (new JsonWriterSettings ().setQuoteNames (false)));
}
示例4: testWriteAndReadMap
import com.helger.commons.collection.impl.CommonsHashMap; //导入依赖的package包/类
@Test
public void testWriteAndReadMap ()
{
final ICommonsMap <String, Object> aMap = new CommonsHashMap<> ();
aMap.put ("foo", "bar");
_testWriteAndRead (aMap);
final ICommonsNavigableMap <String, Object> aTreeMap = new CommonsTreeMap<> ();
aTreeMap.put ("foo", "bar");
aTreeMap.put ("foo2", Integer.valueOf (5));
_testWriteAndRead (aTreeMap);
final ICommonsOrderedMap <String, Object> aLinkedMap = new CommonsLinkedHashMap<> ();
aLinkedMap.put ("foo", "bar");
aLinkedMap.put ("foo2", Integer.valueOf (5));
_testWriteAndRead (aLinkedMap);
}
示例5: testMap
import com.helger.commons.collection.impl.CommonsHashMap; //导入依赖的package包/类
@Test
public void testMap ()
{
final ICommonsMap <String, Object> aMap = new CommonsHashMap <> ();
aMap.put ("foo", "bar");
aMap.put ("foo2", Integer.valueOf (5));
assertTrue (JsonConverter.convertToJson (aMap) instanceof JsonObject);
final ICommonsNavigableMap <String, Object> aTreeMap = new CommonsTreeMap <> ();
aTreeMap.put ("foo", "bar");
aTreeMap.put ("foo2", Integer.valueOf (5));
assertTrue (JsonConverter.convertToJson (aTreeMap) instanceof JsonObject);
final ICommonsOrderedMap <String, Object> aLinkedMap = new CommonsLinkedHashMap <> ();
aLinkedMap.put ("foo", "bar");
aLinkedMap.put ("foo2", Integer.valueOf (5));
assertTrue (JsonConverter.convertToJson (aLinkedMap) instanceof JsonObject);
}
示例6: testMap
import com.helger.commons.collection.impl.CommonsHashMap; //导入依赖的package包/类
@Test
public void testMap ()
{
final ICommonsMap <String, Object> aMap = new CommonsHashMap <> ();
aMap.put ("foo", "bar");
_testEqualsHashcode (aMap);
final ICommonsMap <String, Object> aTreeMap = new CommonsTreeMap <> ();
aTreeMap.put ("foo", "bar");
aTreeMap.put ("foo2", Integer.valueOf (5));
_testEqualsHashcode (aTreeMap);
final ICommonsMap <String, Object> aLinkedMap = new CommonsLinkedHashMap <> ();
aLinkedMap.put ("foo", "bar");
aLinkedMap.put ("foo2", Integer.valueOf (5));
_testEqualsHashcode (aLinkedMap);
}
示例7: internalAddChild
import com.helger.commons.collection.impl.CommonsHashMap; //导入依赖的package包/类
@Nonnull
public final EChange internalAddChild (@Nonnull final KEYTYPE aDataID,
@Nonnull final ITEMTYPE aChild,
final boolean bAllowOverwrite)
{
ValueEnforcer.notNull (aChild, "Child");
// Ensure children are present
if (m_aChildMap != null)
{
if (!bAllowOverwrite && m_aChildMap.containsKey (aDataID))
return EChange.UNCHANGED;
}
else
{
m_aChildMap = new CommonsHashMap <> ();
m_aChildren = new CommonsArrayList <> ();
}
m_aChildMap.put (aDataID, aChild);
m_aChildren.add (aChild);
m_aFactory.onAddItem (aChild);
return EChange.CHANGED;
}
示例8: newMap
import com.helger.commons.collection.impl.CommonsHashMap; //导入依赖的package包/类
@Nonnull
@ReturnsMutableCopy
@SafeVarargs
public static <ELEMENTTYPE> CommonsHashMap <ELEMENTTYPE, ELEMENTTYPE> newMap (@Nullable final ELEMENTTYPE... aValues)
{
if (ArrayHelper.isEmpty (aValues))
return newMap (0);
if ((aValues.length % 2) != 0)
throw new IllegalArgumentException ("The passed array needs an even number of elements!");
final CommonsHashMap <ELEMENTTYPE, ELEMENTTYPE> ret = newMap (aValues.length / 2);
for (int i = 0; i < aValues.length; i += 2)
ret.put (aValues[i], aValues[i + 1]);
return ret;
}
示例9: testReplaceMultipleMap
import com.helger.commons.collection.impl.CommonsHashMap; //导入依赖的package包/类
@Test
public void testReplaceMultipleMap ()
{
final ICommonsMap <String, String> aMap = new CommonsHashMap <> ();
aMap.put ("Hallo", "Hi");
aMap.put ("Welt", "world");
aMap.put ("!", "???");
assertEquals ("Abc die Katze lief im Schnee", StringHelper.replaceMultiple ("Abc die Katze lief im Schnee", aMap));
assertEquals ("Hi Katze", StringHelper.replaceMultiple ("Hallo Katze", aMap));
assertEquals ("Moin world", StringHelper.replaceMultiple ("Moin Welt", aMap));
assertEquals ("Moin welt", StringHelper.replaceMultiple ("Moin welt", aMap));
assertEquals ("Hi", StringHelper.replaceMultiple ("Hallo", aMap));
assertEquals ("Hi Hi", StringHelper.replaceMultiple ("Hallo Hallo", aMap));
assertEquals ("HiHiHi", StringHelper.replaceMultiple ("HalloHalloHallo", aMap));
assertEquals ("Hi world???", StringHelper.replaceMultiple ("Hallo Welt!", aMap));
assertEquals ("Hi world???Hi world???", StringHelper.replaceMultiple ("Hallo Welt!Hallo Welt!", aMap));
}
示例10: testMap
import com.helger.commons.collection.impl.CommonsHashMap; //导入依赖的package包/类
@Test
public void testMap ()
{
final StringMap aMap = new StringMap ("a", "b").add ("c", "d");
assertTrue (EqualsHelper.equalsCollection (aMap, aMap));
assertTrue (EqualsHelper.equalsCollection (aMap, CollectionHelper.makeUnmodifiable (aMap)));
assertTrue (EqualsHelper.equalsCollection (aMap, Collections.synchronizedMap (aMap)));
assertTrue (EqualsHelper.equalsCollection (aMap, new StringMap ("a", "b").add ("c", "d")));
assertTrue (EqualsHelper.equalsCollection (new CommonsHashMap <Integer, Integer> (),
new CommonsHashMap <Double, Float> ()));
assertFalse (EqualsHelper.equalsCollection (aMap, new CommonsHashMap <Integer, Integer> ()));
assertFalse (EqualsHelper.equalsCollection (new CommonsHashMap <Integer, Integer> (), aMap));
assertFalse (EqualsHelper.equalsCollection (aMap, new StringMap ("a", "b")));
assertFalse (EqualsHelper.equalsCollection (aMap, new StringMap ("A", "b").add ("c", "d")));
assertFalse (EqualsHelper.equalsCollection (aMap, new StringMap ("a", "B").add ("c", "d")));
assertFalse (EqualsHelper.equalsCollection (aMap, new StringMap ("a", "b").add ("C", "d")));
assertFalse (EqualsHelper.equalsCollection (aMap, new StringMap ("a", "b").add ("c", "D")));
assertFalse (EqualsHelper.equalsCollection (aMap, new StringMap ("a", "b").add ("c", "d").add ("e", "f")));
assertFalse (EqualsHelper.equalsCollection (aMap, new CommonsArrayList <> ("a", "b", "c")));
assertFalse (EqualsHelper.equalsCollection (aMap, new CommonsHashSet <> ("a", "b", "c")));
assertFalse (EqualsHelper.equalsCollection (aMap, ArrayHelper.newArray ("a", "b", "c")));
}
示例11: testBasic
import com.helger.commons.collection.impl.CommonsHashMap; //导入依赖的package包/类
@Test
public void testBasic ()
{
final WSClientConfig aCfg = new WSClientConfig (URLHelper.getAsURL ("http://www.example.org"));
final ICommonsMap <String, Object> aMap = new CommonsHashMap<> ();
final BindingProvider aBP = new MockBP (aMap);
aCfg.applyWSSettingsToBindingProvider (aBP);
assertEquals (5, aMap.size ());
assertEquals ("http://www.example.org", aMap.get (BindingProvider.ENDPOINT_ADDRESS_PROPERTY));
// 2 versions
assertEquals (Integer.valueOf (WSClientConfig.DEFAULT_CONNECTION_TIMEOUT_MS),
aMap.get ("com.sun.xml.ws.connect.timeout"));
assertEquals (Integer.valueOf (WSClientConfig.DEFAULT_CONNECTION_TIMEOUT_MS),
aMap.get ("com.sun.xml.internal.ws.connect.timeout"));
// 2 versions
assertEquals (Integer.valueOf (WSClientConfig.DEFAULT_REQUEST_TIMEOUT_MS),
aMap.get ("com.sun.xml.ws.request.timeout"));
assertEquals (Integer.valueOf (WSClientConfig.DEFAULT_REQUEST_TIMEOUT_MS),
aMap.get ("com.sun.xml.internal.ws.request.timeout"));
}
示例12: getAllVATItemsForCountry
import com.helger.commons.collection.impl.CommonsHashMap; //导入依赖的package包/类
/**
* Get all VAT types matching the given locale (without any fallback!). It
* contains both the specific definitions and the locale independent
* definitions.
*
* @param aCountry
* The locale to use. May not be <code>null</code>.
* @return A non-<code>null</code> map from ID to the matching VAT item. Also
* the deprecated VAT items are returned! VATTYPE_NONE.getID () is
* used if zero VAT is allowed
*/
@ReturnsMutableCopy
@Nonnull
public ICommonsMap <String, IVATItem> getAllVATItemsForCountry (@Nonnull final Locale aCountry)
{
ValueEnforcer.notNull (aCountry, "Country");
final ICommonsMap <String, IVATItem> ret = new CommonsHashMap <> ();
// first get locale specific VAT types
final VATCountryData aVATCountryData = getVATCountryData (aCountry);
if (aVATCountryData != null)
{
if (aVATCountryData.isZeroVATAllowed ())
ret.put (VATTYPE_NONE.getID (), VATTYPE_NONE);
ret.putAll (aVATCountryData.getAllItems ());
}
return ret;
}
示例13: validateAndProduceSVRL
import com.helger.commons.collection.impl.CommonsHashMap; //导入依赖的package包/类
public static void validateAndProduceSVRL (@Nonnull final File aSchematron, final File aXML) throws Exception
{
// Create the custom parameters
final ICommonsMap <String, Object> aCustomParameters = new CommonsHashMap <> ();
aCustomParameters.put ("xyz", "mobile");
aCustomParameters.put ("expected", "");
final SchematronResourceSCH aSCH = SchematronResourceSCH.fromFile (aSchematron);
// Assign custom parameters
aSCH.setParameters (aCustomParameters);
if (false)
System.out.println (XMLWriter.getNodeAsString (aSCH.getXSLTProvider ().getXSLTDocument ()));
// Perform validation
final SchematronOutputType aSVRL = aSCH.applySchematronValidationToSVRL (new FileSystemResource (aXML));
assertNotNull (aSVRL);
if (false)
System.out.println (new SVRLMarshaller ().getAsString (aSVRL));
}
示例14: getClientUniqueID
import com.helger.commons.collection.impl.CommonsHashMap; //导入依赖的package包/类
@Nullable
static String getClientUniqueID (@Nonnull final X509Certificate aCert)
{
try
{
// subject principal name must be in the order CN=XX,O=YY,C=ZZ
// In some JDK versions it is O=YY,CN=XX,C=ZZ instead (e.g. 1.6.0_45)
final LdapName aLdapName = new LdapName (aCert.getSubjectX500Principal ().getName ());
// Make a map from type to name
final ICommonsMap <String, Rdn> aParts = new CommonsHashMap <> ();
for (final Rdn aRdn : aLdapName.getRdns ())
aParts.put (aRdn.getType (), aRdn);
// Re-order - least important item comes first (=reverse order)!
final String sSubjectName = new LdapName (new CommonsArrayList <> (aParts.get ("C"),
aParts.get ("O"),
aParts.get ("CN"))).toString ();
// subject-name + ":" + serial number hexstring
return sSubjectName + ':' + aCert.getSerialNumber ().toString (16);
}
catch (final Exception ex)
{
s_aLogger.error ("Failed to parse '" + aCert.getSubjectX500Principal ().getName () + "'", ex);
return null;
}
}
示例15: _createContext
import com.helger.commons.collection.impl.CommonsHashMap; //导入依赖的package包/类
@Nonnull
private static WebappContext _createContext (final String sURI)
{
final ICommonsMap <String, String> aInitParams = new CommonsHashMap <> ();
aInitParams.put ("jersey.config.server.provider.packages",
com.helger.pd.indexer.rest.IndexerResource.class.getPackage ().getName ());
return _createContext (URI.create (sURI), ServletContainer.class, null, aInitParams, null);
}