idx int64 0 165k | question stringlengths 73 5.81k | target stringlengths 5 918 |
|---|---|---|
11,400 | public static ApruveResponse < SubscriptionAdjustment > get ( String subscriptionId , String adjustmentId ) { return ApruveClient . getInstance ( ) . get ( getSubscriptionAdjustmentsPath ( subscriptionId ) + adjustmentId , SubscriptionAdjustment . class ) ; } | Get the SubscriptionAdjustment with the given ID |
11,401 | public static ApruveResponse < List < SubscriptionAdjustment > > getAllAdjustments ( String subscriptionId ) { return ApruveClient . getInstance ( ) . index ( getSubscriptionAdjustmentsPath ( subscriptionId ) , new GenericType < List < SubscriptionAdjustment > > ( ) { } ) ; } | Get all SubscriptionAdjustments for the specified Subscription . |
11,402 | public ApruveResponse < SubscriptionAdjustmentCreateResponse > create ( String subscriptionId ) { return ApruveClient . getInstance ( ) . post ( getSubscriptionAdjustmentsPath ( subscriptionId ) , this , SubscriptionAdjustmentCreateResponse . class ) ; } | Create this SubscriptionAdjustment on the Apruve servers . |
11,403 | public static ApruveResponse < SubscriptionAdjustmentDeleteResponse > delete ( String subscriptionId , String adjustmentId ) { return ApruveClient . getInstance ( ) . delete ( getSubscriptionAdjustmentsPath ( subscriptionId ) + adjustmentId , SubscriptionAdjustmentDeleteResponse . class ) ; } | Delete the specified SubscriptionAdjustment from the Apruve servers . This is only allowed for SubscriptionAdjustments that are not in APPLIED status . |
11,404 | public String wrap ( String text ) { StringBuilder sb = new StringBuilder ( ) ; int continuationLength = continuation . length ( ) ; int currentPosition = 0 ; for ( String word : text . split ( " " ) ) { String lastWord ; int wordLength = word . length ( ) ; if ( currentPosition + wordLength <= width ) { if ( currentPosition != 0 ) { sb . append ( " " ) ; currentPosition += 1 ; } sb . append ( lastWord = word ) ; currentPosition += wordLength ; } else { if ( currentPosition > 0 ) { sb . append ( LINE_SEPARATOR ) ; currentPosition = 0 ; } if ( wordLength > width && strict ) { int i = 0 ; while ( i + width < wordLength ) { sb . append ( word . substring ( i , width - continuationLength ) ) . append ( continuation ) . append ( LINE_SEPARATOR ) ; i += width - continuationLength ; } String endOfWord = word . substring ( i ) ; sb . append ( lastWord = endOfWord ) ; currentPosition = endOfWord . length ( ) ; } else { sb . append ( lastWord = word ) ; currentPosition += wordLength ; } } int lastNewLine = lastWord . lastIndexOf ( "\n" ) ; if ( lastNewLine != - 1 ) { currentPosition = lastWord . length ( ) - lastNewLine ; } } return sb . toString ( ) ; } | Wrap the specified text . |
11,405 | public void printMessage ( Diagnostic . Kind kind , CharSequence msg , Element e , AnnotationMirror a , AnnotationValue v ) { JavaFileObject oldSource = null ; JavaFileObject newSource = null ; JCDiagnostic . DiagnosticPosition pos = null ; JavacElements elemUtils = processingEnv . getElementUtils ( ) ; Pair < JCTree , JCCompilationUnit > treeTop = elemUtils . getTreeAndTopLevel ( e , a , v ) ; if ( treeTop != null ) { newSource = treeTop . snd . sourcefile ; if ( newSource != null ) { oldSource = log . useSource ( newSource ) ; pos = treeTop . fst . pos ( ) ; } } try { switch ( kind ) { case ERROR : errorCount ++ ; boolean prev = log . multipleErrors ; log . multipleErrors = true ; try { log . error ( pos , "proc.messager" , msg . toString ( ) ) ; } finally { log . multipleErrors = prev ; } break ; case WARNING : warningCount ++ ; log . warning ( pos , "proc.messager" , msg . toString ( ) ) ; break ; case MANDATORY_WARNING : warningCount ++ ; log . mandatoryWarning ( pos , "proc.messager" , msg . toString ( ) ) ; break ; default : log . note ( pos , "proc.messager" , msg . toString ( ) ) ; break ; } } finally { if ( newSource != null ) log . useSource ( oldSource ) ; } } | Prints a message of the specified kind at the location of the annotation value inside the annotation mirror of the annotated element . |
11,406 | public void addWhereClause ( FreemarkerWhereClause freemarkerWhereClause ) { String outputBody = freemarkerWhereClause . getOutputBody ( ) ; if ( StringUtils . isNotBlank ( outputBody ) ) freemarkerWhereClauses . add ( outputBody ) ; } | Adds a where clause to the current context . Only performed on where clauses which are rendered . |
11,407 | public static Object invoke ( Object object , String methodName , Object ... parameters ) { Method method = getMethodThatMatchesParameters ( object . getClass ( ) , methodName , parameters ) ; if ( method != null ) { try { return method . invoke ( object , parameters ) ; } catch ( IllegalAccessException e ) { throw new RuntimeException ( "Unable to invoke method" , e ) ; } catch ( IllegalArgumentException e ) { throw new RuntimeException ( "Unable to invoke method" , e ) ; } catch ( InvocationTargetException e ) { if ( e . getCause ( ) instanceof RuntimeException ) { throw ( RuntimeException ) e . getCause ( ) ; } throw new RuntimeException ( e . getCause ( ) ) ; } } else { throw new RuntimeException ( "No method that matches [" + methodName + "] for class " + object . getClass ( ) . getSimpleName ( ) ) ; } } | Silently invoke the specified methodName using reflection . |
11,408 | public byte [ ] getContents ( FileColumn [ ] columns , List < String [ ] > lines ) throws IOException { byte [ ] ret ; if ( format . isExcel ( ) ) { ret = getExcelOutput ( columns , lines ) ; } else { ret = getCSVOutput ( lines ) ; } return ret ; } | Returns the formatted output file contents . |
11,409 | private byte [ ] getCSVOutput ( List < String [ ] > lines ) { StringWriter writer = new StringWriter ( ) ; csv = new CSVWriter ( writer , delimiter . separator ( ) . charAt ( 0 ) ) ; for ( int i = 0 ; i < lines . size ( ) ; i ++ ) { csv . writeNext ( ( String [ ] ) lines . get ( i ) , quotes ) ; } return writer . toString ( ) . getBytes ( ) ; } | Returns the CSV output file data . |
11,410 | private byte [ ] getExcelOutput ( FileColumn [ ] columns , List < String [ ] > lines ) throws IOException { baos = new ByteArrayOutputStream ( 1024 ) ; if ( existing != null ) workbook = Workbook . createWorkbook ( format , baos , existing ) ; else workbook = Workbook . createWorkbook ( format , baos ) ; workbook . setHeaders ( hasHeaders ( ) ) ; if ( append && workbook . getSheet ( worksheet ) != null ) workbook . appendToSheet ( columns , lines , worksheet ) ; else workbook . createSheet ( columns , lines , worksheet ) ; workbook . write ( ) ; workbook . close ( ) ; return baos . toByteArray ( ) ; } | Returns the XLS or XLSX output file data . |
11,411 | public MainFrame put ( Widget widget ) { widget . addTo ( user ) ; content = widget != null ? widget . getID ( ) : - 1 ; this . sendElement ( ) ; return this ; } | Adds widget to page |
11,412 | public static < T extends Comparable < ? super T > > boolean greaterThanOrEquals ( final T object , final T other ) { return JudgeUtils . greaterThanOrEquals ( object , other ) ; } | Returns true if object equals other or object greater than other ; false otherwise . |
11,413 | public static < T extends Comparable < ? super T > > boolean greaterThan ( final T object , final T other ) { return JudgeUtils . greaterThan ( object , other ) ; } | Returns true if object greater than other ; false otherwise . |
11,414 | public static < T extends Comparable < ? super T > > boolean lessThanOrEquals ( final T object , final T other ) { return JudgeUtils . lessThanOrEquals ( object , other ) ; } | Returns true if object equals other or object less than other ; false otherwise . |
11,415 | public static < T extends Comparable < ? super T > > boolean lessThan ( final T object , final T other ) { return JudgeUtils . lessThan ( object , other ) ; } | Returns true if object less than other ; false otherwise . |
11,416 | public static < T extends Comparable < ? super T > > void ascDeep ( final T [ ] comparableArray ) { if ( ArrayUtils . isEmpty ( comparableArray ) ) { return ; } ascByReflex ( comparableArray ) ; } | Orders given comparable array by ascending . |
11,417 | public static < T extends Comparable < ? super T > > void descDeep ( final T [ ] comparableArray ) { if ( ArrayUtils . isEmpty ( comparableArray ) ) { return ; } descByReflex ( comparableArray ) ; } | Orders given comparable array by descending . |
11,418 | public static < T > void reverse ( final T array ) { if ( ArrayUtils . isArray ( array ) ) { int mlength = Array . getLength ( array ) - 1 ; Object temp = null ; for ( int i = 0 , j = mlength ; i < mlength ; i ++ , j -- ) { Object arg0 = Array . get ( array , i ) ; Object arg1 = Array . get ( array , j ) ; temp = arg0 ; Array . set ( array , i , arg1 ) ; Array . set ( array , j , temp ) ; } } } | Sort the array in reverse order . |
11,419 | public void contextInitialized ( ServletContextEvent event ) { _registry . put ( INSTANCE , new Pair < Service , Persistence > ( this , null ) ) ; _context = event . getServletContext ( ) ; _application = _context . getContextPath ( ) ; _logger . config ( "application: " + _application ) ; if ( _application . charAt ( 0 ) == '/' ) _application = _application . substring ( 1 ) ; try { ManagementFactory . getPlatformMBeanServer ( ) . setAttribute ( new ObjectName ( "Catalina:host=localhost,name=AccessLogValve,type=Valve" ) , new Attribute ( "condition" , "intrinsic" ) ) ; } catch ( Exception x ) { } } | Initializes the servlet context . |
11,420 | final public void plugInterfaces ( RobotAction newControl , RobotStatus newStatus , WorldInfo newWorld ) { SecurityManager sm = System . getSecurityManager ( ) ; if ( sm != null ) { sm . checkPermission ( new GamePermission ( "connectBank" ) ) ; } control = newControl ; info = newStatus ; world = newWorld ; } | Attaches a control to a bank |
11,421 | final public void setTeamId ( int newId ) { if ( teamId != - 1 ) { throw new IllegalStateException ( "Team Id cannot be modified" ) ; } SecurityManager sm = System . getSecurityManager ( ) ; if ( sm != null ) { sm . checkPermission ( new GamePermission ( "setTeamId" ) ) ; } teamId = newId ; } | Sets the team id . Can only be called once otherwise it will throw an exception |
11,422 | public static String stringFor ( int m ) { if ( m == CUFFT_COMPATIBILITY_NATIVE ) { return "CUFFT_COMPATIBILITY_NATIVE" ; } if ( ( m & CUFFT_COMPATIBILITY_FFTW_ALL ) == CUFFT_COMPATIBILITY_FFTW_ALL ) { return "CUFFT_COMPATIBILITY_FFTW_ALL" ; } StringBuilder sb = new StringBuilder ( ) ; if ( ( m & CUFFT_COMPATIBILITY_FFTW_PADDING ) != 0 ) { sb . append ( "CUFFT_COMPATIBILITY_FFTW_PADDING " ) ; } if ( ( m & CUFFT_COMPATIBILITY_FFTW_ASYMMETRIC ) != 0 ) { sb . append ( "CUFFT_COMPATIBILITY_FFTW_ASYMMETRIC " ) ; } return sb . toString ( ) ; } | Returns the String identifying the given cufftCompatibility |
11,423 | static public String getFormattedBytes ( long bytes , String units , String format ) { double num = bytes ; String [ ] prefix = { "" , "K" , "M" , "G" , "T" } ; int count = 0 ; while ( num >= 1024.0 ) { num = num / 1024.0 ; ++ count ; } DecimalFormat f = new DecimalFormat ( format ) ; return f . format ( num ) + " " + prefix [ count ] + units ; } | Returns the given bytes number formatted as KBytes MBytes or GBytes as appropriate . |
11,424 | static public String getFormattedDate ( long dt ) { String ret = "" ; SimpleDateFormat df = null ; try { if ( dt > 0 ) { df = formatPool . getFormat ( DATE_FORMAT ) ; df . setTimeZone ( DateUtilities . getCurrentTimeZone ( ) ) ; ret = df . format ( new Date ( dt ) ) ; } } catch ( Exception e ) { } if ( df != null ) formatPool . release ( df ) ; return ret ; } | Returns the given date parsed using dd - MM - yyyy . |
11,425 | static public String getLongFormattedDays ( long dt ) { StringBuffer ret = new StringBuffer ( ) ; long days = dt / 86400000L ; long millis = dt - ( days * 86400000L ) ; if ( days > 0 ) { ret . append ( Long . toString ( days ) ) ; ret . append ( " day" ) ; if ( days > 1 ) ret . append ( "s" ) ; } long hours = millis / 3600000L ; millis = millis - ( hours * 3600000L ) ; if ( hours > 0 ) { if ( ret . length ( ) > 0 ) ret . append ( " " ) ; ret . append ( Long . toString ( hours ) ) ; ret . append ( " hour" ) ; if ( hours > 1 ) ret . append ( "s" ) ; } long minutes = millis / 60000L ; millis = millis - ( minutes * 60000L ) ; if ( minutes > 0 ) { if ( ret . length ( ) > 0 ) ret . append ( " " ) ; ret . append ( Long . toString ( minutes ) ) ; ret . append ( " minute" ) ; if ( minutes > 1 ) ret . append ( "s" ) ; } long seconds = millis / 1000L ; if ( seconds > 0 ) { if ( ret . length ( ) > 0 ) ret . append ( " " ) ; ret . append ( Long . toString ( seconds ) ) ; ret . append ( " second" ) ; if ( seconds > 1 ) ret . append ( "s" ) ; } return ret . toString ( ) ; } | Returns the given time formatted as a number of days hours and minutes . |
11,426 | public ClassDocImpl loadClass ( String name ) { try { ClassSymbol c = reader . loadClass ( names . fromString ( name ) ) ; return getClassDoc ( c ) ; } catch ( CompletionFailure ex ) { chk . completionError ( null , ex ) ; return null ; } } | Load ClassDoc by qualified name . |
11,427 | protected void buildProfileIndexFile ( String title , boolean includeScript ) throws IOException { String windowOverview = configuration . getText ( title ) ; Content body = getBody ( includeScript , getWindowTitle ( windowOverview ) ) ; addNavigationBarHeader ( body ) ; addOverviewHeader ( body ) ; addIndex ( body ) ; addOverview ( body ) ; addNavigationBarFooter ( body ) ; printHtmlDocument ( configuration . metakeywords . getOverviewMetaKeywords ( title , configuration . doctitle ) , includeScript , body ) ; } | Generate and prints the contents in the profile index file . Call appropriate methods from the sub - class in order to generate Frame or Non Frame format . |
11,428 | protected void buildProfilePackagesIndexFile ( String title , boolean includeScript , String profileName ) throws IOException { String windowOverview = configuration . getText ( title ) ; Content body = getBody ( includeScript , getWindowTitle ( windowOverview ) ) ; addNavigationBarHeader ( body ) ; addOverviewHeader ( body ) ; addProfilePackagesIndex ( body , profileName ) ; addOverview ( body ) ; addNavigationBarFooter ( body ) ; printHtmlDocument ( configuration . metakeywords . getOverviewMetaKeywords ( title , configuration . doctitle ) , includeScript , body ) ; } | Generate and prints the contents in the profile packages index file . Call appropriate methods from the sub - class in order to generate Frame or Non Frame format . |
11,429 | protected void addIndex ( Content body ) { addIndexContents ( profiles , "doclet.Profile_Summary" , configuration . getText ( "doclet.Member_Table_Summary" , configuration . getText ( "doclet.Profile_Summary" ) , configuration . getText ( "doclet.profiles" ) ) , body ) ; } | Adds the frame or non - frame profile index to the documentation tree . |
11,430 | protected void addProfilePackagesIndex ( Content body , String profileName ) { addProfilePackagesIndexContents ( profiles , "doclet.Profile_Summary" , configuration . getText ( "doclet.Member_Table_Summary" , configuration . getText ( "doclet.Profile_Summary" ) , configuration . getText ( "doclet.profiles" ) ) , body , profileName ) ; } | Adds the frame or non - frame profile packages index to the documentation tree . |
11,431 | protected void addIndexContents ( Profiles profiles , String text , String tableSummary , Content body ) { if ( profiles . getProfileCount ( ) > 0 ) { HtmlTree div = new HtmlTree ( HtmlTag . DIV ) ; div . addStyle ( HtmlStyle . indexHeader ) ; addAllClassesLink ( div ) ; addAllPackagesLink ( div ) ; body . addContent ( div ) ; addProfilesList ( profiles , text , tableSummary , body ) ; } } | Adds profile index contents . Call appropriate methods from the sub - classes . Adds it to the body HtmlTree |
11,432 | protected void addProfilePackagesIndexContents ( Profiles profiles , String text , String tableSummary , Content body , String profileName ) { HtmlTree div = new HtmlTree ( HtmlTag . DIV ) ; div . addStyle ( HtmlStyle . indexHeader ) ; addAllClassesLink ( div ) ; addAllPackagesLink ( div ) ; addAllProfilesLink ( div ) ; body . addContent ( div ) ; addProfilePackagesList ( profiles , text , tableSummary , body , profileName ) ; } | Adds profile packages index contents . Call appropriate methods from the sub - classes . Adds it to the body HtmlTree |
11,433 | public Iterable < DContact > queryByBirthday ( Object parent , java . util . Date birthday ) { return queryByField ( parent , DContactMapper . Field . BIRTHDAY . getFieldName ( ) , birthday ) ; } | query - by method for field birthday |
11,434 | public Iterable < DContact > queryByCompanyName ( Object parent , java . lang . String companyName ) { return queryByField ( parent , DContactMapper . Field . COMPANYNAME . getFieldName ( ) , companyName ) ; } | query - by method for field companyName |
11,435 | public Iterable < DContact > queryByEmail ( Object parent , java . lang . String email ) { return queryByField ( parent , DContactMapper . Field . EMAIL . getFieldName ( ) , email ) ; } | query - by method for field email |
11,436 | public Iterable < DContact > queryByFacebook ( Object parent , java . lang . String facebook ) { return queryByField ( parent , DContactMapper . Field . FACEBOOK . getFieldName ( ) , facebook ) ; } | query - by method for field facebook |
11,437 | public Iterable < DContact > queryByHomePhone ( Object parent , java . lang . String homePhone ) { return queryByField ( parent , DContactMapper . Field . HOMEPHONE . getFieldName ( ) , homePhone ) ; } | query - by method for field homePhone |
11,438 | public Iterable < DContact > queryByLatitude ( Object parent , java . lang . Float latitude ) { return queryByField ( parent , DContactMapper . Field . LATITUDE . getFieldName ( ) , latitude ) ; } | query - by method for field latitude |
11,439 | public Iterable < DContact > queryByLinkedIn ( Object parent , java . lang . String linkedIn ) { return queryByField ( parent , DContactMapper . Field . LINKEDIN . getFieldName ( ) , linkedIn ) ; } | query - by method for field linkedIn |
11,440 | public Iterable < DContact > queryByLongitude ( Object parent , java . lang . Float longitude ) { return queryByField ( parent , DContactMapper . Field . LONGITUDE . getFieldName ( ) , longitude ) ; } | query - by method for field longitude |
11,441 | public Iterable < DContact > queryByMobilePhone ( Object parent , java . lang . String mobilePhone ) { return queryByField ( parent , DContactMapper . Field . MOBILEPHONE . getFieldName ( ) , mobilePhone ) ; } | query - by method for field mobilePhone |
11,442 | public Iterable < DContact > queryByOtherEmail ( Object parent , java . lang . String otherEmail ) { return queryByField ( parent , DContactMapper . Field . OTHEREMAIL . getFieldName ( ) , otherEmail ) ; } | query - by method for field otherEmail |
11,443 | public Iterable < DContact > queryByOtherPhone ( Object parent , java . lang . String otherPhone ) { return queryByField ( parent , DContactMapper . Field . OTHERPHONE . getFieldName ( ) , otherPhone ) ; } | query - by method for field otherPhone |
11,444 | public Iterable < DContact > queryByPrimaryCustomIndex ( Object parent , java . lang . String primaryCustomIndex ) { return queryByField ( parent , DContactMapper . Field . PRIMARYCUSTOMINDEX . getFieldName ( ) , primaryCustomIndex ) ; } | query - by method for field primaryCustomIndex |
11,445 | public Iterable < DContact > queryBySecondaryCustomIndex ( Object parent , java . lang . String secondaryCustomIndex ) { return queryByField ( parent , DContactMapper . Field . SECONDARYCUSTOMINDEX . getFieldName ( ) , secondaryCustomIndex ) ; } | query - by method for field secondaryCustomIndex |
11,446 | public Iterable < DContact > queryByTags ( Object parent , java . lang . Object tags ) { return queryByField ( parent , DContactMapper . Field . TAGS . getFieldName ( ) , tags ) ; } | query - by method for field tags |
11,447 | public Iterable < DContact > queryByTwitter ( Object parent , java . lang . String twitter ) { return queryByField ( parent , DContactMapper . Field . TWITTER . getFieldName ( ) , twitter ) ; } | query - by method for field twitter |
11,448 | public DContact findByUniqueTag ( Object parent , java . lang . String uniqueTag ) { return queryUniqueByField ( parent , DContactMapper . Field . UNIQUETAG . getFieldName ( ) , uniqueTag ) ; } | find - by method for unique field uniqueTag |
11,449 | public Iterable < DContact > queryByWebPage ( Object parent , java . lang . String webPage ) { return queryByField ( parent , DContactMapper . Field . WEBPAGE . getFieldName ( ) , webPage ) ; } | query - by method for field webPage |
11,450 | public Iterable < DContact > queryByWorkPhone ( Object parent , java . lang . String workPhone ) { return queryByField ( parent , DContactMapper . Field . WORKPHONE . getFieldName ( ) , workPhone ) ; } | query - by method for field workPhone |
11,451 | public static int string2int ( String s , int radix ) throws NumberFormatException { if ( radix == 10 ) { return Integer . parseInt ( s , radix ) ; } else { char [ ] cs = s . toCharArray ( ) ; int limit = Integer . MAX_VALUE / ( radix / 2 ) ; int n = 0 ; for ( int i = 0 ; i < cs . length ; i ++ ) { int d = Character . digit ( cs [ i ] , radix ) ; if ( n < 0 || n > limit || n * radix > Integer . MAX_VALUE - d ) throw new NumberFormatException ( ) ; n = n * radix + d ; } return n ; } } | Convert string to integer . |
11,452 | public static long string2long ( String s , int radix ) throws NumberFormatException { if ( radix == 10 ) { return Long . parseLong ( s , radix ) ; } else { char [ ] cs = s . toCharArray ( ) ; long limit = Long . MAX_VALUE / ( radix / 2 ) ; long n = 0 ; for ( int i = 0 ; i < cs . length ; i ++ ) { int d = Character . digit ( cs [ i ] , radix ) ; if ( n < 0 || n > limit || n * radix > Long . MAX_VALUE - d ) throw new NumberFormatException ( ) ; n = n * radix + d ; } return n ; } } | Convert string to long integer . |
11,453 | public static String getResponseMaybe ( SocketManager socketManager , String message ) throws IOException { try { return socketManager . sendAndWait ( message ) ; } catch ( ResponseTimeoutException e ) { socketManager . send ( "help" ) ; return "" ; } } | Send a message and wait for a short period for a response . If no response comes in that time it is assumed that there will be no response from the frontend . This is useful for commands that get a response when there is data available and silence otherwise . |
11,454 | public static String parsePropertyName ( Method method ) { String name = method . getName ( ) ; int i = 0 ; if ( name . startsWith ( "get" ) || name . startsWith ( "set" ) ) { i = 3 ; } else if ( name . startsWith ( "is" ) ) { i = 2 ; } return Character . toLowerCase ( name . charAt ( i ) ) + name . substring ( i + 1 ) ; } | Parses the method name to return a property name if it is a getter or a setter . |
11,455 | public static < E > OptionalFunction < Selection < Method > , E > invoke ( Object ... args ) { return OptionalFunction . of ( selection -> factory . createInvoker ( selection . result ( ) ) . on ( selection . target ( ) ) . withArgs ( args ) ) ; } | Returns a function that invokes a selected method . |
11,456 | public static < E > OptionalFunction < Selection < Constructor < ? > > , E > instantiate ( Object ... args ) { return OptionalFunction . of ( selection -> factory . createInvoker ( selection . result ( ) ) . withArgs ( args ) ) ; } | Returns a function that invokes a selected constructor . |
11,457 | public static < E > OptionalFunction < Selection < Field > , E > getValue ( ) { return OptionalFunction . of ( selection -> factory . createHandler ( selection . result ( ) ) . on ( selection . target ( ) ) . getValue ( ) ) ; } | Returns a function that gets the value of a selected field . |
11,458 | public static Consumer < Selection < Field > > setValue ( Object newValue ) { return selection -> factory . createHandler ( selection . result ( ) ) . on ( selection . target ( ) ) . setValue ( newValue ) ; } | Returns a consumer that sets the value of a selected field . |
11,459 | public Object users ( ) { return new ArrayList < Map < String , Object > > ( ) { { add ( new HashMap < String , Object > ( ) { { put ( "username" , "testUser1" ) ; put ( "groups" , Arrays . asList ( "group1" ) ) ; put ( "password" , "thisMechWillChange" ) ; } } ) ; add ( new HashMap < String , Object > ( ) { { put ( "username" , "testUser2" ) ; put ( "groups" , Arrays . asList ( "group2" ) ) ; put ( "password" , "thisMechWillChange" ) ; } } ) ; } } ; } | Avoiding adding extra dependencies so using hash map . |
11,460 | public boolean nextKeyValue ( ) throws IOException , InterruptedException { if ( ! deserializer . hasNextEvent ( ) ) { return false ; } else { value = deserializer . getNextEvent ( ) ; key = value . getEventDateTime ( ) ; return true ; } } | Read the next key value pair . |
11,461 | public float getProgress ( ) throws IOException , InterruptedException { if ( start == end ) { return 0.0f ; } else { return Math . min ( 1.0f , ( pos - start ) / ( float ) ( end - start ) ) ; } } | The current progress of the record reader through its data . |
11,462 | public void addAttr ( HtmlAttr attrName , String attrValue ) { if ( attrs . isEmpty ( ) ) attrs = new LinkedHashMap < HtmlAttr , String > ( 3 ) ; attrs . put ( nullCheck ( attrName ) , escapeHtmlChars ( attrValue ) ) ; } | Adds an attribute for the HTML tag . |
11,463 | public void addContent ( Content tagContent ) { if ( tagContent instanceof ContentBuilder ) { for ( Content content : ( ( ContentBuilder ) tagContent ) . contents ) { addContent ( content ) ; } } else if ( tagContent == HtmlTree . EMPTY || tagContent . isValid ( ) ) { if ( content . isEmpty ( ) ) content = new ArrayList < Content > ( ) ; content . add ( tagContent ) ; } } | Adds content for the HTML tag . |
11,464 | public static HtmlTree A_NAME ( String name , Content body ) { HtmlTree htmltree = HtmlTree . A_NAME ( name ) ; htmltree . addContent ( nullCheck ( body ) ) ; return htmltree ; } | Generates an HTML anchor tag with name attribute and content . |
11,465 | public static HtmlTree A_NAME ( String name ) { HtmlTree htmltree = new HtmlTree ( HtmlTag . A ) ; htmltree . addAttr ( HtmlAttr . NAME , nullCheck ( name ) ) ; return htmltree ; } | Generates an HTML anchor tag with name attribute . |
11,466 | public static HtmlTree FRAME ( String src , String name , String title , String scrolling ) { HtmlTree htmltree = new HtmlTree ( HtmlTag . FRAME ) ; htmltree . addAttr ( HtmlAttr . SRC , nullCheck ( src ) ) ; htmltree . addAttr ( HtmlAttr . NAME , nullCheck ( name ) ) ; htmltree . addAttr ( HtmlAttr . TITLE , nullCheck ( title ) ) ; if ( scrolling != null ) htmltree . addAttr ( HtmlAttr . SCROLLING , scrolling ) ; return htmltree ; } | Generates a FRAME tag . |
11,467 | public static HtmlTree FRAME ( String src , String name , String title ) { return FRAME ( src , name , title , null ) ; } | Generates a Frame tag . |
11,468 | public static HtmlTree FRAMESET ( String cols , String rows , String title , String onload ) { HtmlTree htmltree = new HtmlTree ( HtmlTag . FRAMESET ) ; if ( cols != null ) htmltree . addAttr ( HtmlAttr . COLS , cols ) ; if ( rows != null ) htmltree . addAttr ( HtmlAttr . ROWS , rows ) ; htmltree . addAttr ( HtmlAttr . TITLE , nullCheck ( title ) ) ; htmltree . addAttr ( HtmlAttr . ONLOAD , nullCheck ( onload ) ) ; return htmltree ; } | Generates a FRAMESET tag . |
11,469 | public static HtmlTree TABLE ( HtmlStyle styleClass , int border , int cellPadding , int cellSpacing , String summary , Content body ) { HtmlTree htmltree = new HtmlTree ( HtmlTag . TABLE , nullCheck ( body ) ) ; if ( styleClass != null ) htmltree . addStyle ( styleClass ) ; htmltree . addAttr ( HtmlAttr . BORDER , Integer . toString ( border ) ) ; htmltree . addAttr ( HtmlAttr . CELLPADDING , Integer . toString ( cellPadding ) ) ; htmltree . addAttr ( HtmlAttr . CELLSPACING , Integer . toString ( cellSpacing ) ) ; htmltree . addAttr ( HtmlAttr . SUMMARY , nullCheck ( summary ) ) ; return htmltree ; } | Generates a Table tag with style class border cell padding cellspacing and summary attributes and some content . |
11,470 | public static String execute ( final boolean withResponse , final String ... command ) throws IOException { final List < String > commands = new ArrayList < > ( ) ; commands . add ( "bash" ) ; commands . add ( "-c" ) ; commands . addAll ( Arrays . asList ( command ) ) ; String response = "" ; final ProcessBuilder pb = new ProcessBuilder ( commands ) ; pb . redirectErrorStream ( true ) ; final Process shell = pb . start ( ) ; if ( withResponse ) { try ( InputStream shellIn = shell . getInputStream ( ) ) { response = toString ( shellIn ) ; } } return response ; } | Execute the given commands and return the result . |
11,471 | private static int checkResult ( int result ) { if ( exceptionsEnabled && result != cufftResult . CUFFT_SUCCESS ) { throw new CudaException ( cufftResult . stringFor ( result ) ) ; } return result ; } | If the given result is different to cufftResult . CUFFT_SUCCESS and exceptions have been enabled this method will throw a CudaException with an error message that corresponds to the given result code . Otherwise the given result is simply returned . |
11,472 | public Object invoke ( Object proxy , Method method , Object [ ] args ) throws Throwable { return connectionHandler . remoteInvocation ( proxy , method , args ) ; } | Delegates call to this proxy to it s ConnectionHandler |
11,473 | public static ImageReader getImageReader ( final Object sourceImage ) throws IOException { ImageInputStream imageInputStream = ImageIO . createImageInputStream ( sourceImage ) ; Iterator < ImageReader > imageReaders = ImageIO . getImageReaders ( imageInputStream ) ; ImageReader destinationImageReader = null ; if ( imageReaders . hasNext ( ) ) { destinationImageReader = imageReaders . next ( ) ; setImageReaderHaveInputStream ( destinationImageReader , imageInputStream ) ; } return destinationImageReader ; } | Get image reader from given source image . |
11,474 | public static ImageReader getImageReaderFromHttpImage ( final String sourceImageHttpURL ) throws IOException { InputStream inputStream = new URL ( sourceImageHttpURL ) . openConnection ( ) . getInputStream ( ) ; return getImageReader ( inputStream ) ; } | Get image reader from given web image . |
11,475 | public < T > T get ( Key < T > key ) { checkState ( ht ) ; Object o = ht . get ( key ) ; if ( o instanceof Factory < ? > ) { Factory < ? > fac = ( Factory < ? > ) o ; o = fac . make ( this ) ; if ( o instanceof Factory < ? > ) throw new AssertionError ( "T extends Context.Factory" ) ; Assert . check ( ht . get ( key ) == o ) ; } return Context . < T > uncheckedCast ( o ) ; } | Get the value for the key in this context . |
11,476 | protected void configure ( Properties p ) { _properties = p ; _host = ( String ) p . remove ( HOST ) ; if ( _host == null ) throw new NoSuchElementException ( HOST ) ; _path = ( String ) p . remove ( PATH ) ; if ( _path == null ) throw new NoSuchElementException ( PATH ) ; } | Configures the RemoteServiceChannel with given properties . |
11,477 | public < T > RemoteService . Response call ( long pause , Functor < T , String > reporter ) throws Exception { String message = null ; while ( true ) { RemoteService . Response response = _caller . call ( ) ; String news = response . params . get ( "message" ) ; if ( news == null ) { if ( _state != null && message != null ) { _state . param = null ; _state . markAttempt ( ) ; } return response ; } else { if ( ! news . equals ( message ) ) { if ( _state != null ) { if ( reporter != null ) reporter . invoke ( "Attempting " + _state . state + ": " + news ) ; _state . param = Progressive . State . clean ( news ) ; _state . markAttempt ( ) ; } else { if ( reporter != null ) reporter . invoke ( news ) ; } message = news ; } Thread . sleep ( pause < PAUSE_BETWEEN_RETRIES ? PAUSE_BETWEEN_RETRIES : pause ) ; } } } | Calls the remote service continuously until a final response is received reporting progress messages via the reporter . |
11,478 | public synchronized V invalidate ( K key ) { Singleton < V > singleton = _cache . get ( key ) ; if ( singleton != null ) { return singleton . clear ( ) ; } else { return null ; } } | Invalidates an entry in the cache . This operation does not constitute a cache replacement . |
11,479 | public List < Attribute . Compound > getRawAttributes ( ) { return ( metadata == null ) ? List . < Attribute . Compound > nil ( ) : metadata . getDeclarationAttributes ( ) ; } | An accessor method for the attributes of this symbol . Attributes of class symbols should be accessed through the accessor method to make sure that the class symbol is loaded . |
11,480 | public List < Attribute . TypeCompound > getRawTypeAttributes ( ) { return ( metadata == null ) ? List . < Attribute . TypeCompound > nil ( ) : metadata . getTypeAttributes ( ) ; } | An accessor method for the type attributes of this symbol . Attributes of class symbols should be accessed through the accessor method to make sure that the class symbol is loaded . |
11,481 | public ClassSymbol enclClass ( ) { Symbol c = this ; while ( c != null && ( ( c . kind & TYP ) == 0 || ! c . type . hasTag ( CLASS ) ) ) { c = c . owner ; } return ( ClassSymbol ) c ; } | The closest enclosing class of this symbol s declaration . |
11,482 | public static int floor ( int n , int m ) { return n >= 0 ? ( n / m ) * m : ( ( n - m + 1 ) / m ) * m ; } | Rounds n down to the nearest multiple of m |
11,483 | public static int ceiling ( int n , int m ) { return n >= 0 ? ( ( n + m - 1 ) / m ) * m : ( n / m ) * m ; } | Rounds n up to the nearest multiple of m |
11,484 | public void add ( Collection < PluginComponent > components ) { for ( PluginComponent component : components ) this . components . put ( component . getId ( ) , component ) ; } | Adds the plugin component list to the plugin components for the account . |
11,485 | private void checkIndex ( ) throws IOException { boolean isUpToDate = true ; if ( ! isUpToDate ( ) ) { closeFile ( ) ; isUpToDate = false ; } if ( zipRandomFile != null || isUpToDate ) { lastReferenceTimeStamp = System . currentTimeMillis ( ) ; return ; } hasPopulatedData = true ; if ( readIndex ( ) ) { lastReferenceTimeStamp = System . currentTimeMillis ( ) ; return ; } directories = Collections . < RelativeDirectory , DirectoryEntry > emptyMap ( ) ; allDirs = Collections . < RelativeDirectory > emptySet ( ) ; try { openFile ( ) ; long totalLength = zipRandomFile . length ( ) ; ZipDirectory directory = new ZipDirectory ( zipRandomFile , 0L , totalLength , this ) ; directory . buildIndex ( ) ; } finally { if ( zipRandomFile != null ) { closeFile ( ) ; } } lastReferenceTimeStamp = System . currentTimeMillis ( ) ; } | Here we need to make sure that the ZipFileIndex is valid . Check the timestamp of the file and if its the same as the one at the time the index was build we don t need to reopen anything . |
11,486 | synchronized Entry getZipIndexEntry ( RelativePath path ) { try { checkIndex ( ) ; DirectoryEntry de = directories . get ( path . dirname ( ) ) ; String lookFor = path . basename ( ) ; return ( de == null ) ? null : de . getEntry ( lookFor ) ; } catch ( IOException e ) { return null ; } } | Returns the ZipFileIndexEntry for a path if there is one . |
11,487 | public synchronized com . sun . tools . javac . util . List < String > getFiles ( RelativeDirectory path ) { try { checkIndex ( ) ; DirectoryEntry de = directories . get ( path ) ; com . sun . tools . javac . util . List < String > ret = de == null ? null : de . getFiles ( ) ; if ( ret == null ) { return com . sun . tools . javac . util . List . < String > nil ( ) ; } return ret ; } catch ( IOException e ) { return com . sun . tools . javac . util . List . < String > nil ( ) ; } } | Returns a javac List of filenames within a directory in the ZipFileIndex . |
11,488 | public synchronized boolean contains ( RelativePath path ) { try { checkIndex ( ) ; return getZipIndexEntry ( path ) != null ; } catch ( IOException e ) { return false ; } } | Tests if a specific path exists in the zip . This method will return true for file entries and directories . |
11,489 | public static List < Event > fromFile ( final File file ) throws IOException , ClassNotFoundException { return fromInputStream ( new FileInputStream ( file ) ) ; } | Given a file written by the serialization - writer library extract all events . This assumes the file was written using ObjectOutputStream . |
11,490 | public boolean add ( String field , List < RDFNode > result ) { this . result . put ( field , result ) ; return true ; } | Add a new result |
11,491 | public boolean add ( String field , RDFNode result ) { if ( ! this . result . containsKey ( field ) ) { this . result . put ( field , new ArrayList < RDFNode > ( ) ) ; } this . result . get ( field ) . add ( result ) ; return true ; } | Add a single result |
11,492 | public Manifest getManifest ( MavenProject project , ManifestConfiguration config ) throws ManifestException , DependencyResolutionRequiredException { Manifest m = new Manifest ( ) ; Manifest . Attribute buildAttr = new Manifest . Attribute ( "Built-By" , System . getProperty ( "user.name" ) ) ; m . addConfiguredAttribute ( buildAttr ) ; Manifest . Attribute createdAttr = new Manifest . Attribute ( "Created-By" , "Apache Maven" ) ; m . addConfiguredAttribute ( createdAttr ) ; if ( config . getPackageName ( ) != null ) { Manifest . Attribute packageAttr = new Manifest . Attribute ( "Package" , config . getPackageName ( ) ) ; m . addConfiguredAttribute ( packageAttr ) ; } Manifest . Attribute buildJdkAttr = new Manifest . Attribute ( "Build-Jdk" , System . getProperty ( "java.version" ) ) ; m . addConfiguredAttribute ( buildJdkAttr ) ; if ( config . isAddClasspath ( ) ) { StringBuffer classpath = new StringBuffer ( ) ; List artifacts = project . getRuntimeClasspathElements ( ) ; String classpathPrefix = config . getClasspathPrefix ( ) ; for ( Iterator iter = artifacts . iterator ( ) ; iter . hasNext ( ) ; ) { File f = new File ( ( String ) iter . next ( ) ) ; if ( f . isFile ( ) ) { if ( classpath . length ( ) > 0 ) { classpath . append ( " " ) ; } classpath . append ( classpathPrefix ) ; classpath . append ( f . getName ( ) ) ; } } if ( classpath . length ( ) > 0 ) { Manifest . Attribute classpathAttr = new Manifest . Attribute ( "Class-Path" , classpath . toString ( ) ) ; m . addConfiguredAttribute ( classpathAttr ) ; } } String mainClass = config . getMainClass ( ) ; if ( mainClass != null && ! "" . equals ( mainClass ) ) { Manifest . Attribute mainClassAttr = new Manifest . Attribute ( "Main-Class" , mainClass ) ; m . addConfiguredAttribute ( mainClassAttr ) ; } return m ; } | Return a pre - configured manifest |
11,493 | @ SuppressWarnings ( "unchecked" ) public Map marshal ( ) { HashMap map = new HashMap ( ) ; map . put ( "jsonrpc" , "2.0" ) ; if ( id != null ) map . put ( "id" , id ) ; if ( error != null ) map . put ( "error" , error . toMap ( ) ) ; else map . put ( "result" , result ) ; return map ; } | Marshals this response to a Map that can be serialized |
11,494 | public static void scan ( ServletContext c , Set < String > jars , Functor < Void , ServiceModule > collector , Logger logger ) { for ( String j : jars ) { logger . config ( "... " + j ) ; try ( JarInputStream jis = new JarInputStream ( j . startsWith ( "/" ) ? c . getResourceAsStream ( j ) : new URL ( j ) . openStream ( ) ) ) { Attributes attrs = jis . getManifest ( ) . getMainAttributes ( ) ; String d = attrs . getValue ( DOMAIN_NAME ) , n = attrs . getValue ( MODULE_NAME ) , s = attrs . getValue ( SIMPLE_NAME ) ; if ( d != null && n != null && s != null ) { collector . invoke ( new ServiceModule ( d , n , s , attrs . getValue ( MODULE_BASE ) , j ) ) ; } } catch ( IOException x ) { logger . log ( Level . WARNING , "Unexpected error during jar inspection, ignored" , x ) ; } catch ( Exception x ) { logger . config ( "Unknown resource ignored" ) ; } } } | Scans a collection of jar files passing recognized Xillium application modules as ServiceModule objects to a collector . |
11,495 | public void writeToJsonGenerator ( final JsonGenerator gen ) throws IOException { gen . writeStartObject ( ) ; gen . writeStringField ( "eventName" , eventName ) ; gen . writeFieldName ( "payload" ) ; getObjectMapper ( ) . writeTree ( gen , root ) ; gen . writeEndObject ( ) ; } | having to know all the events ahead of time . |
11,496 | public synchronized boolean waitForValidValues ( ) throws IOException , FileNotFoundException { for ( int tries = 0 ; tries < 50 ; tries ++ ) { lock ( ) ; getValues ( ) ; unlock ( ) ; if ( containsPortInfo ) { Log . debug ( "Found valid values in port file after waiting " + ( tries * 100 ) + "ms" ) ; return true ; } try { Thread . sleep ( 100 ) ; } catch ( InterruptedException e ) { } } Log . debug ( "Gave up waiting for valid values in port file" ) ; return false ; } | Wait for the port file to contain values that look valid . Return true if a - ok false if the valid values did not materialize within 5 seconds . |
11,497 | public synchronized boolean stillMyValues ( ) throws IOException , FileNotFoundException { for ( ; ; ) { try { lock ( ) ; getValues ( ) ; unlock ( ) ; if ( containsPortInfo ) { if ( serverPort == myServerPort && serverCookie == myServerCookie ) { return true ; } return false ; } return false ; } catch ( FileLockInterruptionException e ) { continue ; } catch ( ClosedChannelException e ) { return false ; } } } | Check if the portfile still contains my values assuming that I am the server . |
11,498 | @ SuppressWarnings ( "unchecked" ) public static < T > T instantiateDefault ( Class < T > someClass ) { if ( someClass . isArray ( ) ) { return ( T ) Array . newInstance ( someClass . getComponentType ( ) , 0 ) ; } else { if ( boolean . class . equals ( someClass ) || Boolean . class . equals ( someClass ) ) { return ( T ) Boolean . FALSE ; } else if ( int . class . equals ( someClass ) || Integer . class . equals ( someClass ) ) { return ( T ) Integer . valueOf ( 0 ) ; } else if ( long . class . equals ( someClass ) || Long . class . equals ( someClass ) ) { return ( T ) Long . valueOf ( 0L ) ; } else if ( short . class . equals ( someClass ) || Short . class . equals ( someClass ) ) { return ( T ) Short . valueOf ( ( short ) 0 ) ; } else if ( float . class . equals ( someClass ) || Float . class . equals ( someClass ) ) { return ( T ) Float . valueOf ( 0f ) ; } else if ( double . class . equals ( someClass ) || Double . class . equals ( someClass ) ) { return ( T ) Double . valueOf ( 0d ) ; } else if ( byte . class . equals ( someClass ) || Byte . class . equals ( someClass ) ) { return ( T ) Byte . valueOf ( ( byte ) 0 ) ; } else if ( char . class . equals ( someClass ) || Character . class . equals ( someClass ) ) { return ( T ) Character . valueOf ( ( char ) 0 ) ; } else { try { Constructor < T > defaultConstructor = someClass . getDeclaredConstructor ( ) ; defaultConstructor . setAccessible ( true ) ; return defaultConstructor . newInstance ( ) ; } catch ( Exception e ) { throw ShedException . wrap ( e , ShedErrorCode . UNABLE_TO_INSTANTIATE_CLASS ) . put ( "class" , someClass ) ; } } } } | Instantiate a class by invoking its default constructor . If the specified class denotes an array an empty array of the correct component type is created . If the specified class denotes a primitive the primitive is created with its default value . |
11,499 | @ SuppressWarnings ( "unchecked" ) public static < T > Optional < Class < T > > optional ( String dependency ) { try { return Optional . of ( ( Class < T > ) Class . forName ( dependency ) ) ; } catch ( ClassNotFoundException | NoClassDefFoundError e ) { return Optional . empty ( ) ; } } | Checks if a class exists in the classpath . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.