idx
int64
0
165k
question
stringlengths
73
4.15k
target
stringlengths
5
918
len_question
int64
21
890
len_target
int64
3
255
16,200
@ Nonnull public EChange add ( @ Nonnull final CALLBACKTYPE aCallback ) { ValueEnforcer . notNull ( aCallback , "Callback" ) ; return m_aRWLock . writeLocked ( ( ) -> m_aCallbacks . addObject ( aCallback ) ) ; }
Add a callback .
63
4
16,201
@ Nonnull public EChange removeObject ( @ Nullable final CALLBACKTYPE aCallback ) { if ( aCallback == null ) return EChange . UNCHANGED ; return m_aRWLock . writeLocked ( ( ) -> m_aCallbacks . removeObject ( aCallback ) ) ; }
Remove the specified callback
65
4
16,202
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 ( ) + " fea...
Emit all supported features to the logger .
108
9
16,203
@ Nullable public static Document getOwnerDocument ( @ Nullable final Node aNode ) { if ( aNode == null ) return null ; if ( aNode instanceof Document ) return ( Document ) aNode ; return aNode . getOwnerDocument ( ) ; }
Get the owner document of the passed node . If the node itself is a document only a cast is performed .
55
22
16,204
@ Nullable public static Element getFirstChildElement ( @ Nullable final Node aStartNode ) { if ( aStartNode == null ) return null ; return NodeListIterator . createChildNodeIterator ( aStartNode ) . findFirstMapped ( filterNodeIsElement ( ) , x -> ( Element ) x ) ; }
Get the first direct child element of the passed element .
68
11
16,205
public static boolean hasChildElementNodes ( @ Nullable final Node aStartNode ) { if ( aStartNode == null ) return false ; return NodeListIterator . createChildNodeIterator ( aStartNode ) . containsAny ( filterNodeIsElement ( ) ) ; }
Check if the passed node has at least one direct child element or not .
57
15
16,206
@ Nonnull public EChange removeParameterWithName ( @ Nullable final String sParamName ) { if ( StringHelper . hasText ( sParamName ) ) { final int nMax = m_aParameters . size ( ) ; for ( int i = 0 ; i < nMax ; ++ i ) { final MimeTypeParameter aParam = m_aParameters . get ( i ) ; if ( aParam . getAttribute ( ) . equals ...
Remove the parameter with the specified name .
132
8
16,207
@ Nonnull public static Matcher getMatcher ( @ Nonnull @ RegEx final String sRegEx , @ Nonnull final String sValue ) { ValueEnforcer . notNull ( sValue , "Value" ) ; return RegExCache . getPattern ( sRegEx ) . matcher ( sValue ) ; }
Get the Java Matcher object for the passed pair of regular expression and value .
68
16
16,208
public static boolean stringMatchesPattern ( @ Nonnull @ RegEx final String sRegEx , @ Nonnull final String sValue ) { return getMatcher ( sRegEx , sValue ) . matches ( ) ; }
A shortcut helper method to determine whether a string matches a certain regular expression or not .
47
17
16,209
public boolean containsCountry ( @ Nullable final String sCountry ) { if ( sCountry == null ) return false ; final String sValidCountry = LocaleHelper . getValidCountryCode ( sCountry ) ; if ( sValidCountry == null ) return false ; return m_aRWLock . readLocked ( ( ) -> m_aCountries . contains ( sValidCountry ) ) ; }
Check if the passed country is known .
83
8
16,210
public static int append ( final int nPrevHashCode , @ Nullable final Object x ) { return append ( nPrevHashCode , HashCodeImplementationRegistry . getHashCode ( x ) ) ; }
Object hash code generation .
44
5
16,211
@ Nonnull @ ReturnsMutableCopy public static HasInputStream multiple ( @ Nonnull final ISupplier < ? extends InputStream > aISP ) { return new HasInputStream ( aISP , true ) ; }
Create a new object with a supplier that can read multiple times .
47
13
16,212
@ Nonnull @ ReturnsMutableCopy public static HasInputStream once ( @ Nonnull final ISupplier < ? extends InputStream > aISP ) { return new HasInputStream ( aISP , false ) ; }
Create a new object with a supplier that can be read only once .
47
14
16,213
private static int _getDistance111 ( @ Nonnull final char [ ] aStr1 , @ Nonnegative final int nLen1 , @ Nonnull final char [ ] aStr2 , @ Nonnegative final int nLen2 ) { // previous cost array, horizontally int [ ] aPrevRow = new int [ nLen1 + 1 ] ; // cost array, horizontally int [ ] aCurRow = new int [ nLen1 + 1 ] ; /...
Main generic Levenshtein implementation that uses 1 for all costs!
326
14
16,214
private static int _getDistance ( @ Nonnull final char [ ] aStr1 , @ Nonnegative final int nLen1 , @ Nonnull final char [ ] aStr2 , @ Nonnegative final int nLen2 , @ Nonnegative final int nCostInsert , @ Nonnegative final int nCostDelete , @ Nonnegative final int nCostSubstitution ) { // previous cost array, horizontal...
Main generic Levenshtein implementation . Assume all preconditions are checked .
372
17
16,215
@ Nullable public static String getUnifiedEmailAddress ( @ Nullable final String sEmailAddress ) { return sEmailAddress == null ? null : sEmailAddress . trim ( ) . toLowerCase ( Locale . US ) ; }
Get the unified version of an email address . It trims leading and trailing spaces and lower - cases the email address .
50
24
16,216
public static boolean isValid ( @ Nullable final String sEmailAddress ) { if ( sEmailAddress == null ) return false ; // Unify (lowercase) final String sUnifiedEmail = getUnifiedEmailAddress ( sEmailAddress ) ; // Pattern matching return s_aPattern . matcher ( sUnifiedEmail ) . matches ( ) ; }
Checks if a value is a valid e - mail address according to a certain regular expression .
75
19
16,217
@ Nonnull public static ESuccess writeMap ( @ Nonnull final Map < String , String > aMap , @ Nonnull @ WillClose final OutputStream aOS ) { ValueEnforcer . notNull ( aMap , "Map" ) ; ValueEnforcer . notNull ( aOS , "OutputStream" ) ; try { final IMicroDocument aDoc = createMapDocument ( aMap ) ; return MicroWriter . wr...
Write the passed map to the passed output stream using the predefined XML layout .
127
16
16,218
@ Nullable public static Transformer newTransformer ( @ Nonnull final TransformerFactory aTransformerFactory ) { ValueEnforcer . notNull ( aTransformerFactory , "TransformerFactory" ) ; try { return aTransformerFactory . newTransformer ( ) ; } catch ( final TransformerConfigurationException ex ) { LOGGER . error ( "Fai...
Create a new XSLT transformer for no specific resource .
89
12
16,219
@ Nonnull public String getRest ( ) { final String ret = m_sInput . substring ( m_nCurIndex ) ; m_nCurIndex = m_nMaxIndex ; return ret ; }
Get all remaining chars and set the index to the end of the input string
45
15
16,220
@ Nonnull public String getUntil ( final char cEndExcl ) { final int nStart = m_nCurIndex ; while ( m_nCurIndex < m_nMaxIndex && getCurrentChar ( ) != cEndExcl ) ++ m_nCurIndex ; return m_sInput . substring ( nStart , m_nCurIndex ) ; }
Get the string until the specified end character but excluding the end character .
79
14
16,221
@ Nullable public DATATYPE getIfChanged ( @ Nullable final DATATYPE aUnchangedValue ) { return m_eChange . isChanged ( ) ? m_aObj : aUnchangedValue ; }
Get the store value if this is a change . Otherwise the passed unchanged value is returned .
50
18
16,222
@ Nullable public DATATYPE getIfUnchanged ( @ Nullable final DATATYPE aChangedValue ) { return m_eChange . isUnchanged ( ) ? m_aObj : aChangedValue ; }
Get the store value if this is unchanged . Otherwise the passed changed value is returned .
50
17
16,223
@ Nonnull public static < DATATYPE > ChangeWithValue < DATATYPE > createChanged ( @ Nullable final DATATYPE aValue ) { return new ChangeWithValue <> ( EChange . CHANGED , aValue ) ; }
Create a new changed object with the given value .
58
10
16,224
@ Nonnull public static < DATATYPE > ChangeWithValue < DATATYPE > createUnchanged ( @ Nullable final DATATYPE aValue ) { return new ChangeWithValue <> ( EChange . UNCHANGED , aValue ) ; }
Create a new unchanged object with the given value .
60
10
16,225
@ Nonnull public static ICommonsList < IAuthToken > getAllTokensOfSubject ( @ Nonnull final IAuthSubject aSubject ) { ValueEnforcer . notNull ( aSubject , "Subject" ) ; return s_aRWLock . readLocked ( ( ) -> CommonsArrayList . createFiltered ( s_aMap . values ( ) , aToken -> aToken . getIdentification ( ) . hasAuthSubj...
Get all tokens of the specified auth subject . All tokens are returned no matter whether they are expired or not .
100
22
16,226
@ 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 <> (...
Remove all tokens of the given subject
196
7
16,227
@ Nullable public static < ENUMTYPE extends Enum < ENUMTYPE > & IHasName > ENUMTYPE getFromNameCaseInsensitiveOrNull ( @ Nonnull final Class < ENUMTYPE > aClass , @ Nullable final String sName ) { return getFromNameCaseInsensitiveOrDefault ( aClass , sName , null ) ; }
Get the enum value with the passed name case insensitive
76
10
16,228
@ Nonnull public static String getEnumID ( @ Nonnull final Enum < ? > aEnum ) { // No explicit null check, because this method is used heavily in // locale resolving, so we want to spare some CPU cycles :) return aEnum . getClass ( ) . getName ( ) + ' ' + aEnum . name ( ) ; }
Get the unique name of the passed enum entry .
78
10
16,229
@ OverrideOnDemand @ Nullable protected IReadableResource internalResolveResource ( @ Nonnull @ Nonempty final String sType , @ Nullable final String sNamespaceURI , @ Nullable final String sPublicId , @ Nullable final String sSystemId , @ Nullable final String sBaseURI ) throws Exception { if ( DEBUG_RESOLVE ) if ( LO...
Internal resource resolving
163
3
16,230
@ Override @ Nullable public final LSInput mainResolveResource ( @ Nonnull @ Nonempty final String sType , @ Nullable final String sNamespaceURI , @ Nullable final String sPublicId , @ Nullable final String sSystemId , @ Nullable final String sBaseURI ) { try { // Try to get the resource final IReadableResource aResolv...
Resolve a resource with the passed parameters
191
8
16,231
@ Nonnull @ ReturnsMutableCopy public static < ELEMENTTYPE > NonBlockingStack < ELEMENTTYPE > newStack ( @ Nullable final ELEMENTTYPE aValue ) { final NonBlockingStack < ELEMENTTYPE > ret = newStack ( ) ; ret . push ( aValue ) ; return ret ; }
Create a new stack with a single element .
67
9
16,232
@ Nonnull @ ReturnsMutableCopy @ SafeVarargs public static < ELEMENTTYPE > NonBlockingStack < ELEMENTTYPE > newStack ( @ Nullable final ELEMENTTYPE ... aValues ) { return new NonBlockingStack <> ( aValues ) ; }
Create a new stack from the given array .
57
9
16,233
@ Nonnull @ ReturnsMutableCopy public static < ELEMENTTYPE > NonBlockingStack < ELEMENTTYPE > newStack ( @ Nullable final Collection < ? extends ELEMENTTYPE > aValues ) { return new NonBlockingStack <> ( aValues ) ; }
Create a new stack from the given collection .
57
9
16,234
@ OverrideOnDemand protected void validateOutgoingBusinessDocument ( @ Nonnull final Element aXML ) throws AS2ClientBuilderException { if ( m_aVESRegistry == null ) { // Create lazily m_aVESRegistry = createValidationRegistry ( ) ; } final IValidationExecutorSet aVES = m_aVESRegistry . getOfID ( m_aVESID ) ; if ( aVES ...
Perform the standard PEPPOL validation of the outgoing business document before sending takes place . In case validation fails an exception is thrown . The validation is configured using the validation key . This method is only called when a validation key was set .
231
48
16,235
@ Nullable public ISessionScope getSessionScopeOfID ( @ Nullable final String sScopeID ) { if ( StringHelper . hasNoText ( sScopeID ) ) return null ; return m_aRWLock . readLocked ( ( ) -> m_aSessionScopes . get ( sScopeID ) ) ; }
Get the session scope with the specified ID . If no such scope exists no further actions are taken .
70
20
16,236
public void onScopeEnd ( @ Nonnull final ISessionScope aSessionScope ) { ValueEnforcer . notNull ( aSessionScope , "SessionScope" ) ; // Only handle scopes that are not yet destructed if ( aSessionScope . isValid ( ) ) { final String sSessionID = aSessionScope . getID ( ) ; final boolean bCanDestroyScope = m_aRWLock . ...
Close the passed session scope gracefully . Each managed scope is guaranteed to be destroyed only once . First the SPI manager is invoked and afterwards the scope is destroyed .
386
32
16,237
public void destroyAllSessions ( ) { // destroy all session scopes (use a copy, because we're invalidating // the sessions internally!) for ( final ISessionScope aSessionScope : getAllSessionScopes ( ) ) { // Unfortunately we need a special handling here if ( aSessionScope . selfDestruct ( ) . isContinue ( ) ) { // Rem...
Destroy all known session scopes . After this method it is ensured that the internal session map is empty .
119
21
16,238
@ Nonnull public static IGlobalScope onGlobalBegin ( @ Nonnull @ Nonempty final String sScopeID ) { return onGlobalBegin ( sScopeID , GlobalScope :: new ) ; }
This method is used to set the initial global scope .
41
11
16,239
public static void onGlobalEnd ( ) { s_aGlobalLock . locked ( ( ) -> { /** * This code removes all attributes set for the global context. This is * necessary, since the attributes would survive a Tomcat servlet context * reload if we don't kill them manually.<br> * Global scope variable may be null if onGlobalBegin() w...
To be called when the singleton global context is to be destroyed .
237
14
16,240
public static void destroySessionScope ( @ Nonnull final ISessionScope aSessionScope ) { ValueEnforcer . notNull ( aSessionScope , "SessionScope" ) ; ScopeSessionManager . getInstance ( ) . onScopeEnd ( aSessionScope ) ; }
Manually destroy the passed session scope .
55
8
16,241
public static void onRequestEnd ( ) { final IRequestScope aRequestScope = getRequestScopeOrNull ( ) ; try { // Do we have something to destroy? if ( aRequestScope != null ) { _destroyRequestScope ( aRequestScope ) ; } else { // Happens after an internal redirect happened in a web-application // (e.g. for 404 page) for ...
To be called after a request finished .
119
8
16,242
public void onDocumentType ( @ Nonnull final String sQualifiedElementName , @ Nullable final String sPublicID , @ Nullable final String sSystemID ) { ValueEnforcer . notNull ( sQualifiedElementName , "QualifiedElementName" ) ; final String sDocType = getDocTypeXMLRepresentation ( m_eXMLVersion , m_aXMLWriterSettings . ...
On XML document type .
124
5
16,243
public void onProcessingInstruction ( @ Nonnull final String sTarget , @ Nullable final String sData ) { _append ( PI_START ) . _append ( sTarget ) ; if ( StringHelper . hasText ( sData ) ) _append ( ' ' ) . _append ( sData ) ; _append ( PI_END ) ; newLine ( ) ; }
On processing instruction
81
3
16,244
public void onEntityReference ( @ Nonnull final String sEntityRef ) { _append ( ER_START ) . _append ( sEntityRef ) . _append ( ER_END ) ; }
On entity reference .
42
4
16,245
public void onContentElementWhitespace ( @ Nullable final CharSequence aWhitespaces ) { if ( StringHelper . hasText ( aWhitespaces ) ) _append ( aWhitespaces . toString ( ) ) ; }
Ignorable whitespace characters .
51
6
16,246
public void onComment ( @ Nullable final String sComment ) { if ( StringHelper . hasText ( sComment ) ) { if ( isThrowExceptionOnNestedComments ( ) ) if ( sComment . contains ( COMMENT_START ) || sComment . contains ( COMMENT_END ) ) throw new IllegalArgumentException ( "XML comment contains nested XML comment: " + sCo...
Comment node .
114
3
16,247
public void onText ( @ Nonnull final char [ ] aText , @ Nonnegative final int nOfs , @ Nonnegative final int nLen ) { onText ( aText , nOfs , nLen , true ) ; }
XML text node .
50
5
16,248
public void onCDATA ( @ Nullable final String sText ) { if ( StringHelper . hasText ( sText ) ) { if ( sText . indexOf ( CDATA_END ) >= 0 ) { // Split CDATA sections if they contain the illegal "]]>" marker final ICommonsList < String > aParts = StringHelper . getExploded ( CDATA_END , sText ) ; final int nParts = aPar...
CDATA node .
233
4
16,249
public void onElementStart ( @ Nullable final String sNamespacePrefix , @ Nonnull final String sTagName , @ Nullable final Map < QName , String > aAttrs , @ Nonnull final EXMLSerializeBracketMode eBracketMode ) { elementStartOpen ( sNamespacePrefix , sTagName ) ; if ( aAttrs != null && ! aAttrs . isEmpty ( ) ) { if ( m...
Start of an element .
614
5
16,250
public void onElementEnd ( @ Nullable final String sNamespacePrefix , @ Nonnull final String sTagName , @ Nonnull final EXMLSerializeBracketMode eBracketMode ) { if ( eBracketMode . isOpenClose ( ) ) { _append ( "</" ) ; if ( StringHelper . hasText ( sNamespacePrefix ) ) _appendMasked ( EXMLCharMode . ELEMENT_NAME , sN...
End of an element .
153
5
16,251
private void _registerTypeConverter ( @ Nonnull final Class < ? > aSrcClass , @ Nonnull final Class < ? > aDstClass , @ Nonnull final ITypeConverter < ? , ? > aConverter ) { ValueEnforcer . notNull ( aSrcClass , "SrcClass" ) ; ValueEnforcer . isTrue ( ClassHelper . isPublic ( aSrcClass ) , ( ) -> "Source " + aSrcClass ...
Register a default type converter .
680
6
16,252
private void _iterateFuzzyConverters ( @ Nonnull final Class < ? > aSrcClass , @ Nonnull final Class < ? > aDstClass , @ Nonnull final ITypeConverterCallback aCallback ) { // For all possible source classes for ( final WeakReference < Class < ? > > aCurWRSrcClass : ClassHierarchyCache . getClassHierarchyIterator ( aSrc...
Iterate all possible fuzzy converters from source class to destination class .
280
14
16,253
public void iterateAllRegisteredTypeConverters ( @ Nonnull final ITypeConverterCallback aCallback ) { // Create a copy of the map final Map < Class < ? > , Map < Class < ? > , ITypeConverter < ? , ? > > > aCopy = m_aRWLock . readLocked ( ( ) -> new CommonsHashMap <> ( m_aConverter ) ) ; // And iterate the copy outer : ...
Iterate all registered type converters . For informational purposes only .
250
13
16,254
@ Nonnull public static Class < ? > [ ] getClassArray ( @ Nullable final Object ... aObjs ) { if ( ArrayHelper . isEmpty ( aObjs ) ) return EMPTY_CLASS_ARRAY ; final Class < ? > [ ] ret = new Class < ? > [ aObjs . length ] ; for ( int i = 0 ; i < aObjs . length ; ++ i ) ret [ i ] = aObjs [ i ] . getClass ( ) ; return r...
Get an array with all the classes of the passed object array .
109
13
16,255
@ Nullable public static < RETURNTYPE > RETURNTYPE invokeMethod ( @ Nonnull final Object aSrcObj , @ Nonnull final String sMethodName , @ Nullable final Object ... aArgs ) throws NoSuchMethodException , IllegalAccessException , InvocationTargetException { return GenericReflection . < RETURNTYPE > invokeMethod ( aSrcObj...
This method dynamically invokes the method with the given name on the given object .
94
16
16,256
@ Nonnull public static < DATATYPE > DATATYPE newInstance ( @ Nonnull final DATATYPE aObj ) throws IllegalAccessException , NoSuchMethodException , InvocationTargetException , InstantiationException { return findConstructor ( aObj ) . newInstance ( ) ; }
Create a new instance of the class identified by the passed object . The default constructor will be invoked .
66
20
16,257
@ Nonnull public static final < T extends AbstractRequestSingleton > T getRequestSingleton ( @ Nonnull final Class < T > aClass ) { return getSingleton ( _getStaticScope ( true ) , aClass ) ; }
Get the singleton object in the current request scope using the passed class . If the singleton is not yet instantiated a new instance is created .
50
30
16,258
public static void forAllClassPathEntries ( @ Nonnull final Consumer < ? super String > aConsumer ) { StringHelper . explode ( SystemProperties . getPathSeparator ( ) , SystemProperties . getJavaClassPath ( ) , aConsumer ) ; }
Add all class path entries into the provided target list .
57
11
16,259
public static void printClassPathEntries ( @ Nonnull final PrintStream aPS , @ Nonnull final String sItemSeparator ) { forAllClassPathEntries ( x -> { aPS . print ( x ) ; aPS . print ( sItemSeparator ) ; } ) ; }
Print all class path entries on the passed print stream using the passed separator
64
15
16,260
@ Nonnull public static ESuccess writeToStream ( @ Nonnull final IMicroNode aNode , @ Nonnull @ WillClose final OutputStream aOS ) { return writeToStream ( aNode , aOS , XMLWriterSettings . DEFAULT_XML_SETTINGS ) ; }
Write a Micro Node to an output stream using the default settings .
61
13
16,261
@ Nullable public static String getNodeAsString ( @ Nonnull final IMicroNode aNode , @ Nonnull final IXMLWriterSettings aSettings ) { ValueEnforcer . notNull ( aNode , "Node" ) ; ValueEnforcer . notNull ( aSettings , "Settings" ) ; try ( final NonBlockingStringWriter aWriter = new NonBlockingStringWriter ( 50 * CGlobal...
Convert the passed micro node to an XML string using the provided settings .
185
15
16,262
@ Nullable public static byte [ ] getNodeAsBytes ( @ Nonnull final IMicroNode aNode , @ Nonnull final IXMLWriterSettings aSettings ) { ValueEnforcer . notNull ( aNode , "Node" ) ; ValueEnforcer . notNull ( aSettings , "Settings" ) ; try ( final NonBlockingByteArrayOutputStream aBAOS = new NonBlockingByteArrayOutputStre...
Convert the passed micro node to an XML byte array using the provided settings .
194
16
16,263
public static < KEYTYPE , DATATYPE , ITEMTYPE extends ITreeItemWithID < KEYTYPE , DATATYPE , ITEMTYPE > > void sortByID ( @ Nonnull final IBasicTree < DATATYPE , ITEMTYPE > aTree , @ Nonnull final Comparator < ? super KEYTYPE > aKeyComparator ) { _sort ( aTree , Comparator . comparing ( IHasID :: getID , aKeyComparator...
Sort each level of the passed tree on the ID with the specified comparator .
106
16
16,264
public static < KEYTYPE , DATATYPE , ITEMTYPE extends ITreeItemWithID < KEYTYPE , DATATYPE , ITEMTYPE > > void sortByValue ( @ Nonnull final IBasicTree < DATATYPE , ITEMTYPE > aTree , @ Nonnull final Comparator < ? super DATATYPE > aValueComparator ) { _sort ( aTree , Comparator . comparing ( IBasicTreeItem :: getData ...
Sort each level of the passed tree on the value with the specified comparator .
110
16
16,265
@ Nonnull public final EChange start ( ) { // Already started? if ( m_nStartDT > 0 ) return EChange . UNCHANGED ; m_nStartDT = getCurrentNanoTime ( ) ; return EChange . CHANGED ; }
Start the stop watch .
57
5
16,266
@ Nonnull public EChange stop ( ) { // Already stopped? if ( m_nStartDT == 0 ) return EChange . UNCHANGED ; final long nCurrentNanoTime = getCurrentNanoTime ( ) ; m_nDurationNanos += ( nCurrentNanoTime - m_nStartDT ) ; m_nStartDT = 0 ; return EChange . CHANGED ; }
Stop the stop watch .
87
5
16,267
@ Nonnull public static TimeValue runMeasured ( @ Nonnull final Runnable aRunnable ) { final StopWatch aSW = createdStarted ( ) ; aRunnable . run ( ) ; final long nNanos = aSW . stopAndGetNanos ( ) ; return new TimeValue ( TimeUnit . NANOSECONDS , nNanos ) ; }
Run the passed runnable and measure the time .
83
11
16,268
@ Nonnull public ErrorTextProvider addItem ( @ Nonnull final EField eField , @ Nonnull @ Nonempty final String sText ) { return addItem ( new FormattableItem ( eField , sText ) ) ; }
Add an error item to be disabled .
50
8
16,269
public int compareTo ( @ Nonnull final Version rhs ) { ValueEnforcer . notNull ( rhs , "Rhs" ) ; // compare major version int ret = m_nMajor - rhs . m_nMajor ; if ( ret == 0 ) { // compare minor version ret = m_nMinor - rhs . m_nMinor ; if ( ret == 0 ) { // compare micro version ret = m_nMicro - rhs . m_nMicro ; if ( r...
Compares two Version objects .
243
6
16,270
@ Nonnull public String getAsString ( final boolean bPrintZeroElements , final boolean bPrintAtLeastMajorAndMinor ) { // Build from back to front final StringBuilder aSB = new StringBuilder ( m_sQualifier != null ? m_sQualifier : "" ) ; if ( m_nMicro > 0 || aSB . length ( ) > 0 || bPrintZeroElements ) { // Micro versio...
Get the string representation of the version number .
299
9
16,271
@ Nonnull public static Version parse ( @ Nullable final String sVersionString , final boolean bOldVersion ) { final String s = sVersionString == null ? "" : sVersionString . trim ( ) ; if ( s . length ( ) == 0 ) return DEFAULT_VERSION ; int nMajor ; int nMinor ; int nMicro ; String sQualifier ; if ( bOldVersion ) { //...
Construct a version object from a string .
731
8
16,272
private void _appendOptionGroup ( final StringBuilder aSB , final OptionGroup aGroup ) { if ( ! aGroup . isRequired ( ) ) aSB . append ( ' ' ) ; final ICommonsList < Option > optList = aGroup . getAllOptions ( ) ; if ( m_aOptionComparator != null ) optList . sort ( m_aOptionComparator ) ; // for each option in the Opti...
Appends the usage clause for an OptionGroup to a StringBuilder . The clause is wrapped in square brackets if the group is required . The display of the options is handled by appendOption
187
37
16,273
public void printUsage ( @ Nonnull final PrintWriter aPW , final int nWidth , final String sCmdLineSyntax ) { final int nArgPos = sCmdLineSyntax . indexOf ( ' ' ) + 1 ; printWrapped ( aPW , nWidth , getSyntaxPrefix ( ) . length ( ) + nArgPos , getSyntaxPrefix ( ) + sCmdLineSyntax ) ; }
Print the sCmdLineSyntax to the specified writer using the specified width .
93
16
16,274
@ Nonnull public EChange registerMimeTypeContent ( @ Nonnull final MimeTypeContent aMimeTypeContent ) { ValueEnforcer . notNull ( aMimeTypeContent , "MimeTypeContent" ) ; return m_aRWLock . writeLocked ( ( ) -> m_aMimeTypeContents . addObject ( aMimeTypeContent ) ) ; }
Register a new MIME content type .
82
8
16,275
@ Nonnull public EChange unregisterMimeTypeContent ( @ Nullable final MimeTypeContent aMimeTypeContent ) { if ( aMimeTypeContent == null ) return EChange . UNCHANGED ; return m_aRWLock . writeLocked ( ( ) -> m_aMimeTypeContents . removeObject ( aMimeTypeContent ) ) ; }
Unregister an existing MIME content type .
81
9
16,276
@ Nullable public IMimeType getMimeTypeFromBytes ( @ Nullable final byte [ ] aBytes , @ Nullable final IMimeType aDefault ) { if ( aBytes == null || aBytes . length == 0 ) return aDefault ; return m_aRWLock . readLocked ( ( ) -> { for ( final MimeTypeContent aMTC : m_aMimeTypeContents ) if ( aMTC . matchesBeginning ( a...
Try to determine the MIME type from the given byte array .
124
13
16,277
public void reinitialize ( ) { m_aRWLock . writeLocked ( ( ) -> { m_aMimeTypeContents . clear ( ) ; _registerDefaultMimeTypeContents ( ) ; } ) ; if ( LOGGER . isDebugEnabled ( ) ) LOGGER . debug ( "Reinitialized " + MimeTypeDeterminator . class . getName ( ) ) ; }
Reset the MimeTypeContent cache to the initial state .
84
13
16,278
public void iterateAllCombinations ( @ Nonnull final ICommonsList < DATATYPE > aElements , @ Nonnull final Consumer < ? super ICommonsList < DATATYPE > > aCallback ) { ValueEnforcer . notNull ( aElements , "Elements" ) ; ValueEnforcer . notNull ( aCallback , "Callback" ) ; for ( int nSlotCount = m_bAllowEmpty ? 0 : 1 ;...
Iterate all combination no matter they are unique or not .
206
12
16,279
@ Nonnull @ ReturnsMutableCopy public ICommonsSet < ICommonsList < DATATYPE > > getCombinations ( @ Nonnull final ICommonsList < DATATYPE > aElements ) { ValueEnforcer . notNull ( aElements , "Elements" ) ; final ICommonsSet < ICommonsList < DATATYPE > > aAllResults = new CommonsHashSet <> ( ) ; iterateAllCombinations ...
Generate all combinations without duplicates .
121
8
16,280
private void _processQueue ( ) { SoftValue < K , V > aSoftValue ; while ( ( aSoftValue = GenericReflection . uncheckedCast ( m_aQueue . poll ( ) ) ) != null ) { m_aSrcMap . remove ( aSoftValue . m_aKey ) ; } }
Here we go through the ReferenceQueue and remove garbage collected SoftValue objects from the HashMap by looking them up using the SoftValue . m_aKey data member .
68
34
16,281
@ Override public V put ( final K aKey , final V aValue ) { // throw out garbage collected values first _processQueue ( ) ; final SoftValue < K , V > aOld = m_aSrcMap . put ( aKey , new SoftValue <> ( aKey , aValue , m_aQueue ) ) ; return aOld == null ? null : aOld . get ( ) ; }
Here we put the key value pair into the HashMap using a SoftValue object .
89
17
16,282
@ Override public void write ( final int c ) { final int nNewCount = m_nCount + 1 ; if ( nNewCount > m_aBuf . length ) m_aBuf = Arrays . copyOf ( m_aBuf , Math . max ( m_aBuf . length << 1 , nNewCount ) ) ; m_aBuf [ m_nCount ] = ( char ) c ; m_nCount = nNewCount ; }
Writes a character to the buffer .
104
8
16,283
@ Override public void write ( @ Nonnull final char [ ] aBuf , @ Nonnegative final int nOfs , @ Nonnegative final int nLen ) { ValueEnforcer . isArrayOfsLen ( aBuf , nOfs , nLen ) ; if ( nLen > 0 ) { final int nNewCount = m_nCount + nLen ; if ( nNewCount > m_aBuf . length ) m_aBuf = Arrays . copyOf ( m_aBuf , Math . ma...
Writes characters to the buffer .
171
7
16,284
@ Override public void write ( @ Nonnull final String sStr , @ Nonnegative final int nOfs , @ Nonnegative final int nLen ) { if ( nLen > 0 ) { final int newcount = m_nCount + nLen ; if ( newcount > m_aBuf . length ) { m_aBuf = Arrays . copyOf ( m_aBuf , Math . max ( m_aBuf . length << 1 , newcount ) ) ; } sStr . getCha...
Write a portion of a string to the buffer .
146
10
16,285
@ Nonnull @ ReturnsMutableCopy public byte [ ] toByteArray ( @ Nonnull final Charset aCharset ) { return StringHelper . encodeCharToBytes ( m_aBuf , 0 , m_nCount , aCharset ) ; }
Returns a copy of the input data as bytes in the correct charset .
58
15
16,286
@ Nonnull public String getAsString ( @ Nonnegative final int nLength ) { ValueEnforcer . isBetweenInclusive ( nLength , "Length" , 0 , m_nCount ) ; return new String ( m_aBuf , 0 , nLength ) ; }
Converts input data to a string .
59
8
16,287
@ Nonnull @ ReturnsMutableCopy @ OverrideOnDemand @ CodingStyleguideUnaware protected ICommonsMap < KEYTYPE , VALUETYPE > createCache ( ) { return hasMaxSize ( ) ? new SoftLinkedHashMap <> ( m_nMaxSize ) : new SoftHashMap <> ( ) ; }
Create a new cache map . This is the internal map that is used to store the items .
75
19
16,288
public VALUETYPE getFromCache ( final KEYTYPE aKey ) { VALUETYPE aValue = getFromCacheNoStats ( aKey ) ; if ( aValue == null ) { // No old value in the cache m_aRWLock . writeLock ( ) . lock ( ) ; try { // Read again, in case the value was set between the two locking // sections // Note: do not increase statistics in t...
Here Nonnull but derived class may be Nullable
268
10
16,289
@ Nonnull @ ReturnsMutableCopy public byte [ ] getAsByteArray ( ) { final byte [ ] aArray = m_aBuffer . array ( ) ; final int nOfs = m_aBuffer . arrayOffset ( ) ; final int nLength = m_aBuffer . position ( ) ; return ArrayHelper . getCopy ( aArray , nOfs , nLength ) ; }
Get everything as a big byte array without altering the ByteBuffer . This works only if the contained ByteBuffer has a backing array .
84
26
16,290
public void writeTo ( @ Nonnull @ WillNotClose final OutputStream aOS , final boolean bClearBuffer ) throws IOException { ValueEnforcer . notNull ( aOS , "OutputStream" ) ; aOS . write ( m_aBuffer . array ( ) , m_aBuffer . arrayOffset ( ) , m_aBuffer . position ( ) ) ; if ( bClearBuffer ) m_aBuffer . clear ( ) ; }
Write everything to the passed output stream and optionally clear the contained buffer . This works only if the contained ByteBuffer has a backing array .
94
27
16,291
@ Nonnull public String getAsString ( @ Nonnull final Charset aCharset ) { return new String ( m_aBuffer . array ( ) , m_aBuffer . arrayOffset ( ) , m_aBuffer . position ( ) , aCharset ) ; }
Get the content as a string without modifying the buffer . This works only if the contained ByteBuffer has a backing array .
61
24
16,292
public void write ( @ Nonnull final ByteBuffer aSrcBuffer ) { ValueEnforcer . notNull ( aSrcBuffer , "SourceBuffer" ) ; if ( m_bCanGrow && aSrcBuffer . remaining ( ) > m_aBuffer . remaining ( ) ) _growBy ( aSrcBuffer . remaining ( ) ) ; m_aBuffer . put ( aSrcBuffer ) ; }
Write the content from the passed byte buffer to this output stream .
89
13
16,293
@ Nonnull public static Homoglyph build ( @ Nonnull final IReadableResource aRes ) throws IOException { ValueEnforcer . notNull ( aRes , "Resource" ) ; return build ( aRes . getReader ( StandardCharsets . ISO_8859_1 ) ) ; }
Parses the specified resource and uses it to construct a populated Homoglyph object .
64
18
16,294
@ Nonnull public static Homoglyph build ( @ Nonnull @ WillClose final Reader aReader ) throws IOException { ValueEnforcer . notNull ( aReader , "reader" ) ; try ( final NonBlockingBufferedReader aBR = new NonBlockingBufferedReader ( aReader ) ) { final ICommonsList < IntSet > aList = new CommonsArrayList <> ( ) ; Strin...
Consumes the supplied Reader and uses it to construct a populated Homoglyph object .
244
17
16,295
public static void setFormattedOutput ( @ Nonnull final Marshaller aMarshaller , final boolean bFormattedOutput ) { _setProperty ( aMarshaller , Marshaller . JAXB_FORMATTED_OUTPUT , Boolean . valueOf ( bFormattedOutput ) ) ; }
Set the standard property for formatting the output or not .
64
11
16,296
public static void setSchemaLocation ( @ Nonnull final Marshaller aMarshaller , @ Nullable final String sSchemaLocation ) { _setProperty ( aMarshaller , Marshaller . JAXB_SCHEMA_LOCATION , sSchemaLocation ) ; }
Set the standard property for setting the namespace schema location
60
10
16,297
public static void setNoNamespaceSchemaLocation ( @ Nonnull final Marshaller aMarshaller , @ Nullable final String sSchemaLocation ) { _setProperty ( aMarshaller , Marshaller . JAXB_NO_NAMESPACE_SCHEMA_LOCATION , sSchemaLocation ) ; }
Set the standard property for setting the no - namespace schema location
70
12
16,298
public static void setFragment ( @ Nonnull final Marshaller aMarshaller , final boolean bFragment ) { _setProperty ( aMarshaller , Marshaller . JAXB_FRAGMENT , Boolean . valueOf ( bFragment ) ) ; }
Set the standard property for marshalling a fragment only .
57
11
16,299
public static void setSunIndentString ( @ Nonnull final Marshaller aMarshaller , @ Nullable final String sIndentString ) { final String sPropertyName = SUN_INDENT_STRING ; _setProperty ( aMarshaller , sPropertyName , sIndentString ) ; }
Set the Sun specific property for the indent string .
65
10