idx int64 0 165k | question stringlengths 73 4.15k | target stringlengths 5 918 | len_question int64 21 890 | len_target int64 3 255 |
|---|---|---|---|---|
7,100 | @ Nonnull public static EChange setConnectionTimeoutMilliSecs ( final long nMilliSecs ) { return s_aRWLock . writeLocked ( ( ) -> { if ( s_nConnectionTimeoutMilliSecs == nMilliSecs ) return EChange . UNCHANGED ; if ( nMilliSecs <= 0 ) LOGGER . warn ( "You are setting an indefinite connection timeout for the mail transport api: " + nMilliSecs ) ; s_nConnectionTimeoutMilliSecs = nMilliSecs ; return EChange . CHANGED ; } ) ; } | Set the connection timeout in milliseconds . Values &le ; 0 are interpreted as indefinite timeout which is not recommended! Changing these settings has no effect on existing mail queues! | 132 | 33 |
7,101 | @ Nonnull public static EChange setTimeoutMilliSecs ( final long nMilliSecs ) { return s_aRWLock . writeLocked ( ( ) -> { if ( s_nTimeoutMilliSecs == nMilliSecs ) return EChange . UNCHANGED ; if ( nMilliSecs <= 0 ) LOGGER . warn ( "You are setting an indefinite socket timeout for the mail transport api: " + nMilliSecs ) ; s_nTimeoutMilliSecs = nMilliSecs ; return EChange . CHANGED ; } ) ; } | Set the socket timeout in milliseconds . Values &le ; 0 are interpreted as indefinite timeout which is not recommended! Changing these settings has no effect on existing mail queues! | 129 | 33 |
7,102 | public static void addConnectionListener ( @ Nonnull final ConnectionListener aConnectionListener ) { ValueEnforcer . notNull ( aConnectionListener , "ConnectionListener" ) ; s_aRWLock . writeLocked ( ( ) -> s_aConnectionListeners . add ( aConnectionListener ) ) ; } | Add a new mail connection listener . | 64 | 7 |
7,103 | @ Nonnull public static EChange removeConnectionListener ( @ Nullable final ConnectionListener aConnectionListener ) { if ( aConnectionListener == null ) return EChange . UNCHANGED ; return s_aRWLock . writeLocked ( ( ) -> s_aConnectionListeners . removeObject ( aConnectionListener ) ) ; } | Remove an existing mail connection listener . | 70 | 7 |
7,104 | public static void addEmailDataTransportListener ( @ Nonnull final IEmailDataTransportListener aEmailDataTransportListener ) { ValueEnforcer . notNull ( aEmailDataTransportListener , "EmailDataTransportListener" ) ; s_aRWLock . writeLocked ( ( ) -> s_aEmailDataTransportListeners . add ( aEmailDataTransportListener ) ) ; } | Add a new mail transport listener . | 86 | 7 |
7,105 | @ Nonnull public static EChange removeEmailDataTransportListener ( @ Nullable final IEmailDataTransportListener aEmailDataTransportListener ) { if ( aEmailDataTransportListener == null ) return EChange . UNCHANGED ; return s_aRWLock . writeLocked ( ( ) -> s_aEmailDataTransportListeners . removeObject ( aEmailDataTransportListener ) ) ; } | Remove an existing mail transport listener . | 89 | 7 |
7,106 | @ SuppressFBWarnings ( "LG_LOST_LOGGER_DUE_TO_WEAK_REFERENCE" ) public static void enableJavaxMailDebugging ( final boolean bDebug ) { java . util . logging . Logger . getLogger ( "com.sun.mail.smtp" ) . setLevel ( bDebug ? Level . FINEST : Level . INFO ) ; java . util . logging . Logger . getLogger ( "com.sun.mail.smtp.protocol" ) . setLevel ( bDebug ? Level . FINEST : Level . INFO ) ; SystemProperties . setPropertyValue ( "mail.socket.debug" , bDebug ) ; SystemProperties . setPropertyValue ( "java.security.debug" , bDebug ? "certpath" : null ) ; SystemProperties . setPropertyValue ( "javax.net.debug" , bDebug ? "trustmanager" : null ) ; } | Enable or disable javax . mail debugging . By default debugging is disabled . | 209 | 16 |
7,107 | public static void setToDefault ( ) { s_aRWLock . writeLocked ( ( ) -> { s_nMaxMailQueueLen = DEFAULT_MAX_QUEUE_LENGTH ; s_nMaxMailSendCount = DEFAULT_MAX_SEND_COUNT ; s_bUseSSL = DEFAULT_USE_SSL ; s_bUseSTARTTLS = DEFAULT_USE_STARTTLS ; s_nConnectionTimeoutMilliSecs = DEFAULT_CONNECT_TIMEOUT_MILLISECS ; s_nTimeoutMilliSecs = DEFAULT_TIMEOUT_MILLISECS ; s_bDebugSMTP = GlobalDebug . isDebugMode ( ) ; s_aConnectionListeners . clear ( ) ; s_aEmailDataTransportListeners . clear ( ) ; } ) ; } | Set all settings to the default . This is helpful for testing . | 185 | 13 |
7,108 | public static byte [ ] convertToKeyByteArray ( String yourGooglePrivateKeyString ) { yourGooglePrivateKeyString = yourGooglePrivateKeyString . replace ( ' ' , ' ' ) ; yourGooglePrivateKeyString = yourGooglePrivateKeyString . replace ( ' ' , ' ' ) ; return Base64 . getDecoder ( ) . decode ( yourGooglePrivateKeyString ) ; } | Converts the given private key as String to an base 64 encoded byte array . | 81 | 16 |
7,109 | public static String signRequest ( final String yourGooglePrivateKeyString , final String path , final String query ) throws NoSuchAlgorithmException , InvalidKeyException , UnsupportedEncodingException , URISyntaxException { // Retrieve the proper URL components to sign final String resource = path + ' ' + query ; // Get an HMAC-SHA1 signing key from the raw key bytes final SecretKeySpec sha1Key = new SecretKeySpec ( convertToKeyByteArray ( yourGooglePrivateKeyString ) , "HmacSHA1" ) ; // Get an HMAC-SHA1 Mac instance and initialize it with the HMAC-SHA1 // key final Mac mac = Mac . getInstance ( "HmacSHA1" ) ; mac . init ( sha1Key ) ; // compute the binary signature for the request final byte [ ] sigBytes = mac . doFinal ( resource . getBytes ( ) ) ; // base 64 encode the binary signature // Base64 is JDK 1.8 only - older versions may need to use Apache // Commons or similar. String signature = Base64 . getEncoder ( ) . encodeToString ( sigBytes ) ; // convert the signature to 'web safe' base 64 signature = signature . replace ( ' ' , ' ' ) ; signature = signature . replace ( ' ' , ' ' ) ; return resource + "&signature=" + signature ; } | Returns the context path with the signature as parameter . | 291 | 10 |
7,110 | public static String signRequest ( final URL url , final String yourGooglePrivateKeyString ) throws NoSuchAlgorithmException , InvalidKeyException , UnsupportedEncodingException , URISyntaxException { // Retrieve the proper URL components to sign final String resource = url . getPath ( ) + ' ' + url . getQuery ( ) ; // Get an HMAC-SHA1 signing key from the raw key bytes final SecretKeySpec sha1Key = new SecretKeySpec ( convertToKeyByteArray ( yourGooglePrivateKeyString ) , "HmacSHA1" ) ; // Get an HMAC-SHA1 Mac instance and initialize it with the HMAC-SHA1 // key final Mac mac = Mac . getInstance ( "HmacSHA1" ) ; mac . init ( sha1Key ) ; // compute the binary signature for the request final byte [ ] sigBytes = mac . doFinal ( resource . getBytes ( ) ) ; // base 64 encode the binary signature // Base64 is JDK 1.8 only - older versions may need to use Apache // Commons or similar. String signature = Base64 . getEncoder ( ) . encodeToString ( sigBytes ) ; // convert the signature to 'web safe' base 64 signature = signature . replace ( ' ' , ' ' ) ; signature = signature . replace ( ' ' , ' ' ) ; final String signedRequestPath = resource + "&signature=" + signature ; final String urlGoogleMapSignedRequest = url . getProtocol ( ) + "://" + url . getHost ( ) + signedRequestPath ; return urlGoogleMapSignedRequest ; } | Returns the full url as String object with the signature as parameter . | 342 | 13 |
7,111 | public static void setResponseHeader ( @ Nonnull @ Nonempty final String sName , @ Nonnull @ Nonempty final String sValue ) { ValueEnforcer . notEmpty ( sName , "Name" ) ; ValueEnforcer . notEmpty ( sValue , "Value" ) ; s_aRWLock . writeLocked ( ( ) -> s_aResponseHeaderMap . setHeader ( sName , sValue ) ) ; } | Sets a response header to the response according to the passed name and value . An existing header entry with the same name is overridden . | 92 | 28 |
7,112 | public static void addResponseHeader ( @ Nonnull @ Nonempty final String sName , @ Nonnull @ Nonempty final String sValue ) { ValueEnforcer . notEmpty ( sName , "Name" ) ; ValueEnforcer . notEmpty ( sValue , "Value" ) ; s_aRWLock . writeLocked ( ( ) -> s_aResponseHeaderMap . addHeader ( sName , sValue ) ) ; } | Adds a response header to the response according to the passed name and value . If an existing header with the same is present the value is added to the list so that the header is emitted more than once . | 92 | 41 |
7,113 | public static < S , T > Map < S , T > merge ( Map < S , T > map , Map < S , T > toMerge ) { Map < S , T > ret = new HashMap < S , T > ( ) ; ret . putAll ( ensure ( map ) ) ; ret . putAll ( ensure ( toMerge ) ) ; return ret ; } | toMerge will overwrite map values . | 81 | 8 |
7,114 | public void addHeader ( @ Nonnull final String sName , @ Nullable final String sValue ) { ValueEnforcer . notNull ( sName , "HeaderName" ) ; final String sNameLower = sName . toLowerCase ( Locale . US ) ; m_aRWLock . writeLocked ( ( ) -> { ICommonsList < String > aHeaderValueList = m_aHeaderNameToValueListMap . get ( sNameLower ) ; if ( aHeaderValueList == null ) { aHeaderValueList = new CommonsArrayList <> ( ) ; m_aHeaderNameToValueListMap . put ( sNameLower , aHeaderValueList ) ; m_aHeaderNameList . add ( sNameLower ) ; } aHeaderValueList . add ( sValue ) ; } ) ; } | Method to add header values to this instance . | 176 | 9 |
7,115 | public static void checkVersion ( GLVersioned required , GLVersioned object ) { if ( ! debug ) { return ; } final GLVersion requiredVersion = required . getGLVersion ( ) ; final GLVersion objectVersion = object . getGLVersion ( ) ; if ( objectVersion . getMajor ( ) > requiredVersion . getMajor ( ) && objectVersion . getMinor ( ) > requiredVersion . getMinor ( ) ) { throw new IllegalStateException ( "Versions not compatible: expected " + requiredVersion + " or lower, got " + objectVersion ) ; } } | Checks if two OpenGL versioned object have compatible version . Throws an exception if that s not the case . A version is determined to be compatible with another is it s lower than the said version . This isn t always true when deprecation is involved but it s an acceptable way of doing this in most implementations . | 119 | 65 |
7,116 | public static int [ ] getPackedPixels ( ByteBuffer imageData , Format format , Rectangle size ) { final int [ ] pixels = new int [ size . getArea ( ) ] ; final int width = size . getWidth ( ) ; final int height = size . getHeight ( ) ; for ( int x = 0 ; x < width ; x ++ ) { for ( int y = 0 ; y < height ; y ++ ) { final int srcIndex = ( x + y * width ) * format . getComponentCount ( ) ; final int destIndex = x + ( height - y - 1 ) * width ; if ( format . hasRed ( ) ) { pixels [ destIndex ] |= ( imageData . get ( srcIndex ) & 0xff ) << 16 ; } if ( format . hasGreen ( ) ) { pixels [ destIndex ] |= ( imageData . get ( srcIndex + 1 ) & 0xff ) << 8 ; } if ( format . hasBlue ( ) ) { pixels [ destIndex ] |= imageData . get ( srcIndex + 2 ) & 0xff ; } if ( format . hasAlpha ( ) ) { pixels [ destIndex ] |= ( imageData . get ( srcIndex + 3 ) & 0xff ) << 24 ; } else { pixels [ destIndex ] |= 0xff000000 ; } } } return pixels ; } | Converts a byte buffer of image data to a flat integer array integer where each pixel is and integer in the ARGB format . Input data is expected to be 8 bits per component . If the format has no alpha 0xFF is written as the value . | 289 | 52 |
7,117 | public static BufferedImage getImage ( ByteBuffer imageData , Format format , Rectangle size ) { final int width = size . getWidth ( ) ; final int height = size . getHeight ( ) ; final BufferedImage image = new BufferedImage ( width , height , BufferedImage . TYPE_INT_ARGB ) ; final int [ ] pixels = ( ( DataBufferInt ) image . getRaster ( ) . getDataBuffer ( ) ) . getData ( ) ; for ( int x = 0 ; x < width ; x ++ ) { for ( int y = 0 ; y < height ; y ++ ) { final int srcIndex = ( x + y * width ) * format . getComponentCount ( ) ; final int destIndex = x + ( height - y - 1 ) * width ; if ( format . hasRed ( ) ) { pixels [ destIndex ] |= ( imageData . get ( srcIndex ) & 0xff ) << 16 ; } if ( format . hasGreen ( ) ) { pixels [ destIndex ] |= ( imageData . get ( srcIndex + 1 ) & 0xff ) << 8 ; } if ( format . hasBlue ( ) ) { pixels [ destIndex ] |= imageData . get ( srcIndex + 2 ) & 0xff ; } if ( format . hasAlpha ( ) ) { pixels [ destIndex ] |= ( imageData . get ( srcIndex + 3 ) & 0xff ) << 24 ; } else { pixels [ destIndex ] |= 0xff000000 ; } } } return image ; } | Converts a byte buffer of image data to a buffered image in the ARGB format . Input data is expected to be 8 bits per component . If the format has no alpha 0xFF is written as the value . | 328 | 45 |
7,118 | public static Vector4f fromIntRGBA ( int r , int g , int b , int a ) { return new Vector4f ( ( r & 0xff ) / 255f , ( g & 0xff ) / 255f , ( b & 0xff ) / 255f , ( a & 0xff ) / 255f ) ; } | Converts 4 byte color components to a normalized float color . | 71 | 12 |
7,119 | public static ByteBuffer createByteBuffer ( int capacity ) { return ByteBuffer . allocateDirect ( capacity * DataType . BYTE . getByteSize ( ) ) . order ( ByteOrder . nativeOrder ( ) ) ; } | Creates a byte buffer of the desired capacity . | 46 | 10 |
7,120 | protected UnmappedReads < Read > getUnmappedMatesOfMappedReads ( String readsetId ) throws GeneralSecurityException , IOException { LOG . info ( "Collecting unmapped mates of mapped reads for injection" ) ; final Iterable < Read > unmappedReadsIterable = getUnmappedReadsIterator ( readsetId ) ; final UnmappedReads < Read > unmappedReads = createUnmappedReads ( ) ; for ( Read read : unmappedReadsIterable ) { unmappedReads . maybeAddRead ( read ) ; } LOG . info ( "Finished collecting unmapped mates of mapped reads: " + unmappedReads . getReadCount ( ) + " found." ) ; return unmappedReads ; } | Gets unmapped mates so we can inject them besides their mapped pairs . | 167 | 15 |
7,121 | public void set ( Rectangle rectangle ) { set ( rectangle . getX ( ) , rectangle . getY ( ) , rectangle . getWidth ( ) , rectangle . getHeight ( ) ) ; } | Sets the rectangle to be an exact copy of the provided one . | 41 | 14 |
7,122 | @ Nullable public static ISessionWebScope getSessionWebScopeOfSession ( @ Nullable final HttpSession aHttpSession ) { return aHttpSession == null ? null : getSessionWebScopeOfID ( aHttpSession . getId ( ) ) ; } | Get the session web scope of the passed HTTP session . | 55 | 11 |
7,123 | public static void destroyAllWebSessions ( ) { // destroy all session web scopes (make a copy, because we're invalidating // the sessions!) for ( final ISessionWebScope aSessionScope : getAllSessionWebScopes ( ) ) { // Unfortunately we need a special handling here if ( aSessionScope . selfDestruct ( ) . isContinue ( ) ) { // Remove from map ScopeSessionManager . getInstance ( ) . onScopeEnd ( aSessionScope ) ; } // Else the destruction was already started! } } | Destroy all available web scopes . | 112 | 7 |
7,124 | private void writeObject ( final ObjectOutputStream aOS ) throws IOException { // Read the data if ( m_aDFOS . isInMemory ( ) ) { _ensureCachedContentIsPresent ( ) ; } else { m_aCachedContent = null ; m_aDFOSFile = m_aDFOS . getFile ( ) ; } // write out values aOS . defaultWriteObject ( ) ; } | Writes the state of this object during serialization . | 91 | 11 |
7,125 | @ Nonnegative public long getSize ( ) { if ( m_nSize >= 0 ) return m_nSize ; if ( m_aCachedContent != null ) return m_aCachedContent . length ; if ( m_aDFOS . isInMemory ( ) ) return m_aDFOS . getDataLength ( ) ; return m_aDFOS . getFile ( ) . length ( ) ; } | Returns the size of the file . | 90 | 7 |
7,126 | @ ReturnsMutableObject ( "Speed" ) @ SuppressFBWarnings ( "EI_EXPOSE_REP" ) @ Nullable public byte [ ] directGet ( ) { if ( isInMemory ( ) ) { _ensureCachedContentIsPresent ( ) ; return m_aCachedContent ; } return SimpleFileIO . getAllFileBytes ( m_aDFOS . getFile ( ) ) ; } | Returns the contents of the file as an array of bytes . If the contents of the file were not yet cached in memory they will be loaded from the disk storage and cached . | 92 | 35 |
7,127 | @ Nonnull public String getStringWithFallback ( @ Nonnull final Charset aFallbackCharset ) { final String sCharset = getCharSet ( ) ; final Charset aCharset = CharsetHelper . getCharsetFromNameOrDefault ( sCharset , aFallbackCharset ) ; return getString ( aCharset ) ; } | Get the string with the charset defined in the content type . | 86 | 13 |
7,128 | public void run ( String [ ] args ) { LOG . info ( "Starting GA4GHPicardRunner" ) ; try { parseCmdLine ( args ) ; buildPicardCommand ( ) ; startProcess ( ) ; pumpInputData ( ) ; waitForProcessEnd ( ) ; } catch ( Exception e ) { System . out . println ( e . getMessage ( ) ) ; e . printStackTrace ( ) ; } } | Sets up required streams and pipes and then spawns the Picard tool | 92 | 13 |
7,129 | void parseCmdLine ( String [ ] args ) { JCommander parser = new JCommander ( this , args ) ; parser . setProgramName ( "GA4GHPicardRunner" ) ; LOG . info ( "Cmd line parsed" ) ; } | Parses cmd line with JCommander | 55 | 9 |
7,130 | private void buildPicardCommand ( ) throws IOException , GeneralSecurityException , URISyntaxException { File picardJarPath = new File ( picardPath , "picard.jar" ) ; if ( ! picardJarPath . exists ( ) ) { throw new IOException ( "Picard tool not found at " + picardJarPath . getAbsolutePath ( ) ) ; } command . add ( "java" ) ; command . add ( picardJVMArgs ) ; command . add ( "-jar" ) ; command . add ( picardJarPath . getAbsolutePath ( ) ) ; command . add ( picardTool ) ; for ( String picardArg : picardArgs ) { if ( picardArg . startsWith ( INPUT_PREFIX ) ) { String inputPath = picardArg . substring ( INPUT_PREFIX . length ( ) ) ; inputs . add ( processInput ( inputPath ) ) ; } else { command . add ( picardArg ) ; } } for ( Input input : inputs ) { command . add ( "INPUT=" + input . pipeName ) ; } } | Adds relevant parts to the cmd line for Picard tool finds and extracts INPUT = arguments and processes them by creating appropriate data pumps . | 243 | 26 |
7,131 | private Input processGA4GHInput ( String input ) throws IOException , GeneralSecurityException , URISyntaxException { GA4GHUrl url = new GA4GHUrl ( input ) ; SAMFilePump pump ; if ( usingGrpc ) { factoryGrpc . configure ( url . getRootUrl ( ) , new Settings ( clientSecretsFilename , apiKey , noLocalServer ) ) ; pump = new ReadIteratorToSAMFilePump < com . google . genomics . v1 . Read , com . google . genomics . v1 . ReadGroupSet , com . google . genomics . v1 . Reference > ( factoryGrpc . get ( url . getRootUrl ( ) ) . getReads ( url ) ) ; } else { factoryRest . configure ( url . getRootUrl ( ) , new Settings ( clientSecretsFilename , apiKey , noLocalServer ) ) ; pump = new ReadIteratorToSAMFilePump < com . google . api . services . genomics . model . Read , com . google . api . services . genomics . model . ReadGroupSet , com . google . api . services . genomics . model . Reference > ( factoryRest . get ( url . getRootUrl ( ) ) . getReads ( url ) ) ; } return new Input ( input , STDIN_FILE_NAME , pump ) ; } | Processes GA4GH based input creates required API connections and data pump | 289 | 14 |
7,132 | private Input processRegularFileInput ( String input ) throws IOException { File inputFile = new File ( input ) ; if ( ! inputFile . exists ( ) ) { throw new IOException ( "Input does not exist: " + input ) ; } if ( pipeFiles ) { SamReader samReader = SamReaderFactory . makeDefault ( ) . open ( inputFile ) ; return new Input ( input , STDIN_FILE_NAME , new SamReaderToSAMFilePump ( samReader ) ) ; } else { return new Input ( input , input , null ) ; } } | Processes regular non GA4GH based file input | 121 | 10 |
7,133 | private void startProcess ( ) throws IOException { LOG . info ( "Building process" ) ; ProcessBuilder processBuilder = new ProcessBuilder ( command ) ; processBuilder . redirectError ( ProcessBuilder . Redirect . INHERIT ) ; processBuilder . redirectOutput ( ProcessBuilder . Redirect . INHERIT ) ; LOG . info ( "Starting process" ) ; process = processBuilder . start ( ) ; LOG . info ( "Process started" ) ; } | Starts the Picard tool process based on constructed command . | 96 | 11 |
7,134 | private void pumpInputData ( ) throws IOException { for ( Input input : inputs ) { if ( input . pump == null ) { continue ; } OutputStream os ; if ( input . pipeName . equals ( STDIN_FILE_NAME ) ) { os = process . getOutputStream ( ) ; } else { throw new IOException ( "Only stdin piping is supported so far." ) ; } input . pump . pump ( os ) ; } } | Loops through inputs and for each pumps the data into the proper pipe stream connected to the executing process . | 95 | 21 |
7,135 | @ Nonnull public static DefaultTreeWithGlobalUniqueID < String , NetworkInterface > createNetworkInterfaceTree ( ) { final DefaultTreeWithGlobalUniqueID < String , NetworkInterface > ret = new DefaultTreeWithGlobalUniqueID <> ( ) ; // Build basic level - all IFs without a parent final ICommonsList < NetworkInterface > aNonRootNIs = new CommonsArrayList <> ( ) ; try { for ( final NetworkInterface aNI : IteratorHelper . getIterator ( NetworkInterface . getNetworkInterfaces ( ) ) ) if ( aNI . getParent ( ) == null ) ret . getRootItem ( ) . createChildItem ( aNI . getName ( ) , aNI ) ; else aNonRootNIs . add ( aNI ) ; } catch ( final Throwable t ) { throw new IllegalStateException ( "Failed to get all network interfaces" , t ) ; } int nNotFound = 0 ; while ( aNonRootNIs . isNotEmpty ( ) ) { final NetworkInterface aNI = aNonRootNIs . removeFirst ( ) ; final DefaultTreeItemWithID < String , NetworkInterface > aParentItem = ret . getItemWithID ( aNI . getParent ( ) . getName ( ) ) ; if ( aParentItem != null ) { // We found the parent aParentItem . createChildItem ( aNI . getName ( ) , aNI ) ; // Reset counter nNotFound = 0 ; } else { // Add again at the end aNonRootNIs . add ( aNI ) ; // Parent not found nNotFound ++ ; // We tried too many times without success - we iterated the whole // remaining list and found no parent tree item if ( nNotFound > aNonRootNIs . size ( ) ) throw new IllegalStateException ( "Seems like we have a data structure inconsistency! Remaining are: " + aNonRootNIs ) ; } } return ret ; } | Create a hierarchical tree of the network interfaces . | 416 | 9 |
7,136 | public static Runner runnerForClass0 ( RunnerBuilder builder , Class < ? > testClass ) throws Throwable { if ( recursiveDepth > 1 || isOnStack ( 0 , CoverageRunner . class . getCanonicalName ( ) ) ) { return builder . runnerForClass ( testClass ) ; } AffectingBuilder affectingBuilder = new AffectingBuilder ( ) ; Runner runner = affectingBuilder . runnerForClass ( testClass ) ; if ( runner != null ) { return runner ; } CoverageMonitor . clean ( ) ; Runner wrapped = builder . runnerForClass ( testClass ) ; return new CoverageRunner ( testClass , wrapped , CoverageMonitor . getURLs ( ) ) ; } | JUnit4 support . | 142 | 5 |
7,137 | private static boolean isOnStack ( int moreThan , String canonicalName ) { StackTraceElement [ ] stackTrace = Thread . currentThread ( ) . getStackTrace ( ) ; int count = 0 ; for ( StackTraceElement element : stackTrace ) { if ( element . getClassName ( ) . startsWith ( canonicalName ) ) { count ++ ; } } return count > moreThan ; } | Checks if the given name is on stack more than the given number of times . This method uses startsWith to check if the given name is on stack so one can pass a package name too . | 90 | 40 |
7,138 | public static void validateHTMLConfiguration ( ) throws IllegalStateException { // This will throw an IllegalStateException for wrong files in html/js.xml // and html/css.xml PhotonCSS . readCSSIncludesForGlobal ( new ClassPathResource ( PhotonCSS . DEFAULT_FILENAME ) ) ; PhotonJS . readJSIncludesForGlobal ( new ClassPathResource ( PhotonJS . DEFAULT_FILENAME ) ) ; } | Check if the referenced JS and CSS files exist | 94 | 9 |
7,139 | @ Nonnull public FineUploader5Form setElementID ( @ Nonnull @ Nonempty final String sElementID ) { ValueEnforcer . notEmpty ( sElementID , "ElementID" ) ; m_sFormElementID = sElementID ; return this ; } | This can be the ID of the < ; form> ; or a reference to the < ; form> ; element . | 58 | 28 |
7,140 | public static void setAuditor ( @ Nonnull final IAuditor aAuditor ) { ValueEnforcer . notNull ( aAuditor , "Auditor" ) ; s_aRWLock . writeLocked ( ( ) -> s_aAuditor = aAuditor ) ; } | Set the global auditor to use . | 61 | 7 |
7,141 | private static boolean startsWith ( String str , String ... prefixes ) { for ( String prefix : prefixes ) { if ( str . startsWith ( prefix ) ) return true ; } return false ; } | Checks if the given string starts with any of the given prefixes . | 42 | 15 |
7,142 | private static List < String > extractClassNames ( String jarName ) throws IOException { List < String > classes = new LinkedList < String > ( ) ; ZipInputStream orig = new ZipInputStream ( new FileInputStream ( jarName ) ) ; for ( ZipEntry entry = orig . getNextEntry ( ) ; entry != null ; entry = orig . getNextEntry ( ) ) { String fullName = entry . getName ( ) . replaceAll ( "/" , "." ) . replace ( ".class" , "" ) ; classes . add ( fullName ) ; } orig . close ( ) ; return classes ; } | Extract class names from the given jar . This method is for debugging purpose . | 132 | 16 |
7,143 | public static void main ( String [ ] args ) throws IOException { if ( args . length != 1 ) { System . out . println ( "There should be an argument: path to a jar." ) ; System . exit ( 0 ) ; } String jarInput = args [ 0 ] ; extract ( new File ( jarInput ) , new File ( "/tmp/junit-ekstazi-agent.jar" ) , new String [ ] { Names . EKSTAZI_PACKAGE_BIN } , new String [ ] { } ) ; for ( String name : extractClassNames ( "/tmp/junit-ekstazi-agent.jar" ) ) { System . out . println ( name ) ; } } | Simple test to print all classes in the given jar . | 154 | 11 |
7,144 | public static boolean isJSNode ( @ Nullable final IHCNode aNode ) { final IHCNode aUnwrappedNode = HCHelper . getUnwrappedNode ( aNode ) ; return isDirectJSNode ( aUnwrappedNode ) ; } | Check if the passed node is a JS node after unwrapping . | 59 | 14 |
7,145 | public static boolean isJSInlineNode ( @ Nullable final IHCNode aNode ) { final IHCNode aUnwrappedNode = HCHelper . getUnwrappedNode ( aNode ) ; return isDirectJSInlineNode ( aUnwrappedNode ) ; } | Check if the passed node is an inline JS node after unwrapping . | 61 | 15 |
7,146 | public static boolean isJSFileNode ( @ Nullable final IHCNode aNode ) { final IHCNode aUnwrappedNode = HCHelper . getUnwrappedNode ( aNode ) ; return isDirectJSFileNode ( aUnwrappedNode ) ; } | Check if the passed node is a file JS node after unwrapping . | 59 | 15 |
7,147 | @ Nonnull public JSVar param ( @ Nonnull @ Nonempty final String sName ) { final JSVar aVar = new JSVar ( sName , null ) ; m_aParams . add ( aVar ) ; return aVar ; } | Add the specified variable to the list of parameters for this function signature . | 53 | 14 |
7,148 | @ Nonnull public JSBlock body ( ) { if ( m_aBody == null ) m_aBody = new JSBlock ( ) . newlineAtEnd ( false ) ; return m_aBody ; } | Get the block that makes up body of this function | 45 | 10 |
7,149 | @ Nonnull public static HCCol perc ( @ Nonnegative final int nPerc ) { return new HCCol ( ) . setWidth ( ECSSUnit . perc ( nPerc ) ) ; } | Create a new column with a certain percentage . | 46 | 9 |
7,150 | public int enrichXml ( final MMOs root ) throws SQLException { int count = 0 ; // TODO: take out the print statements for ( final MMO mmo : root . getMMO ( ) ) { for ( final Utterance utterance : mmo . getUtterances ( ) . getUtterance ( ) ) { for ( final Phrase phrase : utterance . getPhrases ( ) . getPhrase ( ) ) { System . out . printf ( "Phrase: %s\n" , phrase . getPhraseText ( ) ) ; for ( final Mapping mapping : phrase . getMappings ( ) . getMapping ( ) ) { System . out . printf ( "Score: %s\n" , mapping . getMappingScore ( ) ) ; for ( final Candidate candidate : mapping . getMappingCandidates ( ) . getCandidate ( ) ) { final Collection < String > semTypes = new ArrayList <> ( ) ; for ( final SemType st : candidate . getSemTypes ( ) . getSemType ( ) ) { semTypes . add ( st . getvalue ( ) ) ; } // the actual line of work count += addSnomedId ( candidate ) ? 1 : 0 ; System . out . printf ( " %-5s %-9s %s %s %s %s\n" , candidate . getCandidateScore ( ) , candidate . getCandidateCUI ( ) , candidate . getSnomedId ( ) , candidate . getCandidatePreferred ( ) , semTypes , candidate . getSources ( ) . getSource ( ) ) ; } } System . out . println ( ) ; } } } return count ; } | Tries to look up each Mapping Candidate in the SNOMED CT db to add more data . | 364 | 21 |
7,151 | public boolean addSnomedId ( final Candidate candidate ) throws SQLException { final SnomedTerm result = findFromCuiAndDesc ( candidate . getCandidateCUI ( ) , candidate . getCandidatePreferred ( ) ) ; if ( result != null ) { candidate . setSnomedId ( result . snomedId ) ; candidate . setTermType ( result . termType ) ; return true ; } else { // TODO: log this somewhere? System . err . printf ( "WARNING! Could not find the SNOMED CT concept id for UMLS CUI: %s: '%s'\n" , candidate . getCandidateCUI ( ) , candidate . getCandidatePreferred ( ) ) ; return false ; } } | Tries to find this candidate in the SNOMED CT database and if found adds the SNOMED id and term type to the instance . | 161 | 29 |
7,152 | public static boolean looksLikeXHTML ( @ Nullable final String sText ) { // If the text contains an open angle bracket followed by a character that // we think of it as HTML // (?s) enables the "dotall" mode - see Pattern.DOTALL return StringHelper . hasText ( sText ) && RegExHelper . stringMatchesPattern ( "(?s).*<[a-zA-Z].+" , sText ) ; } | Check whether the passed text looks like it contains XHTML code . This is a heuristic check only and does not perform actual parsing! | 99 | 27 |
7,153 | public boolean isValidXHTMLFragment ( @ Nullable final String sXHTMLFragment ) { return StringHelper . hasNoText ( sXHTMLFragment ) || parseXHTMLFragment ( sXHTMLFragment ) != null ; } | Check if the given fragment is valid XHTML 1 . 1 mark - up . This method tries to parse the XHTML fragment so it is potentially slow! | 52 | 31 |
7,154 | @ Nullable public IMicroContainer unescapeXHTMLFragment ( @ Nullable final String sXHTML ) { // Ensure that the content is surrounded by a single tag final IMicroDocument aDoc = parseXHTMLFragment ( sXHTML ) ; if ( aDoc != null && aDoc . getDocumentElement ( ) != null ) { // Find "body" case insensitive final IMicroElement eBody = aDoc . getDocumentElement ( ) . getFirstChildElement ( EHTMLElement . BODY . getElementName ( ) ) ; if ( eBody != null ) { final IMicroContainer ret = new MicroContainer ( ) ; if ( eBody . hasChildren ( ) ) { // We need a copy because detachFromParent is modifying for ( final IMicroNode aChildNode : eBody . getAllChildren ( ) ) ret . appendChild ( aChildNode . detachFromParent ( ) ) ; } return ret ; } } return null ; } | Interpret the passed XHTML fragment as HTML and retrieve a result container with all body elements . | 203 | 19 |
7,155 | @ Nullable @ ContainsSoftMigration public static LocalDateTime readAsLocalDateTime ( @ Nonnull final IMicroElement aElement , @ Nonnull final IMicroQName aLDTName , @ Nonnull final String aDTName ) { LocalDateTime aLDT = aElement . getAttributeValueWithConversion ( aLDTName , LocalDateTime . class ) ; if ( aLDT == null ) { final ZonedDateTime aDT = aElement . getAttributeValueWithConversion ( aDTName , ZonedDateTime . class ) ; if ( aDT != null ) aLDT = aDT . toLocalDateTime ( ) ; } return aLDT ; } | For migration purposes - read LocalDateTime - if no present fall back to DateTime | 148 | 17 |
7,156 | @ Nonnull public BootstrapDisplayBuilder display ( @ Nonnull final EBootstrapDisplayType eDisplay ) { ValueEnforcer . notNull ( eDisplay , "eDisplay" ) ; m_eDisplay = eDisplay ; return this ; } | Set the display type . Default is block . | 51 | 9 |
7,157 | @ Nonnull public final HCHead addCSSAt ( @ Nonnegative final int nIndex , @ Nonnull final IHCNode aCSS ) { ValueEnforcer . notNull ( aCSS , "CSS" ) ; if ( ! HCCSSNodeDetector . isCSSNode ( aCSS ) ) throw new IllegalArgumentException ( aCSS + " is not a valid CSS node!" ) ; m_aCSS . add ( nIndex , aCSS ) ; return this ; } | Add a CSS node at the specified index . | 102 | 9 |
7,158 | @ Nonnull public final HCHead addJS ( @ Nonnull final IHCNode aJS ) { ValueEnforcer . notNull ( aJS , "JS" ) ; if ( ! HCJSNodeDetector . isJSNode ( aJS ) ) throw new IllegalArgumentException ( aJS + " is not a valid JS node!" ) ; m_aJS . add ( aJS ) ; return this ; } | Append some JavaScript code | 91 | 5 |
7,159 | @ Nonnull public final HCHead addJSAt ( @ Nonnegative final int nIndex , @ Nonnull final IHCNode aJS ) { ValueEnforcer . notNull ( aJS , "JS" ) ; if ( ! HCJSNodeDetector . isJSNode ( aJS ) ) throw new IllegalArgumentException ( aJS + " is not a valid JS node!" ) ; m_aJS . add ( nIndex , aJS ) ; return this ; } | Append some JavaScript code at the specified index | 103 | 9 |
7,160 | public static Ekstazi inst ( ) { if ( inst != null ) return inst ; synchronized ( Ekstazi . class ) { if ( inst == null ) { inst = new Ekstazi ( ) ; } } return inst ; } | Returns the only instance of this class . This method will construct and initialize the instance if it was not previously constructed . | 49 | 23 |
7,161 | public void endClassCoverage ( String className , boolean isFailOrError ) { File testResultsDir = new File ( Config . ROOT_DIR_V , Names . TEST_RESULTS_DIR_NAME ) ; File outcomeFile = new File ( testResultsDir , className ) ; if ( isFailOrError ) { // TODO: long names. testResultsDir . mkdirs ( ) ; try { outcomeFile . createNewFile ( ) ; } catch ( IOException e ) { Log . e ( "Unable to create file for a failing test: " + className , e ) ; } } else { outcomeFile . delete ( ) ; } endClassCoverage ( className ) ; } | Saves info about the results of running the given test class . | 150 | 13 |
7,162 | private boolean initAndReportSuccess ( ) { // Load configuration. Config . loadConfig ( ) ; // Initialize storer, hashes, and analyzer. mDependencyAnalyzer = Config . createDepenencyAnalyzer ( ) ; // Establish if Tool is enabled. boolean isEnabled = establishIfEnabled ( ) ; // Return if not enabled or code should not be instrumented. if ( ! isEnabled || ! Config . X_INSTRUMENT_CODE_V || isEkstaziSystemClassLoader ( ) ) { return isEnabled ; } // Set the agent at runtime if not already set. Instrumentation instrumentation = EkstaziAgent . getInstrumentation ( ) ; if ( instrumentation == null ) { Log . d ( "Agent has not been set previously" ) ; instrumentation = DynamicEkstazi . initAgentAtRuntimeAndReportSuccess ( ) ; if ( instrumentation == null ) { Log . d ( "No Instrumentation object found; enabling Ekstazi without using any instrumentation" ) ; return true ; } } else { Log . d ( "Agent has been set previously" ) ; } return true ; } | Initializes this facade . This method should be invoked only once . | 241 | 13 |
7,163 | protected void emitPluginLines ( final MarkdownHCStack aOut , final Line aLines , @ Nonnull final String sMeta ) { Line aLine = aLines ; String sIDPlugin = sMeta ; String sParams = null ; ICommonsMap < String , String > aParams = null ; final int nIdxOfSpace = sMeta . indexOf ( ' ' ) ; if ( nIdxOfSpace != - 1 ) { sIDPlugin = sMeta . substring ( 0 , nIdxOfSpace ) ; sParams = sMeta . substring ( nIdxOfSpace + 1 ) ; if ( sParams != null ) { aParams = parsePluginParams ( sParams ) ; } } if ( aParams == null ) { aParams = new CommonsHashMap <> ( ) ; } final ICommonsList < String > aList = new CommonsArrayList <> ( ) ; while ( aLine != null ) { if ( aLine . m_bIsEmpty ) aList . add ( "" ) ; else aList . add ( aLine . m_sValue ) ; aLine = aLine . m_aNext ; } final AbstractMarkdownPlugin aPlugin = m_aPlugins . get ( sIDPlugin ) ; if ( aPlugin != null ) { aPlugin . emit ( aOut , aList , aParams ) ; } } | interprets a plugin block into the StringBuilder . | 305 | 11 |
7,164 | public static Date copy ( final Date d ) { if ( d == null ) { return null ; } else { return new Date ( d . getTime ( ) ) ; } } | Creates a copy on a Date . | 37 | 8 |
7,165 | public static < A > List < A > list ( A ... elements ) { final List < A > list = new ArrayList < A > ( elements . length ) ; for ( A element : elements ) { list . add ( element ) ; } return list ; } | Returns an array list of elements | 55 | 6 |
7,166 | public static < A > Set < A > set ( A ... elements ) { final Set < A > set = new HashSet < A > ( elements . length ) ; for ( A element : elements ) { set . add ( element ) ; } return set ; } | Returns a hash set of elements | 55 | 6 |
7,167 | public static < A > A execute ( ExceptionAction < A > action ) { try { return action . doAction ( ) ; } catch ( RuntimeException e ) { throw e ; } catch ( Error e ) { throw e ; } catch ( Throwable e ) { throw new RuntimeException ( e ) ; } } | delegate to your to an ExceptionAction and wraps checked exceptions in RuntimExceptions leaving unchecked exceptions alone . | 65 | 23 |
7,168 | public void addFieldInfo ( @ Nonnull @ Nonempty final String sFieldName , @ Nonnull @ Nonempty final String sText ) { add ( SingleError . builderInfo ( ) . setErrorFieldName ( sFieldName ) . setErrorText ( sText ) . build ( ) ) ; } | Add a field specific information message . | 64 | 7 |
7,169 | public void addFieldWarning ( @ Nonnull @ Nonempty final String sFieldName , @ Nonnull @ Nonempty final String sText ) { add ( SingleError . builderWarn ( ) . setErrorFieldName ( sFieldName ) . setErrorText ( sText ) . build ( ) ) ; } | Add a field specific warning message . | 65 | 7 |
7,170 | public void addFieldError ( @ Nonnull @ Nonempty final String sFieldName , @ Nonnull @ Nonempty final String sText ) { add ( SingleError . builderError ( ) . setErrorFieldName ( sFieldName ) . setErrorText ( sText ) . build ( ) ) ; } | Add a field specific error message . | 64 | 7 |
7,171 | @ Nonnull public IUserGroup createNewUserGroup ( @ Nonnull @ Nonempty final String sName , @ Nullable final String sDescription , @ Nullable final Map < String , String > aCustomAttrs ) { // Create user group final UserGroup aUserGroup = new UserGroup ( sName , sDescription , aCustomAttrs ) ; m_aRWLock . writeLocked ( ( ) -> { // Store internalCreateItem ( aUserGroup ) ; } ) ; AuditHelper . onAuditCreateSuccess ( UserGroup . OT , aUserGroup . getID ( ) , sName , sDescription , aCustomAttrs ) ; // Execute callback as the very last action m_aCallbacks . forEach ( aCB -> aCB . onUserGroupCreated ( aUserGroup , false ) ) ; return aUserGroup ; } | Create a new user group . | 180 | 6 |
7,172 | @ Nonnull public IUserGroup createPredefinedUserGroup ( @ Nonnull @ Nonempty final String sID , @ Nonnull @ Nonempty final String sName , @ Nullable final String sDescription , @ Nullable final Map < String , String > aCustomAttrs ) { // Create user group final UserGroup aUserGroup = new UserGroup ( StubObject . createForCurrentUserAndID ( sID , aCustomAttrs ) , sName , sDescription ) ; m_aRWLock . writeLocked ( ( ) -> { // Store internalCreateItem ( aUserGroup ) ; } ) ; AuditHelper . onAuditCreateSuccess ( UserGroup . OT , aUserGroup . getID ( ) , "predefined-usergroup" , sName , sDescription , aCustomAttrs ) ; // Execute callback as the very last action m_aCallbacks . forEach ( aCB -> aCB . onUserGroupCreated ( aUserGroup , true ) ) ; return aUserGroup ; } | Create a predefined user group . | 215 | 7 |
7,173 | @ Nonnull public EChange deleteUserGroup ( @ Nullable final String sUserGroupID ) { if ( StringHelper . hasNoText ( sUserGroupID ) ) return EChange . UNCHANGED ; final UserGroup aDeletedUserGroup = getOfID ( sUserGroupID ) ; if ( aDeletedUserGroup == null ) { AuditHelper . onAuditDeleteFailure ( UserGroup . OT , "no-such-usergroup-id" , sUserGroupID ) ; return EChange . UNCHANGED ; } if ( aDeletedUserGroup . isDeleted ( ) ) { AuditHelper . onAuditDeleteFailure ( UserGroup . OT , "already-deleted" , sUserGroupID ) ; return EChange . UNCHANGED ; } m_aRWLock . writeLock ( ) . lock ( ) ; try { if ( BusinessObjectHelper . setDeletionNow ( aDeletedUserGroup ) . isUnchanged ( ) ) { AuditHelper . onAuditDeleteFailure ( UserGroup . OT , "already-deleted" , sUserGroupID ) ; return EChange . UNCHANGED ; } internalMarkItemDeleted ( aDeletedUserGroup ) ; } finally { m_aRWLock . writeLock ( ) . unlock ( ) ; } AuditHelper . onAuditDeleteSuccess ( UserGroup . OT , sUserGroupID ) ; // Execute callback as the very last action m_aCallbacks . forEach ( aCB -> aCB . onUserGroupDeleted ( aDeletedUserGroup ) ) ; return EChange . CHANGED ; } | Delete the user group with the specified ID | 350 | 8 |
7,174 | @ Nonnull public EChange undeleteUserGroup ( @ Nullable final String sUserGroupID ) { final UserGroup aUserGroup = getOfID ( sUserGroupID ) ; if ( aUserGroup == null ) { AuditHelper . onAuditUndeleteFailure ( UserGroup . OT , sUserGroupID , "no-such-id" ) ; return EChange . UNCHANGED ; } m_aRWLock . writeLock ( ) . lock ( ) ; try { if ( BusinessObjectHelper . setUndeletionNow ( aUserGroup ) . isUnchanged ( ) ) return EChange . UNCHANGED ; internalMarkItemUndeleted ( aUserGroup ) ; } finally { m_aRWLock . writeLock ( ) . unlock ( ) ; } AuditHelper . onAuditUndeleteSuccess ( UserGroup . OT , sUserGroupID ) ; // Execute callback as the very last action m_aCallbacks . forEach ( aCB -> aCB . onUserGroupUndeleted ( aUserGroup ) ) ; return EChange . CHANGED ; } | Undelete the user group with the specified ID . | 237 | 11 |
7,175 | @ Nonnull public EChange renameUserGroup ( @ Nullable final String sUserGroupID , @ Nonnull @ Nonempty final String sNewName ) { // Resolve user group final UserGroup aUserGroup = getOfID ( sUserGroupID ) ; if ( aUserGroup == null ) { AuditHelper . onAuditModifyFailure ( UserGroup . OT , sUserGroupID , "no-such-usergroup-id" , "name" ) ; return EChange . UNCHANGED ; } m_aRWLock . writeLock ( ) . lock ( ) ; try { if ( aUserGroup . setName ( sNewName ) . isUnchanged ( ) ) return EChange . UNCHANGED ; BusinessObjectHelper . setLastModificationNow ( aUserGroup ) ; internalUpdateItem ( aUserGroup ) ; } finally { m_aRWLock . writeLock ( ) . unlock ( ) ; } AuditHelper . onAuditModifySuccess ( UserGroup . OT , "name" , sUserGroupID , sNewName ) ; // Execute callback as the very last action m_aCallbacks . forEach ( aCB -> aCB . onUserGroupRenamed ( aUserGroup ) ) ; return EChange . CHANGED ; } | Rename the user group with the specified ID | 274 | 9 |
7,176 | @ Nonnull public EChange unassignUserFromAllUserGroups ( @ Nullable final String sUserID ) { if ( StringHelper . hasNoText ( sUserID ) ) return EChange . UNCHANGED ; final ICommonsList < IUserGroup > aAffectedUserGroups = new CommonsArrayList <> ( ) ; m_aRWLock . writeLock ( ) . lock ( ) ; try { EChange eChange = EChange . UNCHANGED ; for ( final UserGroup aUserGroup : internalDirectGetAll ( ) ) if ( aUserGroup . unassignUser ( sUserID ) . isChanged ( ) ) { aAffectedUserGroups . add ( aUserGroup ) ; BusinessObjectHelper . setLastModificationNow ( aUserGroup ) ; internalUpdateItem ( aUserGroup ) ; eChange = EChange . CHANGED ; } if ( eChange . isUnchanged ( ) ) return EChange . UNCHANGED ; } finally { m_aRWLock . writeLock ( ) . unlock ( ) ; } AuditHelper . onAuditModifySuccess ( UserGroup . OT , "unassign-user-from-all-usergroups" , sUserID ) ; // Execute callback as the very last action for ( final IUserGroup aUserGroup : aAffectedUserGroups ) m_aCallbacks . forEach ( aCB -> aCB . onUserGroupUserAssignment ( aUserGroup , sUserID , false ) ) ; return EChange . CHANGED ; } /** * Check if the passed user is assigned to the specified user group * * @param sUserGroupID * ID of the user group to check * @param sUserID * ID of the user to be checked. * @return <code>true</code> if the specified user is assigned to the * specified user group. */ public boolean isUserAssignedToUserGroup ( @ Nullable final String sUserGroupID , @ Nullable final String sUserID ) { if ( StringHelper . hasNoText ( sUserID ) ) return false ; final IUserGroup aUserGroup = getOfID ( sUserGroupID ) ; return aUserGroup == null ? false : aUserGroup . containsUserID ( sUserID ) ; } | Unassign the passed user ID from all user groups . | 496 | 12 |
7,177 | @ Nonnull @ ReturnsMutableCopy public ICommonsList < IUserGroup > getAllUserGroupsWithAssignedUser ( @ Nullable final String sUserID ) { if ( StringHelper . hasNoText ( sUserID ) ) return new CommonsArrayList <> ( ) ; return getAll ( aUserGroup -> aUserGroup . containsUserID ( sUserID ) ) ; } | Get a collection of all user groups to which a certain user is assigned to . | 85 | 16 |
7,178 | @ Nonnull @ ReturnsMutableCopy public ICommonsList < String > getAllUserGroupIDsWithAssignedUser ( @ Nullable final String sUserID ) { if ( StringHelper . hasNoText ( sUserID ) ) return new CommonsArrayList <> ( ) ; return getAllMapped ( aUserGroup -> aUserGroup . containsUserID ( sUserID ) , aUserGroup -> aUserGroup . getID ( ) ) ; } | Get a collection of all user group IDs to which a certain user is assigned to . | 98 | 17 |
7,179 | @ Nonnull public EChange unassignRoleFromAllUserGroups ( @ Nullable final String sRoleID ) { if ( StringHelper . hasNoText ( sRoleID ) ) return EChange . UNCHANGED ; final ICommonsList < IUserGroup > aAffectedUserGroups = new CommonsArrayList <> ( ) ; m_aRWLock . writeLock ( ) . lock ( ) ; try { EChange eChange = EChange . UNCHANGED ; for ( final UserGroup aUserGroup : internalDirectGetAll ( ) ) if ( aUserGroup . unassignRole ( sRoleID ) . isChanged ( ) ) { aAffectedUserGroups . add ( aUserGroup ) ; BusinessObjectHelper . setLastModificationNow ( aUserGroup ) ; internalUpdateItem ( aUserGroup ) ; eChange = EChange . CHANGED ; } if ( eChange . isUnchanged ( ) ) return EChange . UNCHANGED ; } finally { m_aRWLock . writeLock ( ) . unlock ( ) ; } AuditHelper . onAuditModifySuccess ( UserGroup . OT , "unassign-role-from-all-usergroups" , sRoleID ) ; // Execute callback as the very last action for ( final IUserGroup aUserGroup : aAffectedUserGroups ) m_aCallbacks . forEach ( aCB -> aCB . onUserGroupRoleAssignment ( aUserGroup , sRoleID , false ) ) ; return EChange . CHANGED ; } /** * Get a collection of all user groups to which a certain role is assigned to. * * @param sRoleID * The role ID to search * @return A non-<code>null</code>but may be empty collection with all * matching user groups. */ @ Nonnull @ ReturnsMutableCopy public ICommonsList < IUserGroup > getAllUserGroupsWithAssignedRole ( @ Nullable final String sRoleID ) { if ( StringHelper . hasNoText ( sRoleID ) ) return getNone ( ) ; return getAll ( aUserGroup -> aUserGroup . containsRoleID ( sRoleID ) ) ; } | Unassign the passed role ID from existing user groups . | 477 | 12 |
7,180 | @ Nonnull @ ReturnsMutableCopy public ICommonsList < String > getAllUserGroupIDsWithAssignedRole ( @ Nullable final String sRoleID ) { if ( StringHelper . hasNoText ( sRoleID ) ) return getNone ( ) ; return getAllMapped ( aUserGroup -> aUserGroup . containsRoleID ( sRoleID ) , IUserGroup :: getID ) ; } | Get a collection of all user group IDs to which a certain role is assigned to . | 88 | 17 |
7,181 | public final void internalSetNodeState ( @ Nonnull final EHCNodeState eNodeState ) { if ( DEBUG_NODE_STATE ) { ValueEnforcer . notNull ( eNodeState , "NodeState" ) ; if ( m_eNodeState . isAfter ( eNodeState ) ) HCConsistencyChecker . consistencyError ( "The new node state is invalid. Got " + eNodeState + " but having " + m_eNodeState ) ; } m_eNodeState = eNodeState ; } | Change the node state internally . Handle with care! | 114 | 10 |
7,182 | public static boolean check ( Class < ? > clz ) { if ( Config . CACHE_SEEN_CLASSES_V ) { int index = hash ( clz ) ; if ( CACHE [ index ] == clz ) { return true ; } CACHE [ index ] = clz ; } return false ; } | Checks if the given class is in cache . If not puts the class in the cache and returns false ; otherwise it returns true . | 71 | 27 |
7,183 | public Map < String , String > getResults ( ) { final Map < String , String > results = new HashMap < String , String > ( sinks . size ( ) ) ; for ( Map . Entry < String , StringSink > entry : sinks . entrySet ( ) ) { results . put ( entry . getKey ( ) , entry . getValue ( ) . result ( ) ) ; } return Collections . unmodifiableMap ( results ) ; } | Get the results as a Map from names to String data . The names are composed of | 95 | 17 |
7,184 | public static void main ( String [ ] args ) { // Parse arguments. String coverageDirName = null ; if ( args . length == 0 ) { System . out . println ( "Incorrect arguments. Directory with coverage has to be specified." ) ; System . exit ( 1 ) ; } coverageDirName = args [ 0 ] ; String mode = null ; if ( args . length > 1 ) { mode = args [ 1 ] ; } boolean forceCacheUse = false ; if ( args . length > 2 ) { forceCacheUse = args [ 2 ] . equals ( FORCE_CACHE_USE ) ; } Set < String > allClasses = new HashSet < String > ( ) ; Set < String > affectedClasses = new HashSet < String > ( ) ; if ( args . length > 3 ) { String options = args [ 3 ] ; Config . loadConfig ( options , true ) ; } else { Config . loadConfig ( ) ; } List < String > nonAffectedClasses = findNonAffectedClasses ( coverageDirName , forceCacheUse , allClasses , affectedClasses ) ; // Print non affected classes. printNonAffectedClasses ( allClasses , affectedClasses , nonAffectedClasses , mode ) ; } | The user has to specify directory that keep coverage and optionally mode that should be used to print non affected classes . | 271 | 22 |
7,185 | private static List < String > findNonAffectedClasses ( String workingDirectory ) { Set < String > allClasses = new HashSet < String > ( ) ; Set < String > affectedClasses = new HashSet < String > ( ) ; loadConfig ( workingDirectory ) ; // Find non affected classes. List < String > nonAffectedClasses = findNonAffectedClasses ( Config . ROOT_DIR_V , true , allClasses , affectedClasses ) ; // Format list to include class names in expected format for Ant and Maven. return formatNonAffectedClassesForAntAndMaven ( nonAffectedClasses ) ; } | Returns list of non affected classes as discovered from the given directory with dependencies . | 144 | 15 |
7,186 | private static void printNonAffectedClasses ( Set < String > allClasses , Set < String > affectedClasses , List < String > nonAffectedClasses , String mode ) { if ( mode != null && mode . equals ( ANT_MODE ) ) { StringBuilder sb = new StringBuilder ( ) ; for ( String className : nonAffectedClasses ) { className = className . replaceAll ( "\\." , "/" ) ; sb . append ( "<exclude name=\"" + className + ".java\"/>" ) ; } System . out . println ( sb ) ; } else if ( mode != null && mode . equals ( MAVEN_SIMPLE_MODE ) ) { StringBuilder sb = new StringBuilder ( ) ; for ( String className : nonAffectedClasses ) { className = className . replaceAll ( "\\." , "/" ) ; sb . append ( "<exclude>" ) ; sb . append ( className ) . append ( ".java" ) ; sb . append ( "</exclude>" ) ; } System . out . println ( sb ) ; } else if ( mode != null && mode . equals ( MAVEN_MODE ) ) { StringBuilder sb = new StringBuilder ( ) ; sb . append ( "<excludes>" ) ; for ( String className : nonAffectedClasses ) { className = className . replaceAll ( "\\." , "/" ) ; sb . append ( "<exclude>" ) ; sb . append ( className ) . append ( ".java" ) ; sb . append ( "</exclude>" ) ; } sb . append ( "</excludes>" ) ; System . out . println ( sb ) ; } else if ( mode != null && mode . equals ( DEBUG_MODE ) ) { System . out . println ( "AFFECTED: " + affectedClasses ) ; System . out . println ( "NONAFFECTED: " + nonAffectedClasses ) ; } else { for ( String className : nonAffectedClasses ) { System . out . println ( className ) ; } } } | Prints non affected classes in the given mode . If mode is not specified one class is printed per line . | 473 | 22 |
7,187 | private static void includeAffected ( Set < String > allClasses , Set < String > affectedClasses , List < File > sortedFiles ) { Storer storer = Config . createStorer ( ) ; Hasher hasher = Config . createHasher ( ) ; NameBasedCheck classCheck = Config . DEBUG_MODE_V != Config . DebugMode . NONE ? new DebugNameCheck ( storer , hasher , DependencyAnalyzer . CLASS_EXT ) : new NameBasedCheck ( storer , hasher , DependencyAnalyzer . CLASS_EXT ) ; NameBasedCheck covCheck = new NameBasedCheck ( storer , hasher , DependencyAnalyzer . COV_EXT ) ; MethodCheck methodCheck = new MethodCheck ( storer , hasher ) ; String prevClassName = null ; for ( File file : sortedFiles ) { String fileName = file . getName ( ) ; String dirName = file . getParent ( ) ; String className = null ; if ( file . isDirectory ( ) ) { continue ; } if ( fileName . endsWith ( DependencyAnalyzer . COV_EXT ) ) { className = covCheck . includeAll ( fileName , dirName ) ; } else if ( fileName . endsWith ( DependencyAnalyzer . CLASS_EXT ) ) { className = classCheck . includeAll ( fileName , dirName ) ; } else { className = methodCheck . includeAll ( fileName , dirName ) ; } // Reset after some time to free space. if ( prevClassName != null && className != null && ! prevClassName . equals ( className ) ) { methodCheck . includeAffected ( affectedClasses ) ; methodCheck = new MethodCheck ( Config . createStorer ( ) , Config . createHasher ( ) ) ; } if ( className != null ) { allClasses . add ( className ) ; prevClassName = className ; } } classCheck . includeAffected ( affectedClasses ) ; covCheck . includeAffected ( affectedClasses ) ; methodCheck . includeAffected ( affectedClasses ) ; } | Find all non affected classes . | 455 | 6 |
7,188 | @ Nonnull public DataTablesDom addCustom ( @ Nonnull @ Nonempty final String sStr ) { ValueEnforcer . notEmpty ( sStr , "Str" ) ; _internalAdd ( sStr ) ; return this ; } | Add a custom element | 50 | 4 |
7,189 | @ Nonnull public FineUploader5Validation setItemLimit ( @ Nonnegative final int nItemLimit ) { ValueEnforcer . isGE0 ( nItemLimit , "ItemLimit" ) ; m_nValidationItemLimit = nItemLimit ; return this ; } | Maximum number of items that can be potentially uploaded in this session . Will reject all items that are added or retried after this limit is reached . | 58 | 29 |
7,190 | @ Nonnull public FineUploader5Validation setMinSizeLimit ( @ Nonnegative final int nMinSizeLimit ) { ValueEnforcer . isGE0 ( nMinSizeLimit , "MinSizeLimit" ) ; m_nValidationMinSizeLimit = nMinSizeLimit ; return this ; } | The minimum allowable size in bytes for an item . | 64 | 10 |
7,191 | @ Nonnull public FineUploader5Validation setSizeLimit ( @ Nonnegative final int nSizeLimit ) { ValueEnforcer . isGE0 ( nSizeLimit , "SizeLimit" ) ; m_nValidationSizeLimit = nSizeLimit ; return this ; } | The maximum allowable size in bytes for an item . | 58 | 10 |
7,192 | private void sendTextToServer ( ) { statusLabel . setText ( "" ) ; conceptList . clear ( ) ; // don't do anything if we have no text final String text = mainTextArea . getText ( ) ; if ( text . length ( ) < 1 ) { statusLabel . setText ( messages . pleaseEnterTextLabel ( ) ) ; return ; } // disable interaction while we wait for the response glassPanel . setPositionAndShow ( ) ; // build up the AnalysisRequest JSON object // start with any options final JSONArray options = new JSONArray ( ) ; setSemanticTypesOption ( types , options ) ; // defaults options . set ( options . size ( ) , new JSONString ( "word_sense_disambiguation" ) ) ; options . set ( options . size ( ) , new JSONString ( "composite_phrases 8" ) ) ; options . set ( options . size ( ) , new JSONString ( "no_derivational_variants" ) ) ; options . set ( options . size ( ) , new JSONString ( "strict_model" ) ) ; options . set ( options . size ( ) , new JSONString ( "ignore_word_order" ) ) ; options . set ( options . size ( ) , new JSONString ( "allow_large_n" ) ) ; options . set ( options . size ( ) , new JSONString ( "restrict_to_sources SNOMEDCT_US" ) ) ; final JSONObject analysisRequest = new JSONObject ( ) ; analysisRequest . put ( "text" , new JSONString ( text ) ) ; analysisRequest . put ( "options" , options ) ; // send the input to the server final RequestBuilder builder = new RequestBuilder ( RequestBuilder . POST , webserviceUrl ) ; builder . setHeader ( "Content-Type" , MediaType . APPLICATION_JSON ) ; builder . setRequestData ( analysisRequest . toString ( ) ) ; // create the async callback builder . setCallback ( new SnomedRequestCallback ( conceptList , statusLabel , glassPanel , typeCodeToDescription ) ) ; // send the request try { builder . send ( ) ; } catch ( final RequestException e ) { statusLabel . setText ( messages . problemPerformingAnalysisLabel ( ) ) ; GWT . log ( "There was a problem performing the analysis: " + e . getMessage ( ) , e ) ; glassPanel . hide ( ) ; } } | send the text from the mainTextArea to the server and accept an async response | 526 | 16 |
7,193 | @ Override public ParseResult parse ( Source source ) { if ( ! testSrcInfo . equals ( source . getSrcInfo ( ) ) ) { throw new RuntimeException ( "testSrcInfo and source.getSrcInfo were not equal. testSrcInfo = " + testSrcInfo + ", source.getSrcInfo = " + source . getSrcInfo ( ) ) ; } try { BufferedReader reader = source . createReader ( ) ; try { if ( ! testString . equals ( reader . readLine ( ) ) ) { throw new RuntimeException ( "testString and reader.readLine() were not equal" ) ; } final String secondLine = reader . readLine ( ) ; if ( secondLine != null ) { throw new RuntimeException ( "got a second line '" + secondLine + "' from the reader" ) ; } } finally { reader . close ( ) ; } } catch ( IOException e ) { throw new RuntimeException ( e ) ; } return testResult ; } | When called this examines the source to make sure the scrcInfo and data are the expected testSrcInfo and testString . It then produces the testDoc as a result | 218 | 35 |
7,194 | public void registerPasswordHashCreator ( @ Nonnull final IPasswordHashCreator aPasswordHashCreator ) { ValueEnforcer . notNull ( aPasswordHashCreator , "PasswordHashCreator" ) ; final String sAlgorithmName = aPasswordHashCreator . getAlgorithmName ( ) ; if ( StringHelper . hasNoText ( sAlgorithmName ) ) throw new IllegalArgumentException ( "PasswordHashCreator algorithm '" + aPasswordHashCreator + "' is empty!" ) ; m_aRWLock . writeLocked ( ( ) -> { if ( m_aPasswordHashCreators . containsKey ( sAlgorithmName ) ) throw new IllegalArgumentException ( "Another PasswordHashCreator for algorithm '" + sAlgorithmName + "' is already registered!" ) ; m_aPasswordHashCreators . put ( sAlgorithmName , aPasswordHashCreator ) ; } ) ; if ( LOGGER . isDebugEnabled ( ) ) LOGGER . debug ( "Registered password hash creator algorithm '" + sAlgorithmName + "' to " + aPasswordHashCreator ) ; } | Register a new password hash creator . No other password hash creator with the same algorithm name may be registered . | 239 | 21 |
7,195 | @ Nullable public IPasswordHashCreator getPasswordHashCreatorOfAlgorithm ( @ Nullable final String sAlgorithmName ) { return m_aRWLock . readLocked ( ( ) -> m_aPasswordHashCreators . get ( sAlgorithmName ) ) ; } | Get the password hash creator of the specified algorithm name . | 62 | 11 |
7,196 | private List < SemanticError > check ( DataType dataType ) { logger . finer ( "Checking semantic constraints on datatype " + dataType . name ) ; final List < SemanticError > errors = new ArrayList < SemanticError > ( ) ; final Set < String > constructorNames = new HashSet < String > ( ) ; for ( Constructor constructor : dataType . constructors ) { logger . finest ( "Checking semantic constraints on constructor " + constructor . name + " in datatype " + dataType . name ) ; if ( dataType . constructors . size ( ) > 1 && dataType . name . equals ( constructor . name ) ) { logger . info ( "Constructor with same name as its data type " + dataType . name + "." ) ; errors . add ( _ConstructorDataTypeConflict ( dataType . name ) ) ; } if ( constructorNames . contains ( constructor . name ) ) { logger . info ( "Two constructors with same name " + constructor . name + " in data type " + dataType . name + "." ) ; errors . add ( _DuplicateConstructor ( dataType . name , constructor . name ) ) ; } else { constructorNames . add ( constructor . name ) ; } errors . addAll ( check ( dataType , constructor ) ) ; } return errors ; } | Checks a data type for duplicate constructor names or constructors having the same name as the data type | 288 | 20 |
7,197 | private List < SemanticError > check ( DataType dataType , Constructor constructor ) { logger . finer ( "Checking semantic constraints on data type " + dataType . name + ", constructor " + constructor . name ) ; final List < SemanticError > errors = new ArrayList < SemanticError > ( ) ; final Set < String > argNames = new HashSet < String > ( ) ; for ( Arg arg : constructor . args ) { if ( argNames . contains ( arg . name ) ) { errors . add ( _DuplicateArgName ( dataType . name , constructor . name , arg . name ) ) ; } else { argNames . add ( arg . name ) ; } errors . addAll ( check ( dataType , constructor , arg ) ) ; } return errors ; } | Check a constructor to make sure it does not duplicate any args and that no arg duplicates any modifiers | 168 | 20 |
7,198 | private List < SemanticError > check ( DataType dataType , Constructor constructor , Arg arg ) { logger . finest ( "Checking semantic constraints on data type " + dataType . name + ", constructor " + constructor . name ) ; final List < SemanticError > errors = new ArrayList < SemanticError > ( ) ; final Set < ArgModifier > modifiers = new HashSet < ArgModifier > ( ) ; for ( ArgModifier modifier : arg . modifiers ) { if ( modifiers . contains ( modifier ) ) { final String modName = ASTPrinter . print ( modifier ) ; errors . add ( _DuplicateModifier ( dataType . name , constructor . name , arg . name , modName ) ) ; } else { modifiers . add ( modifier ) ; } } return errors ; } | Checkt to make sure an arg doesn t have duplicate modifiers | 171 | 12 |
7,199 | @ SuppressWarnings ( "resource" ) @ Nonnull @ OverrideOnDemand @ WillCloseWhenClosed protected CSVWriter createCSVWriter ( @ Nonnull final OutputStream aOS ) { return new CSVWriter ( new OutputStreamWriter ( aOS , m_aCharset ) ) . setSeparatorChar ( m_cSeparatorChar ) . setQuoteChar ( m_cQuoteChar ) . setEscapeChar ( m_cEscapeChar ) . setLineEnd ( m_sLineEnd ) . setAvoidFinalLineEnd ( m_bAvoidFinalLineEnd ) ; } | Create a new CSV writer . | 131 | 6 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.