idx int64 0 165k | question stringlengths 73 4.15k | target stringlengths 5 918 | len_question int64 21 890 | len_target int64 3 255 |
|---|---|---|---|---|
24,600 | public static Type getSuperType ( Type subType , Class < ? > rawSuperType ) { while ( subType != null && getRawClass ( subType ) != rawSuperType ) { subType = getSuperType ( subType ) ; } return subType ; } | Get the super type for a type in its super type chain which has a raw class that matches the specified class . | 57 | 23 |
24,601 | public static boolean isTypeOrSubTypeOf ( Type subType , Type superType ) { Class < ? > sub = getRawClass ( subType ) ; Class < ? > sup = getRawClass ( superType ) ; return sup . isAssignableFrom ( sub ) ; } | Determines if a type is the same or a subtype for another type . | 60 | 17 |
24,602 | public static ParameterizedType createParameterizedType ( Class < ? > rawClass , Type ... genericTypes ) { return new ParameterizedType ( ) { @ Override public Type [ ] getActualTypeArguments ( ) { return genericTypes ; } @ Override public Type getRawType ( ) { return rawClass ; } @ Override public Type getOwnerType ( ) { return null ; } } ; } | Create a parameterized type from a raw class and its type arguments . | 88 | 14 |
24,603 | public static Type getRestResponseBodyType ( Type restResponseReturnType ) { // if this type has type arguments, then we look at the last one to determine if it expects a body final Type [ ] restResponseTypeArguments = TypeUtil . getTypeArguments ( restResponseReturnType ) ; if ( restResponseTypeArguments != null && restResponseTypeArguments . length > 0 ) { return restResponseTypeArguments [ restResponseTypeArguments . length - 1 ] ; } else { // no generic type on this RestResponse sub-type, so we go up to parent return getRestResponseBodyType ( TypeUtil . getSuperType ( restResponseReturnType ) ) ; } } | Returns the body type expected in the rest response . | 147 | 10 |
24,604 | int calculateCode ( byte [ ] key , long tm ) { // Allocating an array of bytes to represent the specified instant // of time. byte [ ] data = new byte [ 8 ] ; long value = tm ; // Converting the instant of time from the long representation to a // big-endian array of bytes (RFC4226, 5.2. Description). for ( int i = 8 ; i -- > 0 ; value >>>= 8 ) { data [ i ] = ( byte ) value ; } // Building the secret key specification for the HmacSHA1 algorithm. SecretKeySpec signKey = new SecretKeySpec ( key , config . getHmacHashFunction ( ) . toString ( ) ) ; try { // Getting an HmacSHA1/HmacSHA256 algorithm implementation from the JCE. Mac mac = Mac . getInstance ( config . getHmacHashFunction ( ) . toString ( ) ) ; // Initializing the MAC algorithm. mac . init ( signKey ) ; // Processing the instant of time and getting the encrypted data. byte [ ] hash = mac . doFinal ( data ) ; // Building the validation code performing dynamic truncation // (RFC4226, 5.3. Generating an HOTP value) int offset = hash [ hash . length - 1 ] & 0xF ; // We are using a long because Java hasn't got an unsigned integer type // and we need 32 unsigned bits). long truncatedHash = 0 ; for ( int i = 0 ; i < 4 ; ++ i ) { truncatedHash <<= 8 ; // Java bytes are signed but we need an unsigned integer: // cleaning off all but the LSB. truncatedHash |= ( hash [ offset + i ] & 0xFF ) ; } // Clean bits higher than the 32nd (inclusive) and calculate the // module with the maximum validation code value. truncatedHash &= 0x7FFFFFFF ; truncatedHash %= config . getKeyModulus ( ) ; // Returning the validation code to the caller. return ( int ) truncatedHash ; } catch ( NoSuchAlgorithmException | InvalidKeyException ex ) { // Logging the exception. LOGGER . log ( Level . SEVERE , ex . getMessage ( ) , ex ) ; // We're not disclosing internal error details to our clients. throw new GoogleAuthenticatorException ( "The operation cannot be performed now." ) ; } } | Calculates the verification code of the provided key at the specified instant of time using the algorithm specified in RFC 6238 . | 510 | 25 |
24,605 | private boolean checkCode ( String secret , long code , long timestamp , int window ) { byte [ ] decodedKey = decodeSecret ( secret ) ; // convert unix time into a 30 second "window" as specified by the // TOTP specification. Using Google's default interval of 30 seconds. final long timeWindow = getTimeWindowFromTime ( timestamp ) ; // Calculating the verification code of the given key in each of the // time intervals and returning true if the provided code is equal to // one of them. for ( int i = - ( ( window - 1 ) / 2 ) ; i <= window / 2 ; ++ i ) { // Calculating the verification code for the current time interval. long hash = calculateCode ( decodedKey , timeWindow + i ) ; // Checking if the provided code is equal to the calculated one. if ( hash == code ) { // The verification code is valid. return true ; } } // The verification code is invalid. return false ; } | This method implements the algorithm specified in RFC 6238 to check if a validation code is valid in a given instant of time for the given secret key . | 205 | 30 |
24,606 | private int generateScratchCode ( ) { while ( true ) { byte [ ] scratchCodeBuffer = new byte [ BYTES_PER_SCRATCH_CODE ] ; secureRandom . nextBytes ( scratchCodeBuffer ) ; int scratchCode = calculateScratchCode ( scratchCodeBuffer ) ; if ( scratchCode != SCRATCH_CODE_INVALID ) { return scratchCode ; } } } | This method creates a new random byte buffer from which a new scratch code is generated . This function is invoked if a scratch code generated from the main buffer is invalid because it does not satisfy the scratch code restrictions . | 87 | 42 |
24,607 | private String calculateSecretKey ( byte [ ] secretKey ) { switch ( config . getKeyRepresentation ( ) ) { case BASE32 : return new Base32 ( ) . encodeToString ( secretKey ) ; case BASE64 : return new Base64 ( ) . encodeToString ( secretKey ) ; default : throw new IllegalArgumentException ( "Unknown key representation type." ) ; } } | This method calculates the secret key given a random byte buffer . | 82 | 12 |
24,608 | private ICredentialRepository getValidCredentialRepository ( ) { ICredentialRepository repository = getCredentialRepository ( ) ; if ( repository == null ) { throw new UnsupportedOperationException ( String . format ( "An instance of the %s service must be " + "configured in order to use this feature." , ICredentialRepository . class . getName ( ) ) ) ; } return repository ; } | This method loads the first available and valid ICredentialRepository registered using the Java service loader API . | 93 | 21 |
24,609 | public ICredentialRepository getCredentialRepository ( ) { if ( this . credentialRepositorySearched ) return this . credentialRepository ; this . credentialRepositorySearched = true ; ServiceLoader < ICredentialRepository > loader = ServiceLoader . load ( ICredentialRepository . class ) ; //noinspection LoopStatementThatDoesntLoop for ( ICredentialRepository repository : loader ) { this . credentialRepository = repository ; break ; } return this . credentialRepository ; } | This method loads the first available ICredentialRepository registered using the Java service loader API . | 110 | 19 |
24,610 | public static void buildMeta ( Writer writer , String indexType , String indexName , Object params , String action , ClientOptions clientOption , boolean upper7 ) throws IOException { if ( params instanceof Map ) { buildMapMeta ( writer , indexType , indexName , ( Map ) params , action , clientOption , upper7 ) ; return ; } Object id = null ; Object parentId = null ; Object routing = null ; Object esRetryOnConflict = null ; Object version = null ; Object versionType = null ; if ( clientOption != null ) { ClassUtil . ClassInfo beanClassInfo = ClassUtil . getClassInfo ( params . getClass ( ) ) ; id = clientOption . getIdField ( ) != null ? BuildTool . getId ( params , beanClassInfo , clientOption . getIdField ( ) ) : null ; parentId = clientOption . getParentIdField ( ) != null ? BuildTool . getParentId ( params , beanClassInfo , clientOption . getParentIdField ( ) ) : null ; routing = clientOption . getRountField ( ) != null ? BuildTool . getRouting ( params , beanClassInfo , clientOption . getRountField ( ) ) : null ; esRetryOnConflict = clientOption . getEsRetryOnConflictField ( ) != null ? BuildTool . getEsRetryOnConflict ( params , beanClassInfo , clientOption . getEsRetryOnConflictField ( ) ) : null ; version = clientOption . getVersionField ( ) != null ? BuildTool . getEsRetryOnConflict ( params , beanClassInfo , clientOption . getVersionField ( ) ) : null ; versionType = clientOption . getVersionTypeField ( ) != null ? BuildTool . getEsRetryOnConflict ( params , beanClassInfo , clientOption . getVersionTypeField ( ) ) : null ; } buildMeta ( writer , indexType , indexName , params , action , id , parentId , routing , esRetryOnConflict , version , versionType , upper7 ) ; } | String docIdKey String parentIdKey String routingKey | 446 | 11 |
24,611 | public boolean process ( ) throws ResourceNotFoundException , ParseErrorException { if ( processed ) return true ; synchronized ( this ) { if ( processed ) return true ; data = null ; errorCondition = null ; Reader is = null ; /* * first, try to get the stream from the loader */ try { is = new BBossStringReader ( template ) ; } catch ( ResourceNotFoundException rnfe ) { /* * remember and re-throw */ errorCondition = rnfe ; processed = true ; throw rnfe ; } /* * if that worked, lets protect in case a loader impl * forgets to throw a proper exception */ if ( is != null ) { /* * now parse the template */ try { BufferedReader br = new BufferedReader ( is ) ; data = rsvc . parse ( br , name ) ; initDocument ( ) ; processed = true ; try { rechecksqlistpl ( ) ; } catch ( Exception e ) { } return true ; } catch ( ParseException pex ) { /* * remember the error and convert */ errorCondition = new ParseErrorException ( pex , name ) ; processed = true ; throw errorCondition ; } catch ( TemplateInitException pex ) { errorCondition = new ParseErrorException ( pex , name ) ; processed = true ; throw errorCondition ; } /** * pass through runtime exceptions */ catch ( RuntimeException e ) { errorCondition = new VelocityException ( "Exception thrown processing Template " + getName ( ) , e ) ; processed = true ; throw errorCondition ; } finally { processed = true ; /* * Make sure to close the inputstream when we are done. */ try { is . close ( ) ; } catch ( IOException e ) { // If we are already throwing an exception then we want the original // exception to be continued to be thrown, otherwise, throw a new Exception. if ( errorCondition == null ) { throw new VelocityException ( e ) ; } } } } else { /* * is == null, therefore we have some kind of file issue */ errorCondition = new ResourceNotFoundException ( "Unknown resource error for resource " + name ) ; processed = true ; throw errorCondition ; } } } | gets the named resource as a stream parses and inits | 461 | 12 |
24,612 | public String addDateDocumentsNew ( String indexName , String addTemplate , List < ? > beans , String refreshOption ) throws ElasticSearchException { return addDateDocuments ( indexName , _doc , addTemplate , beans , refreshOption ) ; } | For Elasticsearch 7 and 7 + | 51 | 7 |
24,613 | @ Deprecated public static Map < String , String > getEscapeMapping ( String in , Map < String , String > headers ) { return getEscapeMapping ( in , headers , false , 0 , 0 ) ; } | Instead of replacing escape sequences in a string this method returns a mapping of an attribute name to the value based on the escape sequence found in the argument string . | 48 | 31 |
24,614 | private void openClient ( String clusterName ) { logger . info ( "Using ElasticSearch hostnames: {} " , Arrays . toString ( serverAddresses ) ) ; Settings settings = null ; Settings . Builder builder = Settings . builder ( ) ; if ( this . elasticUser != null && ! this . elasticUser . equals ( "" ) ) { builder . put ( "cluster.name" , clusterName ) . put ( "xpack.security.user" , this . elasticUser + ":" + this . elasticPassword ) ; // .put("shield.user", // this.elasticUser+":"+this.elasticPassword) } else { builder . put ( "cluster.name" , clusterName ) ; } if ( this . extendElasticsearchPropes != null && extendElasticsearchPropes . size ( ) > 0 ) { Iterator < Entry < Object , Object > > iterator = extendElasticsearchPropes . entrySet ( ) . iterator ( ) ; while ( iterator . hasNext ( ) ) { Entry < Object , Object > entry = iterator . next ( ) ; builder . put ( ( String ) entry . getKey ( ) , String . valueOf ( entry . getValue ( ) ) ) ; } } settings = builder . build ( ) ; try { TransportClient transportClient = this . elasticUser != null && ! this . elasticUser . equals ( "" ) ? new PreBuiltXPackTransportClient ( settings ) : new PreBuiltTransportClient ( settings ) ; // TransportClient transportClient = new TransportClient(settings); for ( TransportAddress host : serverAddresses ) { transportClient . addTransportAddress ( host ) ; } if ( client != null ) { client . close ( ) ; } client = transportClient ; } catch ( RuntimeException e ) { e . printStackTrace ( ) ; } catch ( Throwable e ) { e . printStackTrace ( ) ; } } | Open client to elaticsearch cluster | 409 | 7 |
24,615 | public ClientInterface getRestClient ( ) { if ( restClient == null ) { synchronized ( this ) { if ( restClient == null ) { restClient = ElasticSearchHelper . getRestClientUtil ( ) ; } } } return restClient ; } | Get default elasticsearch server ClientInterface | 53 | 7 |
24,616 | public ClientInterface getConfigRestClient ( String elasticsearchName , String configFile ) { return ElasticSearchHelper . getConfigRestClientUtil ( elasticsearchName , configFile ) ; } | Get Special elasticsearch server ConfigFile ClientInterface | 39 | 9 |
24,617 | public void setStyleClass ( int from , int to , String styleClass ) { setStyle ( from , to , Collections . singletonList ( styleClass ) ) ; } | Convenient method to assign a single style class . | 36 | 10 |
24,618 | TwoDimensional . Position currentLine ( ) { int parIdx = getCurrentParagraph ( ) ; Cell < Paragraph < PS , SEG , S > , ParagraphBox < PS , SEG , S > > cell = virtualFlow . getCell ( parIdx ) ; int lineIdx = cell . getNode ( ) . getCurrentLineIndex ( caretSelectionBind . getUnderlyingCaret ( ) ) ; return paragraphLineNavigator . position ( parIdx , lineIdx ) ; } | Returns the current line as a two - level index . The major number is the paragraph index the minor number is the line number within the paragraph . | 110 | 29 |
24,619 | final ParagraphBox . CaretOffsetX getCaretOffsetX ( CaretNode caret ) { return getCell ( caret . getParagraphIndex ( ) ) . getCaretOffsetX ( caret ) ; } | Returns x coordinate of the caret in the current paragraph . | 48 | 12 |
24,620 | public Paragraph < PS , SEG , S > restyle ( S style ) { return new Paragraph <> ( paragraphStyle , segmentOps , segments , StyleSpans . singleton ( style , length ( ) ) ) ; } | Restyles every segment in the paragraph to have the given style . | 49 | 13 |
24,621 | public Paragraph < PS , SEG , S > setParagraphStyle ( PS paragraphStyle ) { return new Paragraph <> ( paragraphStyle , segmentOps , segments , styles ) ; } | Creates a new Paragraph which has the same contents as the current Paragraph but the given paragraph style . | 40 | 22 |
24,622 | public String getText ( ) { if ( text == null ) { StringBuilder sb = new StringBuilder ( length ( ) ) ; for ( SEG seg : segments ) sb . append ( segmentOps . getText ( seg ) ) ; text = sb . toString ( ) ; } return text ; } | Returns the plain text content of this paragraph not including the line terminator . | 68 | 15 |
24,623 | public Tuple2 < ReadOnlyStyledDocument < PS , SEG , S > , ReadOnlyStyledDocument < PS , SEG , S > > split ( int position ) { return tree . locate ( NAVIGATE , position ) . map ( this :: split ) ; } | Splits this document into two at the given position and returns both halves . | 59 | 15 |
24,624 | public Tuple2 < ReadOnlyStyledDocument < PS , SEG , S > , ReadOnlyStyledDocument < PS , SEG , S > > split ( int paragraphIndex , int columnPosition ) { return tree . splitAt ( paragraphIndex ) . map ( ( l , p , r ) -> { Paragraph < PS , SEG , S > p1 = p . trim ( columnPosition ) ; Paragraph < PS , SEG , S > p2 = p . subSequence ( columnPosition ) ; ReadOnlyStyledDocument < PS , SEG , S > doc1 = new ReadOnlyStyledDocument <> ( l . append ( p1 ) ) ; ReadOnlyStyledDocument < PS , SEG , S > doc2 = new ReadOnlyStyledDocument <> ( r . prepend ( p2 ) ) ; return t ( doc1 , doc2 ) ; } ) ; } | Splits this document into two at the given paragraph s column position and returns both halves . | 192 | 18 |
24,625 | public static < PS , SEG , S > ReadOnlyStyledDocument < PS , SEG , S > constructDocument ( SegmentOps < SEG , S > segmentOps , PS defaultParagraphStyle , Consumer < ReadOnlyStyledDocumentBuilder < PS , SEG , S > > configuration ) { ReadOnlyStyledDocumentBuilder < PS , SEG , S > builder = new ReadOnlyStyledDocumentBuilder <> ( segmentOps , defaultParagraphStyle ) ; configuration . accept ( builder ) ; return builder . build ( ) ; } | Constructs a list of paragraphs | 114 | 6 |
24,626 | public ReadOnlyStyledDocumentBuilder < PS , SEG , S > addParagraph ( List < SEG > segments , StyleSpans < S > styles ) { return addParagraph ( segments , styles , null ) ; } | Adds to the list a paragraph that has multiple segments with multiple styles throughout those segments | 48 | 16 |
24,627 | public ReadOnlyStyledDocumentBuilder < PS , SEG , S > addParagraphs0 ( List < Tuple2 < PS , List < SEG > > > paragraphArgList , StyleSpans < S > entireDocumentStyleSpans ) { return addParagraphList ( paragraphArgList , entireDocumentStyleSpans , Tuple2 :: get1 , Tuple2 :: get2 ) ; } | Adds multiple paragraphs to the list allowing one to specify each paragraph s paragraph style . | 85 | 16 |
24,628 | private void moveContentBreaks ( int numOfBreaks , BreakIterator breakIterator , boolean followingNotPreceding ) { if ( area . getLength ( ) == 0 ) { return ; } breakIterator . setText ( area . getText ( ) ) ; if ( followingNotPreceding ) { breakIterator . following ( getPosition ( ) ) ; } else { breakIterator . preceding ( getPosition ( ) ) ; } for ( int i = 1 ; i < numOfBreaks ; i ++ ) { breakIterator . next ( ) ; } moveTo ( breakIterator . current ( ) ) ; } | Helper method for reducing duplicate code | 128 | 6 |
24,629 | private void insertImage ( ) { String initialDir = System . getProperty ( "user.dir" ) ; FileChooser fileChooser = new FileChooser ( ) ; fileChooser . setTitle ( "Insert image" ) ; fileChooser . setInitialDirectory ( new File ( initialDir ) ) ; File selectedFile = fileChooser . showOpenDialog ( mainStage ) ; if ( selectedFile != null ) { String imagePath = selectedFile . getAbsolutePath ( ) ; imagePath = imagePath . replace ( ' ' , ' ' ) ; ReadOnlyStyledDocument < ParStyle , Either < String , LinkedImage > , TextStyle > ros = ReadOnlyStyledDocument . fromSegment ( Either . right ( new RealLinkedImage ( imagePath ) ) , ParStyle . EMPTY , TextStyle . EMPTY , area . getSegOps ( ) ) ; area . replaceSelection ( ros ) ; } } | Action listener which inserts a new image at the current caret position . | 201 | 14 |
24,630 | CharacterHit hitTextLine ( CaretOffsetX x , int line ) { return text . hitLine ( x . value , line ) ; } | Hits the embedded TextFlow at the given line and x offset . | 30 | 14 |
24,631 | CharacterHit hitText ( CaretOffsetX x , double y ) { return text . hit ( x . value , y ) ; } | Hits the embedded TextFlow at the given x and y offset . | 28 | 14 |
24,632 | @ Override public void selectRangeExpl ( int anchorParagraph , int anchorColumn , int caretParagraph , int caretColumn ) { selectRangeExpl ( textPosition ( anchorParagraph , anchorColumn ) , textPosition ( caretParagraph , caretColumn ) ) ; } | caret selection bind | 60 | 4 |
24,633 | public static LogMonitor logMonitor ( ) { return new LogMonitor ( ) { @ Override public void corruption ( long bytes , String reason ) { System . out . println ( String . format ( "corruption of %s bytes: %s" , bytes , reason ) ) ; } @ Override public void corruption ( long bytes , Throwable reason ) { System . out . println ( String . format ( "corruption of %s bytes" , bytes ) ) ; reason . printStackTrace ( ) ; } } ; } | todo implement real logging | 108 | 5 |
24,634 | @ Override public void seek ( Slice targetKey ) { if ( restartCount == 0 ) { return ; } int left = 0 ; int right = restartCount - 1 ; // binary search restart positions to find the restart position immediately before the targetKey while ( left < right ) { int mid = ( left + right + 1 ) / 2 ; seekToRestartPosition ( mid ) ; if ( comparator . compare ( nextEntry . getKey ( ) , targetKey ) < 0 ) { // key at mid is smaller than targetKey. Therefore all restart // blocks before mid are uninteresting. left = mid ; } else { // key at mid is greater than or equal to targetKey. Therefore // all restart blocks at or after mid are uninteresting. right = mid - 1 ; } } // linear search (within restart block) for first key greater than or equal to targetKey for ( seekToRestartPosition ( left ) ; nextEntry != null ; next ( ) ) { if ( comparator . compare ( peek ( ) . getKey ( ) , targetKey ) >= 0 ) { break ; } } } | Repositions the iterator so the key of the next BlockElement returned greater than or equal to the specified targetKey . | 232 | 24 |
24,635 | private static BlockEntry readEntry ( SliceInput data , BlockEntry previousEntry ) { requireNonNull ( data , "data is null" ) ; // read entry header int sharedKeyLength = VariableLengthQuantity . readVariableLengthInt ( data ) ; int nonSharedKeyLength = VariableLengthQuantity . readVariableLengthInt ( data ) ; int valueLength = VariableLengthQuantity . readVariableLengthInt ( data ) ; // read key Slice key = Slices . allocate ( sharedKeyLength + nonSharedKeyLength ) ; SliceOutput sliceOutput = key . output ( ) ; if ( sharedKeyLength > 0 ) { checkState ( previousEntry != null , "Entry has a shared key but no previous entry was provided" ) ; sliceOutput . writeBytes ( previousEntry . getKey ( ) , 0 , sharedKeyLength ) ; } sliceOutput . writeBytes ( data , nonSharedKeyLength ) ; // read value Slice value = data . readSlice ( valueLength ) ; return new BlockEntry ( key , value ) ; } | Reads the entry at the current data readIndex . After this method data readIndex is positioned at the beginning of the next entry or at the end of data if there was not a next entry . | 220 | 40 |
24,636 | public static boolean setCurrentFile ( File databaseDir , long descriptorNumber ) throws IOException { String manifest = descriptorFileName ( descriptorNumber ) ; String temp = tempFileName ( descriptorNumber ) ; File tempFile = new File ( databaseDir , temp ) ; writeStringToFileSync ( manifest + "\n" , tempFile ) ; File to = new File ( databaseDir , currentFileName ( ) ) ; boolean ok = tempFile . renameTo ( to ) ; if ( ! ok ) { tempFile . delete ( ) ; writeStringToFileSync ( manifest + "\n" , to ) ; } return ok ; } | Make the CURRENT file point to the descriptor file with the specified number . | 131 | 15 |
24,637 | public boolean isBaseLevelForKey ( Slice userKey ) { // Maybe use binary search to find right entry instead of linear search? UserComparator userComparator = inputVersion . getInternalKeyComparator ( ) . getUserComparator ( ) ; for ( int level = this . level + 2 ; level < NUM_LEVELS ; level ++ ) { List < FileMetaData > files = inputVersion . getFiles ( level ) ; while ( levelPointers [ level ] < files . size ( ) ) { FileMetaData f = files . get ( levelPointers [ level ] ) ; if ( userComparator . compare ( userKey , f . getLargest ( ) . getUserKey ( ) ) <= 0 ) { // We've advanced far enough if ( userComparator . compare ( userKey , f . getSmallest ( ) . getUserKey ( ) ) >= 0 ) { // Key falls in this file's range, so definitely not base level return false ; } break ; } levelPointers [ level ] ++ ; } } return true ; } | in levels greater than level + 1 . | 226 | 8 |
24,638 | public boolean shouldStopBefore ( InternalKey internalKey ) { // Scan to find earliest grandparent file that contains key. InternalKeyComparator internalKeyComparator = inputVersion . getInternalKeyComparator ( ) ; while ( grandparentIndex < grandparents . size ( ) && internalKeyComparator . compare ( internalKey , grandparents . get ( grandparentIndex ) . getLargest ( ) ) > 0 ) { if ( seenKey ) { overlappedBytes += grandparents . get ( grandparentIndex ) . getFileSize ( ) ; } grandparentIndex ++ ; } seenKey = true ; if ( overlappedBytes > MAX_GRAND_PARENT_OVERLAP_BYTES ) { // Too much overlap for current output; start new output overlappedBytes = 0 ; return true ; } else { return false ; } } | before processing internal_key . | 174 | 6 |
24,639 | public Slice copySlice ( int index , int length ) { checkPositionIndexes ( index , index + length , this . length ) ; index += offset ; byte [ ] copiedArray = new byte [ length ] ; System . arraycopy ( data , index , copiedArray , 0 , length ) ; return new Slice ( copiedArray ) ; } | Returns a copy of this buffer s sub - region . Modifying the content of the returned buffer or this buffer does not affect each other at all . | 73 | 30 |
24,640 | public Slice slice ( int index , int length ) { if ( index == 0 && length == this . length ) { return this ; } checkPositionIndexes ( index , index + length , this . length ) ; if ( index >= 0 && length == 0 ) { return Slices . EMPTY_SLICE ; } return new Slice ( data , offset + index , length ) ; } | Returns a slice of this buffer s sub - region . Modifying the content of the returned buffer or this buffer affects each other s content while they maintain separate indexes and marks . | 83 | 35 |
24,641 | public ByteBuffer toByteBuffer ( int index , int length ) { checkPositionIndexes ( index , index + length , this . length ) ; index += offset ; return ByteBuffer . wrap ( data , index , length ) . order ( LITTLE_ENDIAN ) ; } | Converts this buffer s sub - region into a NIO buffer . The returned buffer shares the content with this buffer . | 58 | 24 |
24,642 | private LogChunkType readNextChunk ( ) { // clear the current chunk currentChunk = Slices . EMPTY_SLICE ; // read the next block if necessary if ( currentBlock . available ( ) < HEADER_SIZE ) { if ( ! readNextBlock ( ) ) { if ( eof ) { return EOF ; } } } // parse header int expectedChecksum = currentBlock . readInt ( ) ; int length = currentBlock . readUnsignedByte ( ) ; length = length | currentBlock . readUnsignedByte ( ) << 8 ; byte chunkTypeId = currentBlock . readByte ( ) ; LogChunkType chunkType = getLogChunkTypeByPersistentId ( chunkTypeId ) ; // verify length if ( length > currentBlock . available ( ) ) { int dropSize = currentBlock . available ( ) + HEADER_SIZE ; reportCorruption ( dropSize , "Invalid chunk length" ) ; currentBlock = Slices . EMPTY_SLICE . input ( ) ; return BAD_CHUNK ; } // skip zero length records if ( chunkType == ZERO_TYPE && length == 0 ) { // Skip zero length record without reporting any drops since // such records are produced by the writing code. currentBlock = Slices . EMPTY_SLICE . input ( ) ; return BAD_CHUNK ; } // Skip physical record that started before initialOffset if ( endOfBufferOffset - HEADER_SIZE - length < initialOffset ) { currentBlock . skipBytes ( length ) ; return BAD_CHUNK ; } // read the chunk currentChunk = currentBlock . readBytes ( length ) ; if ( verifyChecksums ) { int actualChecksum = getChunkChecksum ( chunkTypeId , currentChunk ) ; if ( actualChecksum != expectedChecksum ) { // Drop the rest of the buffer since "length" itself may have // been corrupted and if we trust it, we could find some // fragment of a real log record that just happens to look // like a valid log record. int dropSize = currentBlock . available ( ) + HEADER_SIZE ; currentBlock = Slices . EMPTY_SLICE . input ( ) ; reportCorruption ( dropSize , "Invalid chunk checksum" ) ; return BAD_CHUNK ; } } // Skip unknown chunk types // Since this comes last so we the, know it is a valid chunk, and is just a type we don't understand if ( chunkType == UNKNOWN ) { reportCorruption ( length , String . format ( "Unknown chunk type %d" , chunkType . getPersistentId ( ) ) ) ; return BAD_CHUNK ; } return chunkType ; } | Return type or one of the preceding special values | 581 | 9 |
24,643 | private void reportCorruption ( long bytes , String reason ) { if ( monitor != null ) { monitor . corruption ( bytes , reason ) ; } } | Reports corruption to the monitor . The buffer must be updated to remove the dropped bytes prior to invocation . | 31 | 20 |
24,644 | private void reportDrop ( long bytes , Throwable reason ) { if ( monitor != null ) { monitor . corruption ( bytes , reason ) ; } } | Reports dropped bytes to the monitor . The buffer must be updated to remove the dropped bytes prior to invocation . | 31 | 21 |
24,645 | public T get ( ) throws InterruptedException { if ( ! valueReady . await ( ( long ) ( timeout * 1000 ) , TimeUnit . MILLISECONDS ) ) { String msg = String . format ( "BlockingVariable.get() timed out after %1.2f seconds" , timeout ) ; throw new SpockTimeoutError ( timeout , msg ) ; } return value ; } | Blocks until a value has been set for this variable or a timeout expires . | 82 | 15 |
24,646 | private void handleWhereBlock ( Method method ) { Block block = method . getLastBlock ( ) ; if ( ! ( block instanceof WhereBlock ) ) return ; new DeepBlockRewriter ( this ) . visit ( block ) ; WhereBlockRewriter . rewrite ( ( WhereBlock ) block , this ) ; } | will then be used by DeepBlockRewriter | 65 | 9 |
24,647 | private void handleFeatureIncludes ( SpecInfo spec , IncludeExcludeCriteria criteria ) { if ( criteria . isEmpty ( ) ) return ; for ( FeatureInfo feature : spec . getAllFeatures ( ) ) if ( hasAnyAnnotation ( feature . getFeatureMethod ( ) , criteria . annotations ) ) feature . setExcluded ( false ) ; } | in contrast to the three other handleXXX methods this one includes nodes | 73 | 13 |
24,648 | @ Override public void visitField ( FieldNode gField ) { PropertyNode owner = spec . getAst ( ) . getProperty ( gField . getName ( ) ) ; if ( gField . isStatic ( ) ) return ; Field field = new Field ( spec , gField , fieldCount ++ ) ; field . setShared ( AstUtil . hasAnnotation ( gField , Shared . class ) ) ; field . setOwner ( owner ) ; spec . getFields ( ) . add ( field ) ; } | although it IS related to a user - provided definition | 110 | 10 |
24,649 | private boolean constructorMayHaveBeenAddedByCompiler ( ConstructorNode constructor ) { Parameter [ ] params = constructor . getParameters ( ) ; Statement firstStat = constructor . getFirstStatement ( ) ; return AstUtil . isJointCompiled ( spec . getAst ( ) ) && constructor . isPublic ( ) && params != null && params . length == 0 && firstStat == null ; } | to add special logic to detect this case . | 85 | 9 |
24,650 | @ Nullable public ExpressionStatement rewrite ( ExpressionStatement stat ) { try { if ( ! isInteraction ( stat ) ) return null ; createBuilder ( ) ; setCount ( ) ; setCall ( ) ; addResponses ( ) ; build ( ) ; return register ( ) ; } catch ( InvalidSpecCompileException e ) { resources . getErrorReporter ( ) . error ( e ) ; return null ; } } | If the given statement is a valid interaction definition returns the rewritten statement . If the given statement is not an interaction definition returns null . If the given statement is an invalid interaction definition records a compile error and returns null . | 89 | 43 |
24,651 | private Object createEmptyWrapper ( Class < ? > type ) { if ( Number . class . isAssignableFrom ( type ) ) { Method method = ReflectionUtil . getDeclaredMethodBySignature ( type , "valueOf" , String . class ) ; if ( method != null && method . getReturnType ( ) == type ) { return ReflectionUtil . invokeMethod ( type , method , "0" ) ; } if ( type == BigInteger . class ) return BigInteger . ZERO ; if ( type == BigDecimal . class ) return BigDecimal . ZERO ; return null ; } if ( type == Boolean . class ) return false ; if ( type == Character . class ) return ( char ) 0 ; // better return something else? return null ; } | also handles some numeric types which aren t primitive wrapper types | 167 | 11 |
24,652 | @ Deprecated public void await ( int value , TimeUnit unit ) throws Throwable { await ( TimeUtil . toSeconds ( value , unit ) ) ; } | Waits until all evaluate blocks have completed or the specified timeout expires . If one of the evaluate blocks throws an exception it is rethrown from this method . | 35 | 32 |
24,653 | private static RunContext createBottomContext ( ) { File spockUserHome = SpockUserHomeUtil . getSpockUserHome ( ) ; DelegatingScript script = new ConfigurationScriptLoader ( spockUserHome ) . loadAutoDetectedScript ( ) ; List < Class < ? > > classes = new ExtensionClassesLoader ( ) . loadClassesFromDefaultLocation ( ) ; return new RunContext ( "default" , spockUserHome , script , classes ) ; } | this shouldn t be much of a problem in practice . | 101 | 11 |
24,654 | public static void closeQuietly ( @ Nullable final Socket ... sockets ) { if ( sockets == null ) return ; for ( Socket socket : sockets ) { if ( socket == null ) return ; try { socket . close ( ) ; } catch ( IOException ignored ) { } } } | In JDK 1 . 6 java . net . Socket doesn t implement Closeable so we have this overload . | 60 | 22 |
24,655 | public static String getText ( Reader reader ) throws IOException { try { StringBuilder source = new StringBuilder ( ) ; BufferedReader buffered = new BufferedReader ( reader ) ; String line = buffered . readLine ( ) ; while ( line != null ) { source . append ( line ) ; source . append ( ' ' ) ; line = buffered . readLine ( ) ; } return source . toString ( ) ; } finally { closeQuietly ( reader ) ; } } | Returns the text read from the given reader as a String . Closes the given reader upon return . | 104 | 20 |
24,656 | public static OperatingSystem getCurrent ( ) { String name = System . getProperty ( "os.name" ) ; String version = System . getProperty ( "os.version" ) ; String lowerName = name . toLowerCase ( ) ; if ( lowerName . contains ( "linux" ) ) return new OperatingSystem ( name , version , Family . LINUX ) ; if ( lowerName . contains ( "mac os" ) || lowerName . contains ( "darwin" ) ) return new OperatingSystem ( name , version , Family . MAC_OS ) ; if ( lowerName . contains ( "windows" ) ) return new OperatingSystem ( name , version , Family . WINDOWS ) ; if ( lowerName . contains ( "sunos" ) ) return new OperatingSystem ( name , version , Family . SOLARIS ) ; return new OperatingSystem ( name , version , Family . OTHER ) ; } | Returns the current operating system . | 190 | 6 |
24,657 | private boolean forbidUseOfSuperInFixtureMethod ( MethodCallExpression expr ) { Method currMethod = resources . getCurrentMethod ( ) ; Expression target = expr . getObjectExpression ( ) ; if ( currMethod instanceof FixtureMethod && target instanceof VariableExpression && ( ( VariableExpression ) target ) . isSuperExpression ( ) && currMethod . getName ( ) . equals ( expr . getMethodAsString ( ) ) ) { resources . getErrorReporter ( ) . error ( expr , "A base class fixture method should not be called explicitly " + "because it is always invoked automatically by the framework" ) ; return true ; } return false ; } | the base method and doesn t know that it will be run automatically ) | 146 | 14 |
24,658 | public static Throwable getRootCause ( Throwable exception ) { Assert . notNull ( exception ) ; return exception . getCause ( ) == null ? exception : getRootCause ( exception . getCause ( ) ) ; } | Returns the innermost cause of the specified exception . If the specified exception has no cause the exception itself is returned . | 47 | 23 |
24,659 | public static List < Throwable > getCauseChain ( Throwable exception ) { Assert . notNull ( exception ) ; List < Throwable > result = new ArrayList <> ( ) ; collectCauseChain ( exception , result ) ; return result ; } | Returns a list of all causes of the specified exception . The first element of the returned list is the specified exception itself ; the last element is its root cause . | 53 | 32 |
24,660 | public static Type getArrayComponentType ( Type type ) { if ( type instanceof Class ) { Class < ? > clazz = ( Class < ? > ) type ; return clazz . getComponentType ( ) ; } else if ( type instanceof GenericArrayType ) { GenericArrayType aType = ( GenericArrayType ) type ; return aType . getGenericComponentType ( ) ; } else { return null ; } } | If type is an array type returns the type of the component of the array . Otherwise returns null . | 89 | 20 |
24,661 | public static Type capture ( Type type ) { VarMap varMap = new VarMap ( ) ; List < CaptureTypeImpl > toInit = new ArrayList <> ( ) ; if ( type instanceof ParameterizedType ) { ParameterizedType pType = ( ParameterizedType ) type ; Class < ? > clazz = ( Class < ? > ) pType . getRawType ( ) ; Type [ ] arguments = pType . getActualTypeArguments ( ) ; TypeVariable < ? > [ ] vars = clazz . getTypeParameters ( ) ; Type [ ] capturedArguments = new Type [ arguments . length ] ; assert arguments . length == vars . length ; for ( int i = 0 ; i < arguments . length ; i ++ ) { Type argument = arguments [ i ] ; if ( argument instanceof WildcardType ) { CaptureTypeImpl captured = new CaptureTypeImpl ( ( WildcardType ) argument , vars [ i ] ) ; argument = captured ; toInit . add ( captured ) ; } capturedArguments [ i ] = argument ; varMap . add ( vars [ i ] , argument ) ; } for ( CaptureTypeImpl captured : toInit ) { captured . init ( varMap ) ; } Type ownerType = ( pType . getOwnerType ( ) == null ) ? null : capture ( pType . getOwnerType ( ) ) ; return new ParameterizedTypeImpl ( clazz , capturedArguments , ownerType ) ; } else { return type ; } } | Applies capture conversion to the given type . | 320 | 9 |
24,662 | public static String getTypeName ( Type type ) { if ( type instanceof Class ) { Class < ? > clazz = ( Class < ? > ) type ; return clazz . isArray ( ) ? ( getTypeName ( clazz . getComponentType ( ) ) + "[]" ) : clazz . getName ( ) ; } else { return type . toString ( ) ; } } | Returns the display name of a Type . | 83 | 8 |
24,663 | private static void buildUpperBoundClassAndInterfaces ( Type type , Set < Class < ? > > result ) { if ( type instanceof ParameterizedType || type instanceof Class < ? > ) { result . add ( erase ( type ) ) ; return ; } for ( Type superType : getExactDirectSuperTypes ( type ) ) { buildUpperBoundClassAndInterfaces ( superType , result ) ; } } | Helper method for getUpperBoundClassAndInterfaces adding the result to the given set . | 91 | 19 |
24,664 | @ Beta public < T > T Mock ( @ NamedParams ( { @ NamedParam ( value = "name" , type = String . class ) , @ NamedParam ( value = "additionalInterfaces" , type = List . class ) , @ NamedParam ( value = "defaultResponse" , type = IDefaultResponse . class ) , @ NamedParam ( value = "verified" , type = Boolean . class ) , @ NamedParam ( value = "useObjenesis" , type = Boolean . class ) } ) Map < String , Object > options ) { invalidMockCreation ( ) ; return null ; } | Creates a mock with the specified options whose type and name are inferred from the left - hand side of the enclosing variable assignment . | 132 | 27 |
24,665 | @ Beta public < T > T Mock ( Map < String , Object > options , Closure interactions ) { invalidMockCreation ( ) ; return null ; } | Creates a mock with the specified options and interactions whose type and name are inferred from the left - hand side of the enclosing assignment . | 34 | 28 |
24,666 | @ Override @ Beta public < T > T Stub ( Class < T > type ) { invalidMockCreation ( ) ; return null ; } | Creates a stub with the specified type . If enclosed in a variable assignment the variable name will be used as the stub s name . | 31 | 27 |
24,667 | @ Override @ Beta public < T > T Spy ( Class < T > type ) { invalidMockCreation ( ) ; return null ; } | Creates a spy with the specified type . If enclosed in a variable assignment the variable name will be used as the spy s name . | 31 | 27 |
24,668 | private boolean hasExpandableVarArgs ( IMockMethod method , List < Object > args ) { List < Class < ? > > paramTypes = method . getParameterTypes ( ) ; return ! paramTypes . isEmpty ( ) && CollectionUtil . getLastElement ( paramTypes ) . isArray ( ) && CollectionUtil . getLastElement ( args ) != null ; } | Tells if the given method call has expandable varargs . Note that Groovy supports vararg syntax for all methods whose last parameter is of array type . | 80 | 32 |
24,669 | public void load ( @ Language ( "Groovy" ) String sourceText ) throws CompilationFailedException { reset ( ) ; try { classLoader . parseClass ( sourceText ) ; } catch ( AstSuccessfullyCaptured e ) { indexAstNodes ( ) ; return ; } throw new AstInspectorException ( "internal error" ) ; } | Compiles the specified source text up to the configured compile phase and stores the resulting AST for subsequent inspection . | 75 | 21 |
24,670 | public void load ( File sourceFile ) throws CompilationFailedException { reset ( ) ; try { classLoader . parseClass ( sourceFile ) ; } catch ( IOException e ) { throw new AstInspectorException ( "cannot read source file" , e ) ; } catch ( AstSuccessfullyCaptured e ) { indexAstNodes ( ) ; return ; } throw new AstInspectorException ( "internal error" ) ; } | Compiles the source text in the specified file up to the configured compile phase and stores the resulting AST for subsequent inspection . | 94 | 24 |
24,671 | private int estimateNumIterations ( Object [ ] dataProviders ) { if ( runStatus != OK ) return - 1 ; if ( dataProviders . length == 0 ) return 1 ; int result = Integer . MAX_VALUE ; for ( Object prov : dataProviders ) { if ( prov instanceof Iterator ) // unbelievably, DGM provides a size() method for Iterators, // although it is of course destructive (i.e. it exhausts the Iterator) continue ; Object rawSize = GroovyRuntimeUtil . invokeMethodQuietly ( prov , "size" ) ; if ( ! ( rawSize instanceof Number ) ) continue ; int size = ( ( Number ) rawSize ) . intValue ( ) ; if ( size < 0 || size >= result ) continue ; result = size ; } return result == Integer . MAX_VALUE ? - 1 : result ; } | - 1 = > unknown | 185 | 5 |
24,672 | private Object [ ] nextArgs ( Iterator [ ] iterators ) { if ( runStatus != OK ) return null ; Object [ ] next = new Object [ iterators . length ] ; for ( int i = 0 ; i < iterators . length ; i ++ ) try { next [ i ] = iterators [ i ] . next ( ) ; } catch ( Throwable t ) { runStatus = supervisor . error ( new ErrorInfo ( currentFeature . getDataProviders ( ) . get ( i ) . getDataProviderMethod ( ) , t ) ) ; return null ; } try { return ( Object [ ] ) invokeRaw ( sharedInstance , currentFeature . getDataProcessorMethod ( ) , next ) ; } catch ( Throwable t ) { runStatus = supervisor . error ( new ErrorInfo ( currentFeature . getDataProcessorMethod ( ) , t ) ) ; return null ; } } | advances iterators and computes args | 189 | 8 |
24,673 | @ Override public < T > T Mock ( Class < T > type ) { return createMock ( inferNameFromType ( type ) , type , MockNature . MOCK , Collections . < String , Object > emptyMap ( ) ) ; } | Creates a mock with the specified type . The mock name will be the types simple name . | 52 | 19 |
24,674 | @ Override public < T > T Mock ( Map < String , Object > options , Class < T > type ) { return createMock ( inferNameFromType ( type ) , type , MockNature . MOCK , options ) ; } | Creates a mock with the specified options and type . The mock name will be the types simple name . | 50 | 21 |
24,675 | @ Override public < T > T Stub ( Class < T > type ) { return createMock ( inferNameFromType ( type ) , type , MockNature . STUB , Collections . < String , Object > emptyMap ( ) ) ; } | Creates a stub with the specified type . The mock name will be the types simple name . | 52 | 19 |
24,676 | @ Override public < T > T Stub ( Map < String , Object > options , Class < T > type ) { return createMock ( inferNameFromType ( type ) , type , MockNature . STUB , options ) ; } | Creates a stub with the specified options and type . The mock name will be the types simple name . | 50 | 21 |
24,677 | @ Override public < T > T Spy ( Class < T > type ) { return createMock ( inferNameFromType ( type ) , type , MockNature . SPY , Collections . < String , Object > emptyMap ( ) ) ; } | Creates a spy with the specified type . The mock name will be the types simple name . | 52 | 19 |
24,678 | @ Override public < T > T Spy ( Map < String , Object > options , Class < T > type ) { return createMock ( inferNameFromType ( type ) , type , MockNature . SPY , options ) ; } | Creates a spy with the specified options and type . The mock name will be the types simple name . | 50 | 21 |
24,679 | public static int getFeatureCount ( Class < ? > spec ) { checkIsSpec ( spec ) ; int count = 0 ; do { for ( Method method : spec . getDeclaredMethods ( ) ) if ( method . isAnnotationPresent ( FeatureMetadata . class ) ) count ++ ; spec = spec . getSuperclass ( ) ; } while ( spec != null && isSpec ( spec ) ) ; return count ; } | Returns the number of features contained in the given specification . Because Spock allows for the dynamic creation of new features at specification run time this number is only an estimate . | 89 | 32 |
24,680 | public boolean hasBytecodeName ( String name ) { if ( featureMethod . hasBytecodeName ( name ) ) return true ; if ( dataProcessorMethod != null && dataProcessorMethod . hasBytecodeName ( name ) ) return true ; for ( DataProviderInfo provider : dataProviders ) if ( provider . getDataProviderMethod ( ) . hasBytecodeName ( name ) ) return true ; return false ; } | Tells if any of the methods associated with this feature has the specified name in bytecode . | 89 | 19 |
24,681 | @ SuppressWarnings ( "unchecked" ) public static List < Statement > getStatements ( MethodNode method ) { Statement code = method . getCode ( ) ; if ( ! ( code instanceof BlockStatement ) ) { // null or single statement BlockStatement block = new BlockStatement ( ) ; if ( code != null ) block . addStatement ( code ) ; method . setCode ( block ) ; } return ( ( BlockStatement ) method . getCode ( ) ) . getStatements ( ) ; } | Returns a list of statements of the given method . Modifications to the returned list will affect the method s statements . | 108 | 23 |
24,682 | public static void fixUpLocalVariables ( List < ? extends Variable > localVariables , VariableScope scope , boolean isClosureScope ) { for ( Variable localVar : localVariables ) { Variable scopeVar = scope . getReferencedClassVariable ( localVar . getName ( ) ) ; if ( scopeVar instanceof DynamicVariable ) { scope . removeReferencedClassVariable ( localVar . getName ( ) ) ; scope . putReferencedLocalVariable ( localVar ) ; if ( isClosureScope ) localVar . setClosureSharedVariable ( true ) ; } } } | Fixes up scope references to variables that used to be free or class variables and have been changed to local variables . | 124 | 23 |
24,683 | private void beforeKey ( ) throws JSONException { Scope context = peek ( ) ; if ( context == Scope . NONEMPTY_OBJECT ) { // first in object out . append ( ' ' ) ; } else if ( context != Scope . EMPTY_OBJECT ) { // not in an object! throw new JSONException ( "Nesting problem" ) ; } newline ( ) ; replaceTop ( Scope . DANGLING_KEY ) ; } | Inserts any necessary separators and whitespace before a name . Also adjusts the stack to expect the key s value . | 96 | 24 |
24,684 | @ Override public String getAuthorizationHeader ( HttpRequest req ) { return generateAuthorizationHeader ( req . getMethod ( ) . name ( ) , req . getURL ( ) , req . getParameters ( ) , oauthToken ) ; } | implementations for Authorization | 53 | 5 |
24,685 | StatusStream getSampleStream ( ) throws TwitterException { ensureAuthorizationEnabled ( ) ; try { return new StatusStreamImpl ( getDispatcher ( ) , http . get ( conf . getStreamBaseURL ( ) + "statuses/sample.json?" + stallWarningsGetParam , null , auth , null ) , conf ) ; } catch ( IOException e ) { throw new TwitterException ( e ) ; } } | Returns a stream of random sample of all public statuses . The default access level provides a small proportion of the Firehose . The Gardenhose access level provides a proportion more suitable for data mining and research applications that desire a larger proportion to be statistically significant sample . | 90 | 54 |
24,686 | private void setHeaders ( HttpRequest req , HttpURLConnection connection ) { if ( logger . isDebugEnabled ( ) ) { logger . debug ( "Request: " ) ; logger . debug ( req . getMethod ( ) . name ( ) + " " , req . getURL ( ) ) ; } String authorizationHeader ; if ( req . getAuthorization ( ) != null && ( authorizationHeader = req . getAuthorization ( ) . getAuthorizationHeader ( req ) ) != null ) { if ( logger . isDebugEnabled ( ) ) { logger . debug ( "Authorization: " , authorizationHeader . replaceAll ( "." , "*" ) ) ; } connection . addRequestProperty ( "Authorization" , authorizationHeader ) ; } if ( req . getRequestHeaders ( ) != null ) { for ( String key : req . getRequestHeaders ( ) . keySet ( ) ) { connection . addRequestProperty ( key , req . getRequestHeaders ( ) . get ( key ) ) ; logger . debug ( key + ": " + req . getRequestHeaders ( ) . get ( key ) ) ; } } } | sets HTTP headers | 244 | 3 |
24,687 | public static List < HttpParameter > decodeParameters ( String queryParameters ) { List < HttpParameter > result = new ArrayList < HttpParameter > ( ) ; for ( String pair : queryParameters . split ( "&" ) ) { String [ ] parts = pair . split ( "=" , 2 ) ; if ( parts . length == 2 ) { String name = decode ( parts [ 0 ] ) ; String value = decode ( parts [ 1 ] ) ; if ( ! name . equals ( "" ) && ! value . equals ( "" ) ) result . add ( new HttpParameter ( name , value ) ) ; } } return result ; } | Parses a query string without the leading ? | 136 | 10 |
24,688 | @ Override public void getOAuthRequestTokenAsync ( ) { getDispatcher ( ) . invokeLater ( new AsyncTask ( OAUTH_REQUEST_TOKEN , listeners ) { @ Override public void invoke ( List < TwitterListener > listeners ) throws TwitterException { RequestToken token = twitter . getOAuthRequestToken ( ) ; for ( TwitterListener listener : listeners ) { try { listener . gotOAuthRequestToken ( token ) ; } catch ( Exception e ) { logger . warn ( "Exception at getOAuthRequestTokenAsync" , e ) ; } } } } ) ; } | implementation for AsyncOAuthSupport | 128 | 8 |
24,689 | public static Status createStatus ( String rawJSON ) throws TwitterException { try { return new StatusJSONImpl ( new JSONObject ( rawJSON ) ) ; } catch ( JSONException e ) { throw new TwitterException ( e ) ; } } | Constructs a Status object from rawJSON string . | 49 | 10 |
24,690 | public static User createUser ( String rawJSON ) throws TwitterException { try { return new UserJSONImpl ( new JSONObject ( rawJSON ) ) ; } catch ( JSONException e ) { throw new TwitterException ( e ) ; } } | Constructs a User object from rawJSON string . | 49 | 10 |
24,691 | public static AccountTotals createAccountTotals ( String rawJSON ) throws TwitterException { try { return new AccountTotalsJSONImpl ( new JSONObject ( rawJSON ) ) ; } catch ( JSONException e ) { throw new TwitterException ( e ) ; } } | Constructs an AccountTotals object from rawJSON string . | 58 | 13 |
24,692 | public static Relationship createRelationship ( String rawJSON ) throws TwitterException { try { return new RelationshipJSONImpl ( new JSONObject ( rawJSON ) ) ; } catch ( JSONException e ) { throw new TwitterException ( e ) ; } } | Constructs a Relationship object from rawJSON string . | 50 | 10 |
24,693 | public static Place createPlace ( String rawJSON ) throws TwitterException { try { return new PlaceJSONImpl ( new JSONObject ( rawJSON ) ) ; } catch ( JSONException e ) { throw new TwitterException ( e ) ; } } | Constructs a Place object from rawJSON string . | 49 | 10 |
24,694 | public static SavedSearch createSavedSearch ( String rawJSON ) throws TwitterException { try { return new SavedSearchJSONImpl ( new JSONObject ( rawJSON ) ) ; } catch ( JSONException e ) { throw new TwitterException ( e ) ; } } | Constructs a SavedSearch object from rawJSON string . | 55 | 12 |
24,695 | public static Trend createTrend ( String rawJSON ) throws TwitterException { try { return new TrendJSONImpl ( new JSONObject ( rawJSON ) ) ; } catch ( JSONException e ) { throw new TwitterException ( e ) ; } } | Constructs a Trend object from rawJSON string . | 49 | 10 |
24,696 | public static Map < String , RateLimitStatus > createRateLimitStatus ( String rawJSON ) throws TwitterException { try { return RateLimitStatusJSONImpl . createRateLimitStatuses ( new JSONObject ( rawJSON ) ) ; } catch ( JSONException e ) { throw new TwitterException ( e ) ; } } | Constructs a RateLimitStatus object from rawJSON string . | 65 | 12 |
24,697 | public static Category createCategory ( String rawJSON ) throws TwitterException { try { return new CategoryJSONImpl ( new JSONObject ( rawJSON ) ) ; } catch ( JSONException e ) { throw new TwitterException ( e ) ; } } | Constructs a Category object from rawJSON string . | 49 | 10 |
24,698 | public static DirectMessage createDirectMessage ( String rawJSON ) throws TwitterException { try { return new DirectMessageJSONImpl ( new JSONObject ( rawJSON ) ) ; } catch ( JSONException e ) { throw new TwitterException ( e ) ; } } | Constructs a DirectMessage object from rawJSON string . | 52 | 11 |
24,699 | public static Location createLocation ( String rawJSON ) throws TwitterException { try { return new LocationJSONImpl ( new JSONObject ( rawJSON ) ) ; } catch ( JSONException e ) { throw new TwitterException ( e ) ; } } | Constructs a Location object from rawJSON string . | 49 | 10 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.