idx int64 0 41.2k | question stringlengths 83 4.15k | target stringlengths 5 715 |
|---|---|---|
27,600 | public V remove ( Object key ) { if ( fast ) { synchronized ( this ) { Map < K , V > temp = cloneMap ( map ) ; V result = temp . remove ( key ) ; map = temp ; return ( result ) ; } } else { synchronized ( map ) { return ( map . remove ( key ) ) ; } } } | Remove any mapping for this key and return any previously mapped value . |
27,601 | public static boolean isFileExist ( String filePath ) { if ( StringUtils . isEmpty ( filePath ) ) { return false ; } File file = new File ( filePath ) ; return ( file . exists ( ) && file . isFile ( ) ) ; } | Indicates if this file represents a file on the underlying file system . |
27,602 | public static boolean isFolderExist ( String directoryPath ) { if ( StringUtils . isEmpty ( directoryPath ) ) { return false ; } File dire = new File ( directoryPath ) ; return ( dire . exists ( ) && dire . isDirectory ( ) ) ; } | Indicates if this file represents a directory on the underlying file system . |
27,603 | public static void addToMediaStore ( Context context , File file ) { String [ ] path = new String [ ] { file . getPath ( ) } ; MediaScannerConnection . scanFile ( context , path , null , null ) ; } | another media scan way |
27,604 | public synchronized long skip ( final long length ) throws IOException { final long skip = super . skip ( length ) ; this . count += skip ; return skip ; } | Skips the stream over the specified number of bytes adding the skipped amount to the count . |
27,605 | public final void notifyHeaderItemRangeInserted ( int positionStart , int itemCount ) { int newHeaderItemCount = getHeaderItemCount ( ) ; if ( positionStart < 0 || itemCount < 0 || positionStart + itemCount > newHeaderItemCount ) { throw new IndexOutOfBoundsException ( "The given range [" + positionStart + " - " + ( po... | Notifies that multiple header items are inserted . |
27,606 | public final void notifyHeaderItemChanged ( int position ) { if ( position < 0 || position >= headerItemCount ) { throw new IndexOutOfBoundsException ( "The given position " + position + " is not within the position bounds for header items [0 - " + ( headerItemCount - 1 ) + "]." ) ; } notifyItemChanged ( position ) ; } | Notifies that a header item is changed . |
27,607 | public final void notifyHeaderItemRangeChanged ( int positionStart , int itemCount ) { if ( positionStart < 0 || itemCount < 0 || positionStart + itemCount >= headerItemCount ) { throw new IndexOutOfBoundsException ( "The given range [" + positionStart + " - " + ( positionStart + itemCount - 1 ) + "] is not within the ... | Notifies that multiple header items are changed . |
27,608 | public void notifyHeaderItemMoved ( int fromPosition , int toPosition ) { if ( fromPosition < 0 || toPosition < 0 || fromPosition >= headerItemCount || toPosition >= headerItemCount ) { throw new IndexOutOfBoundsException ( "The given fromPosition " + fromPosition + " or toPosition " + toPosition + " is not within the ... | Notifies that an existing header item is moved to another position . |
27,609 | public void notifyHeaderItemRangeRemoved ( int positionStart , int itemCount ) { if ( positionStart < 0 || itemCount < 0 || positionStart + itemCount > headerItemCount ) { throw new IndexOutOfBoundsException ( "The given range [" + positionStart + " - " + ( positionStart + itemCount - 1 ) + "] is not within the positio... | Notifies that multiple header items are removed . |
27,610 | public final void notifyContentItemInserted ( int position ) { int newHeaderItemCount = getHeaderItemCount ( ) ; int newContentItemCount = getContentItemCount ( ) ; if ( position < 0 || position >= newContentItemCount ) { throw new IndexOutOfBoundsException ( "The given position " + position + " is not within the posit... | Notifies that a content item is inserted . |
27,611 | public final void notifyContentItemRangeInserted ( int positionStart , int itemCount ) { int newHeaderItemCount = getHeaderItemCount ( ) ; int newContentItemCount = getContentItemCount ( ) ; if ( positionStart < 0 || itemCount < 0 || positionStart + itemCount > newContentItemCount ) { throw new IndexOutOfBoundsExceptio... | Notifies that multiple content items are inserted . |
27,612 | public final void notifyContentItemChanged ( int position ) { if ( position < 0 || position >= contentItemCount ) { throw new IndexOutOfBoundsException ( "The given position " + position + " is not within the position bounds for content items [0 - " + ( contentItemCount - 1 ) + "]." ) ; } notifyItemChanged ( position +... | Notifies that a content item is changed . |
27,613 | public final void notifyContentItemRangeChanged ( int positionStart , int itemCount ) { if ( positionStart < 0 || itemCount < 0 || positionStart + itemCount > contentItemCount ) { throw new IndexOutOfBoundsException ( "The given range [" + positionStart + " - " + ( positionStart + itemCount - 1 ) + "] is not within the... | Notifies that multiple content items are changed . |
27,614 | public final void notifyContentItemMoved ( int fromPosition , int toPosition ) { if ( fromPosition < 0 || toPosition < 0 || fromPosition >= contentItemCount || toPosition >= contentItemCount ) { throw new IndexOutOfBoundsException ( "The given fromPosition " + fromPosition + " or toPosition " + toPosition + " is not wi... | Notifies that an existing content item is moved to another position . |
27,615 | public final void notifyContentItemRemoved ( int position ) { if ( position < 0 || position >= contentItemCount ) { throw new IndexOutOfBoundsException ( "The given position " + position + " is not within the position bounds for content items [0 - " + ( contentItemCount - 1 ) + "]." ) ; } notifyItemRemoved ( position +... | Notifies that a content item is removed . |
27,616 | public final void notifyContentItemRangeRemoved ( int positionStart , int itemCount ) { if ( positionStart < 0 || itemCount < 0 || positionStart + itemCount > contentItemCount ) { throw new IndexOutOfBoundsException ( "The given range [" + positionStart + " - " + ( positionStart + itemCount - 1 ) + "] is not within the... | Notifies that multiple content items are removed . |
27,617 | public final void notifyFooterItemInserted ( int position ) { int newHeaderItemCount = getHeaderItemCount ( ) ; int newContentItemCount = getContentItemCount ( ) ; int newFooterItemCount = getFooterItemCount ( ) ; notifyItemInserted ( position + newHeaderItemCount + newContentItemCount ) ; } | Notifies that a footer item is inserted . |
27,618 | public final void notifyFooterItemRangeInserted ( int positionStart , int itemCount ) { int newHeaderItemCount = getHeaderItemCount ( ) ; int newContentItemCount = getContentItemCount ( ) ; int newFooterItemCount = getFooterItemCount ( ) ; if ( positionStart < 0 || itemCount < 0 || positionStart + itemCount > newFooter... | Notifies that multiple footer items are inserted . |
27,619 | public final void notifyFooterItemChanged ( int position ) { if ( position < 0 || position >= footerItemCount ) { throw new IndexOutOfBoundsException ( "The given position " + position + " is not within the position bounds for footer items [0 - " + ( footerItemCount - 1 ) + "]." ) ; } notifyItemChanged ( position + hea... | Notifies that a footer item is changed . |
27,620 | public final void notifyFooterItemRangeChanged ( int positionStart , int itemCount ) { if ( positionStart < 0 || itemCount < 0 || positionStart + itemCount > footerItemCount ) { throw new IndexOutOfBoundsException ( "The given range [" + positionStart + " - " + ( positionStart + itemCount - 1 ) + "] is not within the p... | Notifies that multiple footer items are changed . |
27,621 | public final void notifyFooterItemMoved ( int fromPosition , int toPosition ) { if ( fromPosition < 0 || toPosition < 0 || fromPosition >= footerItemCount || toPosition >= footerItemCount ) { throw new IndexOutOfBoundsException ( "The given fromPosition " + fromPosition + " or toPosition " + toPosition + " is not withi... | Notifies that an existing footer item is moved to another position . |
27,622 | public final void notifyFooterItemRangeRemoved ( int positionStart , int itemCount ) { if ( positionStart < 0 || itemCount < 0 || positionStart + itemCount > footerItemCount ) { throw new IndexOutOfBoundsException ( "The given range [" + positionStart + " - " + ( positionStart + itemCount - 1 ) + "] is not within the p... | Notifies that multiple footer items are removed . |
27,623 | public View getView ( int position , View convertView , ViewGroup parent ) { if ( position == super . getCount ( ) && isEnableRefreshing ( ) ) { return ( mFooter ) ; } return ( super . getView ( position , convertView , parent ) ) ; } | Get a View that displays the data at the specified position in the data set . In this case if we are at the end of the list and we are still in append mode we ask for a pending view and return it plus kick off the background task to append more data to the wrapped adapter . |
27,624 | public static String [ ] addStringToArray ( String [ ] array , String str ) { if ( isEmpty ( array ) ) { return new String [ ] { str } ; } String [ ] newArr = new String [ array . length + 1 ] ; System . arraycopy ( array , 0 , newArr , 0 , array . length ) ; newArr [ array . length ] = str ; return newArr ; } | Append the given String to the given String array returning a new array consisting of the input array contents plus the given String . |
27,625 | public static String [ ] sortStringArray ( String [ ] array ) { if ( isEmpty ( array ) ) { return new String [ 0 ] ; } Arrays . sort ( array ) ; return array ; } | Turn given source String array into sorted array . |
27,626 | public static String [ ] removeDuplicateStrings ( String [ ] array ) { if ( isEmpty ( array ) ) { return array ; } Set < String > set = new TreeSet < String > ( ) ; Collections . addAll ( set , array ) ; return toStringArray ( set ) ; } | Remove duplicate Strings from the given array . Also sorts the array as it uses a TreeSet . |
27,627 | public static Set < String > commaDelimitedListToSet ( String str ) { Set < String > set = new TreeSet < String > ( ) ; String [ ] tokens = commaDelimitedListToStringArray ( str ) ; Collections . addAll ( set , tokens ) ; return set ; } | Convenience method to convert a CSV string list to a set . Note that this will suppress duplicates . |
27,628 | public static String toSafeFileName ( String name ) { int size = name . length ( ) ; StringBuilder builder = new StringBuilder ( size * 2 ) ; for ( int i = 0 ; i < size ; i ++ ) { char c = name . charAt ( i ) ; boolean valid = c >= 'a' && c <= 'z' ; valid = valid || ( c >= 'A' && c <= 'Z' ) ; valid = valid || ( c >= '0... | Converts any string into a string that is safe to use as a file name . The result will only include ascii characters and numbers and the - _ and . characters . |
27,629 | public List < CardWithActions > getBoardMemberActivity ( String boardId , String memberId , String actionFilter , Argument ... args ) { if ( actionFilter == null ) actionFilter = "all" ; Argument [ ] argsAndFilter = Arrays . copyOf ( args , args . length + 1 ) ; argsAndFilter [ args . length ] = new Argument ( "actions... | FIXME Remove this method |
27,630 | void sign ( byte [ ] data , int offset , int length , ServerMessageBlock request , ServerMessageBlock response ) { request . signSeq = signSequence ; if ( response != null ) { response . signSeq = signSequence + 1 ; response . verifyFailed = false ; } try { update ( macSigningKey , 0 , macSigningKey . length ) ; int in... | Performs MAC signing of the SMB . This is done as follows . The signature field of the SMB is overwritted with the sequence number ; The MD5 digest of the MAC signing key + the entire SMB is taken ; The first 8 bytes of this are placed in the signature field . |
27,631 | public static Object setProperty ( String key , String value ) { return prp . setProperty ( key , value ) ; } | Add a property . |
27,632 | public static NbtAddress [ ] getAllByAddress ( NbtAddress addr ) throws UnknownHostException { try { NbtAddress [ ] addrs = CLIENT . getNodeStatus ( addr ) ; cacheAddressArray ( addrs ) ; return addrs ; } catch ( UnknownHostException uhe ) { throw new UnknownHostException ( "no name with type 0x" + Hexdump . toHexStrin... | Retrieve all addresses of a host by it s address . NetBIOS hosts can have many names for a given IP address . The name and IP address make the NetBIOS address . This provides a way to retrieve the other names for a host with the same IP address . |
27,633 | public String getHostName ( ) { if ( addr instanceof NbtAddress ) { return ( ( NbtAddress ) addr ) . getHostName ( ) ; } return ( ( InetAddress ) addr ) . getHostName ( ) ; } | Return the hostname of this address such as MYCOMPUTER . |
27,634 | public String getHostAddress ( ) { if ( addr instanceof NbtAddress ) { return ( ( NbtAddress ) addr ) . getHostAddress ( ) ; } return ( ( InetAddress ) addr ) . getHostAddress ( ) ; } | Return the IP address as text such as 192 . 168 . 1 . 15 . |
27,635 | public String getUncPath ( ) { getUncPath0 ( ) ; if ( share == null ) { return "\\\\" + url . getHost ( ) ; } return "\\\\" + url . getHost ( ) + canon . replace ( '/' , '\\' ) ; } | Retuns the Windows UNC style path with backslashs intead of forward slashes . |
27,636 | public void createNewFile ( ) throws SmbException { if ( getUncPath0 ( ) . length ( ) == 1 ) { throw new SmbException ( "Invalid operation for workgroups, servers, or shares" ) ; } close ( open0 ( O_RDWR | O_CREAT | O_EXCL , 0 , ATTR_NORMAL , 0 ) , 0L ) ; } | Create a new file but fail if it already exists . The check for existance of the file and it s creation are an atomic operation with respect to other filesystem activities . |
27,637 | private String getProjectName ( ) { String pName = Strings . emptyToNull ( projectName ) ; if ( pName == null ) { pName = Strings . emptyToNull ( junit4 . getProject ( ) . getName ( ) ) ; } if ( pName == null ) { pName = "(unnamed project)" ; } return pName ; } | Return the project name or the default project name . |
27,638 | @ SuppressForbidden ( "legitimate printStackTrace()." ) public void onSuiteResult ( AggregatedSuiteResultEvent e ) { try { if ( jsonWriter == null ) return ; slaves . put ( e . getSlave ( ) . id , e . getSlave ( ) ) ; e . serialize ( jsonWriter , outputStreams ) ; } catch ( Exception ex ) { ex . printStackTrace ( ) ; j... | Emit information about a single suite and all of its tests . |
27,639 | public void onQuit ( AggregatedQuitEvent e ) { if ( jsonWriter == null ) return ; try { jsonWriter . endArray ( ) ; jsonWriter . name ( "slaves" ) ; jsonWriter . beginObject ( ) ; for ( Map . Entry < Integer , ForkedJvmInfo > entry : slaves . entrySet ( ) ) { jsonWriter . name ( Integer . toString ( entry . getKey ( ) ... | All tests completed . |
27,640 | public void setSeed ( String randomSeed ) { if ( ! Strings . isNullOrEmpty ( getProject ( ) . getUserProperty ( SYSPROP_RANDOM_SEED ( ) ) ) ) { String userProperty = getProject ( ) . getUserProperty ( SYSPROP_RANDOM_SEED ( ) ) ; if ( ! userProperty . equals ( randomSeed ) ) { log ( "Ignoring seed attribute because it i... | Initial random seed used for shuffling test suites and other sources of pseudo - randomness . If not set any random value is set . |
27,641 | public void setPrefix ( String prefix ) { if ( ! Strings . isNullOrEmpty ( getProject ( ) . getUserProperty ( SYSPROP_PREFIX ( ) ) ) ) { log ( "Ignoring prefix attribute because it is overridden by user properties." , Project . MSG_WARN ) ; } else { SysGlobals . initializeWith ( prefix ) ; } } | Initializes custom prefix for all junit4 properties . This must be consistent across all junit4 invocations if done from the same classpath . Use only when REALLY needed . |
27,642 | public void addFileSet ( FileSet fs ) { add ( fs ) ; if ( fs . getProject ( ) == null ) { fs . setProject ( getProject ( ) ) ; } } | Adds a set of tests based on pattern matching . |
27,643 | public void addAssertions ( Assertions asserts ) { if ( getCommandline ( ) . getAssertions ( ) != null ) { throw new BuildException ( "Only one assertion declaration is allowed" ) ; } getCommandline ( ) . setAssertions ( asserts ) ; } | Add assertions to tests execution . |
27,644 | private void validateArguments ( ) throws BuildException { Path tempDir = getTempDir ( ) ; if ( tempDir == null ) { throw new BuildException ( "Temporary directory cannot be null." ) ; } if ( Files . exists ( tempDir ) ) { if ( ! Files . isDirectory ( tempDir ) ) { throw new BuildException ( "Temporary directory is not... | Validate arguments . |
27,645 | private void validateJUnit4 ( ) throws BuildException { try { Class < ? > clazz = Class . forName ( "org.junit.runner.Description" ) ; if ( ! Serializable . class . isAssignableFrom ( clazz ) ) { throw new BuildException ( "At least JUnit version 4.10 is required on junit4's taskdef classpath." ) ; } } catch ( ClassNot... | Validate JUnit4 presence in a concrete version . |
27,646 | private org . apache . tools . ant . types . Path resolveFiles ( org . apache . tools . ant . types . Path path ) { org . apache . tools . ant . types . Path cloned = new org . apache . tools . ant . types . Path ( getProject ( ) ) ; for ( String location : path . list ( ) ) { cloned . createPathElement ( ) . setLocati... | Resolve all files from a given path and simplify its definition . |
27,647 | private int determineForkedJvmCount ( TestsCollection testCollection ) { int cores = Runtime . getRuntime ( ) . availableProcessors ( ) ; int jvmCount ; if ( this . parallelism . equals ( PARALLELISM_AUTO ) ) { if ( cores >= 8 ) { jvmCount = 4 ; } else if ( cores >= 4 ) { jvmCount = 3 ; } else if ( cores == 3 ) { jvmCo... | Determine how many forked JVMs to use . |
27,648 | private String escapeAndJoin ( String [ ] commandline ) { StringBuilder b = new StringBuilder ( ) ; Pattern specials = Pattern . compile ( "[\\ ]" ) ; for ( String arg : commandline ) { if ( b . length ( ) > 0 ) { b . append ( " " ) ; } if ( specials . matcher ( arg ) . find ( ) ) { b . append ( '"' ) . append ( arg ) ... | Try to provide an escaped ready - to - use shell line to repeat a given command line . |
27,649 | @ SuppressForbidden ( "legitimate sysstreams." ) private Execute forkProcess ( ForkedJvmInfo slaveInfo , EventBus eventBus , CommandlineJava commandline , TailInputStream eventStream , OutputStream sysout , OutputStream syserr , RandomAccessFile streamsBuffer ) { try { String tempDir = commandline . getSystemProperties... | Execute a slave process . Pump events to the given event bus . |
27,650 | private Path getTempDir ( ) { if ( this . tempDir == null ) { if ( this . dir != null ) { this . tempDir = dir ; } else { this . tempDir = getProject ( ) . getBaseDir ( ) . toPath ( ) ; } } return tempDir ; } | Resolve temporary folder . |
27,651 | private org . apache . tools . ant . types . Path addSlaveClasspath ( ) { org . apache . tools . ant . types . Path path = new org . apache . tools . ant . types . Path ( getProject ( ) ) ; String [ ] REQUIRED_SLAVE_CLASSES = { SlaveMain . class . getName ( ) , Strings . class . getName ( ) , MethodGlobFilter . class .... | Adds a classpath source which contains the given resource . |
27,652 | private void validate ( ) { if ( Strings . emptyToNull ( random ) == null ) { random = Strings . emptyToNull ( getProject ( ) . getProperty ( SYSPROP_RANDOM_SEED ( ) ) ) ; } if ( random == null ) { throw new BuildException ( "Required attribute 'seed' must not be empty. Look at <junit4:pickseed>." ) ; } long [ ] seeds ... | Validate arguments and state . |
27,653 | public void add ( ResourceCollection rc ) { if ( rc instanceof FileSet ) { FileSet fs = ( FileSet ) rc ; fs . setProject ( getProject ( ) ) ; } resources . add ( rc ) ; } | Adds a resource collection with execution hints . |
27,654 | private static void verifyJUnit4Present ( ) { try { Class < ? > clazz = Class . forName ( "org.junit.runner.Description" ) ; if ( ! Serializable . class . isAssignableFrom ( clazz ) ) { JvmExit . halt ( SlaveMain . ERR_OLD_JUNIT ) ; } } catch ( ClassNotFoundException e ) { JvmExit . halt ( SlaveMain . ERR_NO_JUNIT ) ; ... | Verify JUnit presence and version . |
27,655 | public void setShowOutput ( String mode ) { try { this . outputMode = OutputMode . valueOf ( mode . toUpperCase ( Locale . ROOT ) ) ; } catch ( IllegalArgumentException e ) { throw new IllegalArgumentException ( "showOutput accepts any of: " + Arrays . toString ( OutputMode . values ( ) ) + ", value is not valid: " + m... | Display mode for output streams . |
27,656 | private void flushOutput ( ) throws IOException { outStream . flush ( ) ; outWriter . completeLine ( ) ; errStream . flush ( ) ; errWriter . completeLine ( ) ; } | Flush output streams . |
27,657 | private void emitSuiteStart ( Description description , long startTimestamp ) throws IOException { String suiteName = description . getDisplayName ( ) ; if ( useSimpleNames ) { if ( suiteName . lastIndexOf ( '.' ) >= 0 ) { suiteName = suiteName . substring ( suiteName . lastIndexOf ( '.' ) + 1 ) ; } } logShort ( shortT... | Suite prologue . |
27,658 | private void emitSuiteEnd ( AggregatedSuiteResultEvent e , int suitesCompleted ) throws IOException { assert showSuiteSummary ; final StringBuilder b = new StringBuilder ( ) ; final int totalErrors = this . totalErrors . addAndGet ( e . isSuccessful ( ) ? 0 : 1 ) ; b . append ( String . format ( Locale . ROOT , "%sComp... | Suite end . |
27,659 | private void emitStatusLine ( AggregatedResultEvent result , TestStatus status , long timeMillis ) throws IOException { final StringBuilder line = new StringBuilder ( ) ; line . append ( shortTimestamp ( result . getStartTimestamp ( ) ) ) ; line . append ( Strings . padEnd ( statusNames . get ( status ) , 8 , ' ' ) ) ;... | Emit status line for an aggregated event . |
27,660 | private void logShort ( CharSequence message , boolean trim ) throws IOException { int length = message . length ( ) ; if ( trim ) { while ( length > 0 && Character . isWhitespace ( message . charAt ( length - 1 ) ) ) { length -- ; } } char [ ] chars = new char [ length + 1 ] ; for ( int i = 0 ; i < length ; i ++ ) { c... | Log a message line to the output . |
27,661 | public int getIgnoredCount ( ) { int count = 0 ; for ( AggregatedTestResultEvent t : getTests ( ) ) { if ( t . getStatus ( ) == TestStatus . IGNORED || t . getStatus ( ) == TestStatus . IGNORED_ASSUMPTION ) { count ++ ; } } return count ; } | Return the number of ignored or assumption - ignored tests . |
27,662 | public void onQuit ( AggregatedQuitEvent e ) { if ( summaryFile != null ) { try { Persister persister = new Persister ( ) ; persister . write ( new MavenFailsafeSummaryModel ( summaryListener . getResult ( ) ) , summaryFile ) ; } catch ( Exception x ) { junit4 . log ( "Could not serialize summary report." , x , Project... | Write the summary file if requested . |
27,663 | public void onSuiteResult ( AggregatedSuiteResultEvent e ) { summaryListener . suiteSummary ( e ) ; Description suiteDescription = e . getDescription ( ) ; String displayName = suiteDescription . getDisplayName ( ) ; if ( displayName . trim ( ) . isEmpty ( ) ) { junit4 . log ( "Could not emit XML report for suite (null... | Emit information about all of suite s tests . |
27,664 | private TestSuiteModel buildModel ( AggregatedSuiteResultEvent e ) throws IOException { SimpleDateFormat df = new SimpleDateFormat ( "yyyy-MM-dd'T'HH:mm:ss" , Locale . ROOT ) ; TestSuiteModel suite = new TestSuiteModel ( ) ; suite . hostname = "nohost.nodomain" ; suite . name = e . getDescription ( ) . getDisplayName (... | Build data model for serialization . |
27,665 | private String applyFilters ( String methodName ) { if ( filters . isEmpty ( ) ) { return methodName ; } Reader in = new StringReader ( methodName ) ; for ( TokenFilter tf : filters ) { in = tf . chain ( in ) ; } try { return CharStreams . toString ( in ) ; } catch ( IOException e ) { junit4 . log ( "Could not apply fi... | Apply filters to a method name . |
27,666 | void pumpEvents ( InputStream eventStream ) { try { Deserializer deserializer = new Deserializer ( eventStream , refLoader ) ; IEvent event = null ; while ( ( event = deserializer . deserialize ( ) ) != null ) { switch ( event . getType ( ) ) { case APPEND_STDERR : case APPEND_STDOUT : break ; default : lastActivity = ... | Pump events from event stream . |
27,667 | public void onSuiteResult ( AggregatedSuiteResultEvent e ) { long millis = e . getExecutionTime ( ) ; String suiteName = e . getDescription ( ) . getDisplayName ( ) ; List < Long > values = hints . get ( suiteName ) ; if ( values == null ) { hints . put ( suiteName , values = new ArrayList < > ( ) ) ; } values . add ( ... | Remember execution time for all executed suites . |
27,668 | public void onEnd ( AggregatedQuitEvent e ) { try { writeHints ( hintsFile , hints ) ; } catch ( IOException exception ) { outer . log ( "Could not write back the hints file." , exception , Project . MSG_ERR ) ; } } | Write back to hints file . |
27,669 | public static Map < String , List < Long > > readHints ( File hints ) throws IOException { Map < String , List < Long > > result = new HashMap < > ( ) ; InputStream is = new FileInputStream ( hints ) ; mergeHints ( is , result ) ; return result ; } | Read hints from a file . |
27,670 | public static void mergeHints ( InputStream is , Map < String , List < Long > > hints ) throws IOException { final BufferedReader reader = new BufferedReader ( new InputStreamReader ( is , Charsets . UTF_8 ) ) ; String line ; while ( ( line = reader . readLine ( ) ) != null ) { line = line . trim ( ) ; if ( line . isEm... | Read hints from a file and merge with the given hints map . |
27,671 | public static void writeHints ( File file , Map < String , List < Long > > hints ) throws IOException { Closer closer = Closer . create ( ) ; try { BufferedWriter w = closer . register ( Files . newWriter ( file , Charsets . UTF_8 ) ) ; if ( ! ( hints instanceof SortedMap ) ) { hints = new TreeMap < String , List < Lon... | Writes back hints file . |
27,672 | private static String [ ] readArgsFile ( String argsFile ) throws IOException { final ArrayList < String > lines = new ArrayList < String > ( ) ; final BufferedReader reader = new BufferedReader ( new InputStreamReader ( new FileInputStream ( argsFile ) , "UTF-8" ) ) ; try { String line ; while ( ( line = reader . read... | Read arguments from a file . Newline delimited UTF - 8 encoded . No fanciness to avoid dependencies . |
27,673 | @ SuppressForbidden ( "legitimate sysstreams." ) private static void redirectStreams ( final Serializer serializer , final boolean flushFrequently ) { final PrintStream origSysOut = System . out ; final PrintStream origSysErr = System . err ; warnings = System . err ; AccessController . doPrivileged ( new PrivilegedAct... | Redirect standard streams so that the output can be passed to listeners . |
27,674 | @ SuppressForbidden ( "legitimate sysstreams." ) public static void warn ( String message , Throwable t ) { PrintStream w = ( warnings == null ? System . err : warnings ) ; try { w . print ( "WARN: " ) ; w . print ( message ) ; if ( t != null ) { w . print ( " -> " ) ; try { t . printStackTrace ( w ) ; } catch ( OutOfM... | Warning emitter . Uses whatever alternative non - event communication channel is . |
27,675 | private ArrayList < RunListener > instantiateRunListeners ( ) throws Exception { ArrayList < RunListener > instances = new ArrayList < > ( ) ; if ( runListeners != null ) { for ( String className : Arrays . asList ( runListeners . split ( "," ) ) ) { instances . add ( ( RunListener ) this . instantiate ( className ) . ... | Generates JUnit 4 RunListener instances for any user defined RunListeners |
27,676 | public List < Assignment > assign ( Collection < String > suiteNames , int slaves , long seed ) { final Map < String , List < Long > > hints = ExecutionTimesReport . mergeHints ( resources , suiteNames ) ; final List < SuiteHint > costs = new ArrayList < > ( ) ; for ( String suiteName : suiteNames ) { final List < Long... | Assign based on execution time history . The algorithm is a greedy heuristic assigning the longest remaining test to the slave with the shortest - completion time so far . This is not optimal but fast and provides a decent average assignment . |
27,677 | static < K , V > PageMetadata < K , V > mergeTokenAndQueryParameters ( String paginationToken , final ViewQueryParameters < K , V > initialParameters ) { String json = new String ( Base64 . decodeBase64 ( paginationToken ) , Charset . forName ( "UTF-8" ) ) ; Gson paginationTokenGson = getGsonWithKeyAdapter ( initialPar... | Generate a PageMetadata object for the page represented by the specified pagination token . |
27,678 | static String tokenize ( PageMetadata < ? , ? > pageMetadata ) { try { Gson g = getGsonWithKeyAdapter ( pageMetadata . pageRequestParameters ) ; return new String ( Base64 . encodeBase64URLSafe ( g . toJson ( new PaginationToken ( pageMetadata ) ) . getBytes ( "UTF-8" ) ) , Charset . forName ( "UTF-8" ) ) ; } catch ( U... | Generate an opaque pagination token from the supplied PageMetadata . |
27,679 | public FindByIndexOptions useIndex ( String designDocument , String indexName ) { assertNotNull ( designDocument , "designDocument" ) ; assertNotNull ( indexName , "indexName" ) ; JsonArray index = new JsonArray ( ) ; index . add ( new JsonPrimitive ( designDocument ) ) ; index . add ( new JsonPrimitive ( indexName ) )... | Specify a specific index to run the query against |
27,680 | public String getPartialFilterSelector ( ) { return ( def . selector != null ) ? def . selector . toString ( ) : null ; } | Get the JSON string representation of the selector configured for this index . |
27,681 | public com . cloudant . client . api . model . ReplicationResult trigger ( ) { ReplicationResult couchDbReplicationResult = replication . trigger ( ) ; com . cloudant . client . api . model . ReplicationResult replicationResult = new com . cloudant . client . api . model . ReplicationResult ( couchDbReplicationResult )... | Triggers a replication request blocks while the replication is in progress . |
27,682 | public Replication queryParams ( Map < String , Object > queryParams ) { this . replication = replication . queryParams ( queryParams ) ; return this ; } | Specify additional query parameters to be passed to the filter function . |
27,683 | public Replication targetOauth ( String consumerSecret , String consumerKey , String tokenSecret , String token ) { this . replication = replication . targetOauth ( consumerSecret , consumerKey , tokenSecret , token ) ; return this ; } | Set OAuth 1 authentication credentials for the replication target |
27,684 | public List < Task > getActiveTasks ( ) { InputStream response = null ; URI uri = new URIBase ( getBaseUri ( ) ) . path ( "_active_tasks" ) . build ( ) ; try { response = couchDbClient . get ( uri ) ; return getResponseList ( response , couchDbClient . getGson ( ) , DeserializationTypes . TASKS ) ; } finally { close ( ... | Get the list of active tasks from the server . |
27,685 | public Membership getMembership ( ) { URI uri = new URIBase ( getBaseUri ( ) ) . path ( "_membership" ) . build ( ) ; Membership membership = couchDbClient . get ( uri , Membership . class ) ; return membership ; } | Get the list of all nodes and the list of active nodes in the cluster . |
27,686 | public ChangesResult getChanges ( ) { final URI uri = this . databaseHelper . changesUri ( "feed" , "normal" ) ; return client . get ( uri , ChangesResult . class ) ; } | Requests Change notifications of feed type normal . |
27,687 | public Changes parameter ( String name , String value ) { this . databaseHelper . query ( name , value ) ; return this ; } | Add a custom query parameter to the _changes request . Useful for specifying extra parameters to a filter function for example . |
27,688 | private boolean readNextRow ( ) { while ( ! stop ) { String row = getLineWrapped ( ) ; if ( row == null || row . startsWith ( "{\"last_seq\":" ) ) { terminate ( ) ; return false ; } else if ( row . isEmpty ( ) ) { continue ; } setNextRow ( gson . fromJson ( row , ChangesResult . Row . class ) ) ; return true ; } termin... | Reads and sets the next feed in the stream . |
27,689 | public List < Shard > getShards ( ) { InputStream response = null ; try { response = client . couchDbClient . get ( new DatabaseURIHelper ( db . getDBUri ( ) ) . path ( "_shards" ) . build ( ) ) ; return getResponseList ( response , client . getGson ( ) , DeserializationTypes . SHARDS ) ; } finally { close ( response )... | Get info about the shards in the database . |
27,690 | public Shard getShard ( String docId ) { assertNotEmpty ( docId , "docId" ) ; return client . couchDbClient . get ( new DatabaseURIHelper ( db . getDBUri ( ) ) . path ( "_shards" ) . path ( docId ) . build ( ) , Shard . class ) ; } | Get info about the shard a document belongs to . |
27,691 | public < T > List < T > findByIndex ( String selectorJson , Class < T > classOfT ) { return findByIndex ( selectorJson , classOfT , new FindByIndexOptions ( ) ) ; } | Find documents using an index |
27,692 | public < T > QueryResult < T > query ( String partitionKey , String query , final Class < T > classOfT ) { URI uri = new DatabaseURIHelper ( db . getDBUri ( ) ) . partition ( partitionKey ) . path ( "_find" ) . build ( ) ; return this . query ( uri , query , classOfT ) ; } | Execute a partitioned query using an index and a query selector . |
27,693 | public Indexes listIndexes ( ) { URI uri = new DatabaseURIHelper ( db . getDBUri ( ) ) . path ( "_index" ) . build ( ) ; return client . couchDbClient . get ( uri , Indexes . class ) ; } | List the indexes in the database . The returned object allows for listing indexes by type . |
27,694 | public void deleteIndex ( String indexName , String designDocId , String type ) { assertNotEmpty ( indexName , "indexName" ) ; assertNotEmpty ( designDocId , "designDocId" ) ; assertNotNull ( type , "type" ) ; if ( ! designDocId . startsWith ( "_design" ) ) { designDocId = "_design/" + designDocId ; } URI uri = new Dat... | Delete an index with the specified name and type in the given design document . |
27,695 | public < T > T find ( Class < T > classType , String id ) { return db . find ( classType , id ) ; } | Retrieve the document with the specified ID from the database and deserialize to an instance of the POJO of type T . |
27,696 | public DbInfo info ( ) { return client . couchDbClient . get ( new DatabaseURIHelper ( db . getDBUri ( ) ) . getDatabaseUri ( ) , DbInfo . class ) ; } | Get information about this database . |
27,697 | public PartitionInfo partitionInfo ( String partitionKey ) { if ( partitionKey == null ) { throw new UnsupportedOperationException ( "Cannot get partition information for null partition key." ) ; } URI uri = new DatabaseURIHelper ( db . getDBUri ( ) ) . partition ( partitionKey ) . build ( ) ; return client . couchDbCl... | Get information about a partition in this database . |
27,698 | public static Expression type ( String lhs , Type rhs ) { return new Expression ( lhs , "$type" , rhs . toString ( ) ) ; } | Check the document field s type and object |
27,699 | public static PredicateExpression nin ( Object ... rhs ) { PredicateExpression ex = new PredicateExpression ( "$nin" , rhs ) ; if ( rhs . length == 1 ) { ex . single = true ; } return ex ; } | The document field must not exist in the list provided |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.