idx int64 0 165k | question stringlengths 73 5.81k | target stringlengths 5 918 |
|---|---|---|
16,200 | public void onSetListeners ( ) { imageViewPerson . setOnClickListener ( new View . OnClickListener ( ) { public void onClick ( View v ) { PersonHolderListener listener = getListener ( PersonHolderListener . class ) ; if ( listener != null ) { listener . onPersonImageClicked ( getItem ( ) ) ; } } } ) ; } | Optionally override onSetListeners to add listeners to the views . |
16,201 | public static List < Person > getMockPeopleSet1 ( ) { List < Person > listPeople = new ArrayList < Person > ( ) ; listPeople . add ( new Person ( "Henry Blair" , "07123456789" , R . drawable . male1 ) ) ; listPeople . add ( new Person ( "Jenny Curtis" , "07123456789" , R . drawable . female1 ) ) ; listPeople . add ( new Person ( "Vincent Green" , "07123456789" , R . drawable . male2 ) ) ; listPeople . add ( new Person ( "Ada Underwood" , "07123456789" , R . drawable . female2 ) ) ; listPeople . add ( new Person ( "Daniel Erickson" , "07123456789" , R . drawable . male3 ) ) ; listPeople . add ( new Person ( "Maria Ramsey" , "07123456789" , R . drawable . female3 ) ) ; listPeople . add ( new Person ( "Rosemary Munoz" , "07123456789" , R . drawable . female4 ) ) ; listPeople . add ( new Person ( "John Singleton" , "07123456789" , R . drawable . male4 ) ) ; listPeople . add ( new Person ( "Lorena Bowen" , "07123456789" , R . drawable . female5 ) ) ; listPeople . add ( new Person ( "Kevin Stokes" , "07123456789" , R . drawable . male5 ) ) ; listPeople . add ( new Person ( "Johnny Sanders" , "07123456789" , R . drawable . male6 ) ) ; listPeople . add ( new Person ( "Jim Ramirez" , "07123456789" , R . drawable . male7 ) ) ; listPeople . add ( new Person ( "Cassandra Hunter" , "07123456789" , R . drawable . female6 ) ) ; listPeople . add ( new Person ( "Viola Guerrero" , "07123456789" , R . drawable . female7 ) ) ; return listPeople ; } | Returns a mock List of Person objects |
16,202 | public static ItemViewHolder createViewHolder ( View view , Class < ? extends ItemViewHolder > itemViewHolderClass ) { try { Constructor < ? extends ItemViewHolder > constructor = itemViewHolderClass . getConstructor ( View . class ) ; return constructor . newInstance ( view ) ; } catch ( IllegalAccessException e ) { throw new RuntimeException ( e ) ; } catch ( NoSuchMethodException e ) { throw new RuntimeException ( "Unable to find a public constructor that takes an argument View in " + itemViewHolderClass . getSimpleName ( ) , e ) ; } catch ( InvocationTargetException e ) { throw new RuntimeException ( e . getTargetException ( ) ) ; } catch ( InstantiationException e ) { throw new RuntimeException ( "Unable to instantiate " + itemViewHolderClass . getSimpleName ( ) , e ) ; } } | Create a new ItemViewHolder using Java reflection |
16,203 | public static Integer parseItemLayoutId ( Class < ? extends ItemViewHolder > itemViewHolderClass ) { Integer itemLayoutId = ClassAnnotationParser . getLayoutId ( itemViewHolderClass ) ; if ( itemLayoutId == null ) { throw new LayoutIdMissingException ( ) ; } return itemLayoutId ; } | Parses the layout ID annotation form the itemViewHolderClass |
16,204 | public static final String getSingletonScopeKey ( final Class < ? extends AbstractSingleton > aClass ) { ValueEnforcer . notNull ( aClass , "Class" ) ; return new StringBuilder ( DEFAULT_KEY_LENGTH ) . append ( "singleton." ) . append ( aClass . getName ( ) ) . toString ( ) ; } | Create the key which is used to reference the object within the scope . |
16,205 | public static final boolean isSingletonInstantiated ( final IScope aScope , final Class < ? extends AbstractSingleton > aClass ) { return getSingletonIfInstantiated ( aScope , aClass ) != null ; } | Check if a singleton is already instantiated inside a scope |
16,206 | public static final < T extends AbstractSingleton > T getSingleton ( final IScope aScope , final Class < T > aClass ) { ValueEnforcer . notNull ( aScope , "aScope" ) ; ValueEnforcer . notNull ( aClass , "Class" ) ; final String sSingletonScopeKey = getSingletonScopeKey ( aClass ) ; T aInstance = s_aRWLock . readLocked ( ( ) -> aScope . attrs ( ) . getCastedValue ( sSingletonScopeKey ) ) ; if ( aInstance == null || aInstance . isInInstantiation ( ) ) { s_aRWLock . writeLock ( ) . lock ( ) ; try { aInstance = aScope . attrs ( ) . getCastedValue ( sSingletonScopeKey ) ; if ( aInstance == null ) { aInstance = _instantiateSingleton ( aClass , aScope ) ; aScope . attrs ( ) . putIn ( sSingletonScopeKey , aInstance ) ; aInstance . setInInstantiation ( true ) ; try { aInstance . onAfterInstantiation ( aScope ) ; aInstance . setInstantiated ( true ) ; } finally { aInstance . setInInstantiation ( false ) ; } s_aStatsCounterInstantiate . increment ( sSingletonScopeKey ) ; } else { } } finally { s_aRWLock . writeLock ( ) . unlock ( ) ; } } if ( SingletonHelper . isDebugConsistency ( ) ) { if ( ! aInstance . isUsableObject ( ) ) if ( LOGGER . isWarnEnabled ( ) ) LOGGER . warn ( "Singleton '" + aClass . getName ( ) + "' is not usable - please check your calling order: " + aInstance . toString ( ) , SingletonHelper . getDebugStackTrace ( ) ) ; } return aInstance ; } | Get the singleton object in the passed scope using the passed class . If the singleton is not yet instantiated a new instance is created . |
16,207 | public static final < T extends AbstractSingleton > ICommonsList < T > getAllSingletons ( final IScope aScope , final Class < T > aDesiredClass ) { ValueEnforcer . notNull ( aDesiredClass , "DesiredClass" ) ; final ICommonsList < T > ret = new CommonsArrayList < > ( ) ; if ( aScope != null ) for ( final Object aScopeValue : aScope . attrs ( ) . values ( ) ) if ( aScopeValue != null && aDesiredClass . isAssignableFrom ( aScopeValue . getClass ( ) ) ) ret . add ( aDesiredClass . cast ( aScopeValue ) ) ; return ret ; } | Get all singleton objects registered in the respective sub - class of this class . |
16,208 | public final ITEMTYPE createChildItem ( final DATATYPE aData ) { final ITEMTYPE aItem = m_aFactory . create ( thisAsT ( ) ) ; if ( aItem == null ) throw new IllegalStateException ( "null item created!" ) ; aItem . setData ( aData ) ; internalAddChild ( aItem ) ; return aItem ; } | Add a child item to this item . |
16,209 | public static < ELEMENTTYPE > Iterator < ELEMENTTYPE > getCombinedIterator ( final Iterator < ? extends ELEMENTTYPE > aIter1 , final Iterator < ? extends ELEMENTTYPE > aIter2 ) { return new CombinedIterator < > ( aIter1 , aIter2 ) ; } | Get a merged iterator of both iterators . The first iterator is iterated first the second one afterwards . |
16,210 | public static < ELEMENTTYPE > Enumeration < ELEMENTTYPE > getEnumeration ( final Iterator < ELEMENTTYPE > aIter ) { if ( aIter == null ) return new EmptyEnumeration < > ( ) ; return new EnumerationFromIterator < > ( aIter ) ; } | Get an Enumeration object based on an Iterator object . |
16,211 | public static < KEYTYPE , VALUETYPE > Enumeration < Map . Entry < KEYTYPE , VALUETYPE > > getEnumeration ( final Map < KEYTYPE , VALUETYPE > aMap ) { if ( aMap == null ) return new EmptyEnumeration < > ( ) ; return getEnumeration ( aMap . entrySet ( ) ) ; } | Get an Enumeration object based on a Map object . |
16,212 | public EChange addAllFrom ( final MapBasedXPathFunctionResolver aOther , final boolean bOverwrite ) { ValueEnforcer . notNull ( aOther , "Other" ) ; EChange eChange = EChange . UNCHANGED ; for ( final Map . Entry < XPathFunctionKey , XPathFunction > 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 functions from the other function resolver into this resolver . |
16,213 | public EChange removeFunctionsWithName ( final QName aName ) { EChange eChange = EChange . UNCHANGED ; if ( aName != null ) { for ( final XPathFunctionKey aKey : m_aMap . copyOfKeySet ( ) ) if ( aKey . getFunctionName ( ) . equals ( aName ) ) eChange = eChange . or ( removeFunction ( aKey ) ) ; } return eChange ; } | Remove all functions with the same name . This can be helpful when the same function is registered for multiple parameters . |
16,214 | public static ESuccess parseJson ( final Reader aReader , final IJsonParserHandler aParserHandler ) { return parseJson ( aReader , aParserHandler , ( IJsonParserCustomizeCallback ) null , ( IJsonParseExceptionCallback ) null ) ; } | Simple JSON parse method taking only the most basic parameters . |
16,215 | private static EValidity _validateJson ( final Reader aReader ) { final ESuccess eSuccess = parseJson ( aReader , new DoNothingJsonParserHandler ( ) , ( IJsonParserCustomizeCallback ) null , ex -> { } ) ; return EValidity . valueOf ( eSuccess . isSuccess ( ) ) ; } | Validate a JSON without building the tree in memory . |
16,216 | public static IJson readJson ( final Reader aReader , final IJsonParserCustomizeCallback aCustomizeCallback , final IJsonParseExceptionCallback aCustomExceptionCallback ) { final CollectingJsonParserHandler aHandler = new CollectingJsonParserHandler ( ) ; if ( parseJson ( aReader , aHandler , aCustomizeCallback , aCustomExceptionCallback ) . isFailure ( ) ) return null ; return aHandler . getJson ( ) ; } | Main reading of the JSON |
16,217 | public static boolean getBooleanValue ( final Boolean aObj , final boolean bDefault ) { return aObj == null ? bDefault : aObj . booleanValue ( ) ; } | Get the primitive value of the passed object value . |
16,218 | public static String urlDecode ( final String sValue , final Charset aCharset ) { ValueEnforcer . notNull ( sValue , "Value" ) ; ValueEnforcer . notNull ( aCharset , "Charset" ) ; boolean bNeedToChange = false ; final int nLen = sValue . length ( ) ; final StringBuilder aSB = new StringBuilder ( nLen ) ; int nIndex = 0 ; byte [ ] aBytes = null ; while ( nIndex < nLen ) { char c = sValue . charAt ( nIndex ) ; switch ( c ) { case '+' : aSB . append ( ' ' ) ; nIndex ++ ; bNeedToChange = true ; break ; case '%' : try { if ( aBytes == null ) aBytes = new byte [ ( nLen - nIndex ) / 3 ] ; int nPos = 0 ; while ( ( nIndex + 2 ) < nLen && c == '%' ) { final int nValue = Integer . parseInt ( sValue . substring ( nIndex + 1 , nIndex + 3 ) , 16 ) ; if ( nValue < 0 ) throw new IllegalArgumentException ( "URLDecoder: Illegal hex characters in escape (%) pattern - negative value" ) ; aBytes [ nPos ++ ] = ( byte ) nValue ; nIndex += 3 ; if ( nIndex < nLen ) c = sValue . charAt ( nIndex ) ; } if ( nIndex < nLen && c == '%' ) throw new IllegalArgumentException ( "URLDecoder: Incomplete trailing escape (%) pattern" ) ; aSB . append ( StringHelper . decodeBytesToChars ( aBytes , 0 , nPos , aCharset ) ) ; } catch ( final NumberFormatException e ) { throw new IllegalArgumentException ( "URLDecoder: Illegal hex characters in escape (%) pattern - " + e . getMessage ( ) ) ; } bNeedToChange = true ; break ; default : aSB . append ( c ) ; nIndex ++ ; break ; } } return bNeedToChange ? aSB . toString ( ) : sValue ; } | URL - decode the passed value automatically handling charset issues . The implementation is ripped from URLDecoder but does not throw an UnsupportedEncodingException for nothing . |
16,219 | public static String urlEncode ( final String sValue , final Charset aCharset ) { ValueEnforcer . notNull ( sValue , "Value" ) ; ValueEnforcer . notNull ( aCharset , "Charset" ) ; NonBlockingCharArrayWriter aCAW = null ; try { final int nLen = sValue . length ( ) ; boolean bChanged = false ; final StringBuilder aSB = new StringBuilder ( nLen * 2 ) ; final char [ ] aSrcChars = sValue . toCharArray ( ) ; int nIndex = 0 ; while ( nIndex < nLen ) { char c = aSrcChars [ nIndex ] ; if ( NO_URL_ENCODE . get ( c ) ) { if ( c == ' ' ) { c = '+' ; bChanged = true ; } aSB . append ( c ) ; nIndex ++ ; } else { if ( aCAW == null ) aCAW = new NonBlockingCharArrayWriter ( ) ; else aCAW . reset ( ) ; while ( true ) { aCAW . write ( c ) ; if ( Character . isHighSurrogate ( c ) && nIndex + 1 < nLen ) { final char d = aSrcChars [ nIndex + 1 ] ; if ( Character . isLowSurrogate ( d ) ) { aCAW . write ( d ) ; nIndex ++ ; } } nIndex ++ ; if ( nIndex >= nLen ) break ; c = aSrcChars [ nIndex ] ; if ( NO_URL_ENCODE . get ( c ) ) break ; } final byte [ ] aEncodedBytes = aCAW . toByteArray ( aCharset ) ; for ( final byte nEncByte : aEncodedBytes ) { aSB . append ( '%' ) . append ( URL_ENCODE_CHARS [ ( nEncByte >> 4 ) & 0xF ] ) . append ( URL_ENCODE_CHARS [ nEncByte & 0xF ] ) ; } bChanged = true ; } } return bChanged ? aSB . toString ( ) : sValue ; } finally { StreamHelper . close ( aCAW ) ; } } | URL - encode the passed value automatically handling charset issues . This is a ripped optimized version of URLEncoder . encode but without the UnsupportedEncodingException . |
16,220 | public static String getCleanURLPartWithoutUmlauts ( final String sURLPart ) { if ( s_aCleanURLOld == null ) _initCleanURL ( ) ; final char [ ] ret = StringHelper . replaceMultiple ( sURLPart , s_aCleanURLOld , s_aCleanURLNew ) ; return new String ( ret ) ; } | Clean an URL part from nasty Umlauts . This mapping needs extension! |
16,221 | public static ISimpleURL getAsURLData ( final String sHref , final IDecoder < String , String > aParameterDecoder ) { ValueEnforcer . notNull ( sHref , "Href" ) ; final String sRealHref = sHref . trim ( ) ; final IURLProtocol eProtocol = URLProtocolRegistry . getInstance ( ) . getProtocol ( sRealHref ) ; if ( eProtocol != null && ! eProtocol . allowsForQueryParameters ( ) ) return new URLData ( sRealHref , null , null ) ; if ( GlobalDebug . isDebugMode ( ) ) if ( eProtocol != null ) try { new URL ( sRealHref ) ; } catch ( final MalformedURLException ex ) { if ( LOGGER . isWarnEnabled ( ) ) LOGGER . warn ( "java.net.URL claims URL '" + sRealHref + "' to be invalid: " + ex . getMessage ( ) ) ; } String sPath ; URLParameterList aParams = null ; String sAnchor ; String sRemainingHref = sRealHref ; final int nIndexAnchor = sRemainingHref . indexOf ( HASH ) ; if ( nIndexAnchor >= 0 ) { sAnchor = sRemainingHref . substring ( nIndexAnchor + 1 ) . trim ( ) ; sRemainingHref = sRemainingHref . substring ( 0 , nIndexAnchor ) . trim ( ) ; } else sAnchor = null ; final int nQuestionIndex = sRemainingHref . indexOf ( QUESTIONMARK ) ; if ( nQuestionIndex >= 0 ) { final String sQueryString = sRemainingHref . substring ( nQuestionIndex + 1 ) . trim ( ) ; if ( StringHelper . hasText ( sQueryString ) ) aParams = getParsedQueryParameters ( sQueryString , aParameterDecoder ) ; sPath = sRemainingHref . substring ( 0 , nQuestionIndex ) . trim ( ) ; } else sPath = sRemainingHref ; return new URLData ( sPath , aParams , sAnchor ) ; } | Parses the passed URL into a structured form |
16,222 | public void iterateAllRegisteredMicroTypeConverters ( final IMicroTypeConverterCallback aCallback ) { final ICommonsMap < Class < ? > , IMicroTypeConverter < ? > > aCopy = m_aRWLock . readLocked ( m_aMap :: getClone ) ; for ( final Map . Entry < Class < ? > , IMicroTypeConverter < ? > > aEntry : aCopy . entrySet ( ) ) if ( aCallback . call ( aEntry . getKey ( ) , aEntry . getValue ( ) ) . isBreak ( ) ) break ; } | Iterate all registered micro type converters . For informational purposes only . |
16,223 | public static String safeDecodeAsString ( final String sEncoded , final Charset aCharset ) { ValueEnforcer . notNull ( aCharset , "Charset" ) ; if ( sEncoded != null ) try { final byte [ ] aDecoded = decode ( sEncoded , DONT_GUNZIP ) ; return new String ( aDecoded , aCharset ) ; } catch ( final IOException ex ) { } return null ; } | Decode the string and convert it back to a string . |
16,224 | public boolean ready ( ) throws IOException { _ensureOpen ( ) ; if ( m_bSkipLF ) { if ( m_nNextCharIndex >= m_nChars && m_aReader . ready ( ) ) _fill ( ) ; if ( m_nNextCharIndex < m_nChars ) { if ( m_aBuf [ m_nNextCharIndex ] == '\n' ) m_nNextCharIndex ++ ; m_bSkipLF = false ; } } return m_nNextCharIndex < m_nChars || m_aReader . ready ( ) ; } | Tells whether this stream is ready to be read . A buffered character stream is ready if the buffer is not empty or if the underlying character stream is ready . |
16,225 | public EChange addAllFrom ( final MapBasedXPathVariableResolver aOther , final boolean bOverwrite ) { ValueEnforcer . notNull ( aOther , "Other" ) ; EChange eChange = EChange . UNCHANGED ; for ( final Map . Entry < String , ? > aEntry : aOther . getAllVariables ( ) . entrySet ( ) ) { final QName aKey = new QName ( aEntry . getKey ( ) ) ; if ( bOverwrite || ! m_aMap . containsKey ( aKey ) ) { m_aMap . put ( aKey , 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 . |
16,226 | public static void setDefaultJMXDomain ( final String sDefaultJMXDomain ) { ValueEnforcer . notEmpty ( sDefaultJMXDomain , "DefaultJMXDomain" ) ; if ( sDefaultJMXDomain . indexOf ( ':' ) >= 0 || sDefaultJMXDomain . indexOf ( ' ' ) >= 0 ) throw new IllegalArgumentException ( "defaultJMXDomain contains invalid chars: " + sDefaultJMXDomain ) ; s_aRWLock . writeLocked ( ( ) -> s_sDefaultJMXDomain = sDefaultJMXDomain ) ; } | Set the default JMX domain |
16,227 | public EChange add ( final CALLBACKTYPE aCallback ) { ValueEnforcer . notNull ( aCallback , "Callback" ) ; return m_aRWLock . writeLocked ( ( ) -> m_aCallbacks . addObject ( aCallback ) ) ; } | Add a callback . |
16,228 | public EChange removeObject ( final CALLBACKTYPE aCallback ) { if ( aCallback == null ) return EChange . UNCHANGED ; return m_aRWLock . writeLocked ( ( ) -> m_aCallbacks . removeObject ( aCallback ) ) ; } | Remove the specified callback |
16,229 | 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" ) ; } | Emit all supported features to the logger . |
16,230 | public static Document getOwnerDocument ( 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 . |
16,231 | public static Element getFirstChildElement ( 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 . |
16,232 | public static boolean hasChildElementNodes ( 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 . |
16,233 | public EChange removeParameterWithName ( 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 ( sParamName ) ) { m_aParameters . remove ( i ) ; return EChange . CHANGED ; } } } return EChange . UNCHANGED ; } | Remove the parameter with the specified name . |
16,234 | public static Matcher getMatcher ( final String sRegEx , 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 . |
16,235 | public static boolean stringMatchesPattern ( final String sRegEx , final String sValue ) { return getMatcher ( sRegEx , sValue ) . matches ( ) ; } | A shortcut helper method to determine whether a string matches a certain regular expression or not . |
16,236 | public boolean containsCountry ( 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 . |
16,237 | public static int append ( final int nPrevHashCode , final Object x ) { return append ( nPrevHashCode , HashCodeImplementationRegistry . getHashCode ( x ) ) ; } | Object hash code generation . |
16,238 | public static HasInputStream multiple ( final ISupplier < ? extends InputStream > aISP ) { return new HasInputStream ( aISP , true ) ; } | Create a new object with a supplier that can read multiple times . |
16,239 | public static HasInputStream once ( final ISupplier < ? extends InputStream > aISP ) { return new HasInputStream ( aISP , false ) ; } | Create a new object with a supplier that can be read only once . |
16,240 | private static int _getDistance111 ( final char [ ] aStr1 , final int nLen1 , final char [ ] aStr2 , final int nLen2 ) { int [ ] aPrevRow = new int [ nLen1 + 1 ] ; int [ ] aCurRow = new int [ nLen1 + 1 ] ; for ( int i = 0 ; i <= nLen1 ; i ++ ) aPrevRow [ i ] = i ; for ( int j = 0 ; j < nLen2 ; j ++ ) { final int ch2 = aStr2 [ j ] ; aCurRow [ 0 ] = j + 1 ; for ( int i = 0 ; i < nLen1 ; i ++ ) { final int nSubstVal = aStr1 [ i ] == ch2 ? 0 : 1 ; aCurRow [ i + 1 ] = Math . min ( Math . min ( aCurRow [ i ] + 1 , aPrevRow [ i + 1 ] + 1 ) , aPrevRow [ i ] + nSubstVal ) ; } final int [ ] tmp = aPrevRow ; aPrevRow = aCurRow ; aCurRow = tmp ; } return aPrevRow [ nLen1 ] ; } | Main generic Levenshtein implementation that uses 1 for all costs! |
16,241 | private static int _getDistance ( final char [ ] aStr1 , final int nLen1 , final char [ ] aStr2 , final int nLen2 , final int nCostInsert , final int nCostDelete , final int nCostSubstitution ) { int [ ] aPrevRow = new int [ nLen1 + 1 ] ; int [ ] aCurRow = new int [ nLen1 + 1 ] ; for ( int i = 0 ; i <= nLen1 ; i ++ ) aPrevRow [ i ] = i * nCostInsert ; for ( int j = 0 ; j < nLen2 ; j ++ ) { final int ch2 = aStr2 [ j ] ; aCurRow [ 0 ] = ( j + 1 ) * nCostDelete ; for ( int i = 0 ; i < nLen1 ; i ++ ) { final int nSubstCost = aStr1 [ i ] == ch2 ? 0 : nCostSubstitution ; aCurRow [ i + 1 ] = Math . min ( Math . min ( aCurRow [ i ] + nCostInsert , aPrevRow [ i + 1 ] + nCostDelete ) , aPrevRow [ i ] + nSubstCost ) ; } final int [ ] tmp = aPrevRow ; aPrevRow = aCurRow ; aCurRow = tmp ; } return aPrevRow [ nLen1 ] ; } | Main generic Levenshtein implementation . Assume all preconditions are checked . |
16,242 | public static String getUnifiedEmailAddress ( 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 . |
16,243 | public static boolean isValid ( final String sEmailAddress ) { if ( sEmailAddress == null ) return false ; final String sUnifiedEmail = getUnifiedEmailAddress ( sEmailAddress ) ; return s_aPattern . matcher ( sUnifiedEmail ) . matches ( ) ; } | Checks if a value is a valid e - mail address according to a certain regular expression . |
16,244 | public static ESuccess writeMap ( final Map < String , String > aMap , final OutputStream aOS ) { ValueEnforcer . notNull ( aMap , "Map" ) ; ValueEnforcer . notNull ( aOS , "OutputStream" ) ; try { final IMicroDocument aDoc = createMapDocument ( aMap ) ; return MicroWriter . writeToStream ( aDoc , aOS , XMLWriterSettings . DEFAULT_XML_SETTINGS ) ; } finally { StreamHelper . close ( aOS ) ; } } | Write the passed map to the passed output stream using the predefined XML layout . |
16,245 | public static Transformer newTransformer ( final TransformerFactory aTransformerFactory ) { ValueEnforcer . notNull ( aTransformerFactory , "TransformerFactory" ) ; try { return aTransformerFactory . newTransformer ( ) ; } catch ( final TransformerConfigurationException ex ) { LOGGER . error ( "Failed to create transformer" , ex ) ; return null ; } } | Create a new XSLT transformer for no specific resource . |
16,246 | 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 |
16,247 | 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 . |
16,248 | public DATATYPE getIfChanged ( 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 . |
16,249 | public DATATYPE getIfUnchanged ( 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 . |
16,250 | public static < DATATYPE > ChangeWithValue < DATATYPE > createChanged ( final DATATYPE aValue ) { return new ChangeWithValue < > ( EChange . CHANGED , aValue ) ; } | Create a new changed object with the given value . |
16,251 | public static < DATATYPE > ChangeWithValue < DATATYPE > createUnchanged ( final DATATYPE aValue ) { return new ChangeWithValue < > ( EChange . UNCHANGED , aValue ) ; } | Create a new unchanged object with the given value . |
16,252 | public static ICommonsList < IAuthToken > getAllTokensOfSubject ( final IAuthSubject aSubject ) { ValueEnforcer . notNull ( aSubject , "Subject" ) ; return s_aRWLock . readLocked ( ( ) -> CommonsArrayList . createFiltered ( s_aMap . values ( ) , aToken -> aToken . getIdentification ( ) . hasAuthSubject ( aSubject ) ) ) ; } | Get all tokens of the specified auth subject . All tokens are returned no matter whether they are expired or not . |
16,253 | public static int removeAllTokensOfSubject ( final IAuthSubject aSubject ) { ValueEnforcer . notNull ( aSubject , "Subject" ) ; 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 ( ) ; } | Remove all tokens of the given subject |
16,254 | public static < ENUMTYPE extends Enum < ENUMTYPE > & IHasName > ENUMTYPE getFromNameCaseInsensitiveOrNull ( final Class < ENUMTYPE > aClass , final String sName ) { return getFromNameCaseInsensitiveOrDefault ( aClass , sName , null ) ; } | Get the enum value with the passed name case insensitive |
16,255 | public static String getEnumID ( final Enum < ? > aEnum ) { return aEnum . getClass ( ) . getName ( ) + '.' + aEnum . name ( ) ; } | Get the unique name of the passed enum entry . |
16,256 | protected IReadableResource internalResolveResource ( final String sType , final String sNamespaceURI , final String sPublicId , final String sSystemId , final String sBaseURI ) throws Exception { if ( DEBUG_RESOLVE ) if ( LOGGER . isInfoEnabled ( ) ) LOGGER . info ( "internalResolveResource (" + sType + ", " + sNamespaceURI + ", " + sPublicId + ", " + sSystemId + ", " + sBaseURI + ")" ) ; return DefaultResourceResolver . getResolvedResource ( sSystemId , sBaseURI , getClassLoader ( ) ) ; } | Internal resource resolving |
16,257 | public final LSInput mainResolveResource ( final String sType , final String sNamespaceURI , final String sPublicId , final String sSystemId , final String sBaseURI ) { try { final IReadableResource aResolvedResource = internalResolveResource ( sType , sNamespaceURI , sPublicId , sSystemId , sBaseURI ) ; return new ResourceLSInput ( aResolvedResource ) ; } catch ( final Exception ex ) { throw new IllegalStateException ( "Failed to resolve resource '" + sType + "', '" + sNamespaceURI + "', '" + sPublicId + "', '" + sSystemId + "', '" + sBaseURI + "'" , ex ) ; } } | Resolve a resource with the passed parameters |
16,258 | public static < ELEMENTTYPE > NonBlockingStack < ELEMENTTYPE > newStack ( final ELEMENTTYPE aValue ) { final NonBlockingStack < ELEMENTTYPE > ret = newStack ( ) ; ret . push ( aValue ) ; return ret ; } | Create a new stack with a single element . |
16,259 | public static < ELEMENTTYPE > NonBlockingStack < ELEMENTTYPE > newStack ( final ELEMENTTYPE ... aValues ) { return new NonBlockingStack < > ( aValues ) ; } | Create a new stack from the given array . |
16,260 | public static < ELEMENTTYPE > NonBlockingStack < ELEMENTTYPE > newStack ( final Collection < ? extends ELEMENTTYPE > aValues ) { return new NonBlockingStack < > ( aValues ) ; } | Create a new stack from the given collection . |
16,261 | protected void validateOutgoingBusinessDocument ( final Element aXML ) throws AS2ClientBuilderException { if ( m_aVESRegistry == null ) { m_aVESRegistry = createValidationRegistry ( ) ; } final IValidationExecutorSet aVES = m_aVESRegistry . getOfID ( m_aVESID ) ; if ( aVES == null ) throw new AS2ClientBuilderException ( "The validation executor set ID " + m_aVESID . getAsSingleID ( ) + " is unknown!" ) ; final ValidationExecutionManager aVEM = aVES . createExecutionManager ( ) ; final ValidationResultList aValidationResult = aVEM . executeValidation ( ValidationSource . create ( null , aXML ) , ( Locale ) null ) ; if ( aValidationResult . containsAtLeastOneError ( ) ) throw new AS2ClientBuilderValidationException ( aValidationResult ) ; } | 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 . |
16,262 | public ISessionScope getSessionScopeOfID ( 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 . |
16,263 | public void onScopeEnd ( final ISessionScope aSessionScope ) { ValueEnforcer . notNull ( aSessionScope , "SessionScope" ) ; if ( aSessionScope . isValid ( ) ) { final String sSessionID = aSessionScope . getID ( ) ; final boolean bCanDestroyScope = m_aRWLock . writeLocked ( ( ) -> { boolean bWLCanDestroyScope = false ; if ( m_aSessionsInDestruction . add ( sSessionID ) ) { final ISessionScope aRemovedScope = m_aSessionScopes . remove ( sSessionID ) ; if ( ! EqualsHelper . identityEqual ( aRemovedScope , aSessionScope ) ) { LOGGER . error ( "Ending an unknown session with ID '" + sSessionID + "'" ) ; LOGGER . error ( " Scope to be removed: " + aSessionScope ) ; LOGGER . error ( " Removed scope: " + aRemovedScope ) ; } bWLCanDestroyScope = true ; } else LOGGER . info ( "Already destructing session '" + sSessionID + "'" ) ; return bWLCanDestroyScope ; } ) ; if ( bCanDestroyScope ) { try { ScopeSPIManager . getInstance ( ) . onSessionScopeEnd ( aSessionScope ) ; aSessionScope . destroyScope ( ) ; } finally { m_aRWLock . writeLocked ( ( ) -> m_aSessionsInDestruction . remove ( sSessionID ) ) ; } } } } | 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 . |
16,264 | public void destroyAllSessions ( ) { for ( final ISessionScope aSessionScope : getAllSessionScopes ( ) ) { if ( aSessionScope . selfDestruct ( ) . isContinue ( ) ) { onScopeEnd ( aSessionScope ) ; } } _checkIfAnySessionsExist ( ) ; } | Destroy all known session scopes . After this method it is ensured that the internal session map is empty . |
16,265 | public static IGlobalScope onGlobalBegin ( final String sScopeID ) { return onGlobalBegin ( sScopeID , GlobalScope :: new ) ; } | This method is used to set the initial global scope . |
16,266 | public static void onGlobalEnd ( ) { s_aGlobalLock . locked ( ( ) -> { if ( s_aGlobalScope != null ) { ScopeSPIManager . getInstance ( ) . onGlobalScopeEnd ( s_aGlobalScope ) ; final String sDestroyedScopeID = s_aGlobalScope . getID ( ) ; s_aGlobalScope . destroyScope ( ) ; s_aGlobalScope = null ; if ( ScopeHelper . debugGlobalScopeLifeCycle ( LOGGER ) ) LOGGER . info ( "Global scope '" + sDestroyedScopeID + "' shut down!" , ScopeHelper . getDebugStackTrace ( ) ) ; } else LOGGER . warn ( "No global scope present that could be shut down!" ) ; } ) ; } | To be called when the singleton global context is to be destroyed . |
16,267 | public static void destroySessionScope ( final ISessionScope aSessionScope ) { ValueEnforcer . notNull ( aSessionScope , "SessionScope" ) ; ScopeSessionManager . getInstance ( ) . onScopeEnd ( aSessionScope ) ; } | Manually destroy the passed session scope . |
16,268 | public static void onRequestEnd ( ) { final IRequestScope aRequestScope = getRequestScopeOrNull ( ) ; try { if ( aRequestScope != null ) { _destroyRequestScope ( aRequestScope ) ; } else { LOGGER . warn ( "No request scope present that could be ended!" ) ; } } finally { internalClearRequestScope ( ) ; } } | To be called after a request finished . |
16,269 | public void onDocumentType ( final String sQualifiedElementName , final String sPublicID , final String sSystemID ) { ValueEnforcer . notNull ( sQualifiedElementName , "QualifiedElementName" ) ; final String sDocType = getDocTypeXMLRepresentation ( m_eXMLVersion , m_aXMLWriterSettings . getIncorrectCharacterHandling ( ) , sQualifiedElementName , sPublicID , sSystemID ) ; _append ( sDocType ) ; newLine ( ) ; } | On XML document type . |
16,270 | public void onProcessingInstruction ( final String sTarget , final String sData ) { _append ( PI_START ) . _append ( sTarget ) ; if ( StringHelper . hasText ( sData ) ) _append ( ' ' ) . _append ( sData ) ; _append ( PI_END ) ; newLine ( ) ; } | On processing instruction |
16,271 | public void onEntityReference ( final String sEntityRef ) { _append ( ER_START ) . _append ( sEntityRef ) . _append ( ER_END ) ; } | On entity reference . |
16,272 | public void onContentElementWhitespace ( final CharSequence aWhitespaces ) { if ( StringHelper . hasText ( aWhitespaces ) ) _append ( aWhitespaces . toString ( ) ) ; } | Ignorable whitespace characters . |
16,273 | public void onComment ( 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: " + sComment ) ; _append ( COMMENT_START ) . _append ( sComment ) . _append ( COMMENT_END ) ; } } | Comment node . |
16,274 | public void onText ( final char [ ] aText , final int nOfs , final int nLen ) { onText ( aText , nOfs , nLen , true ) ; } | XML text node . |
16,275 | public void onCDATA ( final String sText ) { if ( StringHelper . hasText ( sText ) ) { if ( sText . indexOf ( CDATA_END ) >= 0 ) { final ICommonsList < String > aParts = StringHelper . getExploded ( CDATA_END , sText ) ; final int nParts = aParts . size ( ) ; for ( int i = 0 ; i < nParts ; ++ i ) { _append ( CDATA_START ) ; if ( i > 0 ) _append ( '>' ) ; _appendMasked ( EXMLCharMode . CDATA , aParts . get ( i ) ) ; if ( i < nParts - 1 ) _append ( "]]" ) ; _append ( CDATA_END ) ; } } else { _append ( CDATA_START ) . _appendMasked ( EXMLCharMode . CDATA , sText ) . _append ( CDATA_END ) ; } } } | CDATA node . |
16,276 | public void onElementStart ( final String sNamespacePrefix , final String sTagName , final Map < QName , String > aAttrs , final EXMLSerializeBracketMode eBracketMode ) { elementStartOpen ( sNamespacePrefix , sTagName ) ; if ( aAttrs != null && ! aAttrs . isEmpty ( ) ) { if ( m_bOrderAttributesAndNamespaces ) { final ICommonsSortedMap < QName , String > aNamespaceAttrs = new CommonsTreeMap < > ( CXML . getComparatorQNameForNamespacePrefix ( ) ) ; final ICommonsSortedMap < QName , String > aNonNamespaceAttrs = new CommonsTreeMap < > ( CXML . getComparatorQNameNamespaceURIBeforeLocalPart ( ) ) ; for ( final Map . Entry < QName , String > aEntry : aAttrs . entrySet ( ) ) { final QName aAttrName = aEntry . getKey ( ) ; if ( XMLConstants . XMLNS_ATTRIBUTE_NS_URI . equals ( aAttrName . getNamespaceURI ( ) ) ) aNamespaceAttrs . put ( aAttrName , aEntry . getValue ( ) ) ; else aNonNamespaceAttrs . put ( aAttrName , aEntry . getValue ( ) ) ; } for ( final Map . Entry < QName , String > aEntry : aNamespaceAttrs . entrySet ( ) ) { final QName aAttrName = aEntry . getKey ( ) ; elementAttr ( aAttrName . getPrefix ( ) , aAttrName . getLocalPart ( ) , aEntry . getValue ( ) ) ; } for ( final Map . Entry < QName , String > aEntry : aNonNamespaceAttrs . entrySet ( ) ) { final QName aAttrName = aEntry . getKey ( ) ; elementAttr ( aAttrName . getPrefix ( ) , aAttrName . getLocalPart ( ) , aEntry . getValue ( ) ) ; } } else { for ( final Map . Entry < QName , String > aEntry : aAttrs . entrySet ( ) ) { final QName aAttrName = aEntry . getKey ( ) ; elementAttr ( aAttrName . getPrefix ( ) , aAttrName . getLocalPart ( ) , aEntry . getValue ( ) ) ; } } } elementStartClose ( eBracketMode ) ; } | Start of an element . |
16,277 | public void onElementEnd ( final String sNamespacePrefix , final String sTagName , final EXMLSerializeBracketMode eBracketMode ) { if ( eBracketMode . isOpenClose ( ) ) { _append ( "</" ) ; if ( StringHelper . hasText ( sNamespacePrefix ) ) _appendMasked ( EXMLCharMode . ELEMENT_NAME , sNamespacePrefix ) . _append ( CXML . XML_PREFIX_NAMESPACE_SEP ) ; _appendMasked ( EXMLCharMode . ELEMENT_NAME , sTagName ) . _append ( '>' ) ; } } | End of an element . |
16,278 | private void _registerTypeConverter ( final Class < ? > aSrcClass , final Class < ? > aDstClass , final ITypeConverter < ? , ? > aConverter ) { ValueEnforcer . notNull ( aSrcClass , "SrcClass" ) ; ValueEnforcer . isTrue ( ClassHelper . isPublic ( aSrcClass ) , ( ) -> "Source " + aSrcClass + " is no public class!" ) ; ValueEnforcer . notNull ( aDstClass , "DstClass" ) ; ValueEnforcer . isTrue ( ClassHelper . isPublic ( aDstClass ) , ( ) -> "Destination " + aDstClass + " is no public class!" ) ; ValueEnforcer . isFalse ( aSrcClass . equals ( aDstClass ) , "Source and destination class are equal and therefore no converter is required." ) ; ValueEnforcer . notNull ( aConverter , "Converter" ) ; ValueEnforcer . isFalse ( aConverter instanceof ITypeConverterRule , "Type converter rules must be registered via registerTypeConverterRule" ) ; if ( ClassHelper . areConvertibleClasses ( aSrcClass , aDstClass ) ) if ( LOGGER . isWarnEnabled ( ) ) LOGGER . warn ( "No type converter needed between " + aSrcClass + " and " + aDstClass + " because types are convertible!" ) ; final Map < Class < ? > , ITypeConverter < ? , ? > > aSrcMap = _getOrCreateConverterMap ( aSrcClass ) ; if ( aSrcMap . containsKey ( aDstClass ) ) throw new IllegalArgumentException ( "A mapping from " + aSrcClass + " to " + aDstClass + " is already defined!" ) ; m_aRWLock . writeLocked ( ( ) -> { for ( final WeakReference < Class < ? > > aCurWRDstClass : ClassHierarchyCache . getClassHierarchyIterator ( aDstClass ) ) { final Class < ? > aCurDstClass = aCurWRDstClass . get ( ) ; if ( aCurDstClass != null ) if ( ! aSrcMap . containsKey ( aCurDstClass ) ) { if ( aSrcMap . put ( aCurDstClass , aConverter ) != null ) { if ( LOGGER . isWarnEnabled ( ) ) LOGGER . warn ( "Overwriting converter from " + aSrcClass + " to " + aCurDstClass ) ; } else { if ( LOGGER . isTraceEnabled ( ) ) LOGGER . trace ( "Registered type converter from '" + aSrcClass . toString ( ) + "' to '" + aCurDstClass . toString ( ) + "'" ) ; } } } } ) ; } | Register a default type converter . |
16,279 | private void _iterateFuzzyConverters ( final Class < ? > aSrcClass , final Class < ? > aDstClass , final ITypeConverterCallback aCallback ) { for ( final WeakReference < Class < ? > > aCurWRSrcClass : ClassHierarchyCache . getClassHierarchyIterator ( aSrcClass ) ) { final Class < ? > aCurSrcClass = aCurWRSrcClass . get ( ) ; if ( aCurSrcClass != null ) { final Map < Class < ? > , ITypeConverter < ? , ? > > aConverterMap = m_aConverter . get ( aCurSrcClass ) ; if ( aConverterMap != null ) { final ITypeConverter < ? , ? > aConverter = aConverterMap . get ( aDstClass ) ; if ( aConverter != null ) { if ( aCallback . call ( aCurSrcClass , aDstClass , aConverter ) . isBreak ( ) ) break ; } } } } } | Iterate all possible fuzzy converters from source class to destination class . |
16,280 | public void iterateAllRegisteredTypeConverters ( final ITypeConverterCallback aCallback ) { final Map < Class < ? > , Map < Class < ? > , ITypeConverter < ? , ? > > > aCopy = m_aRWLock . readLocked ( ( ) -> new CommonsHashMap < > ( m_aConverter ) ) ; outer : for ( final Map . Entry < Class < ? > , Map < Class < ? > , ITypeConverter < ? , ? > > > aSrcEntry : aCopy . entrySet ( ) ) { final Class < ? > aSrcClass = aSrcEntry . getKey ( ) ; for ( final Map . Entry < Class < ? > , ITypeConverter < ? , ? > > aDstEntry : aSrcEntry . getValue ( ) . entrySet ( ) ) if ( aCallback . call ( aSrcClass , aDstEntry . getKey ( ) , aDstEntry . getValue ( ) ) . isBreak ( ) ) break outer ; } } | Iterate all registered type converters . For informational purposes only . |
16,281 | public static Class < ? > [ ] getClassArray ( 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 ret ; } | Get an array with all the classes of the passed object array . |
16,282 | public static < RETURNTYPE > RETURNTYPE invokeMethod ( final Object aSrcObj , final String sMethodName , final Object ... aArgs ) throws NoSuchMethodException , IllegalAccessException , InvocationTargetException { return GenericReflection . < RETURNTYPE > invokeMethod ( aSrcObj , sMethodName , getClassArray ( aArgs ) , aArgs ) ; } | This method dynamically invokes the method with the given name on the given object . |
16,283 | public static < DATATYPE > DATATYPE newInstance ( 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 . |
16,284 | public static final < T extends AbstractRequestSingleton > T getRequestSingleton ( 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 . |
16,285 | public static void forAllClassPathEntries ( final Consumer < ? super String > aConsumer ) { StringHelper . explode ( SystemProperties . getPathSeparator ( ) , SystemProperties . getJavaClassPath ( ) , aConsumer ) ; } | Add all class path entries into the provided target list . |
16,286 | public static void printClassPathEntries ( final PrintStream aPS , 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 |
16,287 | public static ESuccess writeToStream ( final IMicroNode aNode , final OutputStream aOS ) { return writeToStream ( aNode , aOS , XMLWriterSettings . DEFAULT_XML_SETTINGS ) ; } | Write a Micro Node to an output stream using the default settings . |
16,288 | public static String getNodeAsString ( final IMicroNode aNode , final IXMLWriterSettings aSettings ) { ValueEnforcer . notNull ( aNode , "Node" ) ; ValueEnforcer . notNull ( aSettings , "Settings" ) ; try ( final NonBlockingStringWriter aWriter = new NonBlockingStringWriter ( 50 * CGlobal . BYTES_PER_KILOBYTE ) ) { if ( writeToWriter ( aNode , aWriter , aSettings ) . isSuccess ( ) ) return aWriter . getAsString ( ) ; } catch ( final Exception ex ) { if ( LOGGER . isErrorEnabled ( ) ) LOGGER . error ( "Error serializing MicroDOM with settings " + aSettings . toString ( ) , ex ) ; } return null ; } | Convert the passed micro node to an XML string using the provided settings . |
16,289 | public static byte [ ] getNodeAsBytes ( final IMicroNode aNode , final IXMLWriterSettings aSettings ) { ValueEnforcer . notNull ( aNode , "Node" ) ; ValueEnforcer . notNull ( aSettings , "Settings" ) ; try ( final NonBlockingByteArrayOutputStream aBAOS = new NonBlockingByteArrayOutputStream ( 50 * CGlobal . BYTES_PER_KILOBYTE ) ) { if ( writeToStream ( aNode , aBAOS , aSettings ) . isSuccess ( ) ) return aBAOS . toByteArray ( ) ; } catch ( final Exception ex ) { if ( LOGGER . isErrorEnabled ( ) ) LOGGER . error ( "Error serializing MicroDOM with settings " + aSettings . toString ( ) , ex ) ; } return null ; } | Convert the passed micro node to an XML byte array using the provided settings . |
16,290 | public static < KEYTYPE , DATATYPE , ITEMTYPE extends ITreeItemWithID < KEYTYPE , DATATYPE , ITEMTYPE > > void sortByID ( final IBasicTree < DATATYPE , ITEMTYPE > aTree , 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 . |
16,291 | public static < KEYTYPE , DATATYPE , ITEMTYPE extends ITreeItemWithID < KEYTYPE , DATATYPE , ITEMTYPE > > void sortByValue ( final IBasicTree < DATATYPE , ITEMTYPE > aTree , final Comparator < ? super DATATYPE > aValueComparator ) { _sort ( aTree , Comparator . comparing ( IBasicTreeItem :: getData , aValueComparator ) ) ; } | Sort each level of the passed tree on the value with the specified comparator . |
16,292 | public final EChange start ( ) { if ( m_nStartDT > 0 ) return EChange . UNCHANGED ; m_nStartDT = getCurrentNanoTime ( ) ; return EChange . CHANGED ; } | Start the stop watch . |
16,293 | public EChange stop ( ) { 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 . |
16,294 | public static TimeValue runMeasured ( 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 . |
16,295 | public ErrorTextProvider addItem ( final EField eField , final String sText ) { return addItem ( new FormattableItem ( eField , sText ) ) ; } | Add an error item to be disabled . |
16,296 | public int compareTo ( final Version rhs ) { ValueEnforcer . notNull ( rhs , "Rhs" ) ; int ret = m_nMajor - rhs . m_nMajor ; if ( ret == 0 ) { ret = m_nMinor - rhs . m_nMinor ; if ( ret == 0 ) { ret = m_nMicro - rhs . m_nMicro ; if ( ret == 0 ) { if ( m_sQualifier != null ) { if ( rhs . m_sQualifier != null ) { ret = m_sQualifier . compareTo ( rhs . m_sQualifier ) ; if ( ret < 0 ) ret = - 1 ; else if ( ret > 0 ) ret = + 1 ; } else ret = 1 ; } else if ( rhs . m_sQualifier != null ) { ret = - 1 ; } else { ret = 0 ; } } } } return ret ; } | Compares two Version objects . |
16,297 | public String getAsString ( final boolean bPrintZeroElements , final boolean bPrintAtLeastMajorAndMinor ) { final StringBuilder aSB = new StringBuilder ( m_sQualifier != null ? m_sQualifier : "" ) ; if ( m_nMicro > 0 || aSB . length ( ) > 0 || bPrintZeroElements ) { if ( aSB . length ( ) > 0 ) aSB . insert ( 0 , '.' ) ; aSB . insert ( 0 , m_nMicro ) ; } if ( bPrintAtLeastMajorAndMinor || m_nMinor > 0 || aSB . length ( ) > 0 || bPrintZeroElements ) { if ( aSB . length ( ) > 0 ) aSB . insert ( 0 , '.' ) ; aSB . insert ( 0 , m_nMinor ) ; } if ( bPrintAtLeastMajorAndMinor || m_nMajor > 0 || aSB . length ( ) > 0 || bPrintZeroElements ) { if ( aSB . length ( ) > 0 ) aSB . insert ( 0 , '.' ) ; aSB . insert ( 0 , m_nMajor ) ; } return aSB . length ( ) > 0 ? aSB . toString ( ) : DEFAULT_VERSION_STRING ; } | Get the string representation of the version number . |
16,298 | public static Version parse ( 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 ) { final String [ ] aParts = StringHelper . getExplodedArray ( '.' , s , 4 ) ; if ( aParts . length > 0 ) nMajor = StringParser . parseInt ( aParts [ 0 ] , 0 ) ; else nMajor = 0 ; if ( aParts . length > 1 ) nMinor = StringParser . parseInt ( aParts [ 1 ] , 0 ) ; else nMinor = 0 ; if ( aParts . length > 2 ) nMicro = StringParser . parseInt ( aParts [ 2 ] , 0 ) ; else nMicro = 0 ; if ( aParts . length > 3 ) sQualifier = StringHelper . hasNoText ( aParts [ 3 ] ) ? null : aParts [ 3 ] ; else sQualifier = null ; } else { Integer aMajor ; Integer aMinor = null ; Integer aMicro = null ; boolean bDone = false ; String [ ] aParts = _extSplit ( s ) ; aMajor = StringParser . parseIntObj ( aParts [ 0 ] ) ; if ( aMajor == null && StringHelper . hasText ( aParts [ 0 ] ) ) { sQualifier = s ; bDone = true ; } else sQualifier = null ; String sRest = ! bDone && aParts . length > 1 ? aParts [ 1 ] : null ; if ( StringHelper . hasText ( sRest ) ) { aParts = _extSplit ( sRest ) ; aMinor = StringParser . parseIntObj ( aParts [ 0 ] ) ; if ( aMinor == null && StringHelper . hasText ( aParts [ 0 ] ) ) { sQualifier = sRest ; bDone = true ; } sRest = ! bDone && aParts . length > 1 ? aParts [ 1 ] : null ; if ( StringHelper . hasText ( sRest ) ) { aParts = _extSplit ( sRest ) ; aMicro = StringParser . parseIntObj ( aParts [ 0 ] ) ; if ( aMicro == null && StringHelper . hasText ( aParts [ 0 ] ) ) { sQualifier = sRest ; bDone = true ; } if ( ! bDone && aParts . length > 1 ) { sQualifier = aParts [ 1 ] ; } } } nMajor = aMajor == null ? 0 : aMajor . intValue ( ) ; nMinor = aMinor == null ? 0 : aMinor . intValue ( ) ; nMicro = aMicro == null ? 0 : aMicro . intValue ( ) ; sQualifier = StringHelper . hasNoText ( sQualifier ) ? null : sQualifier ; } return new Version ( nMajor , nMinor , nMicro , sQualifier ) ; } | Construct a version object from a string . |
16,299 | 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 ) ; final Iterator < Option > it = optList . iterator ( ) ; while ( it . hasNext ( ) ) { _appendOption ( aSB , it . next ( ) , true ) ; if ( it . hasNext ( ) ) aSB . append ( " | " ) ; } if ( ! aGroup . isRequired ( ) ) aSB . append ( ']' ) ; } | 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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.