/** * Emit all supported features to the logger. */ public static void debugLogDOMFeatures () { for (final Map.Entry <EXMLDOMFeatureVersion, ICommonsList <String>> aEntry : s_aSupportedFeatures.entrySet ()) for (final String sFeature : aEntry.getValue ()) if (LOGGER.isInfoEnabled ()) LOGGER.info ("DOM " + aEntry.getKey ().getID () + " feature '" + sFeature + "' is present"); }
@Nullable public WebSpiderInfo getWebSpiderFromUserAgent (@Nonnull final String sUserAgent) { // Search case insensitive (key set is lowercase!) final String sUserAgentLC = _getUnifiedID (sUserAgent); for (final Map.Entry <String, WebSpiderInfo> aEntry : m_aMap.entrySet ()) if (sUserAgentLC.contains (aEntry.getKey ())) return aEntry.getValue (); return null; } }
/** * Find the process identifier with the given ID. This search is done case * insensitive. * * @param sProcIDValue * The value to search. Without any identifier scheme! May be * <code>null</code>. * @return <code>null</code> if no such process identifier exists. */ @Nullable public static IPeppolPredefinedProcessIdentifier getProcessIdentifierOfID (@Nullable final String sProcIDValue) { if (sProcIDValue != null) for (final Map.Entry <String, IPeppolPredefinedProcessIdentifier> aEntry : s_aCodes.entrySet ()) { // PEPPOL: Case sensitive comparison if (sProcIDValue.equals (aEntry.getKey ())) return aEntry.getValue (); } return null; }
/** * Find the document identifier with the given ID. This search is done case * sensitive. * * @param sDocTypeIDValue * The value to search. Without any identifier scheme! May be * <code>null</code>. * @return <code>null</code> if no such document identifier exists. */ @Nullable public static IPeppolPredefinedDocumentTypeIdentifier getDocumentTypeIdentifierOfID (@Nullable final String sDocTypeIDValue) { if (sDocTypeIDValue != null) { for (final Map.Entry <String, IPeppolPredefinedDocumentTypeIdentifier> aEntry : s_aCodes.entrySet ()) { // PEPPOL: case sensitive document types if (sDocTypeIDValue.equals (aEntry.getKey ())) return aEntry.getValue (); } } return null; }
/** * Get the URL matching a given namespace prefix in this level. * * @param sPrefix * The prefix to be searched. If it is <code>null</code> the default * namespace URL is returned. * @return <code>null</code> if the namespace mapping is not used or the URL * otherwise. */ @Nullable public String getNamespaceURIOfPrefix (@Nullable final String sPrefix) { if (StringHelper.hasNoText (sPrefix)) return m_sDefaultNamespaceURI; if (m_aURL2PrefixMap != null) for (final Map.Entry <String, String> aEntry : m_aURL2PrefixMap.entrySet ()) if (aEntry.getValue ().equals (sPrefix)) return aEntry.getKey (); return null; }
public BuildInfo (@Nonnull final ICommonsMap <String, String> aMap) { m_aMap = ValueEnforcer.notNull (aMap, "Map"); m_nVersion = getAsInt ("buildinfo.version", 0); if (m_nVersion < 1) throw new IllegalArgumentException ("The passed map is not a buildinfo map!"); // Extract all system properties and env vars for (final Map.Entry <String, String> aEntry : aMap.entrySet ()) { final String sKey = aEntry.getKey (); if (sKey.startsWith (PREFIX_SYSPROPERTY)) m_aSysProperties.put (sKey.substring (PREFIX_SYSPROPERTY.length ()), aEntry.getValue ()); else if (sKey.startsWith (PREFIX_ENVVAR)) m_aEnvVars.put (sKey.substring (PREFIX_ENVVAR.length ()), aEntry.getValue ()); } }
/** * Iterate all registered micro type converters. For informational purposes * only. * * @param aCallback * The callback invoked for all iterations. */ public void iterateAllRegisteredMicroTypeConverters (@Nonnull final IMicroTypeConverterCallback aCallback) { // Create a static copy of the map (HashMap not weak!) final ICommonsMap <Class <?>, IMicroTypeConverter <?>> aCopy = m_aRWLock.readLocked (m_aMap::getClone); // And iterate the copy for (final Map.Entry <Class <?>, IMicroTypeConverter <?>> aEntry : aCopy.entrySet ()) if (aCallback.call (aEntry.getKey (), aEntry.getValue ()).isBreak ()) break; }
@Override protected void onDestroy (@Nonnull final IScope aScopeInDestruction) { m_aRWLock.writeLocked ( () -> { // Reschedule all existing scheduled items to run now for (final Map.Entry <String, WALListener.WALItem> aEntry : m_aScheduledItems.entrySet ()) { final WALListener.WALItem aItem = aEntry.getValue (); if (aItem.m_aFuture.cancel (false)) { // reschedule to perform it now m_aES.submit (aItem.m_aRunnable); LOGGER.info ("Rescheduled DAO writing for " + aEntry.getKey () + " to happen now"); } else LOGGER.info ("Cannot reschedule DAO writing for " + aEntry.getKey () + " because it is already running"); } // ensure all are cleared m_aScheduledItems.clear (); }); // Wait until all tasks finished ExecutorServiceHelper.shutdownAndWaitUntilAllTasksAreFinished (m_aES); }
/** * Clear all of this session's attributes. */ public void clearAttributes () { for (final Map.Entry <String, Object> entry : m_aAttributes.entrySet ()) { final String sName = entry.getKey (); final Object aValue = entry.getValue (); if (aValue instanceof HttpSessionBindingListener) ((HttpSessionBindingListener) aValue).valueUnbound (new HttpSessionBindingEvent (this, sName, aValue)); } m_aAttributes.clear (); }
@Nonnull public static IMicroDocument getAsPropertiesXML (@Nonnull final ICommonsMap <String, String> aMap) { final IMicroDocument ret = new MicroDocument (); final IMicroElement eRoot = ret.appendElement ("properties"); for (final Map.Entry <String, String> aEntry : aMap.entrySet ()) eRoot.appendElement ("entry").setAttribute ("key", aEntry.getKey ()).appendText (aEntry.getValue ()); return ret; }
/** * Add all variables from the other variable resolver into this resolver. * * @param aOther * The variable resolver to import the variable from. May not be * <code>null</code>. * @param bOverwrite * if <code>true</code> existing variables will be overwritten with the * new variables, otherwise the old variables are kept. * @return {@link EChange} */ @Nonnull public EChange addAllFrom (@Nonnull final MapBasedXPathVariableResolverQName aOther, final boolean bOverwrite) { ValueEnforcer.notNull (aOther, "Other"); EChange eChange = EChange.UNCHANGED; for (final Map.Entry <QName, Object> aEntry : aOther.m_aMap.entrySet ()) if (bOverwrite || !m_aMap.containsKey (aEntry.getKey ())) { m_aMap.put (aEntry.getKey (), aEntry.getValue ()); eChange = EChange.CHANGED; } return eChange; }
/** * Add all variables from the other variable resolver into this resolver. * * @param aOther * The variable resolver to import the variable from. May not be * <code>null</code>. * @param bOverwrite * if <code>true</code> existing variables will be overwritten with the * new variables, otherwise the old variables are kept. * @return {@link EChange} */ @Nonnull public EChange addAllFrom (@Nonnull final MapBasedXPathVariableResolver aOther, final boolean bOverwrite) { ValueEnforcer.notNull (aOther, "Other"); EChange eChange = EChange.UNCHANGED; for (final Map.Entry <String, Object> aEntry : aOther.m_aMap.entrySet ()) if (bOverwrite || !m_aMap.containsKey (aEntry.getKey ())) { m_aMap.put (aEntry.getKey (), aEntry.getValue ()); eChange = EChange.CHANGED; } return eChange; }
/** * Add all variables from the other variable resolver into this resolver. This * methods creates a QName with an empty namespace URI. * * @param aOther * The variable resolver to import the variable from. May not be * <code>null</code>. * @param bOverwrite * if <code>true</code> existing variables will be overwritten with the * new variables, otherwise the old variables are kept. * @return {@link EChange} */ @Nonnull public EChange addAllFrom (@Nonnull final MapBasedXPathVariableResolver aOther, final boolean bOverwrite) { ValueEnforcer.notNull (aOther, "Other"); EChange eChange = EChange.UNCHANGED; for (final Map.Entry <String, ?> aEntry : aOther.getAllVariables ().entrySet ()) { // Local part only to QName final QName aKey = new QName (aEntry.getKey ()); if (bOverwrite || !m_aMap.containsKey (aKey)) { m_aMap.put (aKey, aEntry.getValue ()); eChange = EChange.CHANGED; } } return eChange; }
public void applyToSAXReader (@Nonnull final org.xml.sax.XMLReader aParser) { ValueEnforcer.notNull (aParser, "Parser"); aParser.setContentHandler (getContentHandler ()); aParser.setDTDHandler (getDTDHandler ()); aParser.setEntityResolver (getEntityResolver ()); aParser.setErrorHandler (getErrorHandler ()); // Apply properties if (hasAnyProperties ()) for (final Map.Entry <EXMLParserProperty, Object> aEntry : getAllPropertyValues ().entrySet ()) aEntry.getKey ().applyTo (aParser, aEntry.getValue ()); // Apply features if (hasAnyFeature ()) for (final Map.Entry <EXMLParserFeature, Boolean> aEntry : getAllFeatureValues ().entrySet ()) aEntry.getKey ().applyTo (aParser, aEntry.getValue ().booleanValue ()); }
public AbstractXMLSerializer (@Nonnull final IXMLWriterSettings aSettings) { m_aSettings = ValueEnforcer.notNull (aSettings, "Settings"); final NamespaceContext aNC = aSettings.getNamespaceContext (); m_aNSStack = new NamespaceStack (aNC); if (aSettings.isPutNamespaceContextPrefixesInRoot ()) { if (aNC instanceof IIterableNamespaceContext) { // Put all on top-level for (final Map.Entry <String, String> aEntry : ((IIterableNamespaceContext) aNC).getPrefixToNamespaceURIMap () .entrySet ()) { final String sNSPrefix = aEntry.getKey (); final String sNamespaceURI = aEntry.getValue (); m_aRootNSMap.put (sNSPrefix, sNamespaceURI); } } else LOGGER.error ("XMLWriter settings has 'putNamespaceContextPrefixesInRoot' set to 'true', but the 'NamespaceContext' instance does not implement the 'IIterableNamespaceContext' interface. This functionality therefore does not work."); } }
@Override public void customizeNode (@Nonnull final IHCNode aNode, @Nonnull final EHTMLVersion eHTMLVersion, @Nonnull final IHCHasChildrenMutable <?, ? super IHCNode> aTargetNode) { if (aNode instanceof IHCElement && !(aNode instanceof IHCScript <?>)) { final JSEventMap aEventMap = ((IHCElement <?>) aNode).getEventMap (); if (aEventMap != null) for (final Map.Entry <EJSEvent, CollectingJSCodeProvider> aEntry : aEventMap.getAllEventHandler ().entrySet ()) { // "ag" for "automatically generated" final JSFunction aFunc = new JSFunction ("_photon_ag" + GlobalIDFactory.getNewIntID ()); aFunc.body ().add (aEntry.getValue ()); aTargetNode.addChild (new HCScriptInline (aFunc)); aEventMap.setHandler (aEntry.getKey (), aFunc.invoke ()); } } } }
/** * Remove all tokens of the given subject * * @param aSubject * The subject for which the tokens should be removed. * @return The number of removed tokens. Always ≥ 0. */ @Nonnegative public static int removeAllTokensOfSubject (@Nonnull final IAuthSubject aSubject) { ValueEnforcer.notNull (aSubject, "Subject"); // get all token IDs matching a given subject // Note: required IAuthSubject to implement equals! final ICommonsList <String> aDelTokenIDs = new CommonsArrayList <> (); s_aRWLock.readLocked ( () -> { for (final Map.Entry <String, AuthToken> aEntry : s_aMap.entrySet ()) if (aEntry.getValue ().getIdentification ().hasAuthSubject (aSubject)) aDelTokenIDs.add (aEntry.getKey ()); }); for (final String sDelTokenID : aDelTokenIDs) removeToken (sDelTokenID); return aDelTokenIDs.size (); } }
@Override protected void fillContent (@Nonnull final WPECTYPE aWPEC) { final HCNodeList aNodeList = aWPEC.getNodeList (); final Locale aDisplayLocale = aWPEC.getDisplayLocale (); final HCTable aTable = new HCTable (new DTCol (EText.MSG_APPID.getDisplayText (aDisplayLocale)).setInitialSorting (ESortOrder.ASCENDING), new DTCol (EText.MSG_APP_SERVLET_PATH.getDisplayText (aDisplayLocale))).setID (getID ()); for (final Map.Entry <String, String> aEntry : PhotonGlobalState.getAppIDToServletPathMap ().entrySet ()) { final String sAppID = aEntry.getKey (); final HCRow aRow = aTable.addBodyRow (); aRow.addCell (sAppID); aRow.addCell (aEntry.getValue ()); } aNodeList.addChild (aTable); final DataTables aDataTables = BootstrapDataTables.createDefaultDataTables (aWPEC, aTable); aNodeList.addChild (aDataTables); } }
@Override protected void fillContent (@Nonnull final WPECTYPE aWPEC) { final HCNodeList aNodeList = aWPEC.getNodeList (); final Locale aDisplayLocale = aWPEC.getDisplayLocale (); final HCTable aTable = new HCTable (new DTCol (EText.MSG_APPID.getDisplayText (aDisplayLocale)).setInitialSorting (ESortOrder.ASCENDING), new DTCol (EText.MSG_APP_SERVLET_PATH.getDisplayText (aDisplayLocale))).setID (getID ()); for (final Map.Entry <String, String> aEntry : PhotonGlobalState.getAppIDToServletPathMap ().entrySet ()) { final String sAppID = aEntry.getKey (); final HCRow aRow = aTable.addBodyRow (); aRow.addCell (sAppID); aRow.addCell (aEntry.getValue ()); } aNodeList.addChild (aTable); final DataTables aDataTables = BootstrapDataTables.createDefaultDataTables (aWPEC, aTable); aNodeList.addChild (aDataTables); } }
new DTCol (EText.MSG_OBJECTID.getDisplayText (aDisplayLocale))).setID (getID ()); for (final Map.Entry <String, ILockInfo> aEntry : m_aLockMgr.getAllLockInfos ().entrySet ())