com.helger.commons.collection.impl.ICommonsMap Java Examples
The following examples show how to use
com.helger.commons.collection.impl.ICommonsMap.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: XMLMapHandlerTest.java From ph-commons with Apache License 2.0 | 6 votes |
@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 ()); }
Example #2
Source File: Schematron2XSLTMojoTest.java From ph-schematron with Apache License 2.0 | 6 votes |
@Test public void testCustomParameters () throws Exception { final File aPOM = new File ("src/test/resources/poms/test-sch2xslt1/pom.xml"); assertNotNull (aPOM); assertTrue (aPOM.exists ()); // Use "Configured" to get default values injected final Schematron2XSLTMojo aMojo = (Schematron2XSLTMojo) m_aRule.lookupConfiguredMojo (aPOM.getParentFile (), "convert"); assertNotNull (aMojo); // Making the files is essential, otherwise the paths are interpreted // relative to the test POM! aMojo.setSchematronDirectory (new File ("src/test/resources/schematron").getAbsoluteFile ()); aMojo.setXsltDirectory (new File ("target/test/schematron-via-maven-plugin2").getAbsoluteFile ()); // Test parameters from POM final ICommonsMap <String, String> aParams = aMojo.getParameters (); assertNotNull (aParams); assertEquals (2, aParams.size ()); assertEquals ("true", aParams.get ("allow-foreign")); assertEquals ("else", aParams.get ("anything")); aMojo.execute (); }
Example #3
Source File: Schematron2XSLTMojoFuncTest.java From ph-schematron with Apache License 2.0 | 6 votes |
@Test public void testMavenPlugin () throws MojoExecutionException, MojoFailureException { expect (project.getBasedir ()).andReturn (new File (".")).anyTimes (); replay (project); // Note: default values are not used here OUT.setSchematronDirectory (new File ("src/test/resources/schematron")); OUT.setSchematronPattern ("**/*.sch"); OUT.setXsltDirectory (new File ("target/test/schematron-via-maven-plugin")); OUT.setXsltExtension (".xslt"); final ICommonsMap <String, String> aParams = new CommonsHashMap <> (); aParams.put ("allow-foreign", "true"); OUT.setParameters (aParams); OUT.execute (); verify (project); }
Example #4
Source File: JsonWriterTest.java From ph-commons with Apache License 2.0 | 6 votes |
@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))); }
Example #5
Source File: JsonWriterTest.java From ph-commons with Apache License 2.0 | 6 votes |
@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); }
Example #6
Source File: JsonConverterTest.java From ph-commons with Apache License 2.0 | 6 votes |
@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); }
Example #7
Source File: MultiConfigurationValueProviderTest.java From ph-commons with Apache License 2.0 | 6 votes |
@Test public void testBasic () { final MultiConfigurationValueProvider aMCSVP = new MultiConfigurationValueProvider (); // Lower priority final ICommonsMap <String, String> aMap1 = new CommonsHashMap <> (); aMap1.put ("key1", "value1"); aMap1.put ("key2", "value2"); aMCSVP.addConfigurationSource (new ConfigurationSourceFunction (110, aMap1::get)); // Higher priority - should be returned final ICommonsMap <String, String> aMap2 = new CommonsHashMap <> (); aMap2.put ("key1", "value2"); aMap2.put ("key3", "value3"); aMCSVP.addConfigurationSource (new ConfigurationSourceFunction (111, aMap2::get)); // Resolve assertEquals ("value2", aMCSVP.getConfigurationValue ("key1").getValue ()); assertEquals ("value2", aMCSVP.getConfigurationValue ("key2").getValue ()); assertEquals ("value3", aMCSVP.getConfigurationValue ("key3").getValue ()); assertNull (aMCSVP.getConfigurationValue ("key4")); }
Example #8
Source File: PSXPathBoundAssertReport.java From ph-schematron with Apache License 2.0 | 6 votes |
public PSXPathBoundAssertReport (@Nonnull final PSAssertReport aAssertReport, @Nonnull final String sTestExpression, @Nonnull final XPathExpression aBoundTestExpression, @Nonnull final ICommonsList <PSXPathBoundElement> aBoundContent, @Nonnull final ICommonsMap <String, PSXPathBoundDiagnostic> aBoundDiagnostics) { ValueEnforcer.notNull (aAssertReport, "AssertReport"); ValueEnforcer.notNull (sTestExpression, "TestExpression"); ValueEnforcer.notNull (aBoundTestExpression, "BoundTestExpression"); ValueEnforcer.notNull (aBoundContent, "BoundContent"); ValueEnforcer.notNull (aBoundDiagnostics, "BoundDiagnostics"); m_aAssertReport = aAssertReport; m_sTestExpression = sTestExpression; m_aBoundTestExpression = aBoundTestExpression; m_aBoundContent = aBoundContent; m_aBoundDiagnostics = aBoundDiagnostics; }
Example #9
Source File: EqualsHashcodeFuncTest.java From ph-commons with Apache License 2.0 | 6 votes |
@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); }
Example #10
Source File: WSClientConfigTest.java From ph-commons with Apache License 2.0 | 6 votes |
@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")); }
Example #11
Source File: StringHelperTest.java From ph-commons with Apache License 2.0 | 6 votes |
@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)); }
Example #12
Source File: SchematronValidationMojo.java From ph-schematron with Apache License 2.0 | 5 votes |
@Nonnull @ReturnsMutableCopy @VisibleForTesting ICommonsMap <String, String> getParameters () { return new CommonsHashMap <> (m_aCustomParameters); }
Example #13
Source File: CollectionHelperTest.java From ph-commons with Apache License 2.0 | 5 votes |
@Test @SuppressFBWarnings ("NP_NONNULL_PARAM_VIOLATION") public void testMakeUnmodifiableNotNull () { assertNotNull (makeUnmodifiableNotNull ((Collection <?>) null)); assertNotNull (makeUnmodifiableNotNull ((ICommonsList <?>) null)); assertNotNull (makeUnmodifiableNotNull ((Set <?>) null)); assertNotNull (makeUnmodifiableNotNull ((SortedSet <?>) null)); assertNotNull (makeUnmodifiableNotNull ((Map <?, ?>) null)); assertNotNull (makeUnmodifiableNotNull ((SortedMap <?, ?>) null)); final ICommonsCollection <String> c = newList ("s1", "s2"); assertNotNull (makeUnmodifiableNotNull (c)); assertNotSame (c, makeUnmodifiableNotNull (c)); final ICommonsList <String> l = newList ("s1", "s2"); assertNotNull (makeUnmodifiableNotNull (l)); assertNotSame (l, makeUnmodifiableNotNull (l)); final ICommonsSet <String> s = newSet ("s1", "s2"); assertNotNull (makeUnmodifiableNotNull (s)); assertNotSame (s, makeUnmodifiableNotNull (s)); final ICommonsSortedSet <String> ss = new CommonsTreeSet <> (s); assertNotNull (makeUnmodifiableNotNull (ss)); assertNotSame (ss, makeUnmodifiableNotNull (ss)); final ICommonsMap <String, String> m = newMap ("s1", "s2"); assertNotNull (makeUnmodifiableNotNull (m)); assertNotSame (m, makeUnmodifiableNotNull (m)); final ICommonsSortedMap <String, String> sm = new CommonsTreeMap <> (m); assertNotNull (makeUnmodifiableNotNull (sm)); assertNotSame (sm, makeUnmodifiableNotNull (sm)); }
Example #14
Source File: Schematron2XSLTMojo.java From ph-schematron with Apache License 2.0 | 5 votes |
@Nonnull @ReturnsMutableCopy @VisibleForTesting ICommonsMap <String, String> getParameters () { return new CommonsHashMap <> (m_aCustomParameters); }
Example #15
Source File: PSXPathBoundSchema.java From ph-schematron with Apache License 2.0 | 5 votes |
@Nullable private ICommonsMap <String, PSXPathBoundDiagnostic> _createBoundDiagnostics (@Nonnull final XPath aXPathContext, @Nonnull final PSXPathVariables aGlobalVariables) { final ICommonsMap <String, PSXPathBoundDiagnostic> ret = new CommonsHashMap <> (); boolean bHasAnyError = false; final PSSchema aSchema = getOriginalSchema (); if (aSchema.hasDiagnostics ()) { // For all contained diagnostic elements for (final PSDiagnostic aDiagnostic : aSchema.getDiagnostics ().getAllDiagnostics ()) { final ICommonsList <PSXPathBoundElement> aBoundElements = _createBoundElements (aDiagnostic, aXPathContext, aGlobalVariables); if (aBoundElements == null) { // error already emitted bHasAnyError = true; } else { final PSXPathBoundDiagnostic aBoundDiagnostic = new PSXPathBoundDiagnostic (aDiagnostic, aBoundElements); if (ret.put (aDiagnostic.getID (), aBoundDiagnostic) != null) { error (aDiagnostic, "A diagnostic element with ID '" + aDiagnostic.getID () + "' was overwritten!"); bHasAnyError = true; } } } } if (bHasAnyError) return null; return ret; }
Example #16
Source File: PSPreprocessor.java From ph-schematron with Apache License 2.0 | 5 votes |
@Nullable private PSRule _getPreprocessedRule (@Nonnull final PSRule aRule, @Nonnull final PreprocessorLookup aLookup, @Nonnull final PreprocessorIDPool aIDPool, @Nullable final ICommonsMap <String, String> aParamValueMap) throws SchematronPreprocessException { if (aRule.isAbstract ()) { // Will be inlined return null; } final PSRule ret = new PSRule (); ret.setFlag (aRule.getFlag ()); ret.setRich (aRule.getRichClone ()); ret.setLinkable (aRule.getLinkableClone ()); // abstract is always false ret.setContext (m_aQueryBinding.getWithParamTextsReplaced (aRule.getContext (), aParamValueMap)); ret.setID (aIDPool.getUniqueID (aRule.getID ())); if (aRule.hasAnyInclude ()) throw new SchematronPreprocessException ("Cannot preprocess <rule> with an <include>"); for (final PSLet aLet : aRule.getAllLets ()) ret.addLet (aLet.getClone ()); _resolveRuleContent (aRule.getAllContentElements (), aLookup, aIDPool, aParamValueMap, ret); ret.addForeignElements (aRule.getAllForeignElements ()); ret.addForeignAttributes (aRule.getAllForeignAttributes ()); return ret; }
Example #17
Source File: CollectionHelperTest.java From ph-commons with Apache License 2.0 | 5 votes |
@Test public void testMakeUnmodifiable () { assertNull (makeUnmodifiable ((Collection <?>) null)); assertNull (makeUnmodifiable ((ICommonsList <?>) null)); assertNull (makeUnmodifiable ((Set <?>) null)); assertNull (makeUnmodifiable ((SortedSet <?>) null)); assertNull (makeUnmodifiable ((Map <?, ?>) null)); assertNull (makeUnmodifiable ((SortedMap <?, ?>) null)); final ICommonsCollection <String> c = newList ("s1", "s2"); assertNotNull (makeUnmodifiable (c)); assertNotSame (c, makeUnmodifiable (c)); final ICommonsList <String> l = newList ("s1", "s2"); assertNotNull (makeUnmodifiable (l)); assertNotSame (l, makeUnmodifiable (l)); final ICommonsSet <String> s = newSet ("s1", "s2"); assertNotNull (makeUnmodifiable (s)); assertNotSame (s, makeUnmodifiable (s)); final ICommonsSortedSet <String> ss = new CommonsTreeSet <> (s); assertNotNull (makeUnmodifiable (ss)); assertNotSame (ss, makeUnmodifiable (ss)); final ICommonsMap <String, String> m = newMap ("s1", "s2"); assertNotNull (makeUnmodifiable (m)); assertNotSame (m, makeUnmodifiable (m)); final ICommonsSortedMap <String, String> sm = new CommonsTreeMap <> (m); assertNotNull (makeUnmodifiable (sm)); assertNotSame (sm, makeUnmodifiable (sm)); }
Example #18
Source File: FontKerningFuncTest.java From ph-commons with Apache License 2.0 | 5 votes |
@Test public void testKerning () throws IOException { if (EOperatingSystem.getCurrentOS ().isWindowsBased ()) { // required to get graphics up and running... GraphicsEnvironment.getLocalGraphicsEnvironment (); final int nFontSize = 25; final ICommonsMap <TextAttribute, Object> aTextAttributes = new CommonsHashMap <> (); aTextAttributes.put (TextAttribute.FAMILY, "Arial"); aTextAttributes.put (TextAttribute.SIZE, Float.valueOf (nFontSize)); final Font aFont = Font.getFont (aTextAttributes); final char [] aChars = "T,".toCharArray (); final GlyphVector aGlyphVector = aFont.layoutGlyphVector (new FontRenderContext (new AffineTransform (), false, true), aChars, 0, aChars.length, Font.LAYOUT_LEFT_TO_RIGHT); final int tCode = aGlyphVector.getGlyphCode (0); final int commaCode = aGlyphVector.getGlyphCode (1); final Kerning aKerning = new Kerning (new FileInputStream (System.getenv ("windir") + "/fonts/ARIAL.TTF")); LOGGER.info (Float.toString (aKerning.getValue (tCode, commaCode, nFontSize))); } else LOGGER.warn ("Works only on Windows!"); }
Example #19
Source File: JsonWriterTest.java From ph-commons with Apache License 2.0 | 5 votes |
@Test public void testComplex () { final ICommonsList <JsonObject> aObjs = new CommonsArrayList <> (); for (final ICommonsMap <String, String> aRow : new CommonsArrayList <> (CollectionHelper.newMap ("key", "value"))) { final JsonObject aObj = new JsonObject (); for (final Map.Entry <String, String> aEntry : aRow.entrySet ()) aObj.add (aEntry.getKey (), aEntry.getValue ()); aObjs.add (aObj); } assertEquals ("{\"aa\":[{\"key\":\"value\"}]}", JsonConverter.convertToJson (new JsonObject ().add ("aa", aObjs)).getAsJsonString ()); }
Example #20
Source File: EqualsHelperTest.java From ph-commons with Apache License 2.0 | 5 votes |
@Test public void testComplex () { final ICommonsMap <ICommonsList <String>, ICommonsSet <String>> aMap = new CommonsHashMap <> (); aMap.put (new CommonsArrayList <> ("a", "b", "c"), new CommonsHashSet <> ("a", "b", "c")); aMap.put (new CommonsArrayList <> ("a", "b", "d"), new CommonsHashSet <> ("a", "b", "d")); assertTrue (EqualsHelper.equalsCollection (aMap, CollectionHelper.newMap (aMap))); assertFalse (EqualsHelper.equalsCollection (aMap, ArrayHelper.newArray ("a", "b", "c", "d"))); assertFalse (EqualsHelper.equalsCollection (aMap, new CommonsArrayList <> ("a", "b", "c"))); assertFalse (EqualsHelper.equalsCollection (aMap, new CommonsHashSet <> ("a", "b", "c"))); final ICommonsMap <String, String> aMap1a = new CommonsHashMap <> (); aMap1a.put ("a", "b"); assertFalse (EqualsHelper.equalsCollection (aMap, aMap1a)); final ICommonsMap <ICommonsList <String>, String> aMap2 = new CommonsHashMap <> (); aMap2.put (new CommonsArrayList <> ("a", "b", "c"), "d"); aMap2.put (new CommonsArrayList <> ("a", "b", "d"), "e"); aMap2.put (new CommonsArrayList <> ("a", "b", "e"), null); aMap2.put (null, "g"); assertFalse (EqualsHelper.equalsCollection (aMap, aMap2)); assertFalse (EqualsHelper.equalsCollection (aMap2, aMap)); final ICommonsMap <String, ICommonsList <String>> aMap3 = new CommonsHashMap <> (); aMap3.put ("d", new CommonsArrayList <> ("a", "b", "c")); aMap3.put ("e", new CommonsArrayList <> ("a", "b", "d")); aMap3.put (null, new CommonsArrayList <> ("a", "b", "e")); aMap3.put ("g", null); assertFalse (EqualsHelper.equalsCollection (aMap, aMap3)); assertFalse (EqualsHelper.equalsCollection (aMap3, aMap)); }
Example #21
Source File: TextHelperTest.java From ph-commons with Apache License 2.0 | 5 votes |
@Test public void testCreateMultilingualTextFromMap () { final ICommonsMap <String, String> aParamNames = new CommonsHashMap <> (); IMultilingualText aMLT = TextHelper.createMultilingualTextFromMap (aParamNames); assertEquals (0, aMLT.texts ().size ()); aParamNames.put ("de", "x"); aParamNames.put ("en", "y"); aMLT = TextHelper.createMultilingualTextFromMap (aParamNames); assertEquals (2, aMLT.texts ().size ()); assertEquals ("x", aMLT.getText (L_DE)); assertEquals ("y", aMLT.getText (L_EN)); }
Example #22
Source File: SchematronValidationMojoTest.java From ph-schematron with Apache License 2.0 | 5 votes |
@Test public void testCustomParameters () throws Exception { final File aPOM = new File ("src/test/resources/poms/test-validate1/pom.xml").getAbsoluteFile (); assertNotNull (aPOM); assertTrue (aPOM.exists ()); assertTrue (aPOM.isFile ()); // Use "Configured" to get default values injected final SchematronValidationMojo aMojo = (SchematronValidationMojo) m_aRule.lookupConfiguredMojo (aPOM.getParentFile (), "validate"); assertNotNull (aMojo); // Making the files is essential, otherwise the paths are interpreted // relative to the test POM! aMojo.setSchematronFile (new File ("src/test/resources/schematron/check-classifications.sch").getAbsoluteFile ()); aMojo.setXmlDirectory (new File ("src/test/resources/data").getAbsoluteFile ()); aMojo.setXmlIncludes ("*-valid.xml"); // Test parameters from POM final ICommonsMap <String, String> aParams = aMojo.getParameters (); assertNotNull (aParams); assertEquals (2, aParams.size ()); assertEquals ("true", aParams.get ("allow-foreign")); assertEquals ("else", aParams.get ("anything")); aMojo.execute (); }
Example #23
Source File: PSPreprocessor.java From ph-schematron with Apache License 2.0 | 5 votes |
/** * Resolve all <extends> elements. This method calls itself recursively * until all extends elements are resolved. * * @param aRuleContent * A list consisting of {@link PSAssertReport} and {@link PSExtends} * objects. Never <code>null</code>. * @param aLookup * The rule lookup object * @throws SchematronPreprocessException * If the base rule of an extends object could not be resolved. */ private void _resolveRuleContent (@Nonnull final ICommonsList <IPSElement> aRuleContent, @Nonnull final PreprocessorLookup aLookup, @Nonnull final PreprocessorIDPool aIDPool, @Nullable final ICommonsMap <String, String> aParamValueMap, @Nonnull final PSRule aTargetRule) throws SchematronPreprocessException { for (final IPSElement aElement : aRuleContent) { if (aElement instanceof PSAssertReport) { final PSAssertReport aAssertReport = (PSAssertReport) aElement; aTargetRule.addAssertReport (_getPreprocessedAssert (aAssertReport, aIDPool, aParamValueMap)); } else { final PSExtends aExtends = (PSExtends) aElement; final String sRuleID = aExtends.getRule (); final PSRule aBaseRule = aLookup.getAbstractRuleOfID (sRuleID); if (aBaseRule == null) throw new SchematronPreprocessException ("Failed to resolve rule ID '" + sRuleID + "' in extends statement. Available rules are: " + aLookup.getAllAbstractRuleIDs ()); // Recursively resolve the extends of the base rule _resolveRuleContent (aBaseRule.getAllContentElements (), aLookup, aIDPool, aParamValueMap, aTargetRule); // Copy all lets for (final PSLet aBaseLet : aBaseRule.getAllLets ()) aTargetRule.addLet (aBaseLet.getClone ()); } } }
Example #24
Source File: SystemProperties.java From ph-commons with Apache License 2.0 | 5 votes |
/** * @return A map with all system properties where the key is the system * property name and the value is the system property value. */ @Nonnull @ReturnsMutableCopy public static ICommonsMap <String, String> getAllProperties () { final Properties aProperties = IPrivilegedAction.systemGetProperties ().invokeSafe (); if (aProperties == null) return new CommonsHashMap <> (); return PropertiesHelper.getAsStringMap (aProperties); }
Example #25
Source File: TypeConverterRegistry.java From ph-commons with Apache License 2.0 | 5 votes |
@Nonnull @ReturnsMutableObject ("internal use only") private ICommonsMap <Class <?>, ITypeConverter <?, ?>> _getOrCreateConverterMap (@Nonnull final Class <?> aClass) { ICommonsMap <Class <?>, ITypeConverter <?, ?>> ret = m_aRWLock.readLockedGet ( () -> m_aConverter.get (aClass)); if (ret == null) { // Try again in write lock // Weak hash map because key is a class ret = m_aRWLock.writeLockedGet ( () -> m_aConverter.computeIfAbsent (aClass, k -> new CommonsWeakHashMap <> ())); } return ret; }
Example #26
Source File: MappedCache.java From ph-commons with Apache License 2.0 | 5 votes |
/** * Create a new cache map. This is the internal map that is used to store the * items. * * @return Never <code>null</code>. */ @Nonnull @ReturnsMutableCopy @OverrideOnDemand @CodingStyleguideUnaware protected ICommonsMap <KEYSTORETYPE, Wrapper <VALUETYPE>> createCache () { return hasMaxSize () ? new SoftLinkedHashMap <> (m_nMaxSize) : new SoftHashMap <> (); }
Example #27
Source File: PropertiesHelper.java From ph-commons with Apache License 2.0 | 5 votes |
@Nonnull @ReturnsMutableCopy public static ICommonsMap <String, String> getAsStringMap (@Nonnull final Properties aProps) { ValueEnforcer.notNull (aProps, "Props"); final ICommonsMap <String, String> ret = new CommonsHashMap <> (); for (final Map.Entry <Object, Object> aEntry : aProps.entrySet ()) ret.put ((String) aEntry.getKey (), (String) aEntry.getValue ()); return ret; }
Example #28
Source File: LocaleHelper.java From ph-commons with Apache License 2.0 | 5 votes |
/** * Get all possible locale names in the passed locale * * @param aContentLocale * the locale ID in which the language list is required * @return The mapping from the input locale to the display text. The result * map is not ordered. */ @Nonnull @ReturnsMutableCopy public static ICommonsMap <Locale, String> getAllLocaleDisplayNames (@Nonnull final Locale aContentLocale) { ValueEnforcer.notNull (aContentLocale, "ContentLocale"); return new CommonsHashMap <> (LocaleCache.getInstance ().getAllLocales (), Function.identity (), aLocale -> getLocaleDisplayName (aLocale, aContentLocale)); }
Example #29
Source File: IErrorList.java From ph-commons with Apache License 2.0 | 5 votes |
/** * @return A map with all items mapped from error field name to its * occurrences. */ @Nonnull @ReturnsMutableCopy default ICommonsMap <String, ICommonsList <IError>> getGroupedByFieldName () { return getGrouped (IError::getErrorFieldName); }
Example #30
Source File: IErrorList.java From ph-commons with Apache License 2.0 | 5 votes |
/** * @return A map with all items mapped from error ID to its occurrences. */ @Nonnull @ReturnsMutableCopy default ICommonsMap <String, ICommonsList <IError>> getGroupedByID () { return getGrouped (IError::getErrorID); }