idx int64 0 165k | question stringlengths 73 5.81k | target stringlengths 5 918 |
|---|---|---|
123,800 | protected void toggleTooltip ( Node reference ) { if ( reference instanceof Control ) { this . toggleTooltip ( reference , ( Control ) reference ) ; } } | Sets the error message as tooltip for the matching control and shows them below the same control . |
123,801 | protected void toggleTooltip ( Node reference , Control below ) { String fieldTooltip = field . getTooltip ( ) ; if ( ( reference . isFocused ( ) || reference . isHover ( ) ) && ( ! fieldTooltip . equals ( "" ) || field . getErrorMessages ( ) . size ( ) > 0 ) ) { tooltip . setText ( ( ! fieldTooltip . equals ( "" ) ? f... | Sets the error message as tooltip for the matching control . |
123,802 | protected void updateStyle ( PseudoClass pseudo , boolean newValue ) { if ( node != null ) { node . pseudoClassStateChanged ( pseudo , newValue ) ; } if ( fieldLabel != null ) { fieldLabel . pseudoClassStateChanged ( pseudo , newValue ) ; } } | Sets the css style for the defined properties . |
123,803 | private Callable createListToObjectBinding ( ListProperty < P > listProperty ) { return ( ) -> { if ( ! isListChange ( ) && listProperty . get ( ) != null && listProperty . get ( ) . size ( ) != 0 ) { return listProperty . get ( ) . get ( 0 ) ; } return null ; } ; } | Creates a function which handles binding between a ListProperty and an ObjectProperty . |
123,804 | public boolean isRedundant ( ) { if ( isListChange ( ) ) { return Objects . equals ( oldList . get ( ) , newList . get ( ) ) ; } return oldValue . get ( ) . equals ( newValue . get ( ) ) ; } | Compares newValue and oldValue to see if they are the same . If this is the case this change is redundant since it doesn t represent a true change . This can happen on compounded changes . |
123,805 | public void setupBreadCrumbBar ( ) { String [ ] stringArr = model . getDisplayedCategory ( ) . getBreadcrumb ( ) . split ( BREADCRUMB_DELIMITER ) ; Category [ ] categories = new Category [ stringArr . length ] ; categories [ 0 ] = searchCategory ( stringArr [ 0 ] ) ; for ( int i = 1 ; i < stringArr . length ; ++ i ) { ... | Sets up the BreadcrumbBar depending on the displayed category . |
123,806 | private Category searchCategory ( String breadcrumb ) { return model . getFlatCategoriesLst ( ) . stream ( ) . filter ( cat -> cat . getBreadcrumb ( ) . equals ( breadcrumb ) ) . findAny ( ) . orElse ( null ) ; } | Searches in all categories for the category that matches a breadcrumb . |
123,807 | public static Category of ( String description , Node itemIcon , Group ... groups ) { return new Category ( description , itemIcon , groups ) ; } | Creates a new category from groups . |
123,808 | public void createBreadcrumbs ( List < Category > categories ) { categories . forEach ( category -> { category . setBreadcrumb ( getBreadcrumb ( ) + BREADCRUMB_DELIMITER + category . getDescription ( ) ) ; if ( ! Objects . equals ( category . getGroups ( ) , null ) ) { category . getGroups ( ) . forEach ( group -> grou... | Creates and defines all of the breadcrumbs for all of the categories . |
123,809 | public void translate ( TranslationService translationService ) { if ( translationService == null ) { description . setValue ( descriptionKey . getValue ( ) ) ; return ; } if ( ! Strings . isNullOrEmpty ( descriptionKey . get ( ) ) ) { description . setValue ( translationService . translate ( descriptionKey . get ( ) )... | This internal method is used as a callback for when the translation service or its locale changes . Also applies the translation to all contained sections . |
123,810 | public OverviewStats add ( OverviewStats other ) { this . addFeaturesFailed ( other . getFeaturesFailed ( ) ) ; this . addFeaturesKnown ( other . getFeaturesKnown ( ) ) ; this . addFeaturesPassed ( other . getFeaturesPassed ( ) ) ; this . addFeaturesUndefined ( other . getFeaturesUndefined ( ) ) ; this . addScenariosFa... | Merges 2 overview statistic structures where all corresponding values are simply added to current object . |
123,811 | public OverviewStats valuate ( CucumberScenarioResult scenario ) { this . reset ( ) ; scenario . valuate ( ) ; this . addOverallDuration ( ( float ) scenario . getDuration ( ) ) ; this . addStepsPassed ( scenario . getPassed ( ) ) ; this . addStepsFailed ( scenario . getFailed ( ) ) ; this . addStepsKnown ( scenario . ... | Calculates overall statistics for specific scenario . |
123,812 | public OverviewStats valuate ( CucumberFeatureResult result ) { this . reset ( ) ; result . valuate ( ) ; this . addOverallDuration ( result . getDuration ( ) ) ; if ( result . getStatus ( ) . equals ( "passed" ) ) { this . addFeaturesPassed ( 1 ) ; } else if ( result . getStatus ( ) . equals ( "failed" ) ) { this . ad... | Calculates run statistics for the single feature result . |
123,813 | public OverviewStats valuate ( CucumberFeatureResult [ ] results ) { this . reset ( ) ; for ( CucumberFeatureResult result : results ) { result . valuate ( ) ; this . addOverallDuration ( result . getDuration ( ) ) ; OverviewStats stats = new OverviewStats ( ) ; stats . valuate ( result ) ; this . add ( stats ) ; } ret... | Calculates overall statistics for the group of features . |
123,814 | public void put ( final E e , final long timeStamp ) throws InterruptedException { final ReentrantLock lock = this . lock ; lock . lockInterruptibly ( ) ; try { while ( timeStamp - this . timeStamp > mask ) newSpaceAvailable . await ( ) ; final int timeOffset = ( int ) ( timeStamp - this . timeStamp ) ; assert a [ star... | Inserts an element with given timestamp waiting for space to become available if the timestamp of the element minus the current timestamp of the queue exceeds the queue capacity . |
123,815 | public E take ( ) throws InterruptedException { final ReentrantLock lock = this . lock ; lock . lockInterruptibly ( ) ; try { while ( a [ start ] == null ) nextObjectReady . await ( ) ; @ SuppressWarnings ( "unchecked" ) final E x = ( E ) a [ start ] ; a [ start ] = null ; start = start + 1 & mask ; -- count ; timeStam... | Returns the element with the next timestamp waiting until it is available . |
123,816 | public static ArrayList < Parser < ? > > parsersFromSpecs ( String [ ] specs ) throws IllegalArgumentException , ClassNotFoundException , IllegalAccessException , InvocationTargetException , InstantiationException , NoSuchMethodException , IOException { final ArrayList < Parser < ? > > parsers = new ArrayList < > ( ) ;... | Given an array of parser specifications it returns the corresponding list of parsers ( only the correct specifications are put in the list . |
123,817 | private static Configuration append ( Configuration base , Configuration additional ) { final CompositeConfiguration result = new CompositeConfiguration ( ) ; result . addConfiguration ( additional ) ; result . addConfiguration ( base ) ; return result ; } | Takes two configuration and returns their union with the second overriding the first . |
123,818 | public int get ( final byte [ ] array , final int offset , final int length ) { final long hash = MurmurHash3 . hash ( array , offset , length ) ; final ReadLock readLock = lock [ ( int ) ( hash >>> shift ) ] . readLock ( ) ; try { readLock . lock ( ) ; return stripe [ ( int ) ( hash >>> shift ) ] . get ( array , offse... | Gets the value of the counter associated with a given key . |
123,819 | public int addTo ( final byte [ ] array , final int offset , final int length , final int delta ) { final long hash = MurmurHash3 . hash ( array , offset , length ) ; final WriteLock writeLock = lock [ ( int ) ( hash >>> shift ) ] . writeLock ( ) ; try { writeLock . lock ( ) ; return stripe [ ( int ) ( hash >>> shift )... | Adds a value to the counter associated with a given key . |
123,820 | public int put ( final byte [ ] array , final int offset , final int length , final int value ) { final long hash = MurmurHash3 . hash ( array , offset , length ) ; final WriteLock writeLock = lock [ ( int ) ( hash >>> shift ) ] . writeLock ( ) ; try { writeLock . lock ( ) ; return stripe [ ( int ) ( hash >>> shift ) ]... | Sets the value associated with a given key . |
123,821 | public synchronized void add ( VisitState visitState ) { final boolean wasEntirelyBroken = isEntirelyBroken ( ) ; if ( visitState . lastExceptionClass != null ) brokenVisitStates ++ ; visitStates . add ( visitState ) ; assert brokenVisitStates <= visitStates . size ( ) ; if ( wasEntirelyBroken && ! isEntirelyBroken ( )... | Adds the given visit state to the visit - state queue . |
123,822 | public synchronized void setWorkbenchEntry ( final WorkbenchEntry workbenchEntry ) { assert ! acquired : this ; this . workbenchEntry = workbenchEntry ; if ( ! isEmpty ( ) ) workbenchEntry . add ( this , frontier . workbench ) ; } | Sets the workbench entry and put this visit state in its entry if it is nonempty . |
123,823 | public synchronized void putInEntryIfNotEmpty ( ) { assert workbenchEntry != null : this ; assert acquired : this ; assert workbenchEntry . acquired : workbenchEntry ; if ( ! isEmpty ( ) ) workbenchEntry . add ( this ) ; acquired = false ; } | Puts this visit state in its entry if it not empty . |
123,824 | public void enqueuePathQuery ( final byte [ ] pathQuery ) { synchronized ( this ) { if ( nextFetch == Long . MAX_VALUE ) return ; final boolean wasEmpty = pathQueries . isEmpty ( ) ; pathQueries . enqueue ( pathQuery ) ; if ( wasEmpty ) putInEntryIfNotAcquired ( ) ; } frontier . pathQueriesInQueues . incrementAndGet ( ... | Enqueues a path + query in byte - array representation possibly putting this visit state in its entry . |
123,825 | public byte [ ] dequeue ( ) { final byte [ ] array ; synchronized ( this ) { array = pathQueries . dequeue ( ) ; } if ( array != ROBOTS_PATH ) { frontier . pathQueriesInQueues . decrementAndGet ( ) ; frontier . weightOfpathQueriesInQueues . addAndGet ( - BURL . memoryUsageOf ( array ) ) ; } return array ; } | Removes the first path in the queue . |
123,826 | public int pathQueryLimit ( ) { final double delayRatio = Math . max ( 1 , ( frontier . rc . schemeAuthorityDelay + 1. ) / ( frontier . rc . ipDelay + 1. ) ) ; final double scalingFactor = workbenchEntry == null ? 1 : Math . max ( 1 , workbenchEntry . size ( ) / delayRatio ) ; return ( int ) Math . min ( 300000 / ( fro... | Returns an estimate of the number of path + queries that this visit state should keep in memory . |
123,827 | @ SuppressWarnings ( "deprecation" ) public final static HashFunction forName ( final String messageDigest ) throws NoSuchAlgorithmException { if ( "" . equals ( messageDigest ) ) return null ; if ( "MD5" . equalsIgnoreCase ( messageDigest ) ) return Hashing . md5 ( ) ; if ( "MurmurHash3" . equalsIgnoreCase ( messageDi... | Return the hash function corresponding to a given message - digest algorithm given by name . |
123,828 | protected void writeEntry ( final GZIPArchive . Entry entry ) throws IOException { this . output . write ( GZIPArchive . GZIP_START ) ; writeLEInt ( this . output , entry . mtime ) ; this . output . write ( GZIPArchive . XFL_OS ) ; writeLEShort ( this . output , GZIPArchive . XLEN ) ; this . output . write ( GZIPArchiv... | Writes the entry on the underlying stream . |
123,829 | public GZIPArchive . WriteEntry getEntry ( final String name , final String comment , final Date creationDate ) { crc . reset ( ) ; deflater . reset ( ) ; deflaterStream . reset ( ) ; final GZIPArchive . WriteEntry entry = new GZIPArchive . WriteEntry ( ) ; entry . setName ( name ) ; entry . setComment ( comment ) ; en... | Returns an object that can be used to write an entry in the GZIP archive . |
123,830 | private static void writeLEInt ( OutputStream out , int i ) throws IOException { out . write ( ( byte ) i ) ; out . write ( ( byte ) ( ( i >> 8 ) & 0xFF ) ) ; out . write ( ( byte ) ( ( i >> 16 ) & 0xFF ) ) ; out . write ( ( byte ) ( ( i >> 24 ) & 0xFF ) ) ; } | Writes the given integer in little - endian on the stream . |
123,831 | private static void writeLEShort ( OutputStream out , short s ) throws IOException { out . write ( ( byte ) s ) ; out . write ( ( byte ) ( ( s >> 8 ) & 0xFF ) ) ; } | Writes the given short in little - endian on the stream . |
123,832 | public static < T > ObjectDiskQueue < T > createNew ( final File file , final int bufferSize , final boolean direct ) throws IOException { return new ObjectDiskQueue < > ( ByteDiskQueue . createNew ( file , bufferSize , direct ) ) ; } | Creates a new disk - based queue of objects . |
123,833 | public static < T > ObjectDiskQueue < T > createFromFile ( final long size , final File file , final int bufferSize , final boolean direct ) throws IOException { final ObjectDiskQueue < T > byteArrayDiskQueue = new ObjectDiskQueue < > ( ByteDiskQueue . createFromFile ( file , bufferSize , direct ) ) ; byteArrayDiskQueu... | Creates a new disk - based queue of objects using an existing file . |
123,834 | public synchronized void enqueue ( final T o ) throws IOException { assert o != null ; fbaos . reset ( ) ; BinIO . storeObject ( o , fbaos ) ; byteDiskQueue . enqueueInt ( fbaos . length ) ; byteDiskQueue . enqueue ( fbaos . array , 0 , fbaos . length ) ; size ++ ; } | Enqueues an object to this queue . |
123,835 | @ SuppressWarnings ( "unchecked" ) public synchronized T dequeue ( ) throws IOException { final int length = byteDiskQueue . dequeueInt ( ) ; fbaos . array = ByteArrays . grow ( fbaos . array , length ) ; byteDiskQueue . dequeue ( fbaos . array , 0 , length ) ; size -- ; try { return ( T ) BinIO . loadObject ( new Fast... | Dequeues an object from the queue in FIFO fashion . |
123,836 | public void start ( long previousCrawlDuration ) { requestLogger . start ( previousCrawlDuration ) ; resourceLogger . start ( previousCrawlDuration ) ; transferredBytesLogger . start ( previousCrawlDuration ) ; receivedURLsLogger . start ( previousCrawlDuration ) ; } | Starst all progress loggers . |
123,837 | public void emit ( ) { requestLogger . setAndDisplay ( frontier . fetchedResources . get ( ) + frontier . fetchedRobots . get ( ) ) ; final long duplicates = frontier . duplicates . get ( ) ; final long archetypes = frontier . archetypes ( ) ; resourceLogger . setAndDisplay ( archetypes + duplicates ) ; transferredByte... | Emits the statistics . |
123,838 | private static int readLEInt ( InputStream in ) throws IOException { int i = in . read ( ) & 0xFF ; i |= ( in . read ( ) & 0xFF ) << 8 ; i |= ( in . read ( ) & 0xFF ) << 16 ; i |= ( in . read ( ) & 0xFF ) << 24 ; return i ; } | Reads an integer in little - endian from the stream . |
123,839 | private static short readLEShort ( InputStream in ) throws IOException { short s = ( byte ) in . read ( ) ; s |= ( byte ) in . read ( ) << 8 ; return s ; } | Reads a short in little - endian from the stream . |
123,840 | public static Header getFirstHeader ( final HeaderGroup headers , final WarcHeader . Name name ) { return headers . getFirstHeader ( name . value ) ; } | Returns the first header of given name . |
123,841 | public static boolean apply ( final char [ ] [ ] robotsFilter , final URI url ) { if ( robotsFilter . length == 0 ) return true ; final String pathQuery = BURL . pathAndQuery ( url ) ; int from = 0 ; int to = robotsFilter . length - 1 ; while ( from <= to ) { final int mid = ( from + to ) >>> 1 ; final int cmp = compar... | Checks whether a specified URL passes a specified robots filter . |
123,842 | public boolean apply ( final HttpResponse httpResponse ) { try { final InputStream content = httpResponse . getEntity ( ) . getContent ( ) ; int count = 0 ; for ( int i = BINARY_CHECK_SCAN_LENGTH ; i -- != 0 ; ) { final int b = content . read ( ) ; if ( b == - 1 ) return false ; if ( b == 0 && ++ count == THRESHOLD ) r... | This method implements a simple heuristic for guessing whether a page is binary . |
123,843 | public ByteArrayList fromStream ( final InputStream is ) throws IOException { final int length = Util . readVByte ( is ) ; buffer . size ( length ) ; final int actual = is . read ( buffer . elements ( ) , 0 , length ) ; if ( actual != length ) throw new IOException ( "Asked for " + length + " but got " + actual ) ; ret... | A serializer - deserializer for byte arrays that write the array length using variable - length byte encoding and the writes the content of the array . |
123,844 | public boolean add ( final VisitState v ) { int pos = ( int ) ( MurmurHash3 . hash ( v . schemeAuthority ) & mask ) ; while ( visitState [ pos ] != null ) { if ( Arrays . equals ( visitState [ pos ] . schemeAuthority , v . schemeAuthority ) ) return false ; pos = ( pos + 1 ) & mask ; } visitState [ pos ] = v ; if ( ++ ... | Adds a visit state to the set if necessary . |
123,845 | public boolean remove ( final VisitState k ) { int pos = ( int ) ( MurmurHash3 . hash ( k . schemeAuthority ) & mask ) ; while ( visitState [ pos ] != null ) { if ( visitState [ pos ] == k ) { size -- ; shiftKeys ( pos ) ; return true ; } pos = ( pos + 1 ) & mask ; } return false ; } | Removes a given visit state . |
123,846 | protected void rehash ( final int newN ) { int i = 0 , pos ; final VisitState [ ] visitState = this . visitState ; final int newMask = newN - 1 ; final VisitState [ ] newVisitState = new VisitState [ newN ] ; for ( int j = size ; j -- != 0 ; ) { while ( visitState [ i ] == null ) i ++ ; VisitState v = visitState [ i ] ... | Rehashes the state set to a new size . |
123,847 | public static ByteArrayDiskQueue createNew ( final File file , final int bufferSize , final boolean direct ) throws IOException { return new ByteArrayDiskQueue ( ByteDiskQueue . createNew ( file , bufferSize , direct ) ) ; } | Creates a new disk - based queue of byte arrays . |
123,848 | public static ByteArrayDiskQueue createFromFile ( final long size , final File file , final int bufferSize , final boolean direct ) throws IOException { final ByteArrayDiskQueue byteArrayDiskQueue = new ByteArrayDiskQueue ( ByteDiskQueue . createFromFile ( file , bufferSize , direct ) ) ; byteArrayDiskQueue . size = si... | Creates a new disk - based queue of byte arrays using an existing file . |
123,849 | public synchronized void enqueue ( final byte [ ] array ) throws IOException { assert array != null ; byteDiskQueue . enqueueInt ( array . length ) ; byteDiskQueue . enqueue ( array ) ; size ++ ; } | Enqueues a byte array to this queue . |
123,850 | public static < T > Filter < T > and ( final Filter < T > ... f ) { return new Filter < T > ( ) { public boolean apply ( final T x ) { for ( final Filter < T > filter : f ) if ( ! filter . apply ( x ) ) return false ; return true ; } public String toString ( ) { return "(" + StringUtils . join ( f , " and " ) + ")" ; }... | Produces the conjunction of the given filters . |
123,851 | public static < T > Filter < T > not ( final Filter < T > filter ) { return new AbstractFilter < T > ( ) { public boolean apply ( final T x ) { return ! filter . apply ( x ) ; } public String toString ( ) { return "(not " + filter + ")" ; } public Filter < T > copy ( ) { return not ( filter . copy ( ) ) ; } } ; } | Produces the negation of the given filter . |
123,852 | @ SuppressWarnings ( "unchecked" ) public static < T > Filter < T > getFilterFromSpec ( String className , String spec , Class < T > tClass ) throws ParseException { String filterClassName ; if ( className . indexOf ( '.' ) >= 0 ) filterClassName = className ; else filterClassName = Filter . FILTER_PACKAGE_NAME + "." +... | Creates a filter from a filter class name and an external form . |
123,853 | public static File createHierarchicalTempFile ( final File baseDirectory , final int pathElements , final String prefix , final String suffix ) throws IOException { if ( ! baseDirectory . isDirectory ( ) ) throw new IllegalArgumentException ( baseDirectory + " is not a directory." ) ; if ( pathElements < 0 || pathEleme... | Creates a temporary file with a random hierachical path . |
123,854 | public final static void writeByteArray ( final byte [ ] a , final ObjectOutputStream s ) throws IOException { writeVByte ( a . length , s ) ; s . write ( a ) ; } | Writes a byte array prefixed by its length encoded using vByte . |
123,855 | public final static byte [ ] readByteArray ( final ObjectInputStream s ) throws IOException { final byte [ ] a = new byte [ readVByte ( s ) ] ; s . readFully ( a ) ; return a ; } | Reads a byte array prefixed by its length encoded using vByte . |
123,856 | public static byte [ ] toByteArray ( final String s ) { final byte [ ] byteArray = new byte [ s . length ( ) ] ; for ( int i = s . length ( ) ; i -- != 0 ; ) { assert s . charAt ( i ) < ( char ) 0x80 : s . charAt ( i ) ; byteArray [ i ] = ( byte ) s . charAt ( i ) ; } return byteArray ; } | Returns a byte - array representation of an ASCII string . |
123,857 | public static OutputStream toOutputStream ( final String s , final OutputStream os ) throws IOException { final int length = s . length ( ) ; for ( int i = 0 ; i < length ; i ++ ) { assert s . charAt ( i ) < ( char ) 0x100 : s . charAt ( i ) ; os . write ( s . charAt ( i ) ) ; } return os ; } | Writes a string to an output stream discarding higher order bits . |
123,858 | public boolean add ( final WorkbenchEntry e ) { int pos = hashCode ( e . ipAddress ) & mask ; while ( workbenchEntry [ pos ] != null ) { if ( Arrays . equals ( workbenchEntry [ pos ] . ipAddress , e . ipAddress ) ) return false ; pos = ( pos + 1 ) & mask ; } workbenchEntry [ pos ] = e ; if ( ++ size >= maxFill && n < (... | Adds a workbench entry to the set if necessary . |
123,859 | public boolean remove ( final WorkbenchEntry e ) { int pos = hashCode ( e . ipAddress ) & mask ; while ( workbenchEntry [ pos ] != null ) { if ( workbenchEntry [ pos ] == e ) { size -- ; shiftKeys ( pos ) ; return true ; } pos = ( pos + 1 ) & mask ; } return false ; } | Removes a given workbench entry . |
123,860 | public WorkbenchEntry get ( final byte [ ] address ) { int pos = hashCode ( address ) & mask ; while ( workbenchEntry [ pos ] != null ) { if ( Arrays . equals ( workbenchEntry [ pos ] . ipAddress , address ) ) return workbenchEntry [ pos ] ; pos = ( pos + 1 ) & mask ; } return null ; } | Returns the entry for a given IP address . |
123,861 | protected void rehash ( final int newN ) { int i = 0 , pos ; final WorkbenchEntry [ ] workbenchEntry = this . workbenchEntry ; final int newMask = newN - 1 ; final WorkbenchEntry [ ] newWorkbenchEntry = new WorkbenchEntry [ newN ] ; for ( int j = size ; j -- != 0 ; ) { while ( workbenchEntry [ i ] == null ) i ++ ; Work... | Rehashes the set to a new size . |
123,862 | public int dequeuePathQueries ( final VisitState visitState , final int maxUrls ) throws IOException { if ( maxUrls == 0 ) return 0 ; final int dequeued = ( int ) Math . min ( maxUrls , byteArrayDiskQueues . count ( visitState ) ) ; for ( int i = dequeued ; i -- != 0 ; ) visitState . enqueuePathQuery ( byteArrayDiskQue... | Dequeues at most the given number of path + queries into the given visit state . |
123,863 | public void enqueueURL ( VisitState visitState , final ByteArrayList url ) throws IOException { final byte [ ] urlBuffer = url . elements ( ) ; final int pathQueryStart = BURL . startOfpathAndQuery ( urlBuffer ) ; byteArrayDiskQueues . enqueue ( visitState , urlBuffer , pathQueryStart , url . size ( ) - pathQueryStart ... | Enqueues the given URL as a path + query associated to the scheme + authority of the given visit state . |
123,864 | public void collectIf ( final double threshold , final double targetRatio ) throws IOException { if ( byteArrayDiskQueues . ratio ( ) < threshold ) { LOGGER . info ( "Starting collection..." ) ; byteArrayDiskQueues . collect ( targetRatio ) ; LOGGER . info ( "Completed collection." ) ; } } | Performs a garbage collection if the space used is below a given threshold reaching a given target ratio . |
123,865 | public synchronized void add ( double x ) { final double oldA = a ; a += ( x - a ) / ++ size ; q += ( x - a ) * ( x - oldA ) ; min = Math . min ( min , x ) ; max = Math . max ( max , x ) ; } | Adds a value to the stream . |
123,866 | public void add ( WorkbenchEntry entry ) { assert ! entry . isEmpty ( ) : entry ; assert ! entry . acquired : entry ; entries . add ( entry ) ; approximatedSize . incrementAndGet ( ) ; } | Adds a nonempty not acquired workbench entry to the workbench . |
123,867 | public VisitState acquire ( ) throws InterruptedException { final WorkbenchEntry entry = entries . take ( ) ; assert ! entry . isEmpty ( ) ; assert ! entry . acquired ; entry . acquired = true ; final VisitState visitState = entry . remove ( ) ; assert visitState . workbenchEntry == entry ; assert ! visitState . isEmpt... | Acquires a visit state for a scheme + authority accessible by politeness . Note that this is a blocking method that will wait until such a state is available . |
123,868 | public boolean apply ( final WarcRecord x ) { Header messageType = x . getWarcHeader ( WarcHeader . Name . CONTENT_TYPE ) ; return ( x . getWarcType ( ) == WarcRecord . Type . RESPONSE ) && ( messageType != null && messageType . getValue ( ) . equals ( HttpResponseWarcRecord . HTTP_RESPONSE_MSGTYPE ) ) ; } | Apply the filter to a WarcRecord |
123,869 | public boolean apply ( final WarcRecord x ) { Header s = x . getWarcHeader ( WarcHeader . Name . WARC_PAYLOAD_DIGEST ) ; return s != null && Arrays . equals ( digest , Util . fromHexString ( s . getValue ( ) ) ) ; } | Apply the filter to a given WarcRecord |
123,870 | public boolean cancel ( boolean ignored ) { boolean cancelled = false ; if ( latch . getCount ( ) == 1 ) { latch . countDown ( ) ; output = null ; cancelled = true ; } return cancelled ; } | Cancel the command and notify any waiting consumers . This does not cause the redis server to stop executing the command . |
123,871 | public T get ( ) { try { latch . await ( ) ; return output . get ( ) ; } catch ( InterruptedException e ) { throw new RedisCommandInterruptedException ( e ) ; } } | Get the command output and if the command hasn t completed yet wait until it does . |
123,872 | public T get ( long timeout , TimeUnit unit ) throws TimeoutException { try { if ( ! latch . await ( timeout , unit ) ) { throw new TimeoutException ( "Command timed out" ) ; } } catch ( InterruptedException e ) { throw new RedisCommandInterruptedException ( e ) ; } return output . get ( ) ; } | Get the command output and if the command hasn t completed yet wait up to the specified time until it does . |
123,873 | protected static void writeInt ( ChannelBuffer buf , int value ) { if ( value < 10 ) { buf . writeByte ( '0' + value ) ; return ; } StringBuilder sb = new StringBuilder ( 8 ) ; while ( value > 0 ) { int digit = value % 10 ; sb . append ( ( char ) ( '0' + digit ) ) ; value /= 10 ; } for ( int i = sb . length ( ) - 1 ; i... | Write the textual value of a positive integer to the supplied buffer . |
123,874 | public static byte [ ] decode ( char [ ] src ) { byte [ ] dst = new byte [ src . length / 2 ] ; for ( int si = 0 , di = 0 ; di < dst . length ; di ++ ) { byte high = decode [ src [ si ++ ] & 0x7f ] ; byte low = decode [ src [ si ++ ] & 0x7f ] ; dst [ di ] = ( byte ) ( ( high << 4 ) + low ) ; } return dst ; } | Decode base16 chars to bytes . |
123,875 | public int getNumberBetween ( final int min , final int max ) { if ( max < min ) { throw new IllegalArgumentException ( String . format ( "Minimum must be less than minimum (min=%d, max=%d)" , min , max ) ) ; } if ( max == min ) { return min ; } return min + random . nextInt ( max - min ) ; } | Returns a number betwen min and max |
123,876 | public Date getDateBetween ( final Date minDate , final Date maxDate ) { long seconds = ( maxDate . getTime ( ) - minDate . getTime ( ) ) / 1000 ; seconds = ( long ) ( random . nextDouble ( ) * seconds ) ; Date result = new Date ( ) ; result . setTime ( minDate . getTime ( ) + ( seconds * 1000 ) ) ; return result ; } | Returns a random date between two dates . This method will alter the time component of the dates |
123,877 | public String getRandomText ( final int minLength , final int maxLength ) { validateMinMaxParams ( minLength , maxLength ) ; StringBuilder sb = new StringBuilder ( maxLength ) ; int length = minLength ; if ( maxLength != minLength ) { length = length + random . nextInt ( maxLength - minLength ) ; } while ( length > 0 )... | Returns random text made up of english words |
123,878 | public String getRandomWord ( final int minLength , final int maxLength ) { validateMinMaxParams ( minLength , maxLength ) ; if ( maxLength == 1 ) { if ( chance ( 50 ) ) { return "a" ; } return "I" ; } String [ ] words = contentDataValues . getWords ( ) ; int pos = random . nextInt ( words . length ) ; for ( int i = 0 ... | Returns a valid word based on the length range passed in . The length will always be between the min and max length range inclusive . |
123,879 | public String getNumberText ( final int digits ) { String result = "" ; for ( int i = 0 ; i < digits ; i ++ ) { result = result + random . nextInt ( 10 ) ; } return result ; } | Returns a string containing a set of numbers with a fixed number of digits |
123,880 | public String getEmailAddress ( ) { int test = random . nextInt ( 100 ) ; String email = "" ; if ( test < 50 ) { email = getFirstName ( ) . charAt ( 0 ) + getLastName ( ) ; } else { email = getItem ( contentDataValues . getWords ( ) ) + getItem ( contentDataValues . getWords ( ) ) ; } if ( random . nextInt ( 100 ) > 80... | Generates an email address |
123,881 | public void setBinaryStream ( int parameterIndex , InputStream inputStream , int length ) throws SQLException { if ( length <= 0 ) { throw new SQLException ( "Invalid length " + length ) ; } if ( inputStream == null ) { throw new SQLException ( "Input Stream cannot be null" ) ; } final int bufferSize = 8192 ; byte [ ] ... | Set the parameter from the contents of a binary stream . |
123,882 | public void setBinaryStream ( int parameterIndex , InputStream inputStream , long length ) throws SQLException { if ( length > Integer . MAX_VALUE ) { throw new SQLException ( "SQLDroid does not allow input stream data greater than " + Integer . MAX_VALUE ) ; } setBinaryStream ( parameterIndex , inputStream , ( int ) l... | This is a pass through to the integer version of the same method . That is the long is downcast to an integer . If the length is greater than Integer . MAX_VALUE this method will throw a SQLException . |
123,883 | private String escape ( final String val ) { int len = val . length ( ) ; StringBuilder buf = new StringBuilder ( len ) ; for ( int i = 0 ; i < len ; i ++ ) { if ( val . charAt ( i ) == '\'' ) { buf . append ( '\'' ) ; } buf . append ( val . charAt ( i ) ) ; } return buf . toString ( ) ; } | Applies SQL escapes for special characters in a given string . |
123,884 | public void free ( ) throws SQLException { if ( freed ) { return ; } string = null ; if ( reader != null ) { reader . close ( ) ; } if ( inputStream != null ) { try { inputStream . close ( ) ; } catch ( IOException ioe ) { } } freed = true ; } | Free the Blob object and releases the resources that it holds . The object is invalid once the free method is called . |
123,885 | protected boolean isLockedException ( SQLiteException maybeLocked ) { try { if ( Class . forName ( "android.database.sqlite.SQLiteDatabaseLockedException" , false , getClass ( ) . getClassLoader ( ) ) . isAssignableFrom ( maybeLocked . getClass ( ) ) ) { return true ; } } catch ( ClassNotFoundException e ) { } return f... | Returns true if the exception is an instance of SQLiteDatabaseLockedException . Since this exception does not exist in APIs below 11 this code uses reflection to check the exception type . |
123,886 | public Cursor rawQuery ( String sql , String [ ] makeArgListQueryString ) throws SQLException { Log . v ( "SQLiteDatabase rawQuery: " + Thread . currentThread ( ) . getId ( ) + " \"" + Thread . currentThread ( ) . getName ( ) + "\" " + sql ) ; long timeNow = System . currentTimeMillis ( ) ; long delta = 0 ; do { try { ... | Proxy for the rawQuery command . |
123,887 | public void execNoArgVoidMethod ( Transaction transaction ) throws SQLException { long timeNow = System . currentTimeMillis ( ) ; long delta = 0 ; do { try { switch ( transaction ) { case setTransactionSuccessful : sqliteDatabase . setTransactionSuccessful ( ) ; return ; case beginTransaction : sqliteDatabase . beginTr... | Executes one of the methods in the transactions enum . This just allows the timeout code to be combined in one method . |
123,888 | public int changedRowCount ( ) { if ( getChangedRowCount == null ) { try { getChangedRowCount = sqliteDatabase . getClass ( ) . getMethod ( "changedRowCount" , ( Class < ? > [ ] ) null ) ; } catch ( Exception any ) { try { getChangedRowCount = sqliteDatabase . getClass ( ) . getDeclaredMethod ( "lastChangeCount" , ( Cl... | The count of changed rows . On JNA platforms this is a call to sqlite3_changes On Android it s a convoluted call to a package - private method ( or if that fails the response is 1 . |
123,889 | public static SQLException chainException ( android . database . SQLException sqlException ) { if ( sqlThrowable < 0 || sqlThrowable >= 9 ) { try { sqlThrowable = 9 ; final Constructor < ? > c = SQLException . class . getDeclaredConstructor ( new Class [ ] { Throwable . class } ) ; return ( SQLException ) c . newInstan... | This will create and return an exception . For API levels less than 9 this will return a SQLDroidSQLException for later APIs it will return a SQLException . |
123,890 | public void attachInfo ( Context context , ProviderInfo info ) { super . attachInfo ( context , info ) ; if ( info . exported ) { throw new SecurityException ( "Provider must not be exported" ) ; } if ( ! info . grantUriPermissions ) { throw new SecurityException ( "Provider must grant uri permissions" ) ; } mStrategy ... | After the FileProvider is instantiated this method is called to provide the system with information about the provider . |
123,891 | public static void cleanUp ( Context context ) { File path = getScreenshotFolder ( context ) ; if ( ! path . exists ( ) ) { return ; } delete ( path ) ; } | Delete the screenshot folder for this app . Be careful not to call this before any intents have finished using a screenshot reference . |
123,892 | private static void delete ( File file ) { if ( file . isDirectory ( ) ) { File [ ] files = file . listFiles ( ) ; if ( files != null ) { for ( File child : files ) { delete ( child ) ; } } } file . delete ( ) ; } | Recursive delete of a file or directory . |
123,893 | public static Drawable getCompatDrawable ( Context c , int drawableRes ) { Drawable d = null ; try { if ( Build . VERSION . SDK_INT < Build . VERSION_CODES . LOLLIPOP ) { d = c . getResources ( ) . getDrawable ( drawableRes ) ; } else { d = c . getResources ( ) . getDrawable ( drawableRes , c . getTheme ( ) ) ; } } cat... | helper method to get the drawable by its resource . specific to the correct android version |
123,894 | public static int getThemeAttributeDimensionSize ( Context context , int attr ) { TypedArray a = null ; try { a = context . getTheme ( ) . obtainStyledAttributes ( new int [ ] { attr } ) ; return a . getDimensionPixelSize ( 0 , 0 ) ; } finally { if ( a != null ) { a . recycle ( ) ; } } } | Returns the size in pixels of an attribute dimension |
123,895 | private boolean isMobileNetworkEnabled ( ConnectivityManager connectivityManager ) { final NetworkInfo info = connectivityManager . getNetworkInfo ( ConnectivityManager . TYPE_MOBILE ) ; return ( info != null && info . isConnected ( ) ) ; } | True if mobile network enabled |
123,896 | public void closeDrawer ( ) { if ( drawerLayout != null ) { if ( drawerGravity != 0 ) { drawerLayout . closeDrawer ( drawerGravity ) ; } else { drawerLayout . closeDrawer ( sliderLayout ) ; } } } | close the drawer |
123,897 | public void save ( OnSaveLogListener listener ) { File dir = getLogDir ( ) ; if ( dir == null ) { listener . onError ( "Can't save logs. External storage is not mounted. " + "Check android.permission.WRITE_EXTERNAL_STORAGE permission" ) ; return ; } FileWriter fileWriter = null ; try { File output = new File ( dir , ge... | Save the current logs to disk . |
123,898 | void unregisterReceiver ( ) { try { final Context context = contextRef . get ( ) ; if ( context != null ) { context . unregisterReceiver ( receiver ) ; } } catch ( IllegalArgumentException e ) { } } | Unregister network state broadcast receiver |
123,899 | void registerReceiver ( ) { if ( receiver == null ) { receiver = new NetworkReceiver ( new Listener ( ) { public void post ( NetworkChangeEvent event ) { if ( onNetworkChangedListener != null ) { onNetworkChangedListener . onChanged ( event ) ; } } } ) ; } final Context context = contextRef . get ( ) ; if ( context != ... | Register network state broadcast receiver |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.