idx int64 0 41.2k | question stringlengths 74 4.21k | target stringlengths 5 888 |
|---|---|---|
11,400 | @ SuppressWarnings ( "unchecked" ) public static < T > Predicate < T > and ( final Predicate < ? extends T > ... ps ) { return c -> { for ( final Predicate < ? extends T > p : ps ) { if ( ! ( ( Predicate < T > ) p ) . test ( c ) ) { return false ; } } return true ; } ; } | Combines many predicates into a predicate that accepts its input only if it passes all predicates . |
11,401 | public static < T > Predicate < T > predicate ( final Function < T , Boolean > predicate ) { return predicate :: apply ; } | Turns a function that results in a boxed Boolean into a Predicate . |
11,402 | public void actionPerformed ( ActionEvent e ) { int x = calendarButton . getWidth ( ) - ( int ) popup . getPreferredSize ( ) . getWidth ( ) ; int y = calendarButton . getY ( ) + calendarButton . getHeight ( ) ; Calendar calendar = Calendar . getInstance ( ) ; Date date = dateEditor . getDate ( ) ; if ( date != null ) { calendar . setTime ( date ) ; } jcalendar . setCalendar ( calendar ) ; popup . show ( calendarButton , x , y ) ; dateSelected = false ; } | Called when the jalendar button was pressed . |
11,403 | public void propertyChange ( PropertyChangeEvent evt ) { if ( evt . getPropertyName ( ) . equals ( "day" ) ) { if ( popup . isVisible ( ) && jcalendar . getCalendar ( ) . get ( Calendar . MONTH ) == jcalendar . monthChooser . getMonth ( ) ) { dateSelected = true ; popup . setVisible ( false ) ; setDate ( jcalendar . getCalendar ( ) . getTime ( ) ) ; } } else if ( evt . getPropertyName ( ) . equals ( "date" ) ) { if ( evt . getSource ( ) == dateEditor ) { firePropertyChange ( "date" , evt . getOldValue ( ) , evt . getNewValue ( ) ) ; } else { setDate ( ( Date ) evt . getNewValue ( ) ) ; } } } | Listens for a date property change or a day property change event from the JCalendar . Updates the date editor and closes the popup . |
11,404 | public void setCalendar ( Calendar calendar ) { if ( calendar == null ) { dateEditor . setDate ( null ) ; } else { dateEditor . setDate ( calendar . getTime ( ) ) ; } } | Sets the calendar . Value null will set the null date on the date editor . |
11,405 | public void setEnabled ( boolean enabled ) { super . setEnabled ( enabled ) ; if ( dateEditor != null ) { dateEditor . setEnabled ( enabled ) ; calendarButton . setEnabled ( enabled ) ; } } | Enable or disable the JDateChooser . |
11,406 | public void setFont ( Font font ) { if ( isInitialized ) { dateEditor . getUiComponent ( ) . setFont ( font ) ; jcalendar . setFont ( font ) ; } super . setFont ( font ) ; } | Sets the font of all subcomponents . |
11,407 | public static void main ( String [ ] s ) { JFrame frame = new JFrame ( "JDateChooser" ) ; JDateChooser dateChooser = new JDateChooser ( ) ; frame . getContentPane ( ) . add ( dateChooser ) ; frame . pack ( ) ; frame . setVisible ( true ) ; } | Creates a JFrame with a JDateChooser inside and can be used for testing . |
11,408 | public int getDays ( ) { switch ( _units ) { case Days : return _amount ; case Weeks : return _amount * 7 ; case Months : if ( _amount <= 1 ) return _amount * 30 ; else if ( _amount < 12 ) return ( _amount * 61 ) / 2 ; else return ( _amount * 365 ) / 12 ; default : throw new UnsupportedOperationException ( ) ; } } | Get amount of this Duration in days |
11,409 | public static boolean compare ( Duration a , Duration b ) { if ( null == a || null == b ) return ( null == a ) && ( null == b ) ; return a . equals ( b ) ; } | Compare two Duration instances |
11,410 | public void setAbove ( T assetToRankAheadOf ) { instance . rankAbove ( asset , assetToRankAheadOf , rankAttribute ) ; asset . save ( ) ; } | Set this Entity ahead of the passed in Entity in rank order . |
11,411 | public void setBelow ( T assetToRankAfter ) { instance . rankBelow ( asset , assetToRankAfter , rankAttribute ) ; asset . save ( ) ; } | Set this Entity after the passed in Entity in rank order . |
11,412 | public void bind ( String flavor , Class < ? extends ConsoleEditor > editorClass ) { flavorMap . put ( flavor , editorClass ) ; } | Binds the specified flavor to the specified class . |
11,413 | public Collection < Issue > getIssues ( IssueFilter filter ) { filter = ( filter == null ) ? new IssueFilter ( ) : filter ; filter . team . clear ( ) ; filter . team . add ( this ) ; return getInstance ( ) . get ( ) . issues ( filter ) ; } | Gets the Issues assigned to this Team . |
11,414 | public Collection < Retrospective > getRetrospectives ( RetrospectiveFilter filter ) { filter = ( filter == null ) ? new RetrospectiveFilter ( ) : filter ; filter . team . clear ( ) ; filter . team . add ( this ) ; return getInstance ( ) . get ( ) . retrospectives ( filter ) ; } | Gets the Retrospectives assigned to this Team . |
11,415 | public String getContextUrl ( HttpServletRequest request ) { StringBuffer url = request . getRequestURL ( ) ; String context = request . getContextPath ( ) ; String contextUrl = url . substring ( 0 , url . indexOf ( context ) + context . length ( ) ) ; return contextUrl ; } | Return the full URL of the context . |
11,416 | public Timestamp parse ( String source , ParsePosition pos ) { if ( nanoPattern ) throw new UnsupportedOperationException ( "Not supporting parsing of nanosecond field." ) ; return Timestamp . of ( dateFormat . parse ( source , pos ) ) ; } | Parses the source at the given position . |
11,417 | public Timestamp parse ( String source ) throws ParseException { ParsePosition pos = new ParsePosition ( 0 ) ; Timestamp result = parse ( source , pos ) ; if ( pos . getIndex ( ) == 0 ) throw new ParseException ( "Unparseable date: \"" + source + "\"" , pos . getErrorIndex ( ) ) ; return result ; } | Parses a String and converts it to a Timestamp . |
11,418 | static String defaultPattern ( Locale locale ) { return ( ( SimpleDateFormat ) DateFormat . getDateTimeInstance ( DateFormat . SHORT , DateFormat . MEDIUM , locale ) ) . toPattern ( ) . replace ( "ss" , "ss.SSS" ) ; } | This method returns the default pattern modified to add millisecond after the seconds . |
11,419 | public Project createSubProject ( String name , DateTime beginDate , Schedule schedule ) { return getInstance ( ) . create ( ) . project ( name , this , beginDate , schedule ) ; } | Create a sub project under this project with a name begin date and optional schedule . |
11,420 | public Project createSubProject ( String name , DateTime beginDate ) { return createSubProject ( name , beginDate , null ) ; } | Create a sub project under this project with a name and begin date . |
11,421 | public Epic createEpic ( String name , Map < String , Object > attributes ) { return getInstance ( ) . create ( ) . epic ( name , this , attributes ) ; } | Create a new Epic in this Project . |
11,422 | public Defect createDefect ( String name , Map < String , Object > attributes ) { return getInstance ( ) . create ( ) . defect ( name , this , attributes ) ; } | Create a new Defect in this Project . |
11,423 | public Theme createTheme ( String name , Map < String , Object > attributes ) { return getInstance ( ) . create ( ) . theme ( name , this , attributes ) ; } | Create a new Theme in this Project . |
11,424 | public Goal createGoal ( String name , Map < String , Object > attributes ) { return getInstance ( ) . create ( ) . goal ( name , this , attributes ) ; } | Create a new Goal in this Project . |
11,425 | public Request createRequest ( String name , Map < String , Object > attributes ) { return getInstance ( ) . create ( ) . request ( name , this , attributes ) ; } | Create a new Request in this Project . |
11,426 | public Issue createIssue ( String name , Map < String , Object > attributes ) { return getInstance ( ) . create ( ) . issue ( name , this , attributes ) ; } | Create a new Issue in this Project . |
11,427 | public Retrospective createRetrospective ( String name , Map < String , Object > attributes ) { return getInstance ( ) . create ( ) . retrospective ( name , this , attributes ) ; } | Create a new Retrospective in this Project . |
11,428 | public Iteration createIteration ( Map < String , Object > attributes ) { return getInstance ( ) . create ( ) . iteration ( this , attributes ) ; } | Create a new Iteration in the Project where the schedule is defined . Use the suggested system values for the new iteration . |
11,429 | public RegressionPlan createRegressionPlan ( String name , Map < String , Object > attributes ) { return getInstance ( ) . create ( ) . regressionPlan ( name , this , attributes ) ; } | Creates a new Regression Plan in the Project with additional attributes . |
11,430 | public Environment createEnvironment ( String name , Map < String , Object > attributes ) { return getInstance ( ) . create ( ) . environment ( name , this , attributes ) ; } | Creates a new Environment in the Project with additional attributes . |
11,431 | public Collection < Project > getChildProjects ( ProjectFilter filter , boolean includeSubprojects ) { if ( filter == null ) { filter = new ProjectFilter ( ) ; } filter . parent . clear ( ) ; if ( includeSubprojects ) { filter . parent . addAll ( getThisAndAllChildProjects ( ) ) ; } else { filter . parent . add ( this ) ; } return getInstance ( ) . get ( ) . projects ( filter ) ; } | A collection of sub - projects that belong to this project . |
11,432 | public Collection < Effort > getEffortRecords ( EffortFilter filter , boolean includeSubprojects ) { filter = ( filter != null ) ? filter : new EffortFilter ( ) ; filter . project . clear ( ) ; if ( includeSubprojects ) { for ( Project p : getThisAndAllChildProjects ( ) ) { filter . project . add ( p ) ; } } else { filter . project . add ( this ) ; } return getInstance ( ) . get ( ) . effortRecords ( filter ) ; } | A collection of Effort records that belong to this project . |
11,433 | public Collection < Epic > getEpics ( EpicFilter filter , boolean includeSubprojects ) { filter = ( filter != null ) ? filter : new EpicFilter ( ) ; return getInstance ( ) . get ( ) . epics ( getFilter ( filter , includeSubprojects ) ) ; } | Get Epics in this Project filtered as specified in the passed in filter . |
11,434 | public Collection < Epic > GetTrackedEpics ( ) { Collection < Project > projects = new ArrayList < Project > ( ) ; projects . add ( this ) ; return getInstance ( ) . get ( ) . trackedEpics ( projects ) ; } | Get tracked Epics that belong to current Project . |
11,435 | public Collection < Story > getStories ( StoryFilter filter , boolean includeSubprojects ) { filter = ( filter != null ) ? filter : new StoryFilter ( ) ; return getInstance ( ) . get ( ) . story ( getFilter ( filter , includeSubprojects ) ) ; } | Get stories in this Project filtered as specified in the passed in filter . |
11,436 | public Collection < Defect > getDefects ( DefectFilter filter , boolean includeSubprojects ) { if ( filter == null ) filter = new DefectFilter ( ) ; return getInstance ( ) . get ( ) . defects ( getFilter ( filter , includeSubprojects ) ) ; } | Get Defects in this Project filtered as specified in the passed in filter . |
11,437 | public Collection < PrimaryWorkitem > getPrimaryWorkitems ( PrimaryWorkitemFilter filter , boolean includeSubprojects ) { filter = ( filter != null ) ? filter : new PrimaryWorkitemFilter ( ) ; return getInstance ( ) . get ( ) . primaryWorkitems ( getFilter ( filter , includeSubprojects ) ) ; } | Get PrimaryWorkitems in this Project filtered as specified in the passed in filter . |
11,438 | public Collection < Iteration > getIterations ( IterationFilter filter , boolean includeSubprojects ) { filter = ( filter != null ) ? filter : new IterationFilter ( ) ; filter . schedule . clear ( ) ; if ( includeSubprojects ) { for ( Project p : getThisAndAllChildProjects ( ) ) { filter . schedule . add ( p . getSchedule ( ) ) ; } } else { filter . schedule . add ( getSchedule ( ) ) ; } return getInstance ( ) . get ( ) . iterations ( filter ) ; } | Get Iterations in this Project s schedule filtered as specified in the passed in filter . This returns iterations even if the schedule is defined in a parent project . |
11,439 | public Collection < Theme > getThemes ( ThemeFilter filter , boolean includeSubprojects ) { filter = ( filter != null ) ? filter : new ThemeFilter ( ) ; return getInstance ( ) . get ( ) . themes ( getFilter ( filter , includeSubprojects ) ) ; } | Get Themes in this Project filtered as specified in the passed in filter . |
11,440 | public Collection < SecondaryWorkitem > getSecondaryWorkitems ( SecondaryWorkitemFilter filter , boolean includeSubprojects ) { filter = ( filter != null ) ? filter : new SecondaryWorkitemFilter ( ) ; return getInstance ( ) . get ( ) . secondaryWorkitems ( getFilter ( filter , includeSubprojects ) ) ; } | Get SecondaryWorkitems in this Project filtered as specified in the passed in filter . |
11,441 | public Collection < Task > getTasks ( TaskFilter filter ) { filter = ( filter != null ) ? filter : new TaskFilter ( ) ; return getInstance ( ) . get ( ) . tasks ( getFilter ( filter , false ) ) ; } | Get Tasks in this Project filtered as specified in the passed in filter . |
11,442 | public Collection < Request > getRequests ( RequestFilter filter , boolean includeSubprojects ) { filter = ( filter != null ) ? filter : new RequestFilter ( ) ; return getInstance ( ) . get ( ) . requests ( getFilter ( filter , includeSubprojects ) ) ; } | Get Requests in this Project filtered as specified in the passed in filter . |
11,443 | public Collection < Goal > getGoals ( GoalFilter filter , boolean includeSubprojects ) { filter = ( filter != null ) ? filter : new GoalFilter ( ) ; return getInstance ( ) . get ( ) . goals ( getFilter ( filter , includeSubprojects ) ) ; } | Get Goals in this Project filtered as specified in the passed in filter . |
11,444 | public Collection < Retrospective > getRetrospectives ( RetrospectiveFilter filter , boolean includeSubprojects ) { filter = ( filter != null ) ? filter : new RetrospectiveFilter ( ) ; return getInstance ( ) . get ( ) . retrospectives ( getFilter ( filter , includeSubprojects ) ) ; } | Get Retrospective in this Project filtered as specified in the passed in filter . |
11,445 | public Collection < Issue > getIssues ( IssueFilter filter , boolean includeSubprojects ) { filter = ( filter != null ) ? filter : new IssueFilter ( ) ; return getInstance ( ) . get ( ) . issues ( getFilter ( filter , includeSubprojects ) ) ; } | Get Issues in this Project filtered as specified in the passed in filter . |
11,446 | public Collection < RegressionPlan > getRegressionPlans ( RegressionPlanFilter filter , boolean includeSubprojects ) { filter = ( filter != null ) ? filter : new RegressionPlanFilter ( ) ; filter . project . clear ( ) ; if ( includeSubprojects ) { for ( Project project : getThisAndAllChildProjects ( ) ) { filter . project . add ( project ) ; } } else { filter . project . add ( this ) ; } return getInstance ( ) . get ( ) . regressionPlans ( filter ) ; } | A collection of regression plans that belong to this project . |
11,447 | public Double getTotalEstimate ( PrimaryWorkitemFilter filter , boolean includeChildProjects ) { filter = ( filter != null ) ? filter : new PrimaryWorkitemFilter ( ) ; return getRollup ( "Workitems:PrimaryWorkitem" , "Estimate" , filter , includeChildProjects ) ; } | Retrieves the total estimate for all stories and defects in this project optionally filtered . |
11,448 | public Double getTotalDetailEstimate ( WorkitemFilter filter , boolean includeChildProjects ) { filter = ( filter != null ) ? filter : new WorkitemFilter ( ) ; return getRollup ( "Workitems" , "DetailEstimate" , filter , includeChildProjects ) ; } | Count the total detail estimate for all workitems in this project optionally filtered . |
11,449 | public Double getTotalToDo ( WorkitemFilter filter , boolean includeChildProjects ) { filter = ( filter != null ) ? filter : new WorkitemFilter ( ) ; return getRollup ( "Workitems" , "ToDo" , filter , includeChildProjects ) ; } | Retrieves the total to do for all workitems in this project optionally filtered . |
11,450 | public Double getTotalDone ( WorkitemFilter filter , boolean includeChildProjects ) { filter = ( filter != null ) ? filter : new WorkitemFilter ( ) ; return getRollup ( "Workitems" , "Actuals.Value" , filter , includeChildProjects ) ; } | Retrieves the total done for all workitems in this project optionally filtered . |
11,451 | public Set < String > keySet ( ) throws IOException { Set < String > ret = new HashSet < > ( ) ; JsonParser p = this . getParser ( ) ; JsonToken t ; t = p . nextToken ( ) ; while ( t != null ) { if ( t == JsonToken . FIELD_NAME ) { ret . add ( p . getCurrentName ( ) ) ; } t = p . nextToken ( ) ; } p . close ( ) ; return ret ; } | Return a set of all key names in the component |
11,452 | public String getValue ( String name ) { Properties properties = loadProperties ( ) ; return ( String ) properties . getProperty ( name ) ; } | Get the value associated with name . |
11,453 | public void setValue ( String name , String value ) { Properties properties = loadProperties ( ) ; try ( OutputStream output = new FileOutputStream ( file ) ; ) { properties . setProperty ( name , value ) ; properties . store ( output , "" ) ; output . close ( ) ; } catch ( IOException e ) { logger . warn ( String . format ( "Could not save the keyvalue store, reason:%s" , e . getMessage ( ) ) ) ; } } | Set the value associated with name . |
11,454 | public synchronized boolean markIsTransaction ( String uuid , boolean isTransaction ) { if ( this . isTransaction == null ) { return false ; } this . isTransaction . put ( uuid , isTransaction ) ; return true ; } | Marks a UUID as either a transaction or a query |
11,455 | public void enterInitState ( Event event ) { logger . debug ( String . format ( "Entered state %s" , fsm . current ( ) ) ) ; ChaincodeMessage message = messageHelper ( event ) ; logger . debug ( String . format ( "[%s]Received %s, initializing chaincode" , shortID ( message ) , message . getType ( ) . toString ( ) ) ) ; if ( message . getType ( ) == INIT ) { try { handleInit ( message ) ; } catch ( InvalidTransactionException e ) { e . printStackTrace ( ) ; } } } | enterInitState will initialize the chaincode if entering init from established . |
11,456 | public void handleTransaction ( ChaincodeMessage message ) { Runnable task = ( ) -> { ChaincodeMessage nextStatemessage = null ; boolean send = true ; try { ChaincodeInput input ; try { input = ChaincodeInput . parseFrom ( message . getPayload ( ) ) ; } catch ( Exception e ) { logger . debug ( String . format ( "[%s]Incorrect payload format. Sending %s" , shortID ( message ) , ERROR ) ) ; nextStatemessage = ChaincodeMessage . newBuilder ( ) . setType ( ERROR ) . setPayload ( message . getPayload ( ) ) . setTxid ( message . getTxid ( ) ) . build ( ) ; return ; } markIsTransaction ( message . getTxid ( ) , true ) ; ChaincodeStub stub = new ChaincodeStub ( message . getTxid ( ) , this , message . getSecurityContext ( ) ) ; ByteString response ; try { response = chaincode . runHelper ( stub , getFunction ( input . getArgsList ( ) ) , getParameters ( input . getArgsList ( ) ) ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; System . err . flush ( ) ; logger . error ( String . format ( "[%s]Error running chaincode. Transaction execution failed. Sending %s" , shortID ( message ) , ERROR ) ) ; nextStatemessage = ChaincodeMessage . newBuilder ( ) . setType ( ERROR ) . setPayload ( message . getPayload ( ) ) . setTxid ( message . getTxid ( ) ) . build ( ) ; return ; } finally { deleteIsTransaction ( message . getTxid ( ) ) ; } logger . debug ( String . format ( "[%s]Transaction completed. Sending %s" , shortID ( message ) , COMPLETED ) ) ; Builder builder = ChaincodeMessage . newBuilder ( ) . setType ( COMPLETED ) . setTxid ( message . getTxid ( ) ) ; if ( response != null ) builder . setPayload ( response ) ; nextStatemessage = builder . build ( ) ; } finally { triggerNextState ( nextStatemessage , send ) ; } } ; new Thread ( task ) . start ( ) ; } | handleTransaction Handles request to execute a transaction . |
11,457 | public void handleQuery ( ChaincodeMessage message ) { Runnable task = ( ) -> { ChaincodeMessage serialSendMessage = null ; try { ChaincodeInput input ; try { input = ChaincodeInput . parseFrom ( message . getPayload ( ) ) ; } catch ( Exception e ) { logger . debug ( String . format ( "[%s]Incorrect payload format. Sending %s" , shortID ( message ) , QUERY_ERROR ) ) ; serialSendMessage = ChaincodeMessage . newBuilder ( ) . setType ( QUERY_ERROR ) . setPayload ( ByteString . copyFromUtf8 ( e . getMessage ( ) ) ) . setTxid ( message . getTxid ( ) ) . build ( ) ; return ; } markIsTransaction ( message . getTxid ( ) , false ) ; ChaincodeStub stub = new ChaincodeStub ( message . getTxid ( ) , this , message . getSecurityContext ( ) ) ; ByteString response ; try { response = chaincode . queryHelper ( stub , getFunction ( input . getArgsList ( ) ) , getParameters ( input . getArgsList ( ) ) ) ; } catch ( Exception e ) { logger . debug ( String . format ( "[%s]Query execution failed. Sending %s" , shortID ( message ) , QUERY_ERROR ) ) ; serialSendMessage = ChaincodeMessage . newBuilder ( ) . setType ( QUERY_ERROR ) . setPayload ( ByteString . copyFromUtf8 ( e . getMessage ( ) ) ) . setTxid ( message . getTxid ( ) ) . build ( ) ; return ; } finally { deleteIsTransaction ( message . getTxid ( ) ) ; } logger . debug ( "[" + shortID ( message ) + "]Query completed. Sending " + QUERY_COMPLETED ) ; serialSendMessage = ChaincodeMessage . newBuilder ( ) . setType ( QUERY_COMPLETED ) . setPayload ( response ) . setTxid ( message . getTxid ( ) ) . build ( ) ; } finally { serialSend ( serialSendMessage ) ; } } ; new Thread ( task ) . start ( ) ; } | handleQuery handles request to execute a query . |
11,458 | public void enterTransactionState ( Event event ) { ChaincodeMessage message = messageHelper ( event ) ; logger . debug ( String . format ( "[%s]Received %s, invoking transaction on chaincode(src:%s, dst:%s)" , shortID ( message ) , message . getType ( ) . toString ( ) , event . src , event . dst ) ) ; if ( message . getType ( ) == TRANSACTION ) { handleTransaction ( message ) ; } } | enterTransactionState will execute chaincode s Run if coming from a TRANSACTION event . |
11,459 | public void afterCompleted ( Event event ) { ChaincodeMessage message = messageHelper ( event ) ; logger . debug ( String . format ( "[%s]sending COMPLETED to validator for tid" , shortID ( message ) ) ) ; try { serialSend ( message ) ; } catch ( Exception e ) { event . cancel ( new Exception ( "send COMPLETED failed %s" , e ) ) ; } } | afterCompleted will need to handle COMPLETED event by sending message to the peer |
11,460 | public void afterResponse ( Event event ) { ChaincodeMessage message = messageHelper ( event ) ; try { sendChannel ( message ) ; logger . debug ( String . format ( "[%s]Received %s, communicated (state:%s)" , shortID ( message ) , message . getType ( ) , fsm . current ( ) ) ) ; } catch ( Exception e ) { logger . error ( String . format ( "[%s]error sending %s (state:%s): %s" , shortID ( message ) , message . getType ( ) , fsm . current ( ) , e ) ) ; } } | afterResponse is called to deliver a response or error to the chaincode stub . |
11,461 | public void prepare ( Collection < String > urls , String userAgent ) { List < String > safeUrls = new ArrayList < String > ( urls ) ; FetchThread threads [ ] = new FetchThread [ PREPARE_THREAD_COUNT ] ; for ( int i = 0 ; i < PREPARE_THREAD_COUNT ; i ++ ) { threads [ i ] = new FetchThread ( safeUrls , userAgent ) ; threads [ i ] . start ( ) ; } for ( int i = 0 ; i < PREPARE_THREAD_COUNT ; i ++ ) { try { threads [ i ] . join ( ) ; } catch ( InterruptedException e ) { } } } | Prepare the cache to lookup info for a given set of urls . The fetches happen in parallel so this also makes a good option for speeding up bulk lookups . |
11,462 | public static Statistics statisticsOf ( CollectionNumber data ) { IteratorNumber iterator = data . iterator ( ) ; if ( ! iterator . hasNext ( ) ) { return null ; } int count = 0 ; double min = iterator . nextDouble ( ) ; while ( Double . isNaN ( min ) ) { if ( ! iterator . hasNext ( ) ) { return null ; } else { min = iterator . nextDouble ( ) ; } } double max = min ; double total = min ; double totalSquare = min * min ; count ++ ; while ( iterator . hasNext ( ) ) { double value = iterator . nextDouble ( ) ; if ( ! Double . isNaN ( value ) ) { if ( value > max ) max = value ; if ( value < min ) min = value ; total += value ; totalSquare += value * value ; count ++ ; } } double average = total / count ; double stdDev = Math . sqrt ( totalSquare / count - average * average ) ; return new StatisticsImpl ( count , min , max , average , stdDev ) ; } | Calculates data statistics excluding NaN values . |
11,463 | public static Statistics statisticsOf ( List < Statistics > data ) { if ( data . isEmpty ( ) ) return null ; Iterator < Statistics > iterator = data . iterator ( ) ; if ( ! iterator . hasNext ( ) ) { return null ; } Statistics first = null ; while ( first == null && iterator . hasNext ( ) ) { first = iterator . next ( ) ; } if ( first == null ) return null ; int count = first . getCount ( ) ; double min = first . getMinimum ( ) . doubleValue ( ) ; double max = first . getMaximum ( ) . doubleValue ( ) ; double total = first . getAverage ( ) * first . getCount ( ) ; double totalSquare = ( first . getStdDev ( ) * first . getStdDev ( ) + first . getAverage ( ) * first . getAverage ( ) ) * first . getCount ( ) ; while ( iterator . hasNext ( ) ) { Statistics stats = iterator . next ( ) ; if ( stats . getMaximum ( ) . doubleValue ( ) > max ) max = stats . getMaximum ( ) . doubleValue ( ) ; if ( stats . getMinimum ( ) . doubleValue ( ) < min ) min = stats . getMinimum ( ) . doubleValue ( ) ; total += stats . getAverage ( ) * stats . getCount ( ) ; totalSquare += ( stats . getStdDev ( ) * stats . getStdDev ( ) + stats . getAverage ( ) * stats . getAverage ( ) ) * stats . getCount ( ) ; count += stats . getCount ( ) ; } double average = total / count ; double stdDev = Math . sqrt ( totalSquare / count - average * average ) ; return new StatisticsImpl ( count , min , max , average , stdDev ) ; } | Aggregates statistical information . |
11,464 | public void start ( String [ ] args ) { Options options = new Options ( ) ; options . addOption ( "a" , "peerAddress" , true , "Address of peer to connect to" ) ; options . addOption ( "s" , "securityEnabled" , false , "Present if security is enabled" ) ; options . addOption ( "i" , "id" , true , "Identity of chaincode" ) ; options . addOption ( "o" , "hostNameOverride" , true , "Hostname override for server certificate" ) ; try { CommandLine cl = new DefaultParser ( ) . parse ( options , args ) ; if ( cl . hasOption ( 'a' ) ) { host = cl . getOptionValue ( 'a' ) ; port = new Integer ( host . split ( ":" ) [ 1 ] ) ; host = host . split ( ":" ) [ 0 ] ; } if ( cl . hasOption ( 's' ) ) { tlsEnabled = true ; logger . debug ( "TLS enabled" ) ; if ( cl . hasOption ( 'o' ) ) { hostOverrideAuthority = cl . getOptionValue ( 'o' ) ; logger . debug ( "server host override given " + hostOverrideAuthority ) ; } } if ( cl . hasOption ( 'i' ) ) { id = cl . getOptionValue ( 'i' ) ; } } catch ( ParseException e ) { logger . warn ( "cli parsing failed with exception" , e ) ; } Runnable chaincode = ( ) -> { logger . trace ( "chaincode started" ) ; ManagedChannel connection = newPeerClientConnection ( ) ; logger . trace ( "connection created" ) ; chatWithPeer ( connection ) ; logger . trace ( "chatWithPeer DONE" ) ; } ; new Thread ( chaincode ) . start ( ) ; } | Start entry point for chaincodes bootstrap . |
11,465 | public static Range range ( final double minValue , final double maxValue ) { if ( minValue > maxValue ) { throw new IllegalArgumentException ( "minValue should be less then or equal to maxValue (" + minValue + ", " + maxValue + ")" ) ; } return new Range ( ) { public Number getMinimum ( ) { return minValue ; } public Number getMaximum ( ) { return maxValue ; } public String toString ( ) { return Ranges . toString ( this ) ; } } ; } | Range from given min and max . |
11,466 | public static boolean contains ( Range range , Range subrange ) { return range . getMinimum ( ) . doubleValue ( ) <= subrange . getMinimum ( ) . doubleValue ( ) && range . getMaximum ( ) . doubleValue ( ) >= subrange . getMaximum ( ) . doubleValue ( ) ; } | Determines whether the subrange is contained in the range or not . |
11,467 | public static Range sum ( Range range1 , Range range2 ) { if ( range1 . getMinimum ( ) . doubleValue ( ) <= range2 . getMinimum ( ) . doubleValue ( ) ) { if ( range1 . getMaximum ( ) . doubleValue ( ) >= range2 . getMaximum ( ) . doubleValue ( ) ) { return range1 ; } else { return range ( range1 . getMinimum ( ) . doubleValue ( ) , range2 . getMaximum ( ) . doubleValue ( ) ) ; } } else { if ( range1 . getMaximum ( ) . doubleValue ( ) >= range2 . getMaximum ( ) . doubleValue ( ) ) { return range ( range2 . getMinimum ( ) . doubleValue ( ) , range1 . getMaximum ( ) . doubleValue ( ) ) ; } else { return range2 ; } } } | Determines the range that can contain both ranges . If one of the ranges in contained in the other the bigger range is returned . |
11,468 | public static double normalize ( Range range , double value ) { return normalize ( value , range . getMinimum ( ) . doubleValue ( ) , range . getMaximum ( ) . doubleValue ( ) ) ; } | Returns the value normalized within the range . It performs a linear transformation where the minimum value of the range becomes 0 while the maximum becomes 1 . |
11,469 | public static boolean contains ( Range range , double value ) { return value >= range . getMinimum ( ) . doubleValue ( ) && value <= range . getMaximum ( ) . doubleValue ( ) ; } | Determines whether the value is contained by the range or not . |
11,470 | public static double overlap ( Range range , Range otherRange ) { double minOverlap = Math . max ( range . getMinimum ( ) . doubleValue ( ) , otherRange . getMinimum ( ) . doubleValue ( ) ) ; double maxOverlap = Math . min ( range . getMaximum ( ) . doubleValue ( ) , otherRange . getMaximum ( ) . doubleValue ( ) ) ; double overlapWidth = maxOverlap - minOverlap ; double rangeWidth = range . getMaximum ( ) . doubleValue ( ) - range . getMinimum ( ) . doubleValue ( ) ; double fraction = Math . max ( 0.0 , overlapWidth / rangeWidth ) ; return fraction ; } | Percentage from 0 to 1 of the first range that is contained by the second range . |
11,471 | public static boolean isValid ( Range range ) { if ( range == null ) { return false ; } double min = range . getMinimum ( ) . doubleValue ( ) ; double max = range . getMaximum ( ) . doubleValue ( ) ; return min != max && ! Double . isNaN ( min ) && ! Double . isInfinite ( min ) && ! Double . isNaN ( max ) && ! Double . isInfinite ( max ) ; } | Checks whether the range is of non - zero size and the boundaries are neither NaN or Infinity . |
11,472 | private void loadDefaultConfig ( ) { this . configDir = System . getProperty ( CONFIG_DIR_SYS_PROP ) ; if ( this . configDir == null ) { this . configDir = getDefaultConfigDir ( ) ; } if ( this . configDir == null ) { throw new AssertionError ( "eureka.config.dir not specified in " + FALLBACK_CONFIG_FILE ) ; } File configFile = new File ( this . configDir , PROPERTIES_FILENAME ) ; if ( configFile . exists ( ) ) { LOGGER . info ( "Trying to load default configuration from {}" , configFile . getAbsolutePath ( ) ) ; InputStream inputStream = null ; try { inputStream = new FileInputStream ( configFile ) ; this . properties . load ( inputStream ) ; inputStream . close ( ) ; inputStream = null ; } catch ( IOException ex ) { LOGGER . error ( "Error reading application.properties file {}: {}. " + "Built-in defaults will be used, some " + "of which are unlikely to be what you want." , configFile . getAbsolutePath ( ) , ex . getMessage ( ) ) ; } finally { if ( inputStream != null ) { try { inputStream . close ( ) ; } catch ( IOException ignore ) { } } } } else { LOGGER . warn ( "No configuration file found at {}. " + "Built-in defaults will be used, some " + "of which are unlikely to be what you want." , configFile . getAbsolutePath ( ) ) ; } } | Loads the application configuration . |
11,473 | public Collection < Story > getIdentifiedStories ( StoryFilter filter ) { filter = ( filter != null ) ? filter : new StoryFilter ( ) ; filter . identifiedIn . clear ( ) ; filter . identifiedIn . add ( this ) ; return getInstance ( ) . get ( ) . story ( filter ) ; } | A read - only collection of Stories Identified in the Retrospective . |
11,474 | public ChannelFuture respondEventSource ( Object data , String event ) throws Exception { if ( ! nonChunkedResponseOrFirstChunkSent ) { HttpUtil . setTransferEncodingChunked ( response , true ) ; response . headers ( ) . set ( CONTENT_TYPE , "text/event-stream; charset=UTF-8" ) ; return respondText ( "\r\n" ) ; } return respondText ( renderEventSource ( data , event ) ) ; } | To respond event source call this method as many time as you want . |
11,475 | public boolean isTwitterJsonStringRelatedTo ( String tweet , boolean sender , boolean userMentions , boolean retweetOrigin ) { StatusRepresentation s = new StatusRepresentation ( ) ; s . init ( null , tweet ) ; boolean matches = s . isRelatedTo ( this , true , true , true ) ; return matches ; } | Determines whether the Twitter status is related to one of the users in the set of influential contributors . |
11,476 | public synchronized int purge ( ) { int recordsRemaining = - 1 ; SQLiteDatabase db = null ; Cursor cursor = null ; try { db = getWritableDatabase ( ) ; long earliestValidTime = System . currentTimeMillis ( ) - RECORD_EXPIRY_TIME ; int recordsDeleted = db . delete ( ShareRequestTable . NAME , WHERE_CLAUSE_PURGE_POLICY , new String [ ] { String . valueOf ( earliestValidTime ) , String . valueOf ( ShareRequest . STATE_PROCESSED ) , String . valueOf ( RECORD_MAX_FAILS ) } ) ; cursor = db . query ( ShareRequestTable . NAME , new String [ ] { ShareRequestTable . COLUMN_ID } , null , null , null , null , null ) ; if ( cursor != null ) { recordsRemaining = cursor . getCount ( ) ; } sLogger . log ( WingsDbHelper . class , "purge" , "recordsDeleted=" + recordsDeleted + " recordsRemaining=" + recordsRemaining ) ; } catch ( SQLException e ) { } finally { if ( cursor != null ) { cursor . close ( ) ; } db . close ( ) ; } return recordsRemaining ; } | Purges the database based on the purge policy . |
11,477 | public synchronized void resetProcessingShareRequests ( ) { SQLiteDatabase db = null ; try { db = getWritableDatabase ( ) ; ContentValues values = new ContentValues ( ) ; values . put ( ShareRequestTable . COLUMN_STATE , ShareRequest . STATE_PENDING ) ; int recordsUpdated = db . update ( ShareRequestTable . NAME , values , WHERE_CLAUSE_BY_STATE , new String [ ] { String . valueOf ( ShareRequest . STATE_PROCESSING ) } ) ; sLogger . log ( WingsDbHelper . class , "resetProcessingShareRequests" , "recordsUpdated=" + recordsUpdated ) ; } catch ( SQLException e ) { } finally { db . close ( ) ; } } | Reset all records that somehow got stuck in a processing state . |
11,478 | public ChainCodeResponse deploy ( DeployRequest deployRequest ) throws ChainCodeException , NoAvailableTCertException , CryptoException , IOException { logger . debug ( String . format ( "Received deploy request: %s" , deployRequest ) ) ; if ( null == getMyTCert ( ) && getChain ( ) . isSecurityEnabled ( ) ) { logger . debug ( "Failed getting a new TCert" ) ; throw new NoAvailableTCertException ( "Failed getting a new TCert" ) ; } logger . debug ( "Got a TCert successfully, continue..." ) ; Transaction transaction = DeployTransactionBuilder . newBuilder ( ) . context ( this ) . request ( deployRequest ) . build ( ) ; Fabric . Response response = execute ( transaction ) ; if ( response . getStatus ( ) == StatusCode . FAILURE ) { throw new ChainCodeException ( response . getMsg ( ) . toStringUtf8 ( ) , null ) ; } return new ChainCodeResponse ( transaction . getTxBuilder ( ) . getTxid ( ) , transaction . getChaincodeID ( ) , Status . UNDEFINED , response . getMsg ( ) . toStringUtf8 ( ) ) ; } | Issue a deploy transaction |
11,479 | public ChainCodeResponse invoke ( InvokeRequest invokeRequest ) throws ChainCodeException , NoAvailableTCertException , CryptoException , IOException { logger . debug ( String . format ( "Received invoke request: %s" , invokeRequest ) ) ; setAttrs ( invokeRequest . getAttributes ( ) ) ; if ( null == getMyTCert ( ) && getChain ( ) . isSecurityEnabled ( ) ) { logger . debug ( "Failed getting a new TCert" ) ; throw new NoAvailableTCertException ( "Failed getting a new TCert" ) ; } logger . debug ( "Got a TCert successfully, continue..." ) ; Transaction transaction = InvocationTransactionBuilder . newBuilder ( ) . context ( this ) . request ( invokeRequest ) . build ( ) ; Fabric . Response response = execute ( transaction ) ; if ( response . getStatus ( ) == StatusCode . FAILURE ) { throw new ChainCodeException ( response . getMsg ( ) . toStringUtf8 ( ) , null ) ; } return new ChainCodeResponse ( transaction . getTxBuilder ( ) . getTxid ( ) , transaction . getChaincodeID ( ) , Status . SUCCESS , response . getMsg ( ) . toStringUtf8 ( ) ) ; } | Issue an invoke on chaincode |
11,480 | private Fabric . Response execute ( Transaction tx ) throws CryptoException , IOException { logger . debug ( String . format ( "Executing transaction [%s]" , tx ) ) ; tx . getTxBuilder ( ) . setNonce ( ByteString . copyFrom ( this . nonce ) ) ; logger . debug ( "Process Confidentiality..." ) ; this . processConfidentiality ( tx ) ; logger . debug ( "Sign transaction..." ) ; if ( getChain ( ) . isSecurityEnabled ( ) ) { tx . getTxBuilder ( ) . setCert ( ByteString . copyFrom ( tcert . getCert ( ) ) ) ; byte [ ] txBytes = tx . getTxBuilder ( ) . buildPartial ( ) . toByteArray ( ) ; BigInteger [ ] signature = this . chain . getCryptoPrimitives ( ) . ecdsaSign ( tcert . getPrivateKey ( ) , txBytes ) ; byte [ ] derSignature = this . chain . getCryptoPrimitives ( ) . toDER ( new byte [ ] [ ] { signature [ 0 ] . toByteArray ( ) , signature [ 1 ] . toByteArray ( ) } ) ; tx . getTxBuilder ( ) . setSignature ( ByteString . copyFrom ( derSignature ) ) ; } logger . debug ( "Send transaction..." ) ; logger . debug ( "Confidentiality: " + tx . getTxBuilder ( ) . getConfidentialityLevel ( ) ) ; if ( tx . getTxBuilder ( ) . getConfidentialityLevel ( ) == Chaincode . ConfidentialityLevel . CONFIDENTIAL && tx . getTxBuilder ( ) . getType ( ) == Fabric . Transaction . Type . CHAINCODE_QUERY ) { Fabric . Response response = this . getChain ( ) . sendTransaction ( tx ) ; if ( response . getStatus ( ) == StatusCode . SUCCESS ) { byte [ ] message = decryptResult ( response . getMsg ( ) . toByteArray ( ) ) ; return Fabric . Response . newBuilder ( ) . setStatus ( StatusCode . SUCCESS ) . setMsg ( ByteString . copyFrom ( message ) ) . build ( ) ; } else { return response ; } } else { return this . getChain ( ) . sendTransaction ( tx ) ; } } | Execute a transaction |
11,481 | public static Object wrappedArray ( CollectionNumber coll ) { Object data = wrappedFloatArray ( coll ) ; if ( data != null ) { return data ; } data = wrappedDoubleArray ( coll ) ; if ( data != null ) { return data ; } data = wrappedByteArray ( coll ) ; if ( data != null ) { return data ; } data = wrappedShortArray ( coll ) ; if ( data != null ) { return data ; } data = wrappedIntArray ( coll ) ; if ( data != null ) { return data ; } data = wrappedLongArray ( coll ) ; if ( data != null ) { return data ; } return null ; } | If available return the array wrapped by the collection - USE WITH CAUTION AS IT EXPOSES THE INTERNAL STATE OF THE COLLECTION . This is provided in case an external routine for computation requires you to use array and you want to avoid the copy for performance reason . |
11,482 | public static String generateParameterHash ( String path , String func , List < String > args ) { logger . debug ( String . format ( "GenerateParameterHash : path=%s, func=%s, args=%s" , path , func , args ) ) ; StringBuilder param = new StringBuilder ( path ) ; param . append ( func ) ; args . forEach ( param :: append ) ; String strHash = Hex . toHexString ( hash ( param . toString ( ) . getBytes ( ) , new SHA3Digest ( ) ) ) ; return strHash ; } | Generate parameter hash for the given chain code path func and args |
11,483 | public static void generateTarGz ( String src , String target ) throws IOException { File sourceDirectory = new File ( src ) ; File destinationArchive = new File ( target ) ; String sourcePath = sourceDirectory . getAbsolutePath ( ) ; FileOutputStream destinationOutputStream = new FileOutputStream ( destinationArchive ) ; TarArchiveOutputStream archiveOutputStream = new TarArchiveOutputStream ( new GzipCompressorOutputStream ( new BufferedOutputStream ( destinationOutputStream ) ) ) ; archiveOutputStream . setLongFileMode ( TarArchiveOutputStream . LONGFILE_GNU ) ; try { Collection < File > childrenFiles = org . apache . commons . io . FileUtils . listFiles ( sourceDirectory , null , true ) ; childrenFiles . remove ( destinationArchive ) ; ArchiveEntry archiveEntry ; FileInputStream fileInputStream ; for ( File childFile : childrenFiles ) { String childPath = childFile . getAbsolutePath ( ) ; String relativePath = childPath . substring ( ( sourcePath . length ( ) + 1 ) , childPath . length ( ) ) ; relativePath = FilenameUtils . separatorsToUnix ( relativePath ) ; archiveEntry = new TarArchiveEntry ( childFile , relativePath ) ; fileInputStream = new FileInputStream ( childFile ) ; archiveOutputStream . putArchiveEntry ( archiveEntry ) ; try { IOUtils . copy ( fileInputStream , archiveOutputStream ) ; } finally { IOUtils . closeQuietly ( fileInputStream ) ; archiveOutputStream . closeArchiveEntry ( ) ; } } } finally { IOUtils . closeQuietly ( archiveOutputStream ) ; } } | Compress the given directory src to target tar . gz file |
11,484 | public View viewByContentType ( String contentType ) { for ( View view : views . values ( ) ) { if ( view . getContentType ( ) . equals ( contentType ) ) { return view ; } } return null ; } | Return the first view with the given content type . |
11,485 | public String register ( RegistrationRequest req , Member registrar ) throws RegistrationException { if ( StringUtil . isNullOrEmpty ( req . getEnrollmentID ( ) ) ) { throw new IllegalArgumentException ( "EntrollmentID cannot be null or empty" ) ; } if ( registrar == null ) { throw new IllegalArgumentException ( "Registrar should be a valid member" ) ; } Registrar reg = Registrar . newBuilder ( ) . setId ( Identity . newBuilder ( ) . setId ( registrar . getName ( ) ) . build ( ) ) . build ( ) ; RegisterUserReq . Builder regReqBuilder = RegisterUserReq . newBuilder ( ) ; regReqBuilder . setId ( Identity . newBuilder ( ) . setId ( req . getEnrollmentID ( ) ) . build ( ) ) ; regReqBuilder . setRoleValue ( rolesToMask ( req . getRoles ( ) ) ) ; regReqBuilder . setAffiliation ( req . getAffiliation ( ) ) ; regReqBuilder . setRegistrar ( reg ) ; RegisterUserReq registerReq = regReqBuilder . build ( ) ; byte [ ] buffer = registerReq . toByteArray ( ) ; try { java . security . PrivateKey signKey = cryptoPrimitives . ecdsaKeyFromPrivate ( Hex . decode ( registrar . getEnrollment ( ) . getKey ( ) ) ) ; logger . debug ( "Retreived private key" ) ; BigInteger [ ] signature = cryptoPrimitives . ecdsaSign ( signKey , buffer ) ; logger . debug ( "Signed the request with key" ) ; Signature sig = Signature . newBuilder ( ) . setType ( CryptoType . ECDSA ) . setR ( ByteString . copyFrom ( signature [ 0 ] . toString ( ) . getBytes ( ) ) ) . setS ( ByteString . copyFrom ( signature [ 1 ] . toString ( ) . getBytes ( ) ) ) . build ( ) ; regReqBuilder . setSig ( sig ) ; logger . debug ( "Now sendingt register request" ) ; Token token = this . ecaaClient . registerUser ( regReqBuilder . build ( ) ) ; return token . getTok ( ) . toStringUtf8 ( ) ; } catch ( Exception e ) { throw new RegistrationException ( "Error while registering the user" , e ) ; } } | Register the member and return an enrollment secret . |
11,486 | private List < TCert > processTCertBatch ( GetTCertBatchRequest req , TCertCreateSetResp resp ) throws NoSuchPaddingException , InvalidKeyException , NoSuchAlgorithmException , IllegalBlockSizeException , BadPaddingException , InvalidAlgorithmParameterException , CryptoException , IOException { String enrollKey = req . getEnrollment ( ) . getKey ( ) ; byte [ ] tCertOwnerKDFKey = resp . getCerts ( ) . getKey ( ) . toByteArray ( ) ; List < Ca . TCert > tCerts = resp . getCerts ( ) . getCertsList ( ) ; byte [ ] byte1 = new byte [ ] { 1 } ; byte [ ] byte2 = new byte [ ] { 2 } ; byte [ ] tCertOwnerEncryptKey = Arrays . copyOfRange ( cryptoPrimitives . calculateMac ( tCertOwnerKDFKey , byte1 ) , 0 , 32 ) ; byte [ ] expansionKey = cryptoPrimitives . calculateMac ( tCertOwnerKDFKey , byte2 ) ; List < TCert > tCertBatch = new ArrayList < > ( tCerts . size ( ) ) ; for ( Ca . TCert tCert : tCerts ) { X509Certificate x509Certificate ; try { CertificateFactory cf = CertificateFactory . getInstance ( "X.509" ) ; x509Certificate = ( X509Certificate ) cf . generateCertificate ( tCert . getCert ( ) . newInput ( ) ) ; } catch ( Exception ex ) { logger . debug ( "Warning: problem parsing certificate bytes; retrying ... " , ex ) ; continue ; } byte [ ] tCertIndexCT = fromDer ( x509Certificate . getExtensionValue ( TCERT_ENC_TCERT_INDEX ) ) ; byte [ ] tCertIndex = cryptoPrimitives . aesCBCPKCS7Decrypt ( tCertOwnerEncryptKey , tCertIndexCT ) ; byte [ ] expansionValue = cryptoPrimitives . calculateMac ( expansionKey , tCertIndex ) ; BigInteger k = new BigInteger ( 1 , expansionValue ) ; BigInteger n = ( ( ECPrivateKey ) cryptoPrimitives . ecdsaKeyFromPrivate ( Hex . decode ( enrollKey ) ) ) . getParameters ( ) . getN ( ) . subtract ( BigInteger . ONE ) ; k = k . mod ( n ) . add ( BigInteger . ONE ) ; BigInteger D = ( ( ECPrivateKey ) cryptoPrimitives . ecdsaKeyFromPrivate ( Hex . decode ( enrollKey ) ) ) . getD ( ) . add ( k ) ; D = D . mod ( ( ( ECPrivateKey ) cryptoPrimitives . ecdsaKeyFromPrivate ( Hex . decode ( enrollKey ) ) ) . getParameters ( ) . getN ( ) ) ; TCert tcert = new TCert ( tCert . getCert ( ) . toByteArray ( ) , cryptoPrimitives . ecdsaKeyFromBigInt ( D ) ) ; tCertBatch . add ( tcert ) ; } if ( tCertBatch . size ( ) == 0 ) { throw new RuntimeException ( "Failed fetching TCertBatch. No valid TCert received." ) ; } return tCertBatch ; } | Process a batch of tcerts after having retrieved them from the TCA . |
11,487 | public double getRMSError ( ) { double r = covarCalc . getSumSquaredDeviations ( ) / Math . sqrt ( varCalcX . getSumSquaredDeviations ( ) * varCalcY . getSumSquaredDeviations ( ) ) ; return Math . sqrt ( 1 - r ) * varCalcX . getStdDev ( ) ; } | Returns the r . m . s . error of this regression line . |
11,488 | public boolean isSymbolNull ( String name ) { CommandSymbol s = findSymbol ( name ) ; if ( s == null ) return true ; if ( s instanceof VarCommand ) { VarCommand var = ( VarCommand ) s ; Value v = var . getValue ( this ) ; if ( v == null || v . get ( ) == null || v instanceof NilValue ) return true ; } return false ; } | Returns true if the symbol is null or has not been defined . |
11,489 | public final String [ ] tokenize ( String value ) { StringTokenizer stringTokenizer = new StringTokenizer ( value , getDelimiters ( ) ) ; String [ ] broken = new String [ stringTokenizer . countTokens ( ) ] ; for ( int index = 0 ; index < broken . length ; index ++ ) { broken [ index ] = stringTokenizer . nextToken ( ) ; } return broken ; } | Implementation of this method breaks down passed string into tokens . |
11,490 | protected String getLogFormat ( ) { final String [ ] formats = getResources ( ) . getStringArray ( R . array . format_list ) ; if ( mFormat >= 0 && mFormat < formats . length ) { return formats [ mFormat ] ; } return formats [ FORMAT_DEFAULT ] ; } | The log format to use . Default is time . Override to use a different format . Return null to prompt for format . |
11,491 | protected String getMessageText ( final File pZipFile , final PackageManager pPackageManager ) { String version = "" ; try { final PackageInfo pi = pPackageManager . getPackageInfo ( getPackageName ( ) , 0 ) ; version = " " + pi . versionName ; } catch ( final PackageManager . NameNotFoundException e ) { Log . e ( TAG , "Version name not found" , e ) ; } return getString ( R . string . email_text , version , Build . MODEL , Build . DEVICE , Build . VERSION . RELEASE , Build . ID , pZipFile . getName ( ) , ( pZipFile . length ( ) + 512 ) / 1024 ) ; } | The text of the email . Override to use different text . |
11,492 | protected void beforeWaitForSynchronization ( final T message ) throws CouldNotPerformException { transactionIdField = ProtoBufFieldProcessor . getFieldDescriptor ( message , TransactionIdProvider . TRANSACTION_ID_FIELD_NAME ) ; if ( transactionIdField == null ) { throw new NotAvailableException ( "transaction id field for message[" + message . getClass ( ) . getSimpleName ( ) + "]" ) ; } if ( transactionIdField . getType ( ) != Type . UINT64 ) { throw new CouldNotPerformException ( "Transaction id field of message[" + message . getClass ( ) . getSimpleName ( ) + "] has an unexpected type[" + transactionIdField . getType ( ) . name ( ) + "]" ) ; } } | Verify that the internal future has a transaction id field and that this field is of type long . |
11,493 | protected boolean check ( T message ) throws CouldNotPerformException { final long transactionId = ( long ) message . getField ( transactionIdField ) ; if ( ! message . hasField ( transactionIdField ) || transactionId == 0 ) { logger . warn ( "Received return value without transactionId" ) ; return true ; } return dataProvider . getTransactionId ( ) >= transactionId ; } | Verify that the transaction id of the data provider is greater or equal to the transaction id in the given message . |
11,494 | public static FadeTransition createFadeTransition ( final Node node , final double fromValue , final double toValue , final int cycleCount , final double duration ) { assert node != null ; final FadeTransition fadeTransition = new FadeTransition ( Duration . millis ( duration ) , node ) ; fadeTransition . setFromValue ( fromValue ) ; fadeTransition . setToValue ( toValue ) ; fadeTransition . setCycleCount ( cycleCount ) ; fadeTransition . setAutoReverse ( true ) ; return fadeTransition ; } | Method to create a FadeTransition with several parameters . |
11,495 | public static RotateTransition createRotateTransition ( final Node node , final double fromAngle , final double toAngle , final int cycleCount , final double duration , final Interpolator interpolator , final boolean autoReverse ) { assert node != null ; final RotateTransition rotateTransition = new RotateTransition ( Duration . millis ( duration ) , node ) ; rotateTransition . setFromAngle ( fromAngle ) ; rotateTransition . setToAngle ( toAngle ) ; rotateTransition . setCycleCount ( cycleCount ) ; rotateTransition . setAutoReverse ( autoReverse ) ; rotateTransition . setInterpolator ( interpolator ) ; return rotateTransition ; } | Method to create a RotateTransition with several parameters . |
11,496 | protected void println ( int priority , String msg ) { Log . println ( priority , processTag ( packageName ) , processMessage ( msg ) ) ; } | Print the message . |
11,497 | protected String processMessage ( String msg ) { return String . format ( MSG_FORMAT , Thread . currentThread ( ) . getName ( ) , msg ) ; } | Provide a message for logging . This prepends the current thread to the message . Override this if you want to filter sensitive information or add extra information to each message before dispatching . |
11,498 | protected String processTag ( String packageName ) { final int skipDepth = 6 ; final Thread thread = Thread . currentThread ( ) ; final StackTraceElement trace = thread . getStackTrace ( ) [ skipDepth ] ; return String . format ( TAG_FORMAT , packageName , trace . getFileName ( ) , trace . getLineNumber ( ) ) ; } | Provide a tag for logging . By default this returns a tag with the package name file name and line number of the calling function . Override this to show different information in the tag . |
11,499 | public void waitForData ( ) throws InterruptedException { try { if ( registryRemote == null ) { waitForValue ( ) ; return ; } getRegistryRemote ( ) . waitForData ( ) ; } catch ( CouldNotPerformException ex ) { ExceptionPrinter . printHistory ( "Could not wait until " + getName ( ) + " is ready!" , ex , logger ) ; } } | Method blocks until the remote registry is synchronized . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.