idx
int64
0
165k
question
stringlengths
73
4.15k
target
stringlengths
5
918
len_question
int64
21
890
len_target
int64
3
255
43,600
private void buildInstalledPackagesCache ( Context context ) { final List < PackageInfo > installedPackages = context . getPackageManager ( ) . getInstalledPackages ( 0 ) ; for ( PackageInfo installedPackage : installedPackages ) { addInstalledPackageToCache ( installedPackage . packageName ) ; } }
Builds a cache of installed packages .
68
8
43,601
private void processSwatch ( Bitmap image ) { final Map < Integer , Integer > colorHistogram = processLuminanceData ( image ) ; extractFgBgData ( colorHistogram ) ; // Two-decimal digits of precision for the contrast ratio mContrastRatio = Math . round ( ContrastUtils . calculateContrastRatio ( mBackgroundLuminance , m...
Compute the background and foreground colors and luminance for the image and the contrast ratio .
101
18
43,602
private void extractFgBgData ( Map < Integer , Integer > colorHistogram ) { if ( colorHistogram . isEmpty ( ) ) { // An empty histogram indicates we've encountered a 0px area image. It has no luminance. mBackgroundLuminance = mForegroundLuminance = 0 ; mBackgroundColor = Color . BLACK ; mForegroundColor = Color . BLACK...
Set the fields mBackgroundColor mForegroundColor mBackgroundLuminance and mForegroundLuminance based upon the color histogram .
679
29
43,603
public static AccessibilityNodeInfoCompat focusSearch ( AccessibilityNodeInfoCompat node , int direction ) { final AccessibilityNodeInfoRef ref = AccessibilityNodeInfoRef . unOwned ( node ) ; switch ( direction ) { case SEARCH_FORWARD : { if ( ! ref . nextInOrder ( ) ) { return null ; } return ref . release ( ) ; } cas...
Perform in - order navigation from a given node in a particular direction .
116
15
43,604
public static boolean performNavigationByDOMObject ( AccessibilityNodeInfoCompat node , int direction ) { final int action = ( direction == DIRECTION_FORWARD ) ? AccessibilityNodeInfoCompat . ACTION_NEXT_HTML_ELEMENT : AccessibilityNodeInfoCompat . ACTION_PREVIOUS_HTML_ELEMENT ; return node . performAction ( action ) ;...
Sends an instruction to ChromeVox to navigate by DOM object in the given direction within a node .
80
21
43,605
public static boolean supportsWebActions ( AccessibilityNodeInfoCompat node ) { return AccessibilityNodeInfoUtils . supportsAnyAction ( node , AccessibilityNodeInfoCompat . ACTION_NEXT_HTML_ELEMENT , AccessibilityNodeInfoCompat . ACTION_PREVIOUS_HTML_ELEMENT ) ; }
Determines whether or not the given node contains web content .
67
13
43,606
public static boolean hasLegacyWebContent ( AccessibilityNodeInfoCompat node ) { if ( node == null ) { return false ; } if ( ! supportsWebActions ( node ) ) { return false ; } // ChromeVox does not have sub elements, so if the parent element also has web content // this cannot be ChromeVox. AccessibilityNodeInfoCompat ...
Determines whether or not the given node contains ChromeVox content .
148
15
43,607
public static boolean shouldFocusNode ( Context context , AccessibilityNodeInfoCompat node ) { if ( node == null ) { return false ; } if ( ! isVisibleOrLegacy ( node ) ) { LogUtils . log ( AccessibilityNodeInfoUtils . class , Log . VERBOSE , "Don't focus, node is not visible" ) ; return false ; } if ( FILTER_ACCESSIBIL...
Returns whether a node should receive accessibility focus from navigation . This method should never be called recursively since it traverses up the parent hierarchy on every call .
423
32
43,608
private static boolean hasMatchingAncestor ( Context context , AccessibilityNodeInfoCompat node , NodeFilter filter ) { if ( node == null ) { return false ; } final AccessibilityNodeInfoCompat result = getMatchingAncestor ( context , node , filter ) ; if ( result == null ) { return false ; } result . recycle ( ) ; retu...
Check whether a given node has a scrollable ancestor .
79
11
43,609
private static boolean isScrollable ( AccessibilityNodeInfoCompat node ) { if ( node . isScrollable ( ) ) { return true ; } return supportsAnyAction ( node , AccessibilityNodeInfoCompat . ACTION_SCROLL_FORWARD , AccessibilityNodeInfoCompat . ACTION_SCROLL_BACKWARD ) ; }
Check whether a given node is scrollable .
69
9
43,610
private static boolean hasText ( AccessibilityNodeInfoCompat node ) { if ( node == null ) { return false ; } return ( ! TextUtils . isEmpty ( node . getText ( ) ) || ! TextUtils . isEmpty ( node . getContentDescription ( ) ) ) ; }
Returns whether the specified node has text .
62
8
43,611
public static boolean isTopLevelScrollItem ( Context context , AccessibilityNodeInfoCompat node ) { if ( node == null ) { return false ; } AccessibilityNodeInfoCompat parent = null ; try { parent = node . getParent ( ) ; if ( parent == null ) { // Not a child node of anything. return false ; } if ( isScrollable ( node ...
Determines whether a node is a top - level item in a scrollable container .
250
18
43,612
public static boolean isEdgeListItem ( Context context , AccessibilityNodeInfoCompat node , int direction , NodeFilter filter ) { if ( node == null ) { return false ; } if ( ( direction <= 0 ) && isMatchingEdgeListItem ( context , node , NodeFocusFinder . SEARCH_BACKWARD , FILTER_SCROLL_BACKWARD . and ( filter ) ) ) { ...
Determines if the current item is at the edge of a list by checking the scrollable predecessors of the items on either or both sides .
143
29
43,613
private static boolean isMatchingEdgeListItem ( Context context , AccessibilityNodeInfoCompat cursor , int direction , NodeFilter filter ) { AccessibilityNodeInfoCompat ancestor = null ; AccessibilityNodeInfoCompat searched = null ; AccessibilityNodeInfoCompat searchedAncestor = null ; try { ancestor = getMatchingAnces...
Utility method for determining if a searching past a particular node will fall off the edge of a scrollable container .
294
23
43,614
public static AccessibilityNodeInfoCompat searchFromBfs ( Context context , AccessibilityNodeInfoCompat node , NodeFilter filter ) { if ( node == null ) { return null ; } final LinkedList < AccessibilityNodeInfoCompat > queue = new LinkedList < AccessibilityNodeInfoCompat > ( ) ; queue . add ( AccessibilityNodeInfoComp...
Returns the result of applying a filter using breadth - first traversal .
199
14
43,615
public static AccessibilityNodeInfoCompat searchFromInOrderTraversal ( Context context , AccessibilityNodeInfoCompat root , NodeFilter filter , int direction ) { AccessibilityNodeInfoCompat currentNode = NodeFocusFinder . focusSearch ( root , direction ) ; final HashSet < AccessibilityNodeInfoCompat > seenNodes = new H...
Performs in - order traversal from a given node in a particular direction until a node matching the specified filter is reached .
170
25
43,616
public boolean isCompatible ( DefaultVersionRange otherRange ) { int lowerCompare = compareTo ( this . lowerBound , this . lowerBoundInclusive , otherRange . lowerBound , otherRange . lowerBoundInclusive , false ) ; int upperCompare = compareTo ( this . upperBound , this . upperBoundInclusive , otherRange . upperBound ...
Indicate if the provided version range is compatible with the provided version range .
235
15
43,617
@ Deprecated protected Class < ? > getGenericRole ( Field field ) { Type type = field . getGenericType ( ) ; if ( type instanceof ParameterizedType ) { ParameterizedType pType = ( ParameterizedType ) type ; Type [ ] types = pType . getActualTypeArguments ( ) ; if ( types . length > 0 && types [ types . length - 1 ] ins...
Extract generic type from the list field .
110
9
43,618
private DefaultLocalExtension createExtension ( Extension extension ) { DefaultLocalExtension localExtension = new DefaultLocalExtension ( this , extension ) ; localExtension . setFile ( this . storage . getNewExtensionFile ( localExtension . getId ( ) , localExtension . getType ( ) ) ) ; return localExtension ; }
Create a new local extension from a remote extension .
75
10
43,619
private ExtensionDependency getDependency ( Extension extension , String dependencyId ) { for ( ExtensionDependency dependency : extension . getDependencies ( ) ) { if ( dependency . getId ( ) . equals ( dependencyId ) ) { return dependency ; } } return null ; }
Extract extension with the provided id from the provided extension .
61
12
43,620
private Set < InstalledExtension > getReplacedInstalledExtensions ( Extension extension , String namespace ) throws IncompatibleVersionConstraintException , ResolveException , InstallException { // If a namespace extension already exist on root, fail the install if ( namespace != null ) { checkRootExtension ( extension...
Search and validate existing extensions that will be replaced by the extension .
339
13
43,621
public static boolean verify ( SignerInformation signer , CertifiedPublicKey certKey , BcContentVerifierProviderBuilder contentVerifierProviderBuilder , DigestFactory digestProvider ) throws CMSException { if ( certKey == null ) { throw new CMSException ( "No certified key for proceeding to signature validation." ) ; }...
Verify a CMS signature .
130
6
43,622
public void setProperties ( Map < String , Object > properties ) { this . properties . clear ( ) ; this . properties . putAll ( properties ) ; }
Replace existing properties with provided properties .
34
8
43,623
public < T > Cache < T > createNewCache ( CacheConfiguration config , String cacheHint ) throws CacheException { CacheFactory cacheFactory ; try { cacheFactory = this . componentManager . getInstance ( CacheFactory . class , cacheHint ) ; } catch ( ComponentLookupException e ) { throw new CacheException ( "Failed to ge...
Lookup the cache component with provided hint and create a new cache .
102
14
43,624
private Method getPrivateMethod ( VelMethod velMethod ) throws Exception { Field methodField = velMethod . getClass ( ) . getDeclaredField ( "method" ) ; boolean isAccessible = methodField . isAccessible ( ) ; try { methodField . setAccessible ( true ) ; return ( Method ) methodField . get ( velMethod ) ; } finally { m...
This is hackish but there s no way in Velocity to get access to the underlying Method from a VelMethod instance .
92
24
43,625
private Object [ ] convertArguments ( Object obj , String methodName , Object [ ] args ) { for ( Method method : obj . getClass ( ) . getMethods ( ) ) { if ( method . getName ( ) . equalsIgnoreCase ( methodName ) && ( method . getGenericParameterTypes ( ) . length == args . length || method . isVarArgs ( ) ) ) { try { ...
Converts the given arguments to match a method with the specified name and the same number of formal parameters as the number of arguments .
132
26
43,626
private void initializeExtension ( InstalledExtension installedExtension , String namespaceToLoad , Map < String , Set < InstalledExtension > > initializedExtensions ) throws ExtensionException { if ( installedExtension . getNamespaces ( ) != null ) { if ( namespaceToLoad == null ) { for ( String namespace : installedE...
Initialize extension .
172
4
43,627
private void initializeExtensionInNamespace ( InstalledExtension installedExtension , String namespace , Map < String , Set < InstalledExtension > > initializedExtensions ) throws ExtensionException { // Check if the extension can be available from this namespace if ( ! installedExtension . isValid ( namespace ) ) { re...
Initialize an extension in the given namespace .
180
9
43,628
private void logWarning ( String deprecationType , Object object , String methodName , Info info ) { this . log . warn ( String . format ( "Deprecated usage of %s [%s] in %s@%d,%d" , deprecationType , object . getClass ( ) . getCanonicalName ( ) + "." + methodName , info . getTemplateName ( ) , info . getLine ( ) , inf...
Helper method to log a warning when a deprecation has been found .
105
15
43,629
protected void extractBeanDescriptor ( ) { Object defaultInstance = null ; try { defaultInstance = getBeanClass ( ) . newInstance ( ) ; } catch ( Exception e ) { LOGGER . debug ( "Failed to create a new default instance for class " + this . beanClass + ". The BeanDescriptor will not contains any default value informati...
Extract informations form the bean .
324
8
43,630
protected < T extends Annotation > T extractPropertyAnnotation ( Method writeMethod , Method readMethod , Class < T > annotationClass ) { T parameterDescription = writeMethod . getAnnotation ( annotationClass ) ; if ( parameterDescription == null && readMethod != null ) { parameterDescription = readMethod . getAnnotati...
Get the parameter annotation . Try first on the setter then on the getter if no annotation has been found .
77
23
43,631
public int size ( boolean recurse ) { if ( ! recurse ) { return this . children != null ? this . children . size ( ) : 0 ; } int size = 0 ; for ( LogEvent logEvent : this ) { ++ size ; if ( logEvent instanceof LogTreeNode ) { size += ( ( LogTreeNode ) logEvent ) . size ( true ) ; } } return size ; }
The number of logs .
86
5
43,632
public static CertificateProvider getCertificateProvider ( ComponentManager manager , Store store , CertificateProvider certificateProvider ) throws GeneralSecurityException { CertificateProvider provider = newCertificateProvider ( manager , store ) ; if ( certificateProvider == null ) { return provider ; } return new ...
Get a certificate provider for a given store and an additional certificate provider .
67
14
43,633
public static void addCertificatesToVerifiedData ( Store store , BcCMSSignedDataVerified verifiedData , CertificateFactory certFactory ) { for ( X509CertificateHolder cert : getCertificates ( store ) ) { verifiedData . addCertificate ( BcUtils . convertCertificate ( certFactory , cert ) ) ; } }
Add certificate from signed data to the verified signed data .
76
11
43,634
public static CertificateProvider getCertificateProvider ( ComponentManager manager , Collection < CertifiedPublicKey > certificates ) throws GeneralSecurityException { if ( certificates == null || certificates . isEmpty ( ) ) { return null ; } Collection < X509CertificateHolder > certs = new ArrayList < X509Certificat...
Create a new store containing the given certificates and return it as a certificate provider .
123
16
43,635
private static CertificateProvider newCertificateProvider ( ComponentManager manager , Store store ) throws GeneralSecurityException { try { CertificateProvider provider = manager . getInstance ( CertificateProvider . class , "BCStoreX509" ) ; ( ( BcStoreX509CertificateProvider ) provider ) . setStore ( store ) ; retur...
Wrap a bouncy castle store into an adapter for the CertificateProvider interface .
99
16
43,636
public static CertifiedPublicKey getCertificate ( CertificateProvider provider , SignerInformation signer , CertificateFactory factory ) { SignerId id = signer . getSID ( ) ; if ( provider instanceof BcStoreX509CertificateProvider ) { X509CertificateHolder cert = ( ( BcStoreX509CertificateProvider ) provider ) . getCer...
Retrieve the certificate matching the given signer from the certificate provider .
235
14
43,637
public static Version getStrictVersion ( Collection < ? extends VersionRangeCollection > ranges ) { for ( VersionRangeCollection collection : ranges ) { if ( collection . getRanges ( ) . size ( ) == 1 ) { VersionRange range = collection . getRanges ( ) . iterator ( ) . next ( ) ; if ( range instanceof DefaultVersionRan...
Check if passed range collection is a strict version .
140
10
43,638
public DefaultJobProgressStep addLevel ( int steps , Object newLevelSource , boolean levelStep ) { assertModifiable ( ) ; this . maximumChildren = steps ; this . levelSource = newLevelSource ; if ( steps > 0 ) { this . childSize = 1.0D / steps ; } if ( this . maximumChildren > 0 ) { this . children = new ArrayList <> (...
Add children to the step and return the first one .
135
11
43,639
public DefaultJobProgressStep nextStep ( Message stepMessage , Object newStepSource ) { assertModifiable ( ) ; // Close current step and move to the end finishStep ( ) ; // Add new step return addStep ( stepMessage , newStepSource ) ; }
Move to next child step .
55
6
43,640
public void finishStep ( ) { // Close step if ( this . children != null && ! this . children . isEmpty ( ) ) { this . children . get ( this . children . size ( ) - 1 ) . finish ( ) ; } }
Finish current step .
52
4
43,641
private void removeNodes ( String xpathExpression , Document domdoc ) { List < Node > nodes = domdoc . selectNodes ( xpathExpression ) ; for ( Node node : nodes ) { node . detach ( ) ; } }
Remove the nodes found with the xpath expression .
52
10
43,642
@ Override public < T > T get ( String fieldName ) { switch ( fieldName . toLowerCase ( ) ) { case FIELD_REPOSITORY : return ( T ) getRepository ( ) ; case FIELD_ID : return ( T ) getId ( ) . getId ( ) ; case FIELD_VERSION : return ( T ) getId ( ) . getVersion ( ) ; case FIELD_FEATURE : case FIELD_FEATURES : return ( T...
Get an extension field by name . Fallback on properties .
426
12
43,643
public static String extractXML ( Node node , int start , int length ) { ExtractHandler handler = null ; try { handler = new ExtractHandler ( start , length ) ; Transformer xformer = TransformerFactory . newInstance ( ) . newTransformer ( ) ; xformer . transform ( new DOMSource ( node ) , new SAXResult ( handler ) ) ; ...
Extracts a well - formed XML fragment from the given DOM tree .
138
15
43,644
public static String unescape ( Object content ) { if ( content == null ) { return null ; } String str = String . valueOf ( content ) ; str = APOS_PATTERN . matcher ( str ) . replaceAll ( "'" ) ; str = QUOT_PATTERN . matcher ( str ) . replaceAll ( "\"" ) ; str = LT_PATTERN . matcher ( str ) . replaceAll ( "<" ) ; str =...
Unescape encoded special XML characters . Only &gt ; &lt ; &amp ; and { are unescaped since they are the only ones that affect the resulting markup .
168
36
43,645
public static Document parse ( LSInput source ) { try { LSParser p = LS_IMPL . createLSParser ( DOMImplementationLS . MODE_SYNCHRONOUS , null ) ; // Disable validation, since this takes a lot of time and causes unneeded network traffic p . getDomConfig ( ) . setParameter ( "validate" , false ) ; if ( p . getDomConfig (...
Parse a DOM Document from a source .
176
9
43,646
public static String serialize ( Node node , boolean withXmlDeclaration ) { if ( node == null ) { return "" ; } try { LSOutput output = LS_IMPL . createLSOutput ( ) ; StringWriter result = new StringWriter ( ) ; output . setCharacterStream ( result ) ; LSSerializer serializer = LS_IMPL . createLSSerializer ( ) ; serial...
Serialize a DOM Node into a string with an optional XML declaration at the start .
258
17
43,647
public static String transform ( Source xml , Source xslt ) { if ( xml != null && xslt != null ) { try { StringWriter output = new StringWriter ( ) ; Result result = new StreamResult ( output ) ; javax . xml . transform . TransformerFactory . newInstance ( ) . newTransformer ( xslt ) . transform ( xml , result ) ; retu...
Apply an XSLT transformation to a Document .
131
10
43,648
public static String formatXMLContent ( String content ) throws TransformerFactoryConfigurationError , TransformerException { Transformer transformer = TransformerFactory . newInstance ( ) . newTransformer ( ) ; transformer . setOutputProperty ( OutputKeys . INDENT , "yes" ) ; transformer . setOutputProperty ( "{http:/...
Parse and pretty print a XML content .
365
9
43,649
private void declareProperty ( ExecutionContextProperty property ) { if ( this . properties . containsKey ( property . getKey ( ) ) ) { throw new PropertyAlreadyExistsException ( property . getKey ( ) ) ; } this . properties . put ( property . getKey ( ) , property ) ; }
Declare a property .
63
5
43,650
public Object setExtensionProperty ( String key , Object value ) { return getExtensionProperties ( ) . put ( key , value ) ; }
Sets a custom extension property to be set on each of the extensions that are going to be installed from this request .
31
24
43,651
org . bouncycastle . crypto . params . DSAParameters getDsaParameters ( SecureRandom random , DSAKeyParametersGenerationParameters params ) { DSAParametersGenerator paramGen = getGenerator ( params . getHashHint ( ) ) ; if ( params . use186r3 ( ) ) { DSAParameterGenerationParameters p = new DSAParameterGenerationParame...
Generate DSA parameters .
178
6
43,652
private DSAParametersGenerator getGenerator ( String hint ) { if ( hint == null || "SHA-1" . equals ( hint ) ) { return new DSAParametersGenerator ( ) ; } DigestFactory factory ; try { factory = this . manager . getInstance ( DigestFactory . class , hint ) ; } catch ( ComponentLookupException e ) { throw new Unsupporte...
Create an instance of a DSA parameter generator using the appropriate hash algorithm .
193
15
43,653
static int getUsageIndex ( DSAKeyValidationParameters . Usage usage ) { if ( usage == DSAKeyValidationParameters . Usage . DIGITAL_SIGNATURE ) { return DSAParameterGenerationParameters . DIGITAL_SIGNATURE_USAGE ; } else if ( usage == DSAKeyValidationParameters . Usage . KEY_ESTABLISHMENT ) { return DSAParameterGenerati...
Convert key usage to key usage index .
107
9
43,654
private static DSAKeyValidationParameters . Usage getUsage ( int usage ) { if ( usage == DSAParameterGenerationParameters . DIGITAL_SIGNATURE_USAGE ) { return DSAKeyValidationParameters . Usage . DIGITAL_SIGNATURE ; } else if ( usage == DSAParameterGenerationParameters . KEY_ESTABLISHMENT_USAGE ) { return DSAKeyValidat...
Convert usage index to key usage .
115
8
43,655
@ Override public void addURL ( URL url ) { this . finder . addURI ( URI . create ( url . toExternalForm ( ) ) ) ; }
Add specified URL at the end of the search path .
35
11
43,656
@ Override public void addURLs ( List < URL > urls ) { for ( URL url : urls ) { addURL ( url ) ; } }
Add specified URLs at the end of the search path .
34
11
43,657
@ Override protected Class < ? > findClass ( final String name ) throws ClassNotFoundException { try { return AccessController . doPrivileged ( new PrivilegedExceptionAction < Class < ? > > ( ) { @ Override public Class < ? > run ( ) throws ClassNotFoundException { String path = name . replace ( ' ' , ' ' ) . concat ( ...
Finds and loads the class with the specified name .
197
11
43,658
private boolean isSealed ( String name , Manifest man ) { String path = name . replace ( ' ' , ' ' ) . concat ( "/" ) ; Attributes attr = man . getAttributes ( path ) ; String sealed = null ; if ( attr != null ) { sealed = attr . getValue ( Name . SEALED ) ; } if ( sealed == null ) { if ( ( attr = man . getMainAttribut...
returns true if the specified package name is sealed according to the given manifest .
130
16
43,659
@ Override public URL findResource ( final String name ) { return AccessController . doPrivileged ( new PrivilegedAction < URL > ( ) { @ Override public URL run ( ) { return URIClassLoader . this . finder . findResource ( name ) ; } } , this . acc ) ; }
Finds the resource with the specified name .
66
9
43,660
@ Override public Enumeration < URL > findResources ( final String name ) throws IOException { return AccessController . doPrivileged ( new PrivilegedAction < Enumeration < URL > > ( ) { @ Override public Enumeration < URL > run ( ) { return URIClassLoader . this . finder . findResources ( name ) ; } } , this . acc ) ;...
Returns an Enumeration of URLs representing all of the resources having the specified name .
84
17
43,661
protected ResourceHandle getResourceHandle ( final String name ) { return AccessController . doPrivileged ( new PrivilegedAction < ResourceHandle > ( ) { @ Override public ResourceHandle run ( ) { return URIClassLoader . this . finder . getResource ( name ) ; } } , this . acc ) ; }
Finds the ResourceHandle object for the resource with the specified name .
67
14
43,662
protected Enumeration < ResourceHandle > getResourceHandles ( final String name ) { return AccessController . doPrivileged ( new PrivilegedAction < Enumeration < ResourceHandle > > ( ) { @ Override public Enumeration < ResourceHandle > run ( ) { return URIClassLoader . this . finder . getResources ( name ) ; } } , this...
Returns an Enumeration of ResourceHandle objects representing all of the resources having the specified name .
83
19
43,663
protected void initializePatterns ( ) { this . contentPagePatterns = initializationPagePatterns ( this . contentPages ) ; this . technicalPagePatterns = initializationPagePatterns ( this . technicalPages ) ; // Transform title expectations into Patterns Map < Pattern , Pattern > patterns = new HashMap <> ( ) ; for ( St...
Initialize regex Patterns for performance reasons .
119
8
43,664
protected void executeLicenseGoal ( String goal ) throws MojoExecutionException { // Find the license plugin (it's project's responsibility to make sure the License plugin is properly setup in // its <pluginManagement>, for most XWiki projects it just mean inherits from xwiki-commons-pom) Plugin licensePlugin = this . ...
Executes a goal of the Maven License plugin ( used for adding or checking for license headers .
267
20
43,665
protected Color parseRGB ( String value ) { StringTokenizer items = new StringTokenizer ( value , "," ) ; try { int red = 0 ; if ( items . hasMoreTokens ( ) ) { red = Integer . parseInt ( items . nextToken ( ) . trim ( ) ) ; } int green = 0 ; if ( items . hasMoreTokens ( ) ) { green = Integer . parseInt ( items . nextT...
Parsers a String in the form x y z into an SWT RGB class .
177
18
43,666
public ResourceHandle getResource ( URL source , String name ) { return getResource ( source , name , new HashSet <> ( ) , null ) ; }
Gets resource with given name at the given source URL . If the URL points to a directory the name is the file path relative to this directory . If the URL points to a JAR file the name identifies an entry in that JAR file . If the URL points to a JAR file the resource is not found in that JAR file and the JAR file has ...
33
96
43,667
public ResourceHandle getResource ( URL [ ] sources , String name ) { Set < URL > visited = new HashSet <> ( ) ; for ( URL source : sources ) { ResourceHandle h = getResource ( source , name , visited , null ) ; if ( h != null ) { return h ; } } return null ; }
Gets resource with given name at the given search path . The path is searched iteratively one URL at a time . If the URL points to a directory the name is the file path relative to this directory . If the URL points to the JAR file the name identifies an entry in that JAR file . If the URL points to the JAR file the re...
69
108
43,668
public URL findResource ( URL source , String name ) { return findResource ( source , name , new HashSet <> ( ) , null ) ; }
Fined resource with given name at the given source URL . If the URL points to a directory the name is the file path relative to this directory . If the URL points to a JAR file the name identifies an entry in that JAR file . If the URL points to a JAR file the resource is not found in that JAR file and the JAR file has...
32
96
43,669
public URL findResource ( URL [ ] sources , String name ) { Set < URL > visited = new HashSet <> ( ) ; for ( URL source : sources ) { URL url = findResource ( source , name , visited , null ) ; if ( url != null ) { return url ; } } return null ; }
Finds resource with given name at the given search path . The path is searched iteratively one URL at a time . If the URL points to a directory the name is the file path relative to this directory . If the URL points to the JAR file the name identifies an entry in that JAR file . If the URL points to the JAR file the r...
67
108
43,670
@ Unstable public static String toAlphaNumeric ( String text ) { if ( isEmpty ( text ) ) { return text ; } return stripAccents ( text ) . replaceAll ( "[^a-zA-Z0-9]" , "" ) ; }
Removes all non alpha numerical characters from the passed text . First tries to convert diacritics to their alpha numeric representation .
56
26
43,671
public static List < X509GeneralName > getX509GeneralNames ( GeneralNames genNames ) { if ( genNames == null ) { return null ; } GeneralName [ ] names = genNames . getNames ( ) ; List < X509GeneralName > x509names = new ArrayList < X509GeneralName > ( names . length ) ; for ( GeneralName name : names ) { switch ( name ...
Convert general names from Bouncy Castle general names .
258
12
43,672
public static EnumSet < KeyUsage > getSetOfKeyUsage ( org . bouncycastle . asn1 . x509 . KeyUsage keyUsage ) { if ( keyUsage == null ) { return null ; } Collection < KeyUsage > usages = new ArrayList < KeyUsage > ( ) ; for ( KeyUsage usage : KeyUsage . values ( ) ) { if ( ( ( ( DERBitString ) keyUsage . toASN1Primitive...
Convert usages from Bouncy Castle .
139
10
43,673
public static ExtendedKeyUsages getExtendedKeyUsages ( ExtendedKeyUsage usages ) { if ( usages == null ) { return null ; } List < String > usageStr = new ArrayList < String > ( ) ; for ( KeyPurposeId keyPurposeId : usages . getUsages ( ) ) { usageStr . add ( keyPurposeId . getId ( ) ) ; } return new ExtendedKeyUsages (...
Convert extended usages from Bouncy Castle .
98
11
43,674
public static GeneralNames getGeneralNames ( X509GeneralName [ ] genNames ) { GeneralName [ ] names = new GeneralName [ genNames . length ] ; int i = 0 ; for ( X509GeneralName name : genNames ) { if ( name instanceof BcGeneralName ) { names [ i ++ ] = ( ( BcGeneralName ) name ) . getGeneralName ( ) ; } else { throw new...
Convert a collection of X . 509 general names to Bouncy Castle general names .
126
19
43,675
public static org . bouncycastle . asn1 . x509 . KeyUsage getKeyUsage ( EnumSet < KeyUsage > usages ) { int bitmask = 0 ; for ( KeyUsage usage : usages ) { bitmask |= usage . value ( ) ; } return new org . bouncycastle . asn1 . x509 . KeyUsage ( bitmask ) ; }
Convert a set of key usages to Bouncy Castle key usage .
82
16
43,676
public static ExtendedKeyUsage getExtendedKeyUsage ( Set < String > usages ) { KeyPurposeId [ ] keyUsages = new KeyPurposeId [ usages . size ( ) ] ; int i = 0 ; for ( String usage : usages ) { keyUsages [ i ++ ] = KeyPurposeId . getInstance ( new ASN1ObjectIdentifier ( usage ) ) ; } return new ExtendedKeyUsage ( keyUsa...
Convert a set of extended key usages to Bouncy Castle extended key usage .
98
18
43,677
public void initialize ( ClassLoader classLoader ) { ComponentAnnotationLoader loader = new ComponentAnnotationLoader ( ) ; loader . initialize ( this , classLoader ) ; // Extension point to allow component to manipulate ComponentManager initialized state. try { List < ComponentManagerInitializer > initializers = this ...
Load all component annotations and register them as components .
132
10
43,678
private Attributes getAttributes ( StartElement event ) { AttributesImpl attrs = new AttributesImpl ( ) ; if ( ! event . isStartElement ( ) ) { throw new InternalError ( "getAttributes() attempting to process: " + event ) ; } // Add namspace declarations if required if ( this . filter . getNamespacePrefixes ( ) ) { for...
Get the attributes associated with the given START_ELEMENT StAXevent .
489
16
43,679
@ Override protected TreeMarshaller createMarshallingContext ( HierarchicalStreamWriter writer , ConverterLookup converterLookup , Mapper mapper ) { return new SafeTreeMarshaller ( writer , converterLookup , mapper , RELATIVE ) ; }
If anything goes wrong with an element don t serialize it
56
12
43,680
public Map < String , List < String > > parseQuery ( String query ) { Map < String , List < String > > queryParams = new LinkedHashMap <> ( ) ; if ( query != null ) { for ( NameValuePair params : URLEncodedUtils . parse ( query , StandardCharsets . UTF_8 ) ) { String name = params . getName ( ) ; List < String > values...
Parse a query string into a map of key - value pairs .
151
14
43,681
public static boolean sendEndEvent ( Object filter , FilterDescriptor descriptor , String id , FilterEventParameters parameters ) throws FilterException { FilterElementDescriptor elementDescriptor = descriptor . getElement ( id ) ; if ( elementDescriptor != null && elementDescriptor . getEndMethod ( ) != null ) { sendE...
Call passed end event if possible .
133
7
43,682
public static boolean sendOnEvent ( Object filter , FilterDescriptor descriptor , String id , FilterEventParameters parameters ) throws FilterException { FilterElementDescriptor elementDescriptor = descriptor . getElement ( id ) ; if ( elementDescriptor != null && elementDescriptor . getOnMethod ( ) != null ) { sendEve...
Call passed on event if possible .
133
7
43,683
private void onEventListenerComponentAdded ( ComponentDescriptorAddedEvent event , ComponentManager componentManager , ComponentDescriptor < EventListener > descriptor ) { try { EventListener eventListener = componentManager . getInstance ( EventListener . class , event . getRoleHint ( ) ) ; if ( getListener ( eventLis...
An Event Listener Component has been dynamically registered in the system add it to our cache .
221
18
43,684
private void onEventListenerComponentRemoved ( ComponentDescriptorRemovedEvent event , ComponentManager componentManager , ComponentDescriptor < ? > descriptor ) { EventListener removedEventListener = null ; for ( EventListener eventListener : getListenersByName ( ) . values ( ) ) { if ( eventListener . getClass ( ) ==...
An Event Listener Component has been dynamically unregistered in the system remove it from our cache .
111
19
43,685
protected org . bouncycastle . crypto . CipherParameters getBcCipherParameter ( AsymmetricCipherParameters parameters ) { if ( parameters instanceof BcAsymmetricKeyParameters ) { return ( ( BcAsymmetricKeyParameters ) parameters ) . getParameters ( ) ; } // TODO: convert parameters to compatible ones throw new Unsuppor...
Convert cipher parameters to Bouncy Castle equivalent .
104
11
43,686
public int getDirective ( char [ ] array , int currentIndex , StringBuffer velocityBlock , VelocityParserContext context ) throws InvalidVelocityException { int i = currentIndex + 1 ; // Get macro name StringBuffer directiveNameBuffer = new StringBuffer ( ) ; i = getDirectiveName ( array , i , directiveNameBuffer , nul...
Get any valid Velocity block starting with a sharp character except comments .
367
13
43,687
public int getVelocityIdentifier ( char [ ] array , int currentIndex , StringBuffer velocityBlock , VelocityParserContext context ) throws InvalidVelocityException { // The first character of an identifier must be a [a-zA-Z] if ( ! Character . isLetter ( array [ currentIndex ] ) ) { throw new InvalidVelocityException (...
Get a valid Velocity identifier used for variable of macro .
149
11
43,688
public int getTableElement ( char [ ] array , int currentIndex , StringBuffer velocityBlock , VelocityParserContext context ) { return getParameters ( array , currentIndex , velocityBlock , ' ' , context ) ; }
Get a Velocity table .
45
5
43,689
protected boolean tryInstallExtension ( ExtensionId extensionId , String namespace ) { DefaultExtensionPlanTree currentTree = this . extensionTree . clone ( ) ; try { installExtension ( extensionId , namespace , currentTree ) ; setExtensionTree ( currentTree ) ; return true ; } catch ( InstallException e ) { if ( getRe...
Try to install the provided extension and update the plan if it s working .
144
15
43,690
public static String encode ( String str ) { String encoded ; try { encoded = URLEncoder . encode ( str , "UTF-8" ) . replace ( "." , "%2E" ) . replace ( "*" , "%2A" ) ; } catch ( UnsupportedEncodingException e ) { // Should never happen encoded = str ; } return encoded ; }
Protect passed String to work with as much filesystems as possible .
79
13
43,691
public static boolean isWebjar ( Extension extension ) { // Ideally webjar extensions should have "webjar" type if ( extension . getType ( ) . equals ( WEBJAR ) ) { return true ; } /////////////////////////////// // But it's not the case for: // ** webjar.org releases (i.e. most of the webjars). We assume "org.webjars:...
Find of the passes extension if a webjar .
218
10
43,692
private ExtensionHandler getExtensionHandler ( LocalExtension localExtension ) throws ComponentLookupException { return this . componentManager . getInstance ( ExtensionHandler . class , localExtension . getType ( ) . toLowerCase ( ) ) ; }
Get the handler corresponding to the provided extension .
52
9
43,693
public static boolean matches ( Pattern patternMatcher , Collection < Filter > filters , Extension extension ) { if ( matches ( patternMatcher , extension . getId ( ) . getId ( ) , extension . getDescription ( ) , extension . getSummary ( ) , extension . getName ( ) , ExtensionIdConverter . toStringList ( extension . g...
Matches an extension in a case insensitive way .
115
10
43,694
public static boolean matches ( Collection < Filter > filters , Extension extension ) { if ( filters != null ) { for ( Filter filter : filters ) { if ( ! matches ( filter , extension ) ) { return false ; } } } return true ; }
Make sure the passed extension matches all filters .
51
9
43,695
public static boolean matches ( Pattern patternMatcher , Object ... elements ) { if ( patternMatcher == null ) { return true ; } for ( Object element : elements ) { if ( matches ( patternMatcher , element ) ) { return true ; } } return false ; }
Matches a set of elements in a case insensitive way .
57
12
43,696
public static void sort ( List < ? extends Extension > extensions , Collection < SortClause > sortClauses ) { Collections . sort ( extensions , new SortClauseComparator ( sortClauses ) ) ; }
Sort the passed extensions list based on the passed sort clauses .
44
12
43,697
public static < E extends Extension > IterableResult < E > appendSearchResults ( IterableResult < E > previousSearchResult , IterableResult < E > result ) { AggregatedIterableResult < E > newResult ; if ( previousSearchResult instanceof AggregatedIterableResult ) { newResult = ( ( AggregatedIterableResult < E > ) previ...
Merge provided search results .
151
6
43,698
public static IterableResult < Extension > search ( ExtensionQuery query , Iterable < ExtensionRepository > repositories ) throws SearchException { IterableResult < Extension > searchResult = null ; int currentOffset = query . getOffset ( ) > 0 ? query . getOffset ( ) : 0 ; int currentNb = query . getLimit ( ) ; // A l...
Search passed repositories based of the provided query .
312
9
43,699
public static IterableResult < Extension > search ( ExtensionRepository repository , ExtensionQuery query , IterableResult < Extension > previousSearchResult ) throws SearchException { IterableResult < Extension > result ; if ( repository instanceof Searchable ) { if ( repository instanceof AdvancedSearchable ) { Advan...
Search one repository .
177
4