idx int64 0 41.2k | question stringlengths 83 4.15k | target stringlengths 5 715 |
|---|---|---|
11,700 | protected static String tryCommands ( String [ ] cmds ) { if ( cmds == null ) { return null ; } String output ; for ( int ii = 0 ; ii < cmds . length ; ii ++ ) { output = runCommand ( cmds [ ii ] ) ; if ( output != null ) { return output ; } } return null ; } | Takes a lists of commands and tries to run each one till one works . The idea being to be able to gracefully cope with not knowing where a command is installed on different installations . |
11,701 | protected static String runCommand ( String cmd ) { try { Process p = Runtime . getRuntime ( ) . exec ( cmd ) ; BufferedReader cin = new BufferedReader ( new InputStreamReader ( p . getInputStream ( ) ) ) ; StringBuilder buffer = new StringBuilder ( ) ; String line = "" ; while ( line != null ) { buffer . append ( line... | Run the specified command and return the output as a string . |
11,702 | public static void copyRow ( XSSFSheet srcSheet , XSSFSheet destSheet , int parentSheetRow , int parentSheetColumn , XSSFRow srcRow , XSSFRow destRow , Map < Integer , CellStyle > styleMap ) { Set < CellRangeAddressWrapper > mergedRegions = new TreeSet < CellRangeAddressWrapper > ( ) ; destRow . setHeight ( srcRow . ge... | Copy a row from a sheet to another sheet |
11,703 | public static void copyCell ( XSSFCell oldCell , XSSFCell newCell , Map < Integer , CellStyle > styleMap ) { if ( styleMap != null ) { if ( oldCell . getSheet ( ) . getWorkbook ( ) == newCell . getSheet ( ) . getWorkbook ( ) ) { newCell . setCellStyle ( oldCell . getCellStyle ( ) ) ; } else { int stHashCode = oldCell .... | Copy a cell to another cell |
11,704 | public String connect ( String hostname , int port ) throws IOException , CDDBException { return connect ( hostname , port , CLIENT_NAME , CLIENT_VERSION ) ; } | Connects this CDDB instance to the CDDB server running on the supplied host using the specified port and default client name and version . |
11,705 | public String connect ( String hostname , int port , String clientName , String clientVersion ) throws IOException , CDDBException { String localhost = InetAddress . getLocalHost ( ) . getHostName ( ) ; String username = System . getProperty ( "user.name" ) ; if ( username == null ) { username = "anonymous" ; } InetAdd... | Connects this CDDB instance to the CDDB server running on the supplied host using the specified port . |
11,706 | public String [ ] lscat ( ) throws IOException , CDDBException { if ( _sock == null ) { throw new CDDBException ( 500 , "Not connected" ) ; } Response rsp = request ( "cddb lscat" ) ; if ( rsp . code != 210 ) { throw new CDDBException ( rsp . code , rsp . message ) ; } ArrayList < String > list = new ArrayList < String... | Fetches and returns the list of categories supported by the server . |
11,707 | public Entry [ ] query ( String discid , int [ ] frameOffsets , int length ) throws IOException , CDDBException { if ( _sock == null ) { throw new CDDBException ( 500 , "Not connected" ) ; } StringBuilder req = new StringBuilder ( "cddb query " ) ; req . append ( discid ) . append ( " " ) ; req . append ( frameOffsets ... | Issues a query to the CDDB server using the supplied CD identifying information . |
11,708 | protected final void append ( ArrayList < String > list , int index , String value ) { while ( list . size ( ) <= index ) { list . add ( "" ) ; } list . set ( index , list . get ( index ) + value ) ; } | Appends the supplied string to the contents of the list at the supplied index . If the list has no contents at the supplied index the supplied value becomes the contents at that index . |
11,709 | protected Response request ( String req ) throws IOException { System . err . println ( "REQ:" + req ) ; _out . println ( req ) ; _out . flush ( ) ; String rspstr = _in . readLine ( ) ; if ( rspstr == null ) { throw new EOFException ( ) ; } System . err . println ( "RSP:" + rspstr ) ; Response rsp = new Response ( ) ; ... | Issues a request to the CDDB server and parses the response . |
11,710 | public final Cursor < T > select ( Connection conn , String condition ) { String query = "select " + listOfFields + " from " + name + " " + condition ; return new Cursor < T > ( this , conn , query ) ; } | Select records from database table according to search condition |
11,711 | public synchronized void insert ( Connection conn , T obj ) throws SQLException { StringBuilder sql = new StringBuilder ( "insert into " + name + " (" + listOfFields + ") values (?" ) ; for ( int i = 1 ; i < nColumns ; i ++ ) { sql . append ( ",?" ) ; } sql . append ( ")" ) ; PreparedStatement insertStmt = conn . prepa... | Insert new record in the table . Values of inserted record fields are taken from specified object . |
11,712 | public synchronized void insert ( Connection conn , T [ ] objects ) throws SQLException { StringBuilder sql = new StringBuilder ( "insert into " + name + " (" + listOfFields + ") values (?" ) ; for ( int i = 1 ; i < nColumns ; i ++ ) { sql . append ( ",?" ) ; } sql . append ( ")" ) ; PreparedStatement insertStmt = conn... | Insert several new records in the table . Values of inserted records fields are taken from objects of specified array . |
11,713 | public synchronized int delete ( Connection conn , T obj ) throws SQLException { if ( primaryKeys == null ) { throw new IllegalStateException ( "No primary key for table " + name + "." ) ; } int nDeleted = 0 ; StringBuilder sql = new StringBuilder ( "delete from " + name + " where " + primaryKeys [ 0 ] + " = ?" ) ; for... | Delete record with specified value of primary key from the table . |
11,714 | public synchronized int delete ( Connection conn , T [ ] objects ) throws SQLException { if ( primaryKeys == null ) { throw new IllegalStateException ( "No primary key for table " + name + "." ) ; } int nDeleted = 0 ; StringBuilder sql = new StringBuilder ( "delete from " + name + " where " + primaryKeys [ 0 ] + " = ?"... | Delete records with specified primary keys from the table . |
11,715 | public static boolean restrictQueryExecution ( String sql ) { String [ ] restrictions = { "delete" , "truncate" , "update" , "drop" , "alter" } ; if ( sql != null ) { sql = sql . toLowerCase ( ) ; for ( String restriction : restrictions ) { if ( sql . startsWith ( restriction ) ) { return true ; } String regex = "\\s+"... | Restrict a query execution . Do not allow for database modifications . |
11,716 | public static boolean isValidProcedureCall ( String sql , Dialect dialect ) { if ( sql == null ) { return false ; } if ( dialect instanceof OracleDialect ) { return sql . split ( "\\?" ) . length == 2 ; } else { return true ; } } | See if the sql contains only one ? character |
11,717 | public static Expression compile ( String exp ) { if ( Miscellaneous . isEmpty ( exp ) || exp . equals ( "." ) ) { exp = "$" ; } Queue < String > queue = new LinkedList < String > ( ) ; List < String > tokens = parseTokens ( exp ) ; boolean isInBracket = false ; int numInBracket = 0 ; StringBuilder sb = new StringBuild... | Compiles the expression . |
11,718 | public static void addDragSource ( DragSource source , JComponent comp , boolean autoremove ) { singleton . addSource ( source , comp , autoremove ) ; } | Add the specified component as a source of drags with the DragSource controller . |
11,719 | public static void addDropTarget ( DropTarget target , JComponent comp , boolean autoremove ) { singleton . addTarget ( target , comp , autoremove ) ; } | Add the specified component as a drop target . |
11,720 | protected void addSource ( DragSource source , JComponent comp , boolean autoremove ) { _draggers . put ( comp , source ) ; comp . addMouseListener ( _sourceListener ) ; comp . addMouseMotionListener ( _sourceListener ) ; if ( autoremove ) { comp . addAncestorListener ( _remover ) ; } } | Add a dragsource . |
11,721 | protected void removeSource ( JComponent comp ) { if ( _sourceComp == comp ) { clearComponentCursor ( ) ; _topComp . setCursor ( _topCursor ) ; reset ( ) ; } _draggers . remove ( comp ) ; comp . removeMouseListener ( _sourceListener ) ; comp . removeMouseMotionListener ( _sourceListener ) ; } | Remove a dragsource . |
11,722 | protected void addTarget ( DropTarget target , JComponent comp , boolean autoremove ) { _droppers . put ( comp , target ) ; addTargetListeners ( comp ) ; if ( autoremove ) { comp . addAncestorListener ( _remover ) ; } } | Add a droptarget . |
11,723 | protected void addTargetListeners ( Component comp ) { comp . addMouseListener ( _targetListener ) ; comp . addMouseMotionListener ( _targetListener ) ; if ( comp instanceof Container ) { Container cont = ( Container ) comp ; cont . addContainerListener ( _childListener ) ; for ( int ii = 0 , nn = cont . getComponentCo... | Add the appropriate target listeners to this component and all its children . |
11,724 | protected void removeTargetListeners ( Component comp ) { comp . removeMouseListener ( _targetListener ) ; comp . removeMouseMotionListener ( _targetListener ) ; if ( comp instanceof Container ) { Container cont = ( Container ) comp ; cont . removeContainerListener ( _childListener ) ; for ( int ii = 0 , nn = cont . ge... | Remove the appropriate target listeners to this component and all its children . |
11,725 | protected void setComponentCursor ( Component comp ) { Cursor c = comp . getCursor ( ) ; if ( c != _curCursor ) { assertComponentCursorCleared ( ) ; _lastComp = comp ; _oldCursor = comp . isCursorSet ( ) ? c : null ; comp . setCursor ( _curCursor ) ; } } | Check to see if we need to do component - level cursor setting and take care of it if needed . |
11,726 | protected DropTarget findAppropriateTarget ( Component comp ) { DropTarget target ; while ( comp != null ) { target = ( comp == _sourceComp ) ? null : _droppers . get ( comp ) ; if ( ( target != null ) && comp . isEnabled ( ) && _source . checkDrop ( target ) && target . checkDrop ( _source , _data [ 0 ] ) ) { return t... | Find the lowest accepting parental target to this component . |
11,727 | protected void checkAutoscroll ( MouseEvent exitEvent ) { Component comp = exitEvent . getComponent ( ) ; Point p = exitEvent . getPoint ( ) ; try { Point scr = comp . getLocationOnScreen ( ) ; p . translate ( scr . x , scr . y ) ; } catch ( IllegalComponentStateException icse ) { return ; } Component parent ; DropTarg... | Check to see if we want to enter autoscrolling mode . |
11,728 | protected Rectangle getRectOnScreen ( JComponent comp ) { Rectangle r = comp . getVisibleRect ( ) ; Point p = comp . getLocationOnScreen ( ) ; r . translate ( p . x , p . y ) ; return r ; } | Find the rectangular area that is visible in screen coordinates for the given component . |
11,729 | protected void reset ( ) { _scrollTimer . stop ( ) ; _source = null ; _sourceComp = null ; _lastComp = null ; _lastTarget = null ; _data [ 0 ] = null ; _cursors [ 0 ] = null ; _cursors [ 1 ] = null ; _topComp = null ; _topCursor = null ; _curCursor = null ; _scrollComp = null ; _scrollDim = null ; _scrollPoint = null ;... | Reset dnd to a starting state . |
11,730 | public static Report loadConvertedReport ( InputStream is ) { XStream xstream = XStreamFactory . createXStream ( ) ; InputStreamReader reader = null ; try { reader = new InputStreamReader ( is , "UTF-8" ) ; return ( Report ) xstream . fromXML ( reader ) ; } catch ( Exception e ) { LOG . error ( e . getMessage ( ) , e )... | Create a report object from an input stream |
11,731 | public static Report loadConvertedReport ( String xml ) { XStream xstream = XStreamFactory . createXStream ( ) ; try { return ( Report ) xstream . fromXML ( xml ) ; } catch ( Exception e ) { LOG . error ( e . getMessage ( ) , e ) ; e . printStackTrace ( ) ; return null ; } } | Create a report object from xml |
11,732 | public static Report loadReport ( String xml ) throws LoadReportException { try { String convertedXml = ConverterChain . applyFromXml ( xml ) ; XStream xstream = XStreamFactory . createXStream ( ) ; return ( Report ) xstream . fromXML ( convertedXml ) ; } catch ( ConverterException ex ) { LOG . error ( ex . getMessage ... | Create a report object from xml Do a conversion if it is needed |
11,733 | public static Report loadReport ( InputStream is ) throws LoadReportException { try { String xml = readAsString ( is ) ; String convertedXml = ConverterChain . applyFromXml ( xml ) ; XStream xstream = XStreamFactory . createXStream ( ) ; return ( Report ) xstream . fromXML ( convertedXml ) ; } catch ( Exception ex ) { ... | Create a report object from an input stream Do a conversion if it is needed |
11,734 | public static void saveReport ( Report report , OutputStream out ) { XStream xstream = XStreamFactory . createXStream ( ) ; xstream . toXML ( report , out ) ; } | Write a report object to an output stream |
11,735 | public static void saveReport ( Report report , String path ) { FileOutputStream fos = null ; try { fos = new FileOutputStream ( path ) ; saveReport ( report , fos ) ; } catch ( Exception ex ) { LOG . error ( ex . getMessage ( ) , ex ) ; ex . printStackTrace ( ) ; } finally { if ( fos != null ) { try { fos . close ( ) ... | Write a report object to a file at specified path |
11,736 | public static void saveReport ( String xml , String path ) { FileOutputStream fos = null ; try { fos = new FileOutputStream ( path ) ; fos . write ( xml . getBytes ( "UTF-8" ) ) ; fos . flush ( ) ; } catch ( Exception ex ) { LOG . error ( ex . getMessage ( ) , ex ) ; ex . printStackTrace ( ) ; } finally { if ( fos != n... | Write a xml text to a file at specified path |
11,737 | public static String reportToXml ( Report report ) { XStream xstream = XStreamFactory . createXStream ( ) ; ByteArrayOutputStream bos = new ByteArrayOutputStream ( ) ; xstream . toXML ( report , bos ) ; return bos . toString ( ) ; } | Convert a report object to xml text |
11,738 | public static byte isValid ( String reportVersion ) { if ( isOlderUnsupportedVersion ( reportVersion ) ) { return REPORT_INVALID_OLDER ; } else if ( isNewerUnsupportedVersion ( reportVersion ) ) { return REPORT_INVALID_NEWER ; } else { return REPORT_VALID ; } } | Test if string version given as parameter is valid meaning is over 2 . 0 and no greater than current engine version |
11,739 | public static boolean isOlderUnsupportedVersion ( String version ) { return ( ( version == null ) || "" . equals ( version ) || version . startsWith ( "0" ) || version . startsWith ( "1" ) ) ; } | Return true if version string is less than 2 . 0 |
11,740 | public static boolean isNewerUnsupportedVersion ( String version ) { if ( ( version == null ) || "" . equals ( version ) ) { return true ; } String engineVersion = ReleaseInfoAdapter . getVersionNumber ( ) ; String [ ] ev = engineVersion . split ( "\\." ) ; String [ ] rv = version . split ( "\\." ) ; return ( ( Integer... | Return true if version string is newer than version of the report engine |
11,741 | public static int compareVersions ( String v1 , String v2 ) { String [ ] v1a = v1 . split ( "\\." ) ; String [ ] v2a = v2 . split ( "\\." ) ; Integer v1M = Integer . parseInt ( v1a [ 0 ] ) ; Integer v2M = Integer . parseInt ( v2a [ 0 ] ) ; if ( v1M < v2M ) { return - 1 ; } else if ( v1M > v2M ) { return 1 ; } else { In... | Compare two report versions strings |
11,742 | public static String getVersion ( String reportFile ) { try { String text = readAsString ( reportFile ) ; return getVersionFromText ( text ) ; } catch ( IOException e ) { LOG . error ( e . getMessage ( ) , e ) ; return null ; } } | Get report version from report file |
11,743 | public static String getVersion ( InputStream is ) { try { String text = readAsString ( is ) ; return getVersionFromText ( text ) ; } catch ( IOException e ) { LOG . error ( e . getMessage ( ) , e ) ; return null ; } } | Get report version from input stream to read report file |
11,744 | public static String readAsString ( String reportPath ) throws IOException { StringBuffer fileData = new StringBuffer ( 1000 ) ; BufferedReader reader = new BufferedReader ( new FileReader ( reportPath ) ) ; char [ ] buf = new char [ 1024 ] ; int numRead = 0 ; while ( ( numRead = reader . read ( buf ) ) != - 1 ) { file... | Read a report file as string |
11,745 | public static String readAsString ( InputStream is ) throws IOException { try { return new Scanner ( is , "UTF-8" ) . useDelimiter ( "\\A" ) . next ( ) ; } catch ( java . util . NoSuchElementException e ) { return "" ; } } | Read data from input stream |
11,746 | public static String getFileName ( String filePath ) { if ( filePath == null ) { return filePath ; } int index = filePath . lastIndexOf ( File . separator ) ; if ( index == - 1 ) { return filePath ; } return filePath . substring ( index + 1 ) ; } | Get file name from a file path |
11,747 | public static List < String > getStaticImages ( Report report ) { List < String > images = new ArrayList < String > ( ) ; ReportLayout layout = report . getLayout ( ) ; List < Band > bands = layout . getBands ( ) ; for ( Band band : bands ) { for ( int i = 0 , rows = band . getRowCount ( ) ; i < rows ; i ++ ) { List < ... | Get static images used by report |
11,748 | public static String getSql ( Report report ) { String sql ; if ( report . getSql ( ) != null ) { sql = report . getSql ( ) ; } else { sql = report . getQuery ( ) . toString ( ) ; } return sql ; } | Get sql string from report object |
11,749 | public static List < ExpressionBean > getExpressions ( ReportLayout layout ) { List < ExpressionBean > expressions = new LinkedList < ExpressionBean > ( ) ; for ( Band band : layout . getBands ( ) ) { for ( int i = 0 , rows = band . getRowCount ( ) ; i < rows ; i ++ ) { List < BandElement > list = band . getRow ( i ) ;... | Get expression elements from report layout |
11,750 | public static List < String > getExpressionsNames ( ReportLayout layout ) { List < String > expressions = new LinkedList < String > ( ) ; for ( Band band : layout . getBands ( ) ) { for ( int i = 0 , rows = band . getRowCount ( ) ; i < rows ; i ++ ) { List < BandElement > list = band . getRow ( i ) ; for ( BandElement ... | Get expression names from report layout |
11,751 | public static String isValidSqlWithMessage ( Connection con , String sql , List < QueryParameter > parameters ) { try { QueryUtil qu = new QueryUtil ( con , DialectUtil . getDialect ( con ) ) ; Map < String , QueryParameter > params = new HashMap < String , QueryParameter > ( ) ; for ( QueryParameter qp : parameters ) ... | Test if sql with parameters is valid |
11,752 | public static List < Report > getSubreports ( Report report ) { List < Report > subreports = new ArrayList < Report > ( ) ; List < Band > bands = report . getLayout ( ) . getDocumentBands ( ) ; for ( Band band : bands ) { for ( int i = 0 , rows = band . getRowCount ( ) ; i < rows ; i ++ ) { List < BandElement > list = ... | Get subreports for a report |
11,753 | public static List < Report > getDetailSubreports ( ReportLayout reportLayout ) { List < Report > subreports = new ArrayList < Report > ( ) ; Band band = reportLayout . getDetailBand ( ) ; for ( int i = 0 , rows = band . getRowCount ( ) ; i < rows ; i ++ ) { List < BandElement > list = band . getRow ( i ) ; for ( int j... | Get detail band subreports for a report layout |
11,754 | public static List < Chart > getDetailCharts ( ReportLayout reportLayout ) { List < Chart > charts = new ArrayList < Chart > ( ) ; Band band = reportLayout . getDetailBand ( ) ; for ( int i = 0 , rows = band . getRowCount ( ) ; i < rows ; i ++ ) { List < BandElement > list = band . getRow ( i ) ; for ( int j = 0 , size... | Get detail band charts for a report layout |
11,755 | private static ReportLayout getForReportLayout ( Connection con , ReportLayout layout , ParametersBean pBean ) throws Exception { ReportLayout convertedLayout = ObjectCloner . silenceDeepCopy ( layout ) ; List < Band > bands = convertedLayout . getDocumentBands ( ) ; for ( Band band : bands ) { for ( int i = 0 , rows =... | If a report layout contains a ForReportBandElement we must replace this element with more ReportBandElements This means inserting n - 1 new columns where n is the number of values return by sql inside ForReportBandElement |
11,756 | public static boolean foundFunctionInGroupHeader ( ReportLayout layout , String groupName ) { List < Band > groupHeaderBands = layout . getGroupHeaderBands ( ) ; for ( Band band : groupHeaderBands ) { if ( band . getName ( ) . equals ( ReportLayout . GROUP_HEADER_BAND_NAME_PREFIX + groupName ) ) { return foundFunctionI... | Test to see if a function is found in group header band |
11,757 | public static boolean foundFunctionInAnyGroupHeader ( ReportLayout layout ) { List < Band > groupHeaderBands = layout . getGroupHeaderBands ( ) ; for ( Band band : groupHeaderBands ) { boolean found = foundFunctionInBand ( band ) ; if ( found ) { return true ; } } return false ; } | Test to see if a function is found in any group header band |
11,758 | public void addFieldParser ( String property , FieldParser parser ) { if ( _parsers == null ) { _parsers = new HashMap < String , FieldParser > ( ) ; } _parsers . put ( property , parser ) ; } | Adds a custom parser for the specified named field . |
11,759 | public static Field [ ] getFields ( Class < ? > clazz ) { ArrayList < Field > list = new ArrayList < Field > ( ) ; getFields ( clazz , list ) ; return list . toArray ( new Field [ list . size ( ) ] ) ; } | Get the fields contained in the class and its superclasses . |
11,760 | public static boolean compatibleClasses ( Class < ? > [ ] lhs , Class < ? > [ ] rhs ) { if ( lhs . length != rhs . length ) { return false ; } for ( int i = 0 ; i < lhs . length ; ++ i ) { if ( rhs [ i ] == null || rhs [ i ] . equals ( Void . TYPE ) ) { if ( lhs [ i ] . isPrimitive ( ) ) { return false ; } else { conti... | Tells whether instances of the classes in the rhs array could be used as parameters to a reflective method invocation whose parameter list has types denoted by the lhs array . |
11,761 | public static Method getAccessibleMethodFrom ( Class < ? > clazz , String methodName , Class < ? > [ ] parameterTypes ) { Class < ? > superclass = clazz . getSuperclass ( ) ; Method overriddenMethod = null ; if ( superclass != null && classIsAccessible ( superclass ) ) { try { overriddenMethod = superclass . getMethod ... | Searches for the method with the given name and formal parameter types that is in the nearest accessible class in the class hierarchy starting with clazz s superclass . The superclass and implemented interfaces of clazz are searched then their superclasses etc . until a method is found . Returns null if there is no suc... |
11,762 | public static boolean primitiveIsAssignableFrom ( Class < ? > lhs , Class < ? > rhs ) { if ( lhs == null || rhs == null ) { return false ; } if ( ! ( lhs . isPrimitive ( ) && rhs . isPrimitive ( ) ) ) { return false ; } if ( lhs . equals ( rhs ) ) { return true ; } Set < Class < ? > > wideningSet = _primitiveWideningsM... | Tells whether an instance of the primitive class represented by rhs can be assigned to an instance of the primitive class represented by lhs . |
11,763 | private void createStar ( ) { Point2D . Float point = start ; p = new GeneralPath ( GeneralPath . WIND_NON_ZERO ) ; p . moveTo ( point . x , point . y ) ; p . lineTo ( point . x + 3.0f , point . y - 1.5f ) ; point = ( Point2D . Float ) p . getCurrentPoint ( ) ; p . lineTo ( point . x + 1.5f , point . y - 3.0f ) ; point... | Create the path from start |
11,764 | Shape atLocation ( float x , float y ) { start . setLocation ( x , y ) ; p . reset ( ) ; createStar ( ) ; return p ; } | Modify the location of this star |
11,765 | public static int [ ] add ( int [ ] list , int startIdx , int value ) { if ( list == null ) { list = new int [ DEFAULT_LIST_SIZE ] ; } int llength = list . length ; int index = llength ; for ( int i = startIdx ; i < llength ; i ++ ) { if ( list [ i ] == 0 ) { index = i ; break ; } } if ( index >= list . length ) { list... | Adds the specified value to the next empty slot in the specified list . Begins searching for empty slots at the specified index . This can be used to quickly add values to a list that preserves consecutivity by calling it with the size of the list as the first index to check . |
11,766 | public static int remove ( int [ ] list , int value ) { if ( list == null ) { return 0 ; } int llength = list . length ; for ( int i = 0 ; i < llength ; i ++ ) { int val = list [ i ] ; if ( val == value ) { System . arraycopy ( list , i + 1 , list , i , llength - ( i + 1 ) ) ; list [ llength - 1 ] = 0 ; return val ; } ... | Removes the first value that is equal to the supplied value . The values after the removed value will be slid down the array one spot to fill the place of the removed value . |
11,767 | public static int removeAt ( int [ ] list , int index ) { int llength = list . length ; if ( llength <= index ) { return 0 ; } int val = list [ index ] ; System . arraycopy ( list , index + 1 , list , index , llength - ( index + 1 ) ) ; list [ llength - 1 ] = 0 ; return val ; } | Removes the value at the specified index . The values after the removed value will be slid down the array one spot to fill the place of the removed value . If a null array is supplied or one that is not large enough to accomodate this index zero is returned . |
11,768 | public static int sum ( int [ ] list ) { int total = 0 , lsize = list . length ; for ( int ii = 0 ; ii < lsize ; ii ++ ) { total += list [ ii ] ; } return total ; } | Returns the total of all of the values in the list . |
11,769 | protected static int [ ] accomodate ( int [ ] list , int index ) { int size = list . length ; while ( size <= index ) { size = Math . max ( size * 2 , DEFAULT_LIST_SIZE ) ; } int [ ] newlist = new int [ size ] ; System . arraycopy ( list , 0 , newlist , 0 , list . length ) ; return newlist ; } | Creates a new list that will accomodate the specified index and copies the contents of the old list to the first . |
11,770 | public static Integer [ ] box ( int [ ] list ) { if ( list == null ) { return null ; } Integer [ ] boxed = new Integer [ list . length ] ; for ( int ii = 0 ; ii < list . length ; ii ++ ) { boxed [ ii ] = list [ ii ] ; } return boxed ; } | Covnerts an array of primitives to an array of objects . |
11,771 | public static List < Integer > asList ( int [ ] list ) { if ( list == null ) { return null ; } List < Integer > ilist = new ArrayList < Integer > ( list . length ) ; for ( int ii = 0 ; ii < list . length ; ii ++ ) { ilist . add ( list [ ii ] ) ; } return ilist ; } | Converts an array of primitives to a list of Integers . |
11,772 | public static void attachHandler ( String protocol , Class < ? extends URLStreamHandler > handlerClass ) { if ( _handlers == null ) { _handlers = new HashMap < String , Class < ? extends URLStreamHandler > > ( ) ; URL . setURLStreamHandlerFactory ( new AttachableURLFactory ( ) ) ; } _handlers . put ( protocol . toLower... | Register a URL handler . |
11,773 | public URLStreamHandler createURLStreamHandler ( String protocol ) { Class < ? extends URLStreamHandler > handler = _handlers . get ( protocol . toLowerCase ( ) ) ; if ( handler != null ) { try { return handler . newInstance ( ) ; } catch ( Exception e ) { log . warning ( "Unable to instantiate URLStreamHandler" , "pro... | documentation inherited from interface URLStreamHandlerFactory |
11,774 | public static < E extends Enum < E > & ByteEnum > E fromByte ( Class < E > eclass , byte code ) { for ( E value : eclass . getEnumConstants ( ) ) { if ( value . toByte ( ) == code ) { return value ; } } throw new IllegalArgumentException ( eclass + " has no value with code " + code ) ; } | Returns the enum value with the specified code in the supplied enum class . |
11,775 | public static < E extends Enum < E > & ByteEnum > int setToInt ( Set < E > set ) { int flags = 0 ; for ( E value : set ) { flags |= toIntFlag ( value ) ; } return flags ; } | Convert a Set of ByteEnums into an integer compactly representing the elements that are included . |
11,776 | public static < E extends Enum < E > & ByteEnum > EnumSet < E > intToSet ( Class < E > eclass , int flags ) { EnumSet < E > set = EnumSet . noneOf ( eclass ) ; for ( E value : eclass . getEnumConstants ( ) ) { if ( ( flags & toIntFlag ( value ) ) != 0 ) { set . add ( value ) ; } } return set ; } | Convert an int representation of ByteEnum flags into an EnumSet . |
11,777 | protected static void initLogger ( ) { Factory factory = createConfiguredFactory ( ) ; try { if ( factory == null && System . getProperty ( "log4j.configuration" ) != null ) { factory = ( Factory ) Class . forName ( "com.samskivert.util.Log4JLogger" ) . newInstance ( ) ; } } catch ( SecurityException se ) { } catch ( T... | Called at static initialization time . Selects and initializes our logging backend . |
11,778 | protected Constraints getConstraints ( Component child ) { if ( _constraints != null ) { Constraints c = _constraints . get ( child ) ; if ( c != null ) { return c ; } } return DEFAULT_CONSTRAINTS ; } | Get the Constraints for the specified child component . |
11,779 | protected DimenInfo computeDimens ( Container parent , int type ) { int count = parent . getComponentCount ( ) ; DimenInfo info = new DimenInfo ( ) ; info . dimens = new Dimension [ count ] ; for ( int i = 0 ; i < count ; i ++ ) { Component child = parent . getComponent ( i ) ; if ( ! child . isVisible ( ) ) { continue... | Computes dimensions of the children widgets that are useful for the group layout managers . |
11,780 | protected void checkCreate ( ) { if ( _creator != null && isShowing ( ) ) { setLayout ( new BorderLayout ( ) ) ; add ( _creator . createContent ( ) , BorderLayout . CENTER ) ; _creator = null ; } } | Check to see if we should now create the content . |
11,781 | public void invokeTask ( Component parent , String retryMessage ) throws Exception { while ( true ) { try { invoke ( ) ; return ; } catch ( Exception e ) { Object [ ] options = new Object [ ] { "Retry operation" , "Abort operation" } ; int rv = JOptionPane . showOptionDialog ( parent , retryMessage + "\n\n" + e . getMe... | Invokes the supplied task and catches any thrown exceptions . In the event of an exception the provided message is displayed to the user and the are allowed to retry the task or allow it to fail . |
11,782 | public void update ( ) { osName = System . getProperty ( "os.name" ) ; osVersion = System . getProperty ( "os.version" ) ; osArch = System . getProperty ( "os.arch" ) ; javaVersion = System . getProperty ( "java.version" ) ; javaVendor = System . getProperty ( "java.vendor" ) ; Runtime rtime = Runtime . getRuntime ( ) ... | Updates the system info record s statistics to reflect the current state of the JVM . |
11,783 | public void add ( T element ) { DependencyNode < T > node = new DependencyNode < T > ( element ) ; _nodes . put ( element , node ) ; _orphans . add ( element ) ; } | Adds an element with no initial dependencies from the graph . |
11,784 | public void remove ( T element ) { DependencyNode < T > node = _nodes . remove ( element ) ; _orphans . remove ( element ) ; for ( DependencyNode < T > parent : node . parents ) { parent . children . remove ( node ) ; } for ( DependencyNode < T > child : node . children ) { child . parents . remove ( node ) ; if ( chil... | Removes an element and its dependencies from the graph . |
11,785 | public void addDependency ( T dependant , T dependee ) { _orphans . remove ( dependant ) ; DependencyNode < T > dependantNode = _nodes . get ( dependant ) ; if ( dependantNode == null ) { throw new IllegalArgumentException ( "Unknown dependant? " + dependant ) ; } DependencyNode < T > dependeeNode = _nodes . get ( depe... | Records a new dependency of the dependant upon the dependee . |
11,786 | public boolean dependsOn ( T elem1 , T elem2 ) { DependencyNode < T > node1 = _nodes . get ( elem1 ) ; DependencyNode < T > node2 = _nodes . get ( elem2 ) ; List < DependencyNode < T > > nodesToCheck = new ArrayList < DependencyNode < T > > ( ) ; List < DependencyNode < T > > nodesAlreadyChecked = new ArrayList < Depen... | Returns whether elem1 is designated to depend on elem2 . |
11,787 | public ObserverList < T > toObserverList ( ) { ObserverList < T > list = ObserverList . newSafeInOrder ( ) ; while ( ! isEmpty ( ) ) { list . add ( removeAvailableElement ( ) ) ; } return list ; } | Flattens this graph into an observer list in dependencys order . Empties the graph in the process . |
11,788 | public void remove ( String name ) { String oldValue = getValue ( name , ( String ) null ) ; _prefs . remove ( name ) ; _propsup . firePropertyChange ( name , oldValue , null ) ; } | Remove any set value for the specified preference . |
11,789 | public static String restrictHTML ( String src , boolean allowFormatting , boolean allowImages , boolean allowLinks ) { ArrayList < String > allow = new ArrayList < String > ( ) ; if ( allowFormatting ) { allow . add ( "<b>" ) ; allow . add ( "</b>" ) ; allow . add ( "<i>" ) ; allow . add ( "</i>" ) ; allow . add ( "<u... | Restrict HTML except for the specified tags . |
11,790 | public static String restrictHTML ( String src , String [ ] regexes ) { if ( StringUtil . isBlank ( src ) ) { return src ; } ArrayList < String > list = new ArrayList < String > ( ) ; list . add ( src ) ; for ( String regexe : regexes ) { Pattern p = Pattern . compile ( regexe , Pattern . CASE_INSENSITIVE ) ; for ( int... | Restrict HTML from the specified string except for the specified regular expressions . |
11,791 | public void requestFailed ( Exception cause ) { Object [ ] args = _args != null ? ArrayUtil . append ( _args , cause ) : new Object [ ] { cause } ; if ( _slogger != null ) { _slogger . warning ( _errorText , args ) ; } else if ( _jlogger != null ) { _jlogger . log ( Level . WARNING , Logger . format ( _errorText , args... | from interface ResultListener |
11,792 | public static int compare ( Date d1 , Date d2 ) { Calendar c1 = Calendar . getInstance ( ) ; c1 . setTime ( d1 ) ; Calendar c2 = Calendar . getInstance ( ) ; c2 . setTime ( d2 ) ; if ( c1 . get ( Calendar . YEAR ) == c2 . get ( Calendar . YEAR ) ) { if ( c1 . get ( Calendar . MONTH ) == c2 . get ( Calendar . MONTH ) ) ... | Compares two dates taking into consideration only the year month and day |
11,793 | public static int getYear ( Date date ) { Calendar c = Calendar . getInstance ( ) ; c . setTime ( date ) ; return c . get ( Calendar . YEAR ) ; } | Get the year of the date |
11,794 | public static int getMonth ( Date date ) { Calendar c = Calendar . getInstance ( ) ; c . setTime ( date ) ; return c . get ( Calendar . MONTH ) ; } | Get the month of the date |
11,795 | public static int getDayOfYear ( Date date ) { Calendar c = Calendar . getInstance ( ) ; c . setTime ( date ) ; return c . get ( Calendar . DAY_OF_YEAR ) ; } | Get the day of year of the date |
11,796 | public static int getDayOfMonth ( Date date ) { Calendar c = Calendar . getInstance ( ) ; c . setTime ( date ) ; return c . get ( Calendar . DAY_OF_MONTH ) ; } | Get the day of month of the date |
11,797 | public static int getDayOfWeek ( Date date ) { Calendar c = Calendar . getInstance ( ) ; c . setTime ( date ) ; return c . get ( Calendar . DAY_OF_WEEK ) ; } | Get the day of week of the date |
11,798 | public static int getHour ( Date date ) { Calendar c = Calendar . getInstance ( ) ; c . setTime ( date ) ; return c . get ( Calendar . HOUR_OF_DAY ) ; } | Get the hour of the date |
11,799 | public static int getMinute ( Date date ) { Calendar c = Calendar . getInstance ( ) ; c . setTime ( date ) ; return c . get ( Calendar . MINUTE ) ; } | Get the minute of the date |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.