idx int64 0 165k | question stringlengths 73 4.15k | target stringlengths 5 918 | len_question int64 21 890 | len_target int64 3 255 |
|---|---|---|---|---|
40,500 | public static Path getJarPathFromUrl ( URL jarUrl ) { try { String pathString = jarUrl . getPath ( ) ; // for Jar URL, the path is in the form of: file:/path/to/groovy/myJar.jar!/path/to/resource/myResource.txt int endIndex = pathString . lastIndexOf ( "!" ) ; return Paths . get ( new URI ( pathString . substring ( 0 ,... | Find the jar containing the given resource . | 141 | 8 |
40,501 | public static Set < String > scanClassPath ( final String classPath , final Set < String > excludeJarSet ) { final Set < String > pathSet = new HashSet < String > ( ) ; // Defer to JDKPaths to do the actual classpath scanning. __JDKPaths . processClassPathItem ( classPath , excludeJarSet , pathSet ) ; return pathSet ; ... | Scan the classpath string provided and collect a set of package paths found in jars and classes on the path . | 85 | 22 |
40,502 | public static Set < String > scanClassPath ( final String classPath , final Set < String > excludeJarSet , final Set < String > excludePrefixes , final Set < String > includePrefixes ) { final Set < String > pathSet = new HashSet < String > ( ) ; // Defer to JDKPaths to do the actual classpath scanning. __JDKPaths . pr... | Scan the classpath string provided and collect a set of package paths found in jars and classes on the path . On the resulting path set first exclude those that match any exclude prefixes and then include those that match a set of include prefixes . | 120 | 49 |
40,503 | public static Set < String > scanClassPathWithExcludes ( final String classPath , final Set < String > excludeJarSet , final Set < String > excludePrefixes ) { final Set < String > pathSet = new HashSet < String > ( ) ; // Defer to JDKPaths to do the actual classpath scanning. __JDKPaths . processClassPathItem ( classP... | Scan the classpath string provided and collect a set of package paths found in jars and classes on the path excluding any that match a set of exclude prefixes . | 118 | 32 |
40,504 | public static Set < String > scanClassPathWithIncludes ( final String classPath , final Set < String > excludeJarSet , final Set < String > includePrefixes ) { final Set < String > pathSet = new HashSet < String > ( ) ; // Defer to JDKPaths to do the actual classpath scanning. __JDKPaths . processClassPathItem ( classP... | Scan the classpath string provided and collect a set of package paths found in jars and classes on the path including only those that match a set of include prefixes . | 117 | 33 |
40,505 | public void addClasses ( Set < Class < ? > > classes ) { for ( Class < ? > classToAdd : classes ) { localClassCache . put ( classToAdd . getName ( ) , classToAdd ) ; } } | Manually add the compiled classes to this classloader . This method will not redefine the class so that the class s classloader will continue to be compiler s classloader . | 51 | 35 |
40,506 | public Class < ? > addClassBytes ( String name , byte [ ] classBytes ) { Class < ? > newClass = defineClass ( name , classBytes , 0 , classBytes . length ) ; resolveClass ( newClass ) ; localClassCache . put ( newClass . getName ( ) , newClass ) ; return newClass ; } | Manually add the compiled classes to this classloader . This method will define and resolve the class binding this classloader to the class . | 72 | 27 |
40,507 | public boolean addRepository ( final ArchiveRepository archiveRepository , final int pollInterval , TimeUnit timeUnit , boolean waitForInitialPoll ) { if ( pollInterval <= 0 ) { throw new IllegalArgumentException ( "invalid pollInterval " + pollInterval ) ; } Objects . requireNonNull ( timeUnit , "timeUnit" ) ; Reposit... | Add a repository and schedule polling | 309 | 6 |
40,508 | public static Path getGroovyRuntime ( ) { Path path = ClassPathUtils . findRootPathForResource ( "META-INF/groovy-release-info.properties" , ExampleResourceLocator . class . getClassLoader ( ) ) ; if ( path == null ) { throw new IllegalStateException ( "couldn't find groovy-all.n.n.n.jar in the classpath." ) ; } return... | Locate the groovy - all - n . n . n . jar file on the classpath . | 97 | 21 |
40,509 | public static Path getGroovyPluginLocation ( ) { String resourceName = ClassPathUtils . classNameToResourceName ( GROOVY2_COMPILER_PLUGIN_CLASS ) ; Path path = ClassPathUtils . findRootPathForResource ( resourceName , ExampleResourceLocator . class . getClassLoader ( ) ) ; if ( path == null ) { throw new IllegalStateEx... | Locate the classpath root which contains the groovy2 plugin . | 110 | 14 |
40,510 | public static void populateModuleSpecWithCoreDependencies ( ModuleSpec . Builder moduleSpecBuilder , ScriptArchive scriptArchive ) throws ModuleLoadException { Objects . requireNonNull ( moduleSpecBuilder , "moduleSpecBuilder" ) ; Objects . requireNonNull ( scriptArchive , "scriptArchive" ) ; Set < String > compilerPlu... | Populates a module spec builder with core dependencies on JRE Nicobar itself and compiler plugins . | 222 | 19 |
40,511 | public static ModuleIdentifier createRevisionId ( ModuleId scriptModuleId , long revisionNumber ) { Objects . requireNonNull ( scriptModuleId , "scriptModuleId" ) ; return ModuleIdentifier . create ( scriptModuleId . toString ( ) , Long . toString ( revisionNumber ) ) ; } | Helper method to create a revisionId in a consistent manner | 65 | 11 |
40,512 | private static PathFilter buildFilters ( Set < String > filterPaths , boolean failedMatchValue ) { if ( filterPaths == null ) return PathFilters . acceptAll ( ) ; else if ( filterPaths . isEmpty ( ) ) { return PathFilters . rejectAll ( ) ; } else { MultiplePathFilterBuilder builder = PathFilters . multiplePathFilterBui... | Build a PathFilter for a set of filter paths | 130 | 10 |
40,513 | public void unloadAllModuleRevision ( String scriptModuleId ) { for ( ModuleIdentifier revisionId : getAllRevisionIds ( scriptModuleId ) ) { if ( revisionId . getName ( ) . equals ( scriptModuleId ) ) { unloadModule ( revisionId ) ; } } } | Unload all module revisions with the give script module id | 65 | 11 |
40,514 | public void unloadModule ( ModuleIdentifier revisionId ) { Objects . requireNonNull ( revisionId , "revisionId" ) ; Module module = findLoadedModule ( revisionId ) ; if ( module != null ) { unloadModule ( module ) ; } } | Unload the given revision of a module from the local repository . | 57 | 13 |
40,515 | public Set < ModuleIdentifier > getAllRevisionIds ( String scriptModuleId ) { Objects . requireNonNull ( scriptModuleId , "scriptModuleId" ) ; Set < ModuleIdentifier > revisionIds = new LinkedHashSet < ModuleIdentifier > ( ) ; for ( ModuleIdentifier revisionId : moduleSpecs . keySet ( ) ) { if ( revisionId . getName ( ... | Find all module revisionIds with a common name | 122 | 10 |
40,516 | public DirectedGraph < ModuleId , DefaultEdge > getModuleNameGraph ( ) { SimpleDirectedGraph < ModuleId , DefaultEdge > graph = new SimpleDirectedGraph < ModuleId , DefaultEdge > ( DefaultEdge . class ) ; Map < ModuleId , ModuleIdentifier > moduleIdentifiers = getLatestRevisionIds ( ) ; GraphUtils . addAllVertices ( gr... | Construct the Module dependency graph of a module loader where each vertex is the module name | 203 | 16 |
40,517 | public static Set < ModuleId > getDependencyScriptModuleIds ( ModuleSpec moduleSpec ) { Objects . requireNonNull ( moduleSpec , "moduleSpec" ) ; if ( ! ( moduleSpec instanceof ConcreteModuleSpec ) ) { throw new IllegalArgumentException ( "Unsupported ModuleSpec implementation: " + moduleSpec . getClass ( ) . getName ( ... | Extract the Module dependencies for the given module in the form of ScriptModule ids . | 206 | 18 |
40,518 | private static char [ ] encode ( final byte [ ] data , final char [ ] toDigits ) { final int l = data . length ; final char [ ] out = new char [ l << 1 ] ; // two characters form the hex value. for ( int i = 0 , j = 0 ; i < l ; i ++ ) { out [ j ++ ] = toDigits [ ( 0xF0 & data [ i ] ) >>> 4 ] ; out [ j ++ ] = toDigits [... | Converts an array of bytes into an array of characters representing the hexadecimal values of each byte in order . The returned array will be double the length of the passed array as it takes two characters to represent any given byte . | 122 | 47 |
40,519 | public void trackers ( List < String > value ) { string_vector v = new string_vector ( ) ; for ( String s : value ) { v . push_back ( s ) ; } p . set_trackers ( v ) ; } | If the torrent doesn t have a tracker but relies on the DHT to find peers this method can specify tracker URLs for the torrent . | 53 | 27 |
40,520 | public static AddTorrentParams parseMagnetUri ( String uri ) { error_code ec = new error_code ( ) ; add_torrent_params params = add_torrent_params . parse_magnet_uri ( uri , ec ) ; if ( ec . value ( ) != 0 ) { throw new IllegalArgumentException ( "Invalid magnet uri: " + ec . message ( ) ) ; } return new AddTorrentPara... | Helper function to parse a magnet uri and fill the parameters . | 102 | 13 |
40,521 | public void stop ( ) { if ( session == null ) { return ; } sync . lock ( ) ; try { if ( session == null ) { return ; } onBeforeStop ( ) ; session s = session ; session = null ; // stop alerts loop and session methods // guarantee one more alert is post and detected s . post_session_stats ( ) ; try { // 250 is to ensure... | This method blocks during the destruction of the native session it could take some time don t call this from the UI thread or other sensitive multithreaded code . | 182 | 32 |
40,522 | public void restart ( ) { sync . lock ( ) ; try { stop ( ) ; Thread . sleep ( 1000 ) ; // allow some time to release native resources start ( ) ; } catch ( InterruptedException e ) { // ignore } finally { sync . unlock ( ) ; } } | This method blocks for at least a second plus the time needed to destroy the native session don t call it from the UI thread . | 59 | 26 |
40,523 | public void download ( String magnetUri , File saveDir ) { if ( session == null ) { return ; } error_code ec = new error_code ( ) ; add_torrent_params p = add_torrent_params . parse_magnet_uri ( magnetUri , ec ) ; if ( ec . value ( ) != 0 ) { throw new IllegalArgumentException ( ec . message ( ) ) ; } sha1_hash info_ha... | Downloads a magnet uri . | 236 | 7 |
40,524 | public ArrayList < TcpEndpoint > peers ( ) { tcp_endpoint_vector v = alert . peers ( ) ; int size = ( int ) v . size ( ) ; ArrayList < TcpEndpoint > peers = new ArrayList <> ( size ) ; for ( int i = 0 ; i < size ; i ++ ) { tcp_endpoint endp = v . get ( i ) ; String ip = new Address ( endp . address ( ) ) . toString ( )... | This method creates a new list each time is called . | 134 | 11 |
40,525 | public ArrayList < Pair < String , String > > extraHeaders ( ) { string_string_pair_vector v = e . getExtra_headers ( ) ; int size = ( int ) v . size ( ) ; ArrayList < Pair < String , String > > l = new ArrayList <> ( size ) ; for ( int i = 0 ; i < size ; i ++ ) { string_string_pair p = v . get ( i ) ; l . add ( new Pa... | Any extra HTTP headers that need to be passed to the web seed . | 127 | 14 |
40,526 | private void tick ( long tickIntervalMs ) { for ( int i = 0 ; i < NUM_AVERAGES ; ++ i ) { stat [ i ] . tick ( tickIntervalMs ) ; } } | should be called once every second | 45 | 6 |
40,527 | public List < TorrentHandle > torrents ( ) { torrent_handle_vector v = s . get_torrents ( ) ; int size = ( int ) v . size ( ) ; ArrayList < TorrentHandle > l = new ArrayList <> ( size ) ; for ( int i = 0 ; i < size ; i ++ ) { l . add ( new TorrentHandle ( v . get ( i ) ) ) ; } return l ; } | Returns a list of torrent handles to all the torrents currently in the session . | 94 | 16 |
40,528 | public void dhtPutItem ( byte [ ] publicKey , byte [ ] privateKey , Entry entry , byte [ ] salt ) { s . dht_put_item ( Vectors . bytes2byte_vector ( publicKey ) , Vectors . bytes2byte_vector ( privateKey ) , entry . swig ( ) , Vectors . bytes2byte_vector ( salt ) ) ; } | calling the callback in between is convenient . | 87 | 8 |
40,529 | public String filePath ( int index , String savePath ) { // not calling the corresponding swig function because internally, // the use of the function GetStringUTFChars does not consider the case of // a copy not made return savePath + File . separator + fs . file_path ( index ) ; } | returns the full path to a file . | 65 | 9 |
40,530 | public ArrayList < DhtRoutingBucket > routingTable ( ) { dht_routing_bucket_vector v = alert . getRouting_table ( ) ; int size = ( int ) v . size ( ) ; ArrayList < DhtRoutingBucket > l = new ArrayList <> ( size ) ; for ( int i = 0 ; i < size ; i ++ ) { l . add ( new DhtRoutingBucket ( v . get ( i ) ) ) ; } return l ; } | Contains information about every bucket in the DHT routing table . | 112 | 13 |
40,531 | public SettingsPack connectionsLimit ( int value ) { sp . set_int ( settings_pack . int_types . connections_limit . swigValue ( ) , value ) ; return this ; } | Sets a global limit on the number of connections opened . The number of connections is set to a hard minimum of at least two per torrent so if you set a too low connections limit and open too many torrents the limit will not be met . | 41 | 50 |
40,532 | public SettingsPack maxPeerlistSize ( int value ) { sp . set_int ( settings_pack . int_types . max_peerlist_size . swigValue ( ) , value ) ; return this ; } | Sets the maximum number of peers in the list of known peers . These peers are not necessarily connected so this number should be much greater than the maximum number of connected peers . Peers are evicted from the cache when the list grows passed 90% of this limit and once the size hits the limit peers are no longer ad... | 47 | 92 |
40,533 | public SettingsPack inactivityTimeout ( int value ) { sp . set_int ( settings_pack . int_types . inactivity_timeout . swigValue ( ) , value ) ; return this ; } | if a peer is uninteresting and uninterested for longer than this number of seconds it will be disconnected . default is 10 minutes | 43 | 25 |
40,534 | public SettingsPack enableDht ( boolean value ) { sp . set_bool ( settings_pack . bool_types . enable_dht . swigValue ( ) , value ) ; return this ; } | Starts the dht node and makes the trackerless service available to torrents . | 43 | 17 |
40,535 | public SettingsPack upnpIgnoreNonRouters ( boolean value ) { sp . set_bool ( settings_pack . bool_types . upnp_ignore_nonrouters . swigValue ( ) , value ) ; return this ; } | Indicates whether or not the UPnP implementation should ignore any broadcast response from a device whose address is not the configured router for this machine . i . e . it s a way to not talk to other people s routers by mistake . | 52 | 48 |
40,536 | public TorrentBuilder addNode ( Pair < String , Integer > value ) { if ( value != null ) { this . nodes . add ( value ) ; } return this ; } | This adds a DHT node to the torrent . This especially useful if you re creating a tracker less torrent . It can be used by clients to bootstrap their DHT node from . The node is a hostname and a port number where there is a DHT node running . You can have any number of DHT nodes in a torrent . | 36 | 69 |
40,537 | public Result generate ( ) throws IOException { if ( path == null ) { throw new IOException ( "path can't be null" ) ; } File absPath = path . getAbsoluteFile ( ) ; file_storage fs = new file_storage ( ) ; add_files_listener l1 = new add_files_listener ( ) { @ Override public boolean pred ( String p ) { return listener... | This function will generate a result withe the . torrent file as a bencode tree . | 590 | 18 |
40,538 | public static byte [ ] bytes ( File file ) throws IOException { InputStream in = null ; try { in = openInputStream ( file ) ; return toByteArray ( in , file . length ( ) ) ; } finally { closeQuietly ( in ) ; } } | Reads the contents of a file into a byte array . The file is always closed . | 58 | 18 |
40,539 | public Priority [ ] filePriorities ( ) { int_vector v = th . get_file_priorities2 ( ) ; int size = ( int ) v . size ( ) ; Priority [ ] arr = new Priority [ size ] ; for ( int i = 0 ; i < size ; i ++ ) { arr [ i ] = Priority . fromSwig ( v . get ( i ) ) ; } return arr ; } | Returns a vector with the priorities of all files . | 90 | 10 |
40,540 | public String name ( ) { torrent_status ts = th . status ( torrent_handle . query_name ) ; return ts . getName ( ) ; } | The name of the torrent . Typically this is derived from the . torrent file . In case the torrent was started without metadata and hasn t completely received it yet it returns the name given to it when added to the session . | 33 | 44 |
40,541 | public static < T , S extends T > Optional < T > of ( S value ) { if ( value == null ) { throw new IllegalArgumentException ( "Optional does not support NULL, use Optional.empty() instead." ) ; } return new Optional < T > ( value ) ; } | Create a new Optional containing value . | 61 | 7 |
40,542 | public ErrorResponse parseError ( Response response ) { if ( response . isSuccessful ( ) ) { throw new IllegalArgumentException ( "Response must be unsuccessful." ) ; } Converter < ResponseBody , ErrorResponse > responseBodyObjectConverter = retrofit . responseBodyConverter ( ErrorResponse . class , new Annotation [ 0 ... | A helper to assist with decoding unsuccessful responses . | 121 | 9 |
40,543 | public static void notEmpty ( Collection collection , String name ) { notNull ( collection , name ) ; if ( collection . isEmpty ( ) ) { throw new IllegalArgumentException ( name + " must not be empty" ) ; } } | Checks that a given collection is not null and not empty . | 50 | 13 |
40,544 | public static void notEmpty ( Object [ ] arr , String name ) { notNull ( arr , name ) ; if ( arr . length == 0 ) { throw new IllegalArgumentException ( name + "must not be empty" ) ; } } | Checks that a given array is not null and not empty . | 51 | 13 |
40,545 | public static void notEmpty ( Map map , String name ) { notNull ( map , name ) ; if ( map . isEmpty ( ) ) { throw new IllegalArgumentException ( name + " must not be empty" ) ; } } | Checks that a given map is not null and not empty . | 50 | 13 |
40,546 | public static void isBetween ( Integer value , int min , int max , String name ) { notNull ( value , name ) ; if ( value < min || value > max ) { throw new IllegalArgumentException ( name + "(" + value + ") out of range: " + min + " <= " + name + " <= " + max ) ; } } | Checks that i is not null and is in the range min < ; = i < ; = max . | 77 | 24 |
40,547 | public static void isPositive ( Integer value , String name ) { notNull ( value , name ) ; if ( value < 0 ) { throw new IllegalArgumentException ( name + "must be a positive number." ) ; } } | Checks that i is not null and is a positive number | 49 | 12 |
40,548 | public static Map < String , String > arrayToMap ( String [ ] args ) { if ( args . length % 2 != 0 ) { throw new IllegalArgumentException ( "Must pass in an even number of args, one key per value." ) ; } Map < String , String > ret = new HashMap <> ( ) ; for ( int i = 0 ; i < args . length ; i += 2 ) { ret . put ( args... | Helper to convert an alternating key1 value1 key2 value2 ... array into a map . | 110 | 19 |
40,549 | private static < T > int binarySearch0 ( Sortable < T > a , int fromIndex , int toIndex , T key , Comparator < ? super T > c ) { if ( c == null ) { throw new NullPointerException ( ) ; } int low = fromIndex ; int high = toIndex - 1 ; while ( low <= high ) { int mid = ( low + high ) >>> 1 ; T midVal = a . at ( mid ) ; i... | Like public version but without range checks . | 161 | 8 |
40,550 | public void addState ( ) { DiffHistoryDataState nextState = new DiffHistoryDataState ( stateEngine , typeDiffInstructions ) ; if ( currentDataState != null ) newHistoricalState ( currentDataState , nextState ) ; currentDataState = nextState ; } | Call this method after new data has been loaded by the FastBlobStateEngine . This will add a historical record of the differences between the previous state and this new state . | 58 | 35 |
40,551 | public String generateDiff ( String objectType , Object from , Object to ) { GenericObject fromGenericObject = from == null ? null : genericObjectFramework . serialize ( from , objectType ) ; GenericObject toGenericObject = to == null ? null : genericObjectFramework . serialize ( to , objectType ) ; return generateDiff... | Generate the HTML difference between two objects . | 82 | 9 |
40,552 | public String generateDiff ( GenericObject from , GenericObject to ) { StringBuilder builder = new StringBuilder ( ) ; builder . append ( "<table class=\"nomargin diff\">" ) ; builder . append ( "<thead>" ) ; builder . append ( "<tr>" ) ; builder . append ( "<th/>" ) ; builder . append ( "<th class=\"texttitle\">From</... | Generate the HTML difference between two GenericObjects . | 184 | 11 |
40,553 | public DiffReport performDiff ( FastBlobStateEngine fromState , FastBlobStateEngine toState ) throws DiffReportGenerationException { return performDiff ( null , fromState , toState ) ; } | Perform a diff between two data states . | 43 | 9 |
40,554 | public void runCycle ( int ... valuesForMap ) { /// prepare the map Object array recycler for a new cycle. HeapFriendlyMapArrayRecycler . get ( ) . swapCycleObjectArrays ( ) ; try { makeDataAvailableToApplication ( valuesForMap ) ; } finally { // fill all of the Object arrays which were returned to the pool on this cyc... | For each cycle we need to perform some administrative tasks . | 128 | 11 |
40,555 | public void serializePrimitive ( S rec , String fieldName , long value ) { serializePrimitive ( rec , fieldName , Long . valueOf ( value ) ) ; } | Can be overridden to avoid boxing a long where appropriate | 38 | 11 |
40,556 | public void serializePrimitive ( S rec , String fieldName , float value ) { serializePrimitive ( rec , fieldName , Float . valueOf ( value ) ) ; } | Can be overridden to avoid boxing a float where appropriate | 38 | 11 |
40,557 | public void serializePrimitive ( S rec , String fieldName , double value ) { serializePrimitive ( rec , fieldName , Double . valueOf ( value ) ) ; } | Can be overridden to avoid boxing a double where appropriate | 38 | 11 |
40,558 | public < K , V > void serializeSortedMap ( S rec , String fieldName , String keyTypeName , String valueTypeName , SortedMap < K , V > obj ) { serializeMap ( rec , fieldName , keyTypeName , valueTypeName , obj ) ; } | Serialize sorted map | 62 | 4 |
40,559 | private < K , V > List < Map . Entry < K , V > > sortedEntryList ( Map < K , V > obj ) { List < Map . Entry < K , V > > entryList = new ArrayList < Map . Entry < K , V > > ( obj . entrySet ( ) ) ; Collections . sort ( entryList , new Comparator < Map . Entry < K , V > > ( ) { @ Override @ SuppressWarnings ( { "unchecke... | diffs to match up better . | 212 | 7 |
40,560 | public List < Object > getList ( DiffPropertyPath path ) { Integer listIndex = fieldValuesLists . get ( path ) ; if ( listIndex == null ) return null ; return getList ( listIndex . intValue ( ) ) ; } | Get the list of values associated with the supplied DiffPropertyPath | 52 | 12 |
40,561 | private void reset ( ) { int count = 0 ; for ( int i = 0 ; i < tableLength ; i ++ ) { long t = tableAt ( i ) ; count += Long . bitCount ( t & ONE_MASK ) ; tableAt ( i , ( t >>> 1 ) & RESET_MASK ) ; } size = ( size >>> 1 ) - ( count >>> 2 ) ; } | Reduces every counter by half of its original value . | 85 | 11 |
40,562 | public long average ( ) { double sum = 0 ; int count = 0 ; for ( float d = 0 ; d <= 1.0d ; d += 0.02d ) { sum += inverseCumProb ( d ) ; count += 1 ; } return ( long ) ( sum / count ) ; } | approximation of the average ; slightly costly to calculate so should not be invoked frequently | 65 | 17 |
40,563 | void add ( long hashEntryAdr , long expireAt ) { // just ignore the fact that expireAt can be less than current time int slotNum = slot ( expireAt ) ; slots [ slotNum ] . add ( hashEntryAdr , expireAt ) ; } | Add a cache entry . | 56 | 5 |
40,564 | void remove ( long hashEntryAdr , long expireAt ) { int slot = slot ( expireAt ) ; slots [ slot ] . remove ( hashEntryAdr ) ; } | Remote a cache entry . | 37 | 5 |
40,565 | int removeExpired ( TimeoutHandler expireHandler ) { // ensure the clock never goes backwards long t = ticker . currentTimeMillis ( ) ; int expired = 0 ; for ( int i = 0 ; i < slotCount ; i ++ ) { expired += slots [ i ] . removeExpired ( t , expireHandler ) ; } return expired ; } | Remove expired entries . | 75 | 4 |
40,566 | private void assertValidDateFieldType ( Optional < Field > field ) { field . ifPresent ( it -> { if ( SUPPORTED_DATE_TYPES . contains ( it . getType ( ) . getName ( ) ) ) { return ; } Class < ? > type = it . getType ( ) ; if ( Jsr310Converters . supports ( type ) || ThreeTenBackPortConverters . supports ( type ) ) { re... | Checks whether the given field has a type that is a supported date type . | 152 | 16 |
40,567 | protected < X > long calculateTotal ( Pageable pager , List < X > result ) { if ( pager . hasPrevious ( ) ) { if ( CollectionUtils . isEmpty ( result ) ) { return - 1 ; } if ( result . size ( ) == pager . getPageSize ( ) ) { return - 1 ; } return ( pager . getPageNumber ( ) - 1 ) * pager . getPageSize ( ) + result . si... | Calculate total mount . | 133 | 6 |
40,568 | protected final int bindLimitParameters ( RowSelection selection , PreparedStatement statement , int index ) throws SQLException { if ( ! supportsVariableLimit ( ) || ! LimitHelper . hasMaxRows ( selection ) ) { return 0 ; } final int firstRow = convertToFirstRowValue ( LimitHelper . getFirstRow ( selection ) ) ; final... | Default implementation of binding parameter values needed by the LIMIT clause . | 188 | 13 |
40,569 | public < T > T markCreated ( T source ) { Assert . notNull ( source , "Entity must not be null!" ) ; return touch ( source , true ) ; } | Marks the given object as created . | 38 | 8 |
40,570 | public < T > T markModified ( T source ) { Assert . notNull ( source , "Entity must not be null!" ) ; return touch ( source , false ) ; } | Marks the given object as modified . | 39 | 8 |
40,571 | protected final boolean isAuditable ( Object source ) { Assert . notNull ( source , "Source must not be null!" ) ; return factory . getBeanWrapperFor ( source ) . isPresent ( ) ; } | Returns whether the given source is considered to be auditable in the first place | 47 | 15 |
40,572 | private Optional < Object > touchAuditor ( AuditableBeanWrapper < ? > wrapper , boolean isNew ) { Assert . notNull ( wrapper , "AuditableBeanWrapper must not be null!" ) ; return auditorAware . map ( it -> { Optional < ? > auditor = it . getCurrentAuditor ( ) ; Assert . notNull ( auditor , ( ) -> String . format ( "Aud... | Sets modifying and creating auditor . Creating auditor is only set on new auditables . | 182 | 17 |
40,573 | private Optional < TemporalAccessor > touchDate ( AuditableBeanWrapper < ? > wrapper , boolean isNew ) { Assert . notNull ( wrapper , "AuditableBeanWrapper must not be null!" ) ; Optional < TemporalAccessor > now = dateTimeProvider . getNow ( ) ; Assert . notNull ( now , ( ) -> String . format ( "Now must not be null! ... | Touches the auditable regarding modification and creation date . Creation date is only set on new auditables . | 170 | 22 |
40,574 | protected SqlSource buildSqlSourceFromStrings ( String [ ] strings , Class < ? > parameterTypeClass ) { final StringBuilder sql = new StringBuilder ( ) ; for ( String fragment : strings ) { sql . append ( fragment ) ; sql . append ( " " ) ; } LanguageDriver languageDriver = getLanguageDriver ( ) ; return languageDriver... | build sql source for mybatis from string concat by array . | 100 | 14 |
40,575 | public static boolean hasMaxRows ( RowSelection selection ) { return selection != null && selection . getMaxRows ( ) != null && selection . getMaxRows ( ) > 0 ; } | Is a max row limit indicated? | 42 | 7 |
40,576 | public static int getFirstRow ( RowSelection selection ) { return ( selection == null || selection . getFirstRow ( ) == null ) ? 0 : selection . getFirstRow ( ) ; } | Retrieve the indicated first row for pagination | 41 | 9 |
40,577 | public static List < Event > parse ( String requestBody , String signatureHeader , String webhookEndpointSecret ) { if ( isValidSignature ( requestBody , signatureHeader , webhookEndpointSecret ) ) { return WebhookParser . parse ( requestBody ) ; } else { throw new InvalidSignatureException ( ) ; } } | Validates that a webhook was genuinely sent by GoCardless using isValidSignature and then parses it into an array of com . gocardless . resources . Event objects representing each event included in the webhook . | 70 | 46 |
40,578 | public static boolean isValidSignature ( String requestBody , String signatureHeader , String webhookEndpointSecret ) { String computedSignature = new HmacUtils ( HmacAlgorithms . HMAC_SHA_256 , webhookEndpointSecret ) . hmacHex ( requestBody ) ; return MessageDigest . isEqual ( signatureHeader . getBytes ( ) , compute... | Validates that a webhook was genuinely sent by GoCardless by computing its signature using the body and your webhook endpoint secret and comparing that with the signature included in the Webhook - Signature header . | 92 | 41 |
40,579 | public static GoCardlessApiException toException ( ApiErrorResponse error ) { switch ( error . getType ( ) ) { case GOCARDLESS : return new GoCardlessInternalException ( error ) ; case INVALID_API_USAGE : return new InvalidApiUsageException ( error ) ; case INVALID_STATE : return new InvalidStateException ( error ) ; c... | Maps an error response to an exception . | 125 | 8 |
40,580 | public Map < String , String > getLinks ( ) { if ( links == null ) { return ImmutableMap . of ( ) ; } return ImmutableMap . copyOf ( links ) ; } | Returns the IDs of related objects . | 41 | 7 |
40,581 | private void buildRecorderFromObject ( int opcode , String owner , String name , String signature , boolean itf ) { super . visitMethodInsn ( opcode , owner , name , signature , itf ) ; // -> stack: ... newobj super . visitInsn ( Opcodes . DUP ) ; // -> stack: ... newobj newobj super . visitInsn ( Opcodes . DUP ) ; // ... | object then we get the class and invoke the recorder . | 239 | 11 |
40,582 | @ Override public void visitMaxs ( int maxStack , int maxLocals ) { if ( localScopes != null ) { for ( VariableScope scope : localScopes ) { super . visitLocalVariable ( "xxxxx$" + scope . index , scope . desc , null , scope . start , scope . end , scope . index ) ; } } super . visitMaxs ( maxStack , maxLocals ) ; } | Called by the ASM framework once the class is done being visited to compute stack & local variable count maximums . | 91 | 24 |
40,583 | private int newLocal ( Type type , String typeDesc , Label begin , Label end ) { int newVar = lvs . newLocal ( type ) ; getLocalScopes ( ) . add ( new VariableScope ( newVar , begin , end , typeDesc ) ) ; return newVar ; } | Helper method to allocate a new local variable and account for its scope . | 62 | 14 |
40,584 | @ Override public void visitMultiANewArrayInsn ( String typeName , int dimCount ) { // stack: ... dim1 dim2 dim3 ... dimN super . visitMultiANewArrayInsn ( typeName , dimCount ) ; // -> stack: ... aref calculateArrayLengthAndDispatch ( typeName , dimCount ) ; } | multianewarray gets its very own visit method in the ASM framework so we hook it here . This bytecode is different from most in that it consumes a variable number of stack elements during execution . The number of stack elements consumed is specified by the dimCount operand . | 73 | 56 |
40,585 | public static void instrumentClass ( Class < ? > c , ConstructorCallback < ? > sampler ) throws UnmodifiableClassException { // IMPORTANT: Don't forget that other threads may be accessing this // class while this code is running. Specifically, the class may be // executed directly after the retransformClasses is called... | Ensures that the given sampler will be invoked every time a constructor for class c is invoked . | 250 | 21 |
40,586 | public static byte [ ] instrument ( byte [ ] originalBytes , Class < ? > classBeingRedefined ) { try { ClassReader cr = new ClassReader ( originalBytes ) ; ClassWriter cw = new ClassWriter ( cr , ClassWriter . COMPUTE_MAXS ) ; VerifyingClassAdapter vcw = new VerifyingClassAdapter ( cw , originalBytes , cr . getClassNam... | Given the bytes representing a class add invocations of the ConstructorCallback method to the constructor . | 196 | 19 |
40,587 | @ SuppressWarnings ( "unchecked" ) public static void invokeSamplers ( Object o ) { Class < ? > currentClass = o . getClass ( ) ; while ( currentClass != null ) { List < ConstructorCallback < ? > > samplers = samplerMap . get ( currentClass ) ; if ( samplers != null ) { // Leave in the @SuppressWarnings, because we def... | Bytecode is rewritten to invoke this method ; it calls the sampler for the given class . Note that unless the javaagent command line argument subclassesAlso is specified it won t do anything if o is a subclass of the class that was supposed to be tracked . | 255 | 53 |
40,588 | public byte [ ] toByteArray ( ) { if ( state != State . PASS ) { logger . log ( Level . WARNING , "Failed to instrument class " + className + " because " + message ) ; return original ; } return cw . toByteArray ( ) ; } | Returns the byte array that contains the byte code for this class . | 60 | 13 |
40,589 | private static long getObjectSize ( Object obj , boolean isArray , Instrumentation instr ) { if ( isArray ) { return instr . getObjectSize ( obj ) ; } Class < ? > clazz = obj . getClass ( ) ; Long classSize = classSizesMap . get ( clazz ) ; if ( classSize == null ) { classSize = instr . getObjectSize ( obj ) ; classSiz... | Returns the size of the given object . If the object is not an array we check the cache first and update it as necessary . | 105 | 26 |
40,590 | public static void recordAllocation ( int count , String desc , Object newObj ) { if ( Objects . equals ( recordingAllocation . get ( ) , Boolean . TRUE ) ) { return ; } recordingAllocation . set ( Boolean . TRUE ) ; if ( count >= 0 ) { desc = desc . replace ( ' ' , ' ' ) ; } // Copy value into local variable to preven... | Records the allocation . This method is invoked on every allocation performed by the system . | 278 | 17 |
40,591 | @ Override public void onNewTraces ( List < Trace > traces ) { int tracesRemoved = updateTraceBuffer ( traces ) ; List < Trace > tracesToNotify = getCurrentTraces ( ) ; view . showTraces ( tracesToNotify , tracesRemoved ) ; } | Given a list of Trace objects to show updates the buffer of traces and refresh the view . | 61 | 18 |
40,592 | public void updateFilter ( String filter ) { if ( isInitialized ) { LynxConfig lynxConfig = lynx . getConfig ( ) ; lynxConfig . setFilter ( filter ) ; lynx . setConfig ( lynxConfig ) ; clearView ( ) ; restartLynx ( ) ; } } | Updates the filter used to know which Trace objects we have to show in the UI . | 64 | 18 |
40,593 | public void onShareButtonClicked ( ) { List < Trace > tracesToShare = new LinkedList < Trace > ( traceBuffer . getTraces ( ) ) ; String plainTraces = generatePlainTracesToShare ( tracesToShare ) ; if ( ! view . shareTraces ( plainTraces ) ) { view . notifyShareTracesFailed ( ) ; } } | Generates a plain representation of all the Trace objects this presenter has stored and share them to other applications . | 82 | 21 |
40,594 | @ Override public void run ( ) { super . run ( ) ; try { process = Runtime . getRuntime ( ) . exec ( "logcat -v time" ) ; } catch ( IOException e ) { Log . e ( LOGTAG , "IOException executing logcat command." , e ) ; } readLogcat ( ) ; } | Starts reading traces from the application logcat and notifying listeners if needed . | 72 | 16 |
40,595 | private void generateFiveRandomTracesPerSecond ( ) { logGeneratorThread = new Thread ( new Runnable ( ) { @ Override public void run ( ) { while ( continueReading ) { int traceLevel = traceCounter % 6 ; switch ( traceLevel ) { case 0 : Log . d ( "Lynx" , traceCounter + " - Debug trace generated automatically" ) ; break... | Random traces generator used just for this demo application . | 259 | 10 |
40,596 | @ Override protected void onVisibilityChanged ( View changedView , int visibility ) { super . onVisibilityChanged ( changedView , visibility ) ; if ( changedView != this ) { return ; } if ( visibility == View . VISIBLE ) { resumePresenter ( ) ; } else { pausePresenter ( ) ; } } | Initializes or stops LynxPresenter based on visibility changes . Doing this Lynx is not going to read your application Logcat if LynxView is not visible or attached . | 69 | 36 |
40,597 | public void setLynxConfig ( LynxConfig lynxConfig ) { validateLynxConfig ( lynxConfig ) ; boolean hasChangedLynxConfig = ! this . lynxConfig . equals ( lynxConfig ) ; if ( hasChangedLynxConfig ) { this . lynxConfig = ( LynxConfig ) lynxConfig . clone ( ) ; updateFilterText ( ) ; updateAdapter ( ) ; updateSpinner ( ) ; ... | Given a valid LynxConfig object update all the dependencies to apply this new configuration . | 105 | 17 |
40,598 | @ CheckResult @ Override public boolean shareTraces ( String fullTraces ) { try { shareTracesInternal ( fullTraces ) ; return true ; } catch ( RuntimeException exception1 ) { // Likely cause is a TransactionTooLargeException on API levels 15+. try { /* * Limit trace size to between 100kB and 400kB, since Unicode charac... | Uses an intent to share content and given one String with all the information related to the List of traces shares this information with other applications . | 174 | 28 |
40,599 | private void configureCursorColor ( ) { try { Field f = TextView . class . getDeclaredField ( "mCursorDrawableRes" ) ; f . setAccessible ( true ) ; f . set ( et_filter , R . drawable . edit_text_cursor_color ) ; } catch ( Exception e ) { Log . e ( LOGTAG , "Error trying to change cursor color text cursor drawable to nu... | Hack to change EditText cursor color even if the API level is lower than 12 . Please don t do this at home . | 98 | 25 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.