idx
int64
0
165k
question
stringlengths
73
4.15k
target
stringlengths
5
918
len_question
int64
21
890
len_target
int64
3
255
43,700
private < E , F > void displayInlineDiff ( UnifiedDiffElement < E , F > previous , UnifiedDiffElement < E , F > next , UnifiedDiffConfiguration < E , F > config ) { try { List < F > previousSubElements = config . getSplitter ( ) . split ( previous . getValue ( ) ) ; List < F > nextSubElements = config . getSplitter ( )...
Computes the changes between two versions of an element by splitting the element into sub - elements and displays the result using the in - line format .
279
29
43,701
protected List < Element > filterChildren ( Element parent , String tagName ) { List < Element > result = new ArrayList < Element > ( ) ; Node current = parent . getFirstChild ( ) ; while ( current != null ) { if ( current . getNodeName ( ) . equals ( tagName ) ) { result . add ( ( Element ) current ) ; } current = cur...
Utility method for filtering an element s children with a tagName .
93
14
43,702
protected List < Element > filterDescendants ( Element parent , String [ ] tagNames ) { List < Element > result = new ArrayList < Element > ( ) ; for ( String tagName : tagNames ) { NodeList nodes = parent . getElementsByTagName ( tagName ) ; for ( int i = 0 ; i < nodes . getLength ( ) ; i ++ ) { Element element = ( El...
Utility method for filtering an element s descendants by their tag names .
107
14
43,703
protected boolean hasAttribute ( List < Element > elements , String attributeName , boolean checkValue ) { boolean hasAttribute = true ; if ( ! checkValue ) { for ( Element e : elements ) { hasAttribute = e . hasAttribute ( attributeName ) ? hasAttribute : false ; } } else { String attributeValue = null ; for ( Element...
Utility method for checking if a list of elements have the same attribute set . If the checkValue is true the values of the given attribute will be checked for equivalency .
126
35
43,704
protected void moveChildren ( Element parent , Element destination ) { NodeList children = parent . getChildNodes ( ) ; while ( children . getLength ( ) > 0 ) { destination . appendChild ( parent . removeChild ( parent . getFirstChild ( ) ) ) ; } }
Moves all child elements of the parent into destination element .
59
12
43,705
static org . bouncycastle . crypto . params . DHParameters getDhParameters ( SecureRandom random , DHKeyParametersGenerationParameters params ) { DHParametersGenerator paramGen = new DHParametersGenerator ( ) ; paramGen . init ( params . getStrength ( ) * 8 , params . getCertainty ( ) , random ) ; return paramGen . gen...
Generate DH parameters .
81
5
43,706
private DefaultLocalExtension loadDescriptor ( File descriptor ) throws InvalidExtensionException { FileInputStream fis ; try { fis = new FileInputStream ( descriptor ) ; } catch ( FileNotFoundException e ) { throw new InvalidExtensionException ( "Failed to open descriptor for reading" , e ) ; } try { DefaultLocalExten...
Local extension descriptor from a file .
257
7
43,707
private String getFilePath ( ExtensionId id , String fileExtension ) { String encodedId = PathUtils . encode ( id . getId ( ) ) ; String encodedVersion = PathUtils . encode ( id . getVersion ( ) . toString ( ) ) ; String encodedType = PathUtils . encode ( fileExtension ) ; return encodedId + File . separator + encodedV...
Get file path in the local extension repository .
105
9
43,708
public void removeExtension ( DefaultLocalExtension extension ) throws IOException { File descriptorFile = extension . getDescriptorFile ( ) ; if ( descriptorFile == null ) { throw new IOException ( "Exception does not exists" ) ; } descriptorFile . delete ( ) ; DefaultLocalExtensionFile extensionFile = extension . get...
Remove extension from storage .
87
5
43,709
private void parse ( ) { this . elements = new ArrayList <> ( ) ; try { for ( Tokenizer tokenizer = new Tokenizer ( this . rawVersion ) ; tokenizer . next ( ) ; ) { Element element = new Element ( tokenizer ) ; this . elements . add ( element ) ; if ( element . getVersionType ( ) != Type . STABLE ) { this . type = elem...
Parse the string representation of the version into separated elements .
162
12
43,710
private static void trimPadding ( List < Element > elements ) { for ( ListIterator < Element > it = elements . listIterator ( elements . size ( ) ) ; it . hasPrevious ( ) ; ) { Element element = it . previous ( ) ; if ( element . compareTo ( null ) == 0 ) { it . remove ( ) ; } else { break ; } } }
Remove empty elements .
80
4
43,711
private static int comparePadding ( List < Element > elements , int index , Boolean number ) { int rel = 0 ; for ( Iterator < Element > it = elements . listIterator ( index ) ; it . hasNext ( ) ; ) { Element element = it . next ( ) ; if ( number != null && number . booleanValue ( ) != element . isNumber ( ) ) { break ;...
Compare the end of the version with 0 .
109
9
43,712
public static Collection < String > importProperty ( MutableExtension extension , String propertySuffix , Collection < String > def ) { Object obj = importProperty ( extension , propertySuffix ) ; if ( obj == null ) { return def ; } else if ( obj instanceof Collection ) { return ( Collection ) obj ; } else if ( obj ins...
Delete and return the value of the passed special property as a Collection of Strings .
116
17
43,713
protected void sendEntryAddedEvent ( CacheEntryEvent < T > event ) { for ( org . xwiki . cache . event . CacheEntryListener < T > listener : this . cacheEntryListeners . getListeners ( org . xwiki . cache . event . CacheEntryListener . class ) ) { listener . cacheEntryAdded ( event ) ; } }
Helper method to send event when a new cache entry is inserted .
74
13
43,714
protected void sendEntryRemovedEvent ( CacheEntryEvent < T > event ) { for ( org . xwiki . cache . event . CacheEntryListener < T > listener : this . cacheEntryListeners . getListeners ( org . xwiki . cache . event . CacheEntryListener . class ) ) { listener . cacheEntryRemoved ( event ) ; } disposeCacheValue ( event ....
Helper method to send event when an existing cache entry is removed .
91
13
43,715
protected void sendEntryModifiedEvent ( CacheEntryEvent < T > event ) { for ( org . xwiki . cache . event . CacheEntryListener < T > listener : this . cacheEntryListeners . getListeners ( org . xwiki . cache . event . CacheEntryListener . class ) ) { listener . cacheEntryModified ( event ) ; } }
Helper method to send event when a cache entry is modified .
76
12
43,716
protected void disposeCacheValue ( T value ) { if ( value instanceof DisposableCacheValue ) { try { ( ( DisposableCacheValue ) value ) . dispose ( ) ; } catch ( Throwable e ) { // We catch Throwable because this method is usually automatically called by an event send by the cache // implementation and there is no reaso...
Dispose the value being removed from the cache .
136
10
43,717
public X509ExtensionBuilder addExtension ( ASN1ObjectIdentifier oid , boolean critical , ASN1Encodable value ) { try { this . extensions . addExtension ( oid , critical , value . toASN1Primitive ( ) . getEncoded ( ASN1Encoding . DER ) ) ; } catch ( IOException e ) { // Very unlikely throw new IllegalArgumentException (...
Add an extension .
111
4
43,718
public Version getVersion ( String rawVersion ) { Version version = this . versions . get ( rawVersion ) ; if ( version == null ) { version = new DefaultVersion ( rawVersion ) ; this . versions . put ( rawVersion , version ) ; } return version ; }
Store and return a weak reference equals to the passed version .
57
12
43,719
public VersionConstraint getVersionConstraint ( String rawConstraint ) { VersionConstraint constraint = this . versionConstrains . get ( rawConstraint ) ; if ( constraint == null ) { constraint = new DefaultVersionConstraint ( rawConstraint ) ; this . versionConstrains . put ( rawConstraint , constraint ) ; } return co...
Store and return a weak reference equals to the passed version constraint .
83
13
43,720
protected void extendsTBSCertificate ( BcX509TBSCertificateBuilder builder , CertifiedPublicKey issuer , PrincipalIndentifier subjectName , PublicKeyParameters subject , X509CertificateParameters parameters ) throws IOException { // Do nothing by default. }
Extend TBS certificate depending of certificate version .
54
10
43,721
public TBSCertificate buildTBSCertificate ( PrincipalIndentifier subjectName , PublicKeyParameters subject , X509CertificateParameters parameters ) throws IOException { PrincipalIndentifier issuerName ; CertifiedPublicKey issuer = null ; if ( this . signer instanceof CertifyingSigner ) { issuer = ( ( CertifyingSigner )...
Build the TBS Certificate .
210
6
43,722
private void runInitializers ( ExecutionContext context ) throws ExecutionContextException { for ( ExecutionContextInitializer initializer : this . initializerProvider . get ( ) ) { initializer . initialize ( context ) ; } }
Run the initializers .
45
5
43,723
private Class < ? > getFieldRole ( Field field , Requirement requirement ) { Class < ? > role ; // Handle case of list or map if ( isDependencyOfListType ( field . getType ( ) ) ) { role = getGenericRole ( field ) ; } else { role = field . getType ( ) ; } return role ; }
Extract component role from the field to inject .
75
10
43,724
private void openTag ( String qName , Attributes atts ) { this . result . append ( ' ' ) . append ( qName ) ; for ( int i = 0 ; i < atts . getLength ( ) ; i ++ ) { this . result . append ( ' ' ) . append ( atts . getQName ( i ) ) . append ( "=\"" ) . append ( atts . getValue ( i ) ) . append ( ' ' ) ; } this . result ....
Append an open tag with the given specification to the result buffer .
111
14
43,725
private void checkValue ( Object value ) { if ( this . nonNull && value == null ) { throw new IllegalArgumentException ( String . format ( "The property [%s] may not be null!" , getKey ( ) ) ) ; } if ( getType ( ) != null && value != null && ! getType ( ) . isAssignableFrom ( value . getClass ( ) ) ) { throw new Illega...
Check that the value is compatible with the configure constraints .
143
11
43,726
protected static int [ ] newKeySizeArray ( int minSize , int maxSize , int step ) { int [ ] result = new int [ ( ( maxSize - minSize ) / step ) + 1 ] ; for ( int i = minSize , j = 0 ; i <= maxSize ; i += step , j ++ ) { result [ j ] = i ; } return result ; }
Helper function to create supported key size arrays .
82
9
43,727
public BcX509v3TBSCertificateBuilder setExtensions ( CertifiedPublicKey issuer , PublicKeyParameters subject , X509Extensions extensions1 , X509Extensions extensions2 ) throws IOException { DefaultX509ExtensionBuilder extBuilder = new DefaultX509ExtensionBuilder ( ) ; extBuilder . addAuthorityKeyIdentifier ( issuer ) ....
Set the extensions of a v3 certificate .
152
9
43,728
public < E > List < E > unmodifiable ( List < E > input ) { if ( input == null ) { return null ; } return Collections . unmodifiableList ( input ) ; }
Returns an unmodifiable view of the specified list .
42
11
43,729
public < K , V > Map < K , V > unmodifiable ( Map < K , V > input ) { if ( input == null ) { return null ; } return Collections . unmodifiableMap ( input ) ; }
Returns an unmodifiable view of the specified map .
48
11
43,730
public < E > Set < E > unmodifiable ( Set < E > input ) { if ( input == null ) { return null ; } return Collections . unmodifiableSet ( input ) ; }
Returns an unmodifiable view of the specified set .
42
11
43,731
public < E > Collection < E > unmodifiable ( Collection < E > input ) { if ( input == null ) { return null ; } return Collections . unmodifiableCollection ( input ) ; }
Returns an unmodifiable view of the specified collection .
42
11
43,732
public < E > boolean reverse ( List < E > input ) { if ( input == null ) { return false ; } try { Collections . reverse ( input ) ; return true ; } catch ( UnsupportedOperationException ex ) { return false ; } }
Reverse the order of the elements within a list so that the last element is moved to the beginning of the list the next - to - last element to the second position and so on . The input list is modified in place so this operation will succeed only if the list is modifiable .
52
59
43,733
public < E extends Comparable < E > > boolean sort ( List < E > input ) { if ( input == null ) { return false ; } try { Collections . sort ( input ) ; return true ; } catch ( UnsupportedOperationException ex ) { return false ; } }
Sort the elements within a list according to their natural order . The input list is modified in place so this operation will succeed only if the list is modifiable .
58
32
43,734
private < E > boolean isFullyModified ( List commonAncestor , Patch < E > patchCurrent ) { return patchCurrent . size ( ) == 1 && commonAncestor . size ( ) == patchCurrent . get ( 0 ) . getPrevious ( ) . size ( ) ; }
Check if the content is completely different between the ancestor and the current version
62
14
43,735
@ Override public Iterator getIterator ( Object obj , Info i ) throws Exception { if ( obj != null ) { SecureIntrospectorControl sic = ( SecureIntrospectorControl ) this . introspector ; if ( sic . checkObjectExecutePermission ( obj . getClass ( ) , null ) ) { return super . getIterator ( obj , i ) ; } else { this . lo...
Get an iterator from the given object . Since the superclass method this secure version checks for execute permission .
120
21
43,736
protected void unpackXARToOutputDirectory ( Artifact artifact , String [ ] includes , String [ ] excludes ) throws MojoExecutionException { if ( ! this . outputBuildDirectory . exists ( ) ) { this . outputBuildDirectory . mkdirs ( ) ; } File file = artifact . getFile ( ) ; unpack ( file , this . outputBuildDirectory , ...
Unpacks A XAR artifacts into the build output directory along with the project s XAR files .
92
20
43,737
protected Set < Artifact > resolveArtifactDependencies ( Artifact artifact ) throws ArtifactResolutionException , ArtifactNotFoundException , ProjectBuildingException { Artifact pomArtifact = this . factory . createArtifact ( artifact . getGroupId ( ) , artifact . getArtifactId ( ) , artifact . getVersion ( ) , "" , "p...
This method resolves all transitive dependencies of an artifact .
125
11
43,738
protected XWikiDocument getDocFromXML ( File file ) throws MojoExecutionException { XWikiDocument doc ; try { doc = new XWikiDocument ( ) ; doc . fromXML ( file ) ; } catch ( Exception e ) { throw new MojoExecutionException ( String . format ( "Failed to parse [%s]." , file . getAbsolutePath ( ) ) , e ) ; } return doc ...
Load a XWiki document from its XML representation .
92
10
43,739
private void repair ( ) throws IOException { File folder = this . configuration . getStorage ( ) ; if ( folder . exists ( ) ) { if ( ! folder . isDirectory ( ) ) { throw new IOException ( "Not a directory: " + folder ) ; } repairFolder ( folder ) ; } }
Load jobs from directory .
65
5
43,740
public void runJob ( ) { try { this . currentJob = this . jobQueue . take ( ) ; // Create a clean Execution Context ExecutionContext context = new ExecutionContext ( ) ; try { this . executionContextManager . initialize ( context ) ; } catch ( ExecutionContextException e ) { throw new RuntimeException ( "Failed to init...
Execute one job .
125
5
43,741
private void initRepositoryFeatures ( ) { if ( this . repositoryVersion == null ) { // Default features this . repositoryVersion = new DefaultVersion ( Resources . VERSION10 ) ; this . filterable = false ; this . sortable = false ; // Get remote features CloseableHttpResponse response ; try { response = getRESTResource...
Check what is supported by the remote repository .
193
9
43,742
public void fromXML ( Document domdoc ) throws DocumentException { this . encoding = domdoc . getXMLEncoding ( ) ; Element rootElement = domdoc . getRootElement ( ) ; this . reference = readDocumentReference ( domdoc ) ; this . locale = rootElement . attributeValue ( "locale" ) ; if ( this . locale == null ) { // Fallb...
Parse XML document to extract document information .
520
9
43,743
public static String readElement ( Element rootElement , String elementName ) throws DocumentException { String result = null ; Element element = rootElement . element ( elementName ) ; if ( element != null ) { // Make sure the element does not have any child element if ( ! element . isTextOnly ( ) ) { throw new Docume...
Read an element from the XML .
104
7
43,744
public static X509CertificateHolder getX509CertificateHolder ( CertifiedPublicKey cert ) { if ( cert instanceof BcX509CertifiedPublicKey ) { return ( ( BcX509CertifiedPublicKey ) cert ) . getX509CertificateHolder ( ) ; } else { try { return new X509CertificateHolder ( cert . getEncoded ( ) ) ; } catch ( IOException e )...
Convert certified public key to certificate holder .
118
9
43,745
public static AsymmetricKeyParameter getAsymmetricKeyParameter ( PublicKeyParameters publicKey ) { if ( publicKey instanceof BcAsymmetricKeyParameters ) { return ( ( BcAsymmetricKeyParameters ) publicKey ) . getParameters ( ) ; } else { try { return PublicKeyFactory . createKey ( publicKey . getEncoded ( ) ) ; } catch ...
Convert public key parameters to asymmetric key parameter .
111
11
43,746
public static SubjectPublicKeyInfo getSubjectPublicKeyInfo ( PublicKeyParameters publicKey ) { try { if ( publicKey instanceof BcPublicKeyParameters ) { return ( ( BcPublicKeyParameters ) publicKey ) . getSubjectPublicKeyInfo ( ) ; } else { return SubjectPublicKeyInfoFactory . createSubjectPublicKeyInfo ( getAsymmetric...
Convert public key parameter to subject public key info .
117
11
43,747
public static X509CertificateHolder getX509CertificateHolder ( TBSCertificate tbsCert , byte [ ] signature ) { ASN1EncodableVector v = new ASN1EncodableVector ( ) ; v . add ( tbsCert ) ; v . add ( tbsCert . getSignature ( ) ) ; v . add ( new DERBitString ( signature ) ) ; return new X509CertificateHolder ( Certificate ...
Build the structure of an X . 509 certificate .
114
11
43,748
public static boolean isAlgorithlIdentifierEqual ( AlgorithmIdentifier id1 , AlgorithmIdentifier id2 ) { if ( ! id1 . getAlgorithm ( ) . equals ( id2 . getAlgorithm ( ) ) ) { return false ; } if ( id1 . getParameters ( ) == null ) { return ! ( id2 . getParameters ( ) != null && ! id2 . getParameters ( ) . equals ( DERN...
Compare two algorithm identifier .
171
5
43,749
public static Signer updateDEREncodedObject ( Signer signer , ASN1Encodable tbsObj ) throws IOException { OutputStream sOut = signer . getOutputStream ( ) ; DEROutputStream dOut = new DEROutputStream ( sOut ) ; dOut . writeObject ( tbsObj ) ; sOut . close ( ) ; return signer ; }
DER encode an ASN . 1 object into the given signer and return the signer .
83
19
43,750
public static X500Name getX500Name ( PrincipalIndentifier principal ) { if ( principal instanceof BcPrincipalIdentifier ) { return ( ( BcPrincipalIdentifier ) principal ) . getX500Name ( ) ; } else { return new X500Name ( principal . getName ( ) ) ; } }
Convert principal identifier to X . 500 name .
69
10
43,751
public static AlgorithmIdentifier getSignerAlgoritmIdentifier ( Signer signer ) { if ( signer instanceof ContentSigner ) { return ( ( ContentSigner ) signer ) . getAlgorithmIdentifier ( ) ; } else { return AlgorithmIdentifier . getInstance ( signer . getEncoded ( ) ) ; } }
Get the algorithm identifier of a signer .
76
9
43,752
public static CertifiedPublicKey convertCertificate ( CertificateFactory certFactory , X509CertificateHolder cert ) { if ( cert == null ) { return null ; } if ( certFactory instanceof BcX509CertificateFactory ) { return ( ( BcX509CertificateFactory ) certFactory ) . convert ( cert ) ; } else { try { return certFactory ...
Convert a Bouncy Castle certificate holder into a certified public key .
122
15
43,753
protected void addCachedExtension ( E extension ) { if ( ! this . extensions . containsKey ( extension . getId ( ) ) ) { // extensions this . extensions . put ( extension . getId ( ) , extension ) ; // versions addCachedExtensionVersion ( extension . getId ( ) . getId ( ) , extension ) ; if ( ! this . strictId ) { for ...
Register a new extension .
111
5
43,754
protected void addCachedExtensionVersion ( String feature , E extension ) { // versions List < E > versions = this . extensionsVersions . get ( feature ) ; if ( versions == null ) { versions = new ArrayList < E > ( ) ; this . extensionsVersions . put ( feature , versions ) ; versions . add ( extension ) ; } else { int ...
Register extension in all caches .
140
6
43,755
protected void removeCachedExtension ( E extension ) { // Remove the extension from the memory. this . extensions . remove ( extension . getId ( ) ) ; // versions removeCachedExtensionVersion ( extension . getId ( ) . getId ( ) , extension ) ; if ( ! this . strictId ) { for ( String feature : extension . getFeatures ( ...
Remove extension from all caches .
95
6
43,756
protected void removeCachedExtensionVersion ( String feature , E extension ) { // versions List < E > extensionVersions = this . extensionsVersions . get ( feature ) ; extensionVersions . remove ( extension ) ; if ( extensionVersions . isEmpty ( ) ) { this . extensionsVersions . remove ( feature ) ; } }
Remove passed extension associated to passed feature from the cache .
66
11
43,757
public static byte [ ] convert ( char [ ] password , ToBytesMode mode ) { byte [ ] passwd ; switch ( mode ) { case PKCS12 : passwd = PBEParametersGenerator . PKCS12PasswordToBytes ( password ) ; break ; case PKCS5 : passwd = PBEParametersGenerator . PKCS5PasswordToBytes ( password ) ; break ; default : passwd = PBEPara...
Convert password to bytes .
115
6
43,758
public static String getPrefix ( String namespaceString ) { Namespace namespace = toNamespace ( namespaceString ) ; return namespace != null ? namespace . getType ( ) : null ; }
Extract prefix of the id used to find custom factory .
39
12
43,759
private void filter ( Element list ) { // Iterate all the child nodes of the given list to see who's allowed and who's not allowed inside it. Node child = list . getFirstChild ( ) ; Node previousListItem = null ; while ( child != null ) { Node nextSibling = child . getNextSibling ( ) ; if ( isAllowedInsideList ( child ...
Transforms the given list in a valid XHTML list by moving the nodes that are not allowed inside &lt ; ul&gt ; and &lt ; ol&gt ; in &lt ; li&gt ; elements .
289
45
43,760
private boolean isAllowedInsideList ( Node node ) { return ( node . getNodeType ( ) != Node . ELEMENT_NODE || node . getNodeName ( ) . equalsIgnoreCase ( TAG_LI ) ) && ( node . getNodeType ( ) != Node . TEXT_NODE || node . getNodeValue ( ) . trim ( ) . length ( ) == 0 ) ; }
Checks if a given node is allowed or not as a child of a &lt ; ul&gt ; or &lt ; ol&gt ; element .
85
32
43,761
private ComponentDescriptor createComponentDescriptor ( Class < ? > componentClass , String hint , Type componentRoleType ) { DefaultComponentDescriptor descriptor = new DefaultComponentDescriptor ( ) ; descriptor . setRoleType ( componentRoleType ) ; descriptor . setImplementation ( componentClass ) ; descriptor . set...
Create a component descriptor for the passed component implementation class hint and component role class .
210
16
43,762
public synchronized void flushEvents ( ) { while ( ! this . events . isEmpty ( ) ) { ComponentEventEntry entry = this . events . pop ( ) ; sendEvent ( entry . event , entry . descriptor , entry . componentManager ) ; } }
Force to send all stored events .
53
7
43,763
private void notifyComponentEvent ( Event event , ComponentDescriptor < ? > descriptor , ComponentManager componentManager ) { if ( this . shouldStack ) { synchronized ( this ) { this . events . push ( new ComponentEventEntry ( event , descriptor , componentManager ) ) ; } } else { sendEvent ( event , descriptor , comp...
Send or stack the provided event dependening on the configuration .
74
12
43,764
private void sendEvent ( Event event , ComponentDescriptor < ? > descriptor , ComponentManager componentManager ) { if ( this . observationManager != null ) { this . observationManager . notify ( event , componentManager , descriptor ) ; } }
Send the event .
50
4
43,765
public static CertifyingSigner getInstance ( boolean forSigning , CertifiedKeyPair certifier , SignerFactory factory ) { return new CertifyingSigner ( certifier . getCertificate ( ) , factory . getInstance ( forSigning , certifier . getPrivateKey ( ) ) ) ; }
Get a certifying signer instance from the given signer factory for a given certifier .
64
19
43,766
protected void jobStarting ( ) { this . jobContext . pushCurrentJob ( this ) ; this . observationManager . notify ( new JobStartedEvent ( getRequest ( ) . getId ( ) , getType ( ) , this . request ) , this ) ; if ( this . status instanceof AbstractJobStatus ) { ( ( AbstractJobStatus < R > ) this . status ) . setStartDat...
Called when the job is starting .
253
8
43,767
protected void jobFinished ( Throwable error ) { this . lock . lock ( ) ; try { if ( this . status instanceof AbstractJobStatus ) { // Store error ( ( AbstractJobStatus ) this . status ) . setError ( error ) ; } // Give a chance to any listener to do custom action associated to the job this . observationManager . notif...
Called when the job is done .
500
8
43,768
protected void initializeUberspector ( String classname ) { // Avoids direct recursive calls if ( ! StringUtils . isEmpty ( classname ) && ! classname . equals ( this . getClass ( ) . getCanonicalName ( ) ) ) { Uberspect u = instantiateUberspector ( classname ) ; if ( u == null ) { return ; } // Set the log and runtime...
Instantiates and initializes an uberspector class and adds it to the array . Also set the log and runtime services if the class implements the proper interfaces .
233
34
43,769
protected Uberspect instantiateUberspector ( String classname ) { Object o = null ; try { o = ClassUtils . getNewInstance ( classname ) ; } catch ( ClassNotFoundException e ) { this . log . warn ( String . format ( "The specified uberspector [%s]" + " does not exist or is not accessible to the current classloader." , c...
Tries to create an uberspector instance using reflection .
298
13
43,770
private void validateExtension ( LocalExtension localExtension , boolean dependencies ) { Collection < String > namespaces = DefaultInstalledExtension . getNamespaces ( localExtension ) ; if ( namespaces == null ) { if ( dependencies || ! DefaultInstalledExtension . isDependency ( localExtension , null ) ) { try { vali...
Check extension validity and set it as not installed if not .
384
12
43,771
private DefaultInstalledExtension validateExtension ( LocalExtension localExtension , String namespace , Map < String , ExtensionDependency > managedDependencies ) throws InvalidExtensionException { DefaultInstalledExtension installedExtension = this . extensions . get ( localExtension . getId ( ) ) ; if ( installedExt...
Check extension validity against a specific namespace .
481
8
43,772
public static void setFieldValue ( Object instanceContainingField , String fieldName , Object fieldValue ) { // Find the class containing the field to set Class < ? > targetClass = instanceContainingField . getClass ( ) ; while ( targetClass != null ) { for ( Field field : targetClass . getDeclaredFields ( ) ) { if ( f...
Sets a value to a field using reflection even if the field is private .
287
16
43,773
public static Type resolveType ( Type targetType , Type rootType ) { Type resolvedType ; if ( targetType instanceof ParameterizedType && rootType instanceof ParameterizedType ) { ParameterizedType parameterizedType = ( ParameterizedType ) targetType ; resolvedType = resolveType ( ( Class < ? > ) parameterizedType . get...
Find and replace the generic parameters with the real types .
135
11
43,774
@ Unstable public static String serializeType ( Type type ) { if ( type == null ) { return null ; } StringBuilder sb = new StringBuilder ( ) ; if ( type instanceof ParameterizedType ) { ParameterizedType parameterizedType = ( ParameterizedType ) type ; String rawTypeName = getTypeName ( parameterizedType . getRawType (...
Serialize a type in a String using a standard definition .
445
12
43,775
public V get ( K key , V defaultValue ) { // Check if we only know an equal entry V sharedValue = get ( key ) ; if ( sharedValue == null ) { // If no entry can be found, store and return the passed one sharedValue = defaultValue ; // Make sure to remember the entry put ( key , defaultValue ) ; } // Return the shared en...
Get the value associated to the passed key . If no value can be found stored and return the passed default value .
84
23
43,776
public void put ( K key , V value ) { this . lock . writeLock ( ) . lock ( ) ; try { this . map . put ( key , new SoftReference <> ( value ) ) ; } finally { this . lock . writeLock ( ) . unlock ( ) ; } }
Associate passed key to passed value .
62
8
43,777
private void cacheEntryInserted ( String key , T value ) { InfinispanCacheEntryEvent < T > event = new InfinispanCacheEntryEvent <> ( new InfinispanCacheEntry < T > ( this , key , value ) ) ; T previousValue = this . preEventData . get ( key ) ; if ( previousValue != null ) { if ( previousValue != value ) { disposeCach...
Dispatch data insertion event .
115
5
43,778
private void cacheEntryRemoved ( String key , T value ) { InfinispanCacheEntryEvent < T > event = new InfinispanCacheEntryEvent <> ( new InfinispanCacheEntry < T > ( this , key , value ) ) ; sendEntryRemovedEvent ( event ) ; }
Dispatch data remove event .
61
5
43,779
private void checkNonCoreGroupId ( Model model ) throws EnforcerRuleException { String groupId = model . getGroupId ( ) ; if ( groupId . equals ( CORE_GROUP_ID ) || ( groupId . startsWith ( CORE_GROUP_ID_PREFIX ) && ! groupId . equals ( CONTRIB_GROUP_ID ) && ! groupId . startsWith ( CONTRIB_GROUP_ID_PREFIX ) ) ) { thro...
Make sure the group id does not start with org . xwiki or starts with org . xwiki . contrib .
137
24
43,780
private void checkNonCoreArtifactId ( Model model ) throws EnforcerRuleException { String artifactId = model . getArtifactId ( ) ; for ( String prefix : CORE_ARTIFACT_ID_PREFIXES ) { if ( artifactId . startsWith ( prefix ) ) { throw new EnforcerRuleException ( "The [%s] artifact id prefix is reserved for XWiki Core Com...
Make sure that non core artifacts don t use reserved artifact prefixes .
93
14
43,781
public void writeStartDocument ( String encoding , String version ) throws FilterException { try { this . writer . writeStartDocument ( encoding , version ) ; } catch ( XMLStreamException e ) { throw new FilterException ( "Failed to write start document" , e ) ; } }
Write the XML Declaration .
59
5
43,782
private String getTypeName ( Type type ) { String name ; if ( type instanceof Class ) { name = ( ( Class < ? > ) type ) . getName ( ) ; } else if ( type instanceof ParameterizedType ) { name = ( ( Class < ? > ) ( ( ParameterizedType ) type ) . getRawType ( ) ) . getName ( ) ; } else { name = type . toString ( ) ; } ret...
Get class name without generics .
99
7
43,783
private String getTypeGenericName ( Type type ) { StringBuilder sb = new StringBuilder ( getTypeName ( type ) ) ; if ( type instanceof ParameterizedType ) { ParameterizedType parameterizedType = ( ParameterizedType ) type ; Type [ ] generics = parameterizedType . getActualTypeArguments ( ) ; if ( generics . length > 0 ...
Get type name .
168
4
43,784
public void updateExtensions ( ) { // Start a background thread to get more details about the found extensions Thread thread = new Thread ( new Runnable ( ) { @ Override public void run ( ) { DefaultCoreExtensionRepository . this . scanner . updateExtensions ( DefaultCoreExtensionRepository . this . extensions . values...
Update core extensions only if there is any remote repository and it s not disabled .
123
16
43,785
public void startListening ( ) { // Register progress listener this . observationManager . addListener ( new WrappedThreadEventListener ( this . progress ) ) ; // Isolate log for the job status this . logListener = new LoggerListener ( LoggerListener . class . getName ( ) + ' ' + hashCode ( ) , this . logs ) ; if ( isI...
Start listening to events .
126
5
43,786
public void stopListening ( ) { if ( isIsolated ( ) ) { this . loggerManager . popLogListener ( ) ; } else { this . observationManager . removeListener ( this . logListener . getName ( ) ) ; } this . observationManager . removeListener ( this . progress . getName ( ) ) ; // Make sure the progress is closed this . progr...
Stop listening to events .
91
5
43,787
public < E > List < InlineDiffChunk < E > > inline ( List < E > previous , List < E > next ) { setError ( null ) ; try { return this . inlineDiffDisplayer . display ( this . diffManager . diff ( previous , next , null ) ) ; } catch ( DiffException e ) { setError ( e ) ; return null ; } }
Builds an in - line diff between two versions of a list of elements .
82
16
43,788
public List < InlineDiffChunk < Character > > inline ( String previous , String next ) { setError ( null ) ; try { return this . inlineDiffDisplayer . display ( this . diffManager . diff ( this . charSplitter . split ( previous ) , this . charSplitter . split ( next ) , null ) ) ; } catch ( DiffException e ) { setError...
Builds an in - line diff between two versions of a text .
91
14
43,789
public X509CertificateHolder getCertificate ( Selector selector ) { try { return ( X509CertificateHolder ) this . store . getMatches ( selector ) . iterator ( ) . next ( ) ; } catch ( Throwable t ) { return null ; } }
Get the first certificate matching the provided selector .
59
9
43,790
public void initialize ( ComponentManager manager , ClassLoader classLoader ) { try { // Find all declared components by retrieving the list defined in COMPONENT_LIST. List < ComponentDeclaration > componentDeclarations = getDeclaredComponents ( classLoader , COMPONENT_LIST ) ; // Find all the Component overrides and a...
Loads all components defined using annotations .
318
8
43,791
private Collection < ComponentDescriptor < ? > > getComponentsDescriptors ( ClassLoader classLoader , List < ComponentDeclaration > componentDeclarations ) { // For each component class name found, load its class and use introspection to find the necessary // annotations required to create a Component Descriptor. Map <...
Find all component descriptors out of component declarations .
390
10
43,792
private List < ComponentDeclaration > getDeclaredComponents ( ClassLoader classLoader , String location ) throws IOException { List < ComponentDeclaration > annotatedClassNames = new ArrayList <> ( ) ; Enumeration < URL > urls = classLoader . getResources ( location ) ; while ( urls . hasMoreElements ( ) ) { URL url = ...
Get all components listed in the passed resource file .
160
10
43,793
public List < ComponentDeclaration > getDeclaredComponentsFromJAR ( InputStream jarFile ) throws IOException { ZipInputStream zis = new ZipInputStream ( jarFile ) ; List < ComponentDeclaration > componentDeclarations = null ; List < ComponentDeclaration > componentOverrideDeclarations = null ; for ( ZipEntry entry = zi...
Get all components listed in a JAR file .
307
10
43,794
public CertifiedPublicKey convert ( X509CertificateHolder cert ) { if ( cert == null ) { return null ; } return new BcX509CertifiedPublicKey ( cert , this . factory ) ; }
Convert Bouncy Castle certificate holder .
45
9
43,795
private void surroundWithParagraph ( Document document , Node body , Node beginNode , Node endNode ) { // surround all the nodes starting with the marker node with a paragraph. Element paragraph = document . createElement ( TAG_P ) ; body . insertBefore ( paragraph , beginNode ) ; Node child = beginNode ; while ( child...
Surround passed nodes with a paragraph element .
108
9
43,796
private void validateBean ( Object bean ) throws PropertyException { if ( getValidatorFactory ( ) != null ) { Validator validator = getValidatorFactory ( ) . getValidator ( ) ; Set < ConstraintViolation < Object > > constraintViolations = validator . validate ( bean ) ; if ( ! constraintViolations . isEmpty ( ) ) { thr...
Validate populated values based on JSR 303 .
117
10
43,797
public < E > DiffResult < E > diff ( List < E > previous , List < E > next , DiffConfiguration < E > configuration ) { DiffResult < E > result ; try { result = this . diffManager . diff ( previous , next , configuration ) ; } catch ( DiffException e ) { result = new DefaultDiffResult < E > ( previous , next ) ; result ...
Produce a diff between the two provided versions .
104
10
43,798
public < E > MergeResult < E > merge ( List < E > commonAncestor , List < E > next , List < E > current , MergeConfiguration < E > configuration ) { MergeResult < E > result ; try { result = this . diffManager . merge ( commonAncestor , next , current , configuration ) ; } catch ( MergeException e ) { result = new Defa...
Execute a 3 - way merge on provided versions .
124
11
43,799
void analyseRevision ( R revision , List < E > previous ) { if ( currentRevision == null ) { return ; } if ( previous == null || previous . isEmpty ( ) ) { resolveRemainingToCurrent ( ) ; } else { resolveToCurrent ( DiffUtils . diff ( currentRevisionContent , previous ) . getDeltas ( ) ) ; assert currentRevisionContent...
Resolve revision of line to current revision based on given previous content and prepare for next analysis .
103
19