idx int64 0 41.2k | question stringlengths 74 4.21k | target stringlengths 5 888 |
|---|---|---|
11,300 | public void updateDialogMsg ( final int resId ) { if ( dialog != null ) { this . dialog . setMessage ( dialog . getContext ( ) . getText ( resId ) ) ; } } | Change the message in progress dialog |
11,301 | private ListDouble convertToListDouble ( List < String > tokens ) { double [ ] values = new double [ tokens . size ( ) ] ; for ( int i = 0 ; i < values . length ; i ++ ) { if ( tokens . get ( i ) . isEmpty ( ) ) { values [ i ] = Double . NaN ; } else { values [ i ] = Double . parseDouble ( tokens . get ( i ) ) ; } } return new ArrayDouble ( values ) ; } | Given a list of tokens convert them to a list of numbers . |
11,302 | static List < String > csvLines ( Reader reader ) { try { BufferedReader br = new BufferedReader ( reader ) ; List < String > lines = new ArrayList < > ( ) ; String line ; String longLine = null ; while ( ( line = br . readLine ( ) ) != null ) { if ( longLine == null ) { longLine = line ; } else { longLine = longLine . concat ( "\n" ) . concat ( line ) ; } if ( isEvenQuotes ( longLine ) ) { lines . add ( longLine ) ; longLine = null ; } } if ( longLine != null ) { lines . add ( longLine ) ; } return lines ; } catch ( IOException ex ) { throw new RuntimeException ( "Couldn't process data" , ex ) ; } } | Divides the whole text into lines . |
11,303 | static boolean isEvenQuotes ( String string ) { boolean even = true ; for ( int i = 0 ; i < string . length ( ) ; i ++ ) { if ( string . charAt ( i ) == '\"' ) { even = ! even ; } } return even ; } | Determines whether the string contains an even number of double quote characters . |
11,304 | private List < String > parseTitles ( State state , String line ) { List < String > titles = new ArrayList < > ( ) ; state . mLineTokens . reset ( line ) ; while ( state . mLineTokens . find ( ) ) { String value ; if ( state . mLineTokens . start ( 2 ) >= 0 ) { value = state . mLineTokens . group ( 2 ) ; } else { value = state . mQuote . reset ( state . mLineTokens . group ( 1 ) ) . replaceAll ( "\"" ) ; } titles . add ( value ) ; } return titles ; } | Parses the first line to get the column names . |
11,305 | private void parseLine ( State state , String line ) { boolean firstEmpty = false ; if ( line . startsWith ( state . currentSeparator ) ) { line = " " + line ; firstEmpty = true ; } state . mLineTokens . reset ( line ) ; int nColumn = 0 ; while ( state . mLineTokens . find ( ) ) { if ( nColumn == state . nColumns ) { state . columnMismatch = true ; return ; } String token ; if ( state . mLineTokens . start ( 2 ) >= 0 ) { token = state . mLineTokens . group ( 2 ) ; if ( firstEmpty ) { token = "" ; firstEmpty = false ; } if ( ! isTokenNumberParsable ( state , token ) ) { state . columnNumberParsable . set ( nColumn , false ) ; } } else { token = state . mQuote . reset ( state . mLineTokens . group ( 1 ) ) . replaceAll ( "\"" ) ; state . columnNumberParsable . set ( nColumn , false ) ; } state . columnTokens . get ( nColumn ) . add ( token ) ; nColumn ++ ; } if ( nColumn != state . nColumns ) { state . columnMismatch = true ; } } | Parses a line saving the tokens and determines the type match . |
11,306 | private boolean isTokenNumberParsable ( State state , String token ) { if ( token . isEmpty ( ) ) { return true ; } return state . mDouble . reset ( token ) . matches ( ) ; } | Check whether the token can be parsed to a number . |
11,307 | private boolean isFirstLineData ( State state , List < String > headerTokens ) { boolean headerCompatible = true ; boolean allStrings = true ; for ( int i = 0 ; i < state . nColumns ; i ++ ) { if ( state . columnNumberParsable . get ( i ) ) { allStrings = false ; if ( ! isTokenNumberParsable ( state , headerTokens . get ( i ) ) ) { headerCompatible = false ; } } } return ! allStrings && headerCompatible ; } | Checks whether the header can be safely interpreted as data . This is used for the auto header detection . |
11,308 | private List < String > joinList ( final String head , final List < String > tail ) { return new AbstractList < String > ( ) { public String get ( int index ) { if ( index == 0 ) { return head ; } else { return tail . get ( index - 1 ) ; } } public int size ( ) { return tail . size ( ) + 1 ; } } ; } | Takes an elements and a list and returns a new list with both . |
11,309 | public Rule getMatchingRule ( String surt , Date captureDate , Date retrievalDate , String who ) { NewSurtTokenizer tok = new NewSurtTokenizer ( surt ) ; Rule ruleGeneral = null ; for ( String key : tok . getSearchList ( ) ) { Iterable < Rule > rules = rulemap . get ( key ) ; if ( rules != null ) { for ( Rule rule : rules ) { if ( rule . matches ( surt , captureDate , retrievalDate , who ) ) { if ( ( who != null ) && who . equals ( rule . getWho ( ) ) ) { return rule ; } else if ( ruleGeneral == null ) { ruleGeneral = rule ; } } } } } return ruleGeneral ; } | Return the most specific matching rule for the given request . |
11,310 | public synchronized void move ( int line , int column ) { if ( lines ( ) < line ) { this . column = 1 ; } else { String targetLine = lines . get ( line - 1 ) ; if ( targetLine . length ( ) < column ) { this . column = targetLine . length ( ) + 1 ; } else { this . column = column ; } } this . line = line ; } | Moves the index to the specified line and column . If the requested line is greater that the actual lines number and exception is thrown . If the requested column is greater than the line width the index is moved to the end of the line . |
11,311 | public void moveToEndOfFile ( ) { int targetLine = lines . size ( ) + 1 ; move ( targetLine , getContent ( targetLine ) . length ( ) ) ; } | Moves cursor to the end of the line . |
11,312 | public UpdateResponse upsertDataWithObjectMapper ( Object sourceObject , String index , String type , String id ) { return upsertData ( JMElasticsearchUtil . buildSourceByJsonMapper ( sourceObject ) , index , type , id ) ; } | Upsert data with object mapper update response . |
11,313 | public ActionFuture < UpdateResponse > upsertDataASyncWithObjectMapper ( Object sourceObject , String index , String type , String id ) { return upsertDataAsync ( JMElasticsearchUtil . buildSourceByJsonMapper ( sourceObject ) , index , type , id ) ; } | Upsert data a sync with object mapper action future . |
11,314 | public IndexResponse sendDataWithObjectMapper ( Object sourceObject , String index , String type , String id ) { return sendData ( JMElasticsearchUtil . buildSourceByJsonMapper ( sourceObject ) , index , type , id ) ; } | Send data with object mapper index response . |
11,315 | public String sendDataWithObjectMapper ( Object sourceObject , String index , String type ) { return sendDataWithObjectMapper ( sourceObject , index , type , null ) . getId ( ) ; } | Send data with object mapper string . |
11,316 | public ActionFuture < IndexResponse > sendDataAsyncWithObjectMapper ( Object sourceObject , String index , String type , String id ) { return indexQueryAsync ( buildIndexRequest ( JMElasticsearchUtil . buildSourceByJsonMapper ( sourceObject ) , index , type , id ) ) ; } | Send data async with object mapper action future . |
11,317 | private synchronized int read ( long timeout , boolean isPeek ) throws IOException { if ( exception != null ) { assert ch == - 2 ; IOException toBeThrown = exception ; if ( ! isPeek ) exception = null ; throw toBeThrown ; } if ( ch >= - 1 ) { assert exception == null ; } else if ( ( timeout == 0L || isShutdown ) && ! threadIsReading ) { ch = in . read ( ) ; } else { if ( ! threadIsReading ) { threadIsReading = true ; notify ( ) ; } boolean isInfinite = ( timeout <= 0L ) ; while ( isInfinite || timeout > 0L ) { long start = System . currentTimeMillis ( ) ; try { wait ( timeout ) ; } catch ( InterruptedException e ) { } if ( exception != null ) { assert ch == - 2 ; IOException toBeThrown = exception ; if ( ! isPeek ) exception = null ; throw toBeThrown ; } if ( ch >= - 1 ) { assert exception == null ; break ; } if ( ! isInfinite ) { timeout -= System . currentTimeMillis ( ) - start ; } } } int ret = ch ; if ( ! isPeek ) { ch = - 2 ; } return ret ; } | Attempts to read a character from the input stream for a specific period of time . |
11,318 | public static < R extends ActionRequestBuilder > R logRequestQuery ( String method , R requestBuilder , Object ... params ) { if ( params == null ) JMLog . debug ( log , method , requestBuilder ) ; else JMLog . debug ( log , method , Arrays . asList ( params ) , requestBuilder ) ; return requestBuilder ; } | Log request query r . |
11,319 | public Cell < C , T > add ( C widget ) { Cell < C , T > cell = toolkit . obtainCell ( this ) ; cell . widget = widget ; if ( cells . size ( ) > 0 ) { Cell < C , T > lastCell = cells . get ( cells . size ( ) - 1 ) ; if ( ! lastCell . endRow ) { cell . column = lastCell . column + lastCell . colspan ; cell . row = lastCell . row ; } else { cell . column = 0 ; cell . row = lastCell . row + 1 ; } if ( cell . row > 0 ) { outer : for ( int i = cells . size ( ) - 1 ; i >= 0 ; i -- ) { Cell < C , T > other = cells . get ( i ) ; for ( int column = other . column , nn = column + other . colspan ; column < nn ; column ++ ) { if ( column == cell . column ) { cell . cellAboveIndex = i ; break outer ; } } } } } else { cell . column = 0 ; cell . row = 0 ; } cells . add ( cell ) ; cell . set ( cellDefaults ) ; if ( cell . column < columnDefaults . size ( ) ) { Cell < C , T > columnCell = columnDefaults . get ( cell . column ) ; if ( columnCell != null ) cell . merge ( columnCell ) ; } cell . merge ( rowDefaults ) ; if ( widget != null ) toolkit . addChild ( table , widget ) ; return cell ; } | Adds a new cell to the table with the specified widget . |
11,320 | public Cell < C , T > row ( ) { if ( cells . size ( ) > 0 ) endRow ( ) ; if ( rowDefaults != null ) toolkit . freeCell ( rowDefaults ) ; rowDefaults = toolkit . obtainCell ( this ) ; rowDefaults . clear ( ) ; return rowDefaults ; } | Indicates that subsequent cells should be added to a new row and returns the cell values that will be used as the defaults for all cells in the new row . |
11,321 | public Cell < C , T > columnDefaults ( int column ) { Cell < C , T > cell = columnDefaults . size ( ) > column ? columnDefaults . get ( column ) : null ; if ( cell == null ) { cell = toolkit . obtainCell ( this ) ; cell . clear ( ) ; if ( column >= columnDefaults . size ( ) ) { for ( int i = columnDefaults . size ( ) ; i < column ; i ++ ) columnDefaults . add ( null ) ; columnDefaults . add ( cell ) ; } else columnDefaults . set ( column , cell ) ; } return cell ; } | Gets the cell values that will be used as the defaults for all cells in the specified column . Columns are indexed starting at 0 . |
11,322 | public void clear ( ) { for ( int i = cells . size ( ) - 1 ; i >= 0 ; i -- ) { Cell < C , T > cell = cells . get ( i ) ; if ( cell . widget != null ) toolkit . removeChild ( table , cell . widget ) ; toolkit . freeCell ( cell ) ; } cells . clear ( ) ; rows = 0 ; columns = 0 ; if ( rowDefaults != null ) toolkit . freeCell ( rowDefaults ) ; rowDefaults = null ; invalidate ( ) ; } | Removes all widgets and cells from the table . |
11,323 | public Cell < C , T > getCell ( C widget ) { for ( int i = 0 , n = cells . size ( ) ; i < n ; i ++ ) { Cell < C , T > c = cells . get ( i ) ; if ( c . widget == widget ) return c ; } return null ; } | Returns the cell for the specified widget in this table or null . |
11,324 | public BaseTableLayout < C , T > debug ( Debug debug ) { this . debug = debug ; if ( debug == Debug . none ) toolkit . clearDebugRectangles ( this ) ; else invalidate ( ) ; return this ; } | Turns on debug lines . |
11,325 | public int getRow ( float y ) { int row = 0 ; y += h ( padTop ) ; int i = 0 , n = cells . size ( ) ; if ( n == 0 ) return - 1 ; if ( n == 1 ) return 0 ; if ( cells . get ( 0 ) . widgetY < cells . get ( 1 ) . widgetY ) { while ( i < n ) { Cell < C , T > c = cells . get ( i ++ ) ; if ( c . getIgnore ( ) ) continue ; if ( c . widgetY + c . computedPadTop > y ) break ; if ( c . endRow ) row ++ ; } return row - 1 ; } while ( i < n ) { Cell < C , T > c = cells . get ( i ++ ) ; if ( c . getIgnore ( ) ) continue ; if ( c . widgetY + c . computedPadTop < y ) break ; if ( c . endRow ) row ++ ; } return row ; } | Returns the row index for the y coordinate or - 1 if there are no cells . |
11,326 | public static < T > JoinerQuery < T , T > from ( EntityPath < T > from ) { return new JoinerQueryBase < > ( from , from ) ; } | Build from clause of query |
11,327 | public static < T > JoinerQuery < T , Long > count ( EntityPath < T > from ) { JoinerQueryBase < T , Long > request = new JoinerQueryBase < > ( from , true ) ; request . distinct ( false ) ; return request ; } | Build count query |
11,328 | public StatusRepresentation init ( StatusRepresentation s ) { _source = s . _source ; _status = s . _status ; _jsonString = s . _jsonString ; _jsonObj = s . _jsonObj ; _id = s . _id ; return this ; } | Initializes the object to contain the given status |
11,329 | public StatusRepresentation init ( String source , String jsonString ) { if ( jsonString == null || jsonString . contains ( "{" ) ) return init ( source , null , jsonString , null ) ; init ( source , null , null , null ) ; _id = Long . valueOf ( jsonString . trim ( ) ) ; return this ; } | Initializes the object to contain the given status . |
11,330 | public StatusRepresentation init ( String source , Object status , String jsonString , JsonObject jsonObj ) { _source = source ; _status = status ; _jsonString = jsonString ; _jsonObj = jsonObj ; _id = null ; return this ; } | Initializes the object to contain the given status from multiple representations of the object . |
11,331 | public boolean isRelatedTo ( InfluentialContributorSet infs , boolean sender , boolean userMentions , boolean retweetOrigin ) { if ( sender ) { JsonElement js = getJsonObject ( ) . get ( "user" ) ; if ( js != null ) { js = js . getAsJsonObject ( ) . get ( "id" ) ; if ( js != null ) { String userId = js . getAsString ( ) ; if ( infs . contains ( userId ) ) return true ; } } } if ( retweetOrigin ) { JsonElement js = getJsonObject ( ) . get ( "retweeted_status" ) ; if ( js != null ) { js = js . getAsJsonObject ( ) . get ( "user" ) ; if ( js != null ) { js = js . getAsJsonObject ( ) . get ( "id" ) ; if ( js != null ) { String userId = js . getAsString ( ) ; if ( infs . contains ( userId ) ) return true ; } } } } if ( userMentions ) { JsonElement js = getJsonObject ( ) . get ( "entities" ) ; if ( js != null ) { js = js . getAsJsonObject ( ) . get ( "user_mentions" ) ; if ( js != null ) { JsonArray jsa = js . getAsJsonArray ( ) ; for ( int j = 0 ; j < jsa . size ( ) ; j ++ ) { js = jsa . get ( j ) . getAsJsonObject ( ) . get ( "id" ) ; if ( js != null ) { String userId = js . getAsString ( ) ; if ( infs . contains ( userId ) ) return true ; } } } } } return false ; } | Determines whether the Twitter status is related to one of the users in the set of given ids . |
11,332 | public final void saveKeyStore ( OutputStream output , KeyStore keyStore , char [ ] password ) throws IOException { logger . entry ( ) ; try { keyStore . store ( output , password ) ; } catch ( KeyStoreException | NoSuchAlgorithmException | CertificateException e ) { RuntimeException exception = new RuntimeException ( "An unexpected exception occurred while attempting to save a keystore." , e ) ; logger . error ( exception . toString ( ) ) ; throw exception ; } logger . exit ( ) ; } | This method saves a PKCS12 format key store out to an output stream . |
11,333 | public final KeyStore retrieveKeyStore ( InputStream input , char [ ] password ) throws IOException { logger . entry ( ) ; try { KeyStore keyStore = KeyStore . getInstance ( KEY_STORE_FORMAT ) ; keyStore . load ( input , password ) ; logger . exit ( ) ; return keyStore ; } catch ( KeyStoreException | NoSuchAlgorithmException | CertificateException e ) { RuntimeException exception = new RuntimeException ( "An unexpected exception occurred while attempting to retrieve a keystore." , e ) ; logger . error ( exception . toString ( ) ) ; throw exception ; } } | This method retrieves a PKCS12 format key store from an input stream . |
11,334 | public final X509Certificate retrieveCertificate ( KeyStore keyStore , String certificateName ) { try { logger . entry ( ) ; X509Certificate certificate = ( X509Certificate ) keyStore . getCertificate ( certificateName ) ; logger . exit ( ) ; return certificate ; } catch ( KeyStoreException e ) { RuntimeException exception = new RuntimeException ( "An unexpected exception occurred while attempting to retrieve a certificate." , e ) ; logger . error ( exception . toString ( ) ) ; throw exception ; } } | This method retrieves a public certificate from a key store . |
11,335 | public final PrivateKey retrievePrivateKey ( KeyStore keyStore , String keyName , char [ ] password ) { try { logger . entry ( ) ; PrivateKey privateKey = ( PrivateKey ) keyStore . getKey ( keyName , password ) ; logger . exit ( ) ; return privateKey ; } catch ( KeyStoreException | NoSuchAlgorithmException | UnrecoverableKeyException e ) { RuntimeException exception = new RuntimeException ( "An unexpected exception occurred while attempting to retrieve a private key." , e ) ; logger . error ( exception . toString ( ) ) ; throw exception ; } } | This method retrieves a private key from a key store . |
11,336 | public final KeyStore createPkcs12KeyStore ( String keyName , char [ ] password , PrivateKey privateKey , X509Certificate certificate ) { logger . entry ( ) ; List < X509Certificate > certificates = new ArrayList < > ( ) ; certificates . add ( certificate ) ; KeyStore keyStore = createPkcs12KeyStore ( keyName , password , privateKey , certificates ) ; logger . exit ( ) ; return keyStore ; } | This method creates a new PKCS12 format key store containing a named private key and public certificate . |
11,337 | public final KeyStore createPkcs12KeyStore ( String keyName , char [ ] password , PrivateKey privateKey , List < X509Certificate > certificates ) { try { logger . entry ( ) ; X509Certificate [ ] chain = new X509Certificate [ certificates . size ( ) ] ; chain = certificates . toArray ( chain ) ; KeyStore keyStore = KeyStore . getInstance ( KEY_STORE_FORMAT ) ; keyStore . load ( null , null ) ; keyStore . setKeyEntry ( keyName , privateKey , password , chain ) ; logger . exit ( ) ; return keyStore ; } catch ( IOException | KeyStoreException | NoSuchAlgorithmException | CertificateException e ) { RuntimeException exception = new RuntimeException ( "An unexpected exception occurred while attempting to create a new keystore." , e ) ; logger . error ( exception . toString ( ) ) ; throw exception ; } } | This method creates a new PKCS12 format key store containing a named private key and public certificate chain . |
11,338 | public final String encodeKeyStore ( KeyStore keyStore , char [ ] password ) { logger . entry ( ) ; try ( ByteArrayOutputStream out = new ByteArrayOutputStream ( ) ) { keyStore . store ( out , password ) ; out . flush ( ) ; byte [ ] bytes = out . toByteArray ( ) ; String encodedKeyStore = Base64Utils . encode ( bytes ) ; logger . exit ( ) ; return encodedKeyStore ; } catch ( IOException | KeyStoreException | NoSuchAlgorithmException | CertificateException e ) { RuntimeException exception = new RuntimeException ( "An unexpected exception occurred while attempting to encode a keystore." , e ) ; logger . error ( exception . toString ( ) ) ; throw exception ; } } | This method encodes a PKCS12 format key store into a base 64 string format . |
11,339 | public final KeyStore decodeKeyStore ( String base64String , char [ ] password ) { logger . entry ( ) ; byte [ ] bytes = Base64Utils . decode ( base64String ) ; try ( ByteArrayInputStream in = new ByteArrayInputStream ( bytes ) ) { KeyStore keyStore = KeyStore . getInstance ( KEY_STORE_FORMAT ) ; keyStore . load ( in , password ) ; logger . exit ( ) ; return keyStore ; } catch ( IOException | KeyStoreException | NoSuchAlgorithmException | CertificateException e ) { RuntimeException exception = new RuntimeException ( "An unexpected exception occurred while attempting to decode a keystore." , e ) ; logger . error ( exception . toString ( ) ) ; throw exception ; } } | This method decodes a PKCS12 format key store from its encrypted byte stream . |
11,340 | public void decodeFlipped ( ByteBuffer buffer , int stride , Format fmt ) throws IOException { if ( stride <= 0 ) { throw new IllegalArgumentException ( "stride" ) ; } int pos = buffer . position ( ) ; int posDelta = ( height - 1 ) * stride ; buffer . position ( pos + posDelta ) ; decode ( buffer , - stride , fmt ) ; buffer . position ( buffer . position ( ) + posDelta ) ; } | Decodes the image into the specified buffer . The last line is placed at the current position . After decode the buffer position is at the end of the first line . |
11,341 | public void setBulkProcessor ( Listener bulkProcessorListener , int bulkActions , long bulkSizeKB , int flushIntervalSeconds ) { this . bulkProcessor = buildBulkProcessor ( bulkProcessorListener , bulkActions , bulkSizeKB , flushIntervalSeconds ) ; } | Sets bulk processor . |
11,342 | public Builder getBulkProcessorBuilder ( Listener bulkProcessorListener , Integer bulkActions , ByteSizeValue byteSizeValue , TimeValue flushInterval , Integer concurrentRequests , BackoffPolicy backoffPolicy ) { Builder builder = BulkProcessor . builder ( jmESClient , bulkProcessorListener ) ; ifNotNull ( bulkActions , builder :: setBulkActions ) ; ifNotNull ( byteSizeValue , builder :: setBulkSize ) ; ifNotNull ( flushInterval , builder :: setFlushInterval ) ; ifNotNull ( concurrentRequests , builder :: setConcurrentRequests ) ; ifNotNull ( backoffPolicy , builder :: setBackoffPolicy ) ; return builder ; } | Gets bulk processor builder . |
11,343 | public void closeBulkProcessor ( ) { Optional . ofNullable ( bulkProcessor ) . filter ( peek ( BulkProcessor :: flush ) ) . ifPresent ( BulkProcessor :: close ) ; } | Close bulk processor . |
11,344 | public void sendBulkDataAsync ( List < ? extends Map < String , ? > > bulkSourceList , String index , String type ) { executeBulkRequestAsync ( buildBulkIndexRequestBuilder ( bulkSourceList . stream ( ) . map ( source -> jmESClient . prepareIndex ( index , type ) . setSource ( source ) ) . collect ( toList ( ) ) ) ) ; } | Send bulk data async . |
11,345 | public void sendBulkDataWithObjectMapperAsync ( List < Object > objectBulkData , String index , String type ) { executeBulkRequestAsync ( buildBulkIndexRequestBuilder ( objectBulkData . stream ( ) . map ( sourceObject -> jmESClient . prepareIndex ( index , type ) . setSource ( JMElasticsearchUtil . buildSourceByJsonMapper ( sourceObject ) ) ) . collect ( toList ( ) ) ) ) ; } | Send bulk data with object mapper async . |
11,346 | public BulkRequestBuilder buildBulkIndexRequestBuilder ( List < IndexRequestBuilder > indexRequestBuilderList ) { BulkRequestBuilder bulkRequestBuilder = jmESClient . prepareBulk ( ) ; for ( IndexRequestBuilder indexRequestBuilder : indexRequestBuilderList ) bulkRequestBuilder . add ( indexRequestBuilder ) ; return bulkRequestBuilder ; } | Build bulk index request builder bulk request builder . |
11,347 | public BulkRequestBuilder buildDeleteBulkRequestBuilder ( List < DeleteRequestBuilder > deleteRequestBuilderList ) { BulkRequestBuilder bulkRequestBuilder = jmESClient . prepareBulk ( ) ; for ( DeleteRequestBuilder deleteRequestBuilder : deleteRequestBuilderList ) bulkRequestBuilder . add ( deleteRequestBuilder ) ; return bulkRequestBuilder ; } | Build delete bulk request builder bulk request builder . |
11,348 | public BulkRequestBuilder buildUpdateBulkRequestBuilder ( List < UpdateRequestBuilder > updateRequestBuilderList ) { BulkRequestBuilder bulkRequestBuilder = jmESClient . prepareBulk ( ) ; for ( UpdateRequestBuilder updateRequestBuilder : updateRequestBuilderList ) bulkRequestBuilder . add ( updateRequestBuilder ) ; return bulkRequestBuilder ; } | Build update bulk request builder bulk request builder . |
11,349 | public void executeBulkRequestAsync ( BulkRequestBuilder bulkRequestBuilder , ActionListener < BulkResponse > bulkResponseActionListener ) { JMLog . info ( log , "executeBulkRequestAsync" , bulkRequestBuilder , bulkResponseActionListener ) ; bulkRequestBuilder . execute ( bulkResponseActionListener ) ; } | Execute bulk request async . |
11,350 | public BulkResponse executeBulkRequest ( BulkRequestBuilder bulkRequestBuilder ) { JMLog . info ( log , "executeBulkRequest" , bulkRequestBuilder ) ; return bulkRequestBuilder . execute ( ) . actionGet ( ) ; } | Execute bulk request bulk response . |
11,351 | public BulkResponse deleteBulkDocs ( String index , String type , QueryBuilder filterQueryBuilder ) { return executeBulkRequest ( buildDeleteBulkRequestBuilder ( buildExtractDeleteRequestBuilderList ( index , type , filterQueryBuilder ) ) ) ; } | Delete bulk docs bulk response . |
11,352 | void set2 ( int newPrice , int optCur , int back ) { price = newPrice ; optPrev = optCur + 1 ; backPrev = back ; prev1IsLiteral = true ; hasPrev2 = false ; } | Sets to indicate two LZMA symbols of which the first one is a literal . |
11,353 | void set3 ( int newPrice , int optCur , int back2 , int len2 , int back ) { price = newPrice ; optPrev = optCur + len2 + 1 ; backPrev = back ; prev1IsLiteral = true ; hasPrev2 = true ; optPrev2 = optCur ; backPrev2 = back2 ; } | Sets to indicate three LZMA symbols of which the second one is a literal . |
11,354 | public Exception cancel ( Exception error ) { cancelled = true ; if ( error != null ) { this . error = error ; } return error ; } | Can be called in before_EVENT or leave_STATE to cancel the current transition before it happens . It takes an optional error which will overwrite the event s error if it had already been set . |
11,355 | public DeleteIndexResponse deleteIndices ( String ... indices ) { DeleteIndexRequestBuilder requestBuilder = esClient . admin ( ) . indices ( ) . prepareDelete ( indices ) ; return JMElasticsearchUtil . logRequestQueryAndReturn ( "deleteIndices" , requestBuilder , requestBuilder . execute ( ) ) ; } | Delete indices delete index response . |
11,356 | public DeleteResponse deleteDoc ( String index , String type , String id ) { return deleteQuery ( esClient . prepareDelete ( index , type , id ) ) ; } | Delete doc delete response . |
11,357 | public static List < SurtNode > nodesFromSurt ( String surt ) { List < SurtNode > list = new ArrayList < SurtNode > ( ) ; String running = "" ; for ( String token : new NewSurtTokenizer ( surt ) ) { running += token ; list . add ( new SurtNode ( token , running ) ) ; } return list ; } | Return a list of the elements in a given SURT . |
11,358 | public void redrawFooter ( ) { saveCursorPosition ( ) ; Ansi style = ansi ( ) ; if ( getTheme ( ) . getFooterBackground ( ) != null ) { style . bg ( getTheme ( ) . getFooterBackground ( ) ) ; } if ( getTheme ( ) . getFooterForeground ( ) != null ) { style . fg ( getTheme ( ) . getFooterForeground ( ) ) ; } getConsole ( ) . out ( ) . print ( style ) ; getConsole ( ) . out ( ) . print ( ansi ( ) . cursor ( getTerminal ( ) . getHeight ( ) + 1 - getFooterSize ( ) , 1 ) . eraseLine ( Ansi . Erase . FORWARD ) ) ; for ( int i = 1 ; i <= helpLines . size ( ) ; i ++ ) { String helpLine = helpLines . get ( i - 1 ) ; int startColumn = ( getTerminal ( ) . getWidth ( ) - helpLine . length ( ) ) / 2 ; getConsole ( ) . out ( ) . print ( ansi ( ) . cursor ( getTerminal ( ) . getHeight ( ) + 1 - getFooterSize ( ) + i , 1 ) . eraseLine ( Ansi . Erase . FORWARD ) ) ; getConsole ( ) . out ( ) . print ( ansi ( ) . cursor ( getTerminal ( ) . getHeight ( ) + 1 - getFooterSize ( ) + i , startColumn ) ) ; getConsole ( ) . out ( ) . print ( helpLine ) ; } getConsole ( ) . out ( ) . print ( ansi ( ) . reset ( ) ) ; restoreCursorPosition ( ) ; } | Refreshes the footer that displays the current line and column . |
11,359 | public static void unfailable ( final ThrowingRunnable runnable ) { try { runnable . run ( ) ; } catch ( final Exception exc ) { Optional . ofNullable ( Thread . currentThread ( ) . getUncaughtExceptionHandler ( ) ) . ifPresent ( ueh -> ueh . uncaughtException ( Thread . currentThread ( ) , exc ) ) ; } } | Runs the given ThrowingRunnable and catches all Exceptions reporting them to the uncaught exception handler . |
11,360 | public static int binarySearchValueOrLower ( ListNumber values , double value ) { if ( value <= values . getDouble ( 0 ) ) { return 0 ; } if ( value >= values . getDouble ( values . size ( ) - 1 ) ) { return values . size ( ) - 1 ; } int index = binarySearch ( 0 , values . size ( ) - 1 , values , value ) ; while ( index != 0 && value == values . getDouble ( index - 1 ) ) { index -- ; } return index ; } | Finds the value in the list or the one right below it . |
11,361 | public static int binarySearchValueOrHigher ( ListNumber values , double value ) { if ( value <= values . getDouble ( 0 ) ) { return 0 ; } if ( value >= values . getDouble ( values . size ( ) - 1 ) ) { return values . size ( ) - 1 ; } int index = binarySearch ( 0 , values . size ( ) - 1 , values , value ) ; while ( index != values . size ( ) - 1 && value > values . getDouble ( index ) ) { index ++ ; } while ( index != values . size ( ) - 1 && value == values . getDouble ( index + 1 ) ) { index ++ ; } return index ; } | Finds the value in the list or the one right above it . |
11,362 | public static ListNumber linearList ( final double initialValue , final double increment , final int size ) { if ( size <= 0 ) { throw new IllegalArgumentException ( "Size must be positive (was " + size + " )" ) ; } return new LinearListDouble ( size , initialValue , increment ) ; } | Creates a list of equally spaced values given the first value the step between element and the size of the list . |
11,363 | public static ListDouble rescale ( final ListNumber data , final double factor , final double offset ) { if ( factor == 1.0 ) return add ( data , offset ) ; return new ListDouble ( ) { public double getDouble ( int index ) { return factor * data . getDouble ( index ) + offset ; } public int size ( ) { return data . size ( ) ; } } ; } | Performs a linear transformation on the data . |
11,364 | public static ListDouble inverseRescale ( final ListNumber data , final double numerator , final double offset ) { return new ListDouble ( ) { public double getDouble ( int index ) { return numerator / data . getDouble ( index ) + offset ; } public int size ( ) { return data . size ( ) ; } } ; } | Performs a linear transformation on inverse value of each number in a list . |
11,365 | public static ListDouble pow ( final ListNumber data , final double expon ) { return new ListDouble ( ) { public double getDouble ( int index ) { return Math . pow ( data . getDouble ( index ) , expon ) ; } public int size ( ) { return data . size ( ) ; } } ; } | Raises each value in a list to the same power . |
11,366 | public static ListDouble pow ( final double base , final ListNumber expons ) { return new ListDouble ( ) { public double getDouble ( int index ) { return Math . pow ( base , expons . getDouble ( index ) ) ; } public int size ( ) { return expons . size ( ) ; } } ; } | Raises a value to the power of each value in a list . |
11,367 | public static ListDouble add ( final ListNumber data1 , final ListNumber data2 ) { if ( data1 . size ( ) != data2 . size ( ) ) throw new IllegalArgumentException ( "Can't sum ListNumbers of different size (" + data1 . size ( ) + " - " + data2 . size ( ) + ")" ) ; return new ListDouble ( ) { public double getDouble ( int index ) { return data1 . getDouble ( index ) + data2 . getDouble ( index ) ; } public int size ( ) { return data1 . size ( ) ; } } ; } | Returns a list where each element is the sum of the elements of the two lists at the same index . The lists have to match in size . |
11,368 | void validate ( ) throws ApplicationUnavailableException , AuthenticationException { V1ConnectionValidator validator = new V1ConnectionValidator ( applicationPath , username , password , proxySettings ) ; for ( String key : customHttpHeaders . keySet ( ) ) { validator . getCustomHttpHeaders ( ) . put ( key , customHttpHeaders . get ( key ) ) ; } try { validator . checkConnection ( ) ; } catch ( ConnectionException e ) { throw new ApplicationUnavailableException ( "Unable to connect to VersionOne." , e ) ; } try { validator . checkAuthentication ( ) ; } catch ( ConnectionException e ) { throw new AuthenticationException ( "Invalid username or password." , e ) ; } } | Validates server connection and authentication . |
11,369 | private synchronized static void acquireWakeLock ( Context context ) { if ( sWakeLock == null ) { PowerManager powerManager = ( PowerManager ) context . getApplicationContext ( ) . getSystemService ( Context . POWER_SERVICE ) ; sWakeLock = powerManager . newWakeLock ( PowerManager . PARTIAL_WAKE_LOCK , NAME ) ; sWakeLock . setReferenceCounted ( true ) ; } sWakeLock . acquire ( ) ; sLogger . log ( WingsService . class , "acquireWakeLock" , "sWakeLock=" + sWakeLock ) ; } | Acquires a wake lock . |
11,370 | private synchronized static void releaseWakeLock ( ) { if ( sWakeLock != null ) { if ( sWakeLock . isHeld ( ) ) { sWakeLock . release ( ) ; if ( ! sWakeLock . isHeld ( ) ) { sWakeLock = null ; } } else { sWakeLock = null ; } } sLogger . log ( WingsService . class , "releaseWakeLock" , "sWakeLock=" + sWakeLock ) ; } | Releases the wake lock if one is held . |
11,371 | private void scheduleRetry ( ) { Context appContext = getApplicationContext ( ) ; long nextRetry = System . currentTimeMillis ( ) + RetryPolicy . incrementAndGetTime ( appContext ) ; scheduleWingsService ( appContext , nextRetry ) ; } | Schedules a retry in the future . This method figures out how far in the future the next attempt should be . |
11,372 | public Task createTask ( String name , Map < String , Object > attributes ) { return getInstance ( ) . create ( ) . task ( name , this , attributes ) ; } | Create a task that belongs to this item . |
11,373 | public Collection < SecondaryWorkitem > getSecondaryWorkitems ( SecondaryWorkitemFilter filter ) { if ( filter == null ) { filter = new SecondaryWorkitemFilter ( ) ; } filter . parent . clear ( ) ; filter . parent . add ( this ) ; return getInstance ( ) . get ( ) . secondaryWorkitems ( filter ) ; } | Collection of Tasks and Tests that belong to this primary workitem . |
11,374 | public Story generateStory ( Map < String , Object > attributes ) { Story result = getInstance ( ) . createNew ( Story . class , this ) ; getInstance ( ) . create ( ) . addAttributes ( result , attributes ) ; result . save ( ) ; return result ; } | Creates a Story from this Request . |
11,375 | public Defect generateDefect ( Map < String , Object > attributes ) { Defect result = getInstance ( ) . createNew ( Defect . class , this ) ; getInstance ( ) . create ( ) . addAttributes ( result , attributes ) ; result . save ( ) ; return result ; } | Creates a Defect from this Request . |
11,376 | public static String unescapeString ( String escapedString ) { Matcher match = escapeSequence . matcher ( escapedString ) ; StringBuffer output = new StringBuffer ( ) ; while ( match . find ( ) ) { match . appendReplacement ( output , substitution ( match . group ( ) ) ) ; } match . appendTail ( output ) ; return output . toString ( ) ; } | Takes an escaped string and returns the unescaped version |
11,377 | public void raiseEvent ( String eventName , Object ... args ) throws InTrasistionException , InvalidEventException , UnknownEventException , NoTransitionException , CancelledException , AsyncException , NotInTransitionException { if ( transition != null ) throw new InTrasistionException ( eventName ) ; String dst = transitions . get ( new EventKey ( eventName , current ) ) ; if ( dst == null ) { for ( EventKey key : transitions . keySet ( ) ) { if ( key . event . equals ( eventName ) ) { throw new InvalidEventException ( eventName , current ) ; } } throw new UnknownEventException ( eventName ) ; } Event event = new Event ( this , eventName , current , dst , null , false , false , args ) ; callCallbacks ( event , CallbackType . BEFORE_EVENT ) ; if ( current . equals ( dst ) ) { callCallbacks ( event , CallbackType . AFTER_EVENT ) ; throw new NoTransitionException ( event . error ) ; } transition = ( ) -> { current = dst ; try { callCallbacks ( event , CallbackType . ENTER_STATE ) ; callCallbacks ( event , CallbackType . AFTER_EVENT ) ; } catch ( Exception e ) { throw new InternalError ( e ) ; } } ; callCallbacks ( event , CallbackType . LEAVE_STATE ) ; transition ( ) ; } | Initiates a state transition with the named event . The call takes a variable number of arguments that will be passed to the callback if defined . |
11,378 | public void callCallbacks ( Event event , CallbackType type ) throws CancelledException , AsyncException { String trigger = event . name ; if ( type == CallbackType . LEAVE_STATE ) trigger = event . src ; else if ( type == CallbackType . ENTER_STATE ) trigger = event . dst ; Callback [ ] callbacks = new Callback [ ] { this . callbacks . get ( new CallbackKey ( trigger , type ) ) , this . callbacks . get ( new CallbackKey ( "" , type ) ) , } ; for ( Callback callback : callbacks ) { if ( callback != null ) { callback . run ( event ) ; if ( type == CallbackType . LEAVE_STATE ) { if ( event . cancelled ) { transition = null ; throw new CancelledException ( event . error ) ; } else if ( event . async ) { throw new AsyncException ( event . error ) ; } } else if ( type == CallbackType . BEFORE_EVENT ) { if ( event . cancelled ) { throw new CancelledException ( event . error ) ; } } } } } | Calls the callbacks of type type ; first the named then the general version . |
11,379 | public void save ( Map < String , Object > properties ) throws PropertyException { try { mWriter . save ( properties ) ; } catch ( IOException e ) { throw new PropertyException ( e . getMessage ( ) ) ; } } | Save all properties in a file . |
11,380 | public Object getValue ( String propertyPath , Object defaultValue ) { Object o = null ; try { o = getValue ( propertyPath ) ; } catch ( PropertyException e ) { return defaultValue ; } return o ; } | Get the value from the property path . If the property path does not exist the default value is returned . |
11,381 | public String getString ( String propertyPath , String defaultValue ) { Object o = getValue ( propertyPath , defaultValue ) ; if ( o != null ) { return o . toString ( ) ; } else { return ( String ) o ; } } | Get the String - value from the property path . If the property path does not exist the default value is returned . |
11,382 | public int getInt ( String propertyPath , int defaultValue ) { Object o = getValue ( propertyPath , defaultValue ) ; return Integer . parseInt ( o . toString ( ) ) ; } | Get the int - value from the property path . If the property path does not exist the default value is returned . |
11,383 | public double getDouble ( String propertyPath ) throws PropertyException { Object o = getValue ( propertyPath ) ; return Double . parseDouble ( o . toString ( ) ) ; } | Get the double - value from the property path . |
11,384 | public boolean getBoolean ( String propertyPath ) throws PropertyException { Object o = getValue ( propertyPath ) ; return Boolean . parseBoolean ( o . toString ( ) ) ; } | Get the boolean - value from the property path . |
11,385 | @ SuppressWarnings ( "unused" ) private String removeLastToken ( String propertyPath ) { String [ ] propertyKeyArray = propertyPath . split ( "\\." ) ; StringBuilder sb = new StringBuilder ( ) ; for ( int i = 0 ; i < propertyKeyArray . length - 2 ; i ++ ) { sb . append ( propertyKeyArray [ i ] ) ; sb . append ( '.' ) ; } sb . append ( propertyKeyArray [ propertyKeyArray . length - 2 ] ) ; return sb . toString ( ) ; } | Remove the last part of a property path . |
11,386 | public Collection < Theme > getChildThemes ( ThemeFilter filter ) { filter = ( filter != null ) ? filter : new ThemeFilter ( ) ; filter . parent . clear ( ) ; filter . parent . add ( this ) ; return getInstance ( ) . get ( ) . themes ( filter ) ; } | Child Themes of this Theme . |
11,387 | public Collection < Request > getRequests ( RequestFilter filter ) { filter = ( filter != null ) ? filter : new RequestFilter ( ) ; filter . issues . clear ( ) ; filter . issues . add ( this ) ; return getInstance ( ) . get ( ) . requests ( filter ) ; } | Requests associated with this Issue . |
11,388 | public Collection < Epic > getBlockedEpics ( EpicFilter filter ) { filter = ( filter != null ) ? filter : new EpicFilter ( ) ; filter . blockingIssues . clear ( ) ; filter . blockingIssues . add ( this ) ; return getInstance ( ) . get ( ) . epics ( filter ) ; } | Epics that cannot be completed because of this Issue . |
11,389 | public int compareTo ( Timestamp other ) { if ( unixSec < other . unixSec ) { return - 1 ; } else if ( unixSec == other . unixSec ) { if ( nanoSec < other . nanoSec ) { return - 1 ; } else if ( nanoSec == other . nanoSec ) { return 0 ; } else { return 1 ; } } else { return 1 ; } } | Defines the natural ordering for timestamp as forward in time . |
11,390 | public Timestamp plus ( TimeDuration duration ) { return createWithCarry ( unixSec + duration . getSec ( ) , nanoSec + duration . getNanoSec ( ) ) ; } | Adds the given duration to this timestamp and returns the result . |
11,391 | private static Timestamp createWithCarry ( long seconds , long nanos ) { if ( nanos > 999999999 ) { seconds = seconds + nanos / 1000000000 ; nanos = nanos % 1000000000 ; } if ( nanos < 0 ) { long pastSec = nanos / 1000000000 ; pastSec -- ; seconds += pastSec ; nanos -= pastSec * 1000000000 ; } return new Timestamp ( seconds , ( int ) nanos ) ; } | Creates a new time stamp by carrying nanosecs into seconds if necessary . |
11,392 | public TimeDuration durationBetween ( Timestamp time ) { long nanoSecDiff = time . nanoSec - nanoSec ; nanoSecDiff += ( time . unixSec - unixSec ) * 1000000000 ; nanoSecDiff = Math . abs ( nanoSecDiff ) ; return TimeDuration . ofNanos ( nanoSecDiff ) ; } | Calculates the time between the reference and this timeStamp . The resulting duration is the absolute value so it does not matter on which object the function is called . |
11,393 | public TimeDuration durationFrom ( Timestamp reference ) { long nanoSecDiff = nanoSec - reference . nanoSec ; nanoSecDiff += ( unixSec - reference . unixSec ) * 1000000000 ; return TimeDuration . ofNanos ( nanoSecDiff ) ; } | Calculates the time passed from the reference to this timeStamp . The result is the relative time from the reference to this timestamp so that reference + result = this . |
11,394 | public void itemStateChanged ( ItemEvent iEvt ) { String item = ( String ) iEvt . getItem ( ) ; int i ; for ( i = 0 ; i < localeCount ; i ++ ) { if ( locales [ i ] . getDisplayName ( ) . equals ( item ) ) break ; } setLocale ( locales [ i ] , false ) ; } | The ItemListener for the locales . |
11,395 | public Enumeration elements ( ) { Iterator iter ; Vector list ; iter = m_Words . iterator ( ) ; list = new Vector ( ) ; while ( iter . hasNext ( ) ) list . add ( iter . next ( ) ) ; Collections . sort ( list ) ; return list . elements ( ) ; } | Returns a sorted enumeration over all stored stopwords |
11,396 | public void read ( BufferedReader reader ) throws Exception { String line ; clear ( ) ; while ( ( line = reader . readLine ( ) ) != null ) { line = line . trim ( ) ; if ( line . startsWith ( "#" ) ) continue ; add ( line ) ; } reader . close ( ) ; } | Generates a new Stopwords object from the reader . The reader is closed automatically . |
11,397 | public void write ( BufferedWriter writer ) throws Exception { Enumeration enm ; writer . write ( "# generated " + new Date ( ) ) ; writer . newLine ( ) ; enm = elements ( ) ; while ( enm . hasMoreElements ( ) ) { writer . write ( enm . nextElement ( ) . toString ( ) ) ; writer . newLine ( ) ; } writer . flush ( ) ; writer . close ( ) ; } | Writes the current stopwords to the given writer . The writer is closed automatically . |
11,398 | public IFilterTerm buildFilter ( IAssetType assetType , V1Instance instance ) { FilterBuilder builder = new FilterBuilder ( assetType , instance ) ; internalModifyFilter ( builder ) ; internalModifyState ( builder ) ; return builder . root . hasTerm ( ) ? builder . root : null ; } | Create representation one filter term on a query . |
11,399 | public static < A , B > Function < B , A > constant ( final A a ) { return b -> a ; } | Returns a function that ignores it s arguments and always returns the given value . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.