idx
int64
0
41.2k
question
stringlengths
73
5.81k
target
stringlengths
5
918
600
public void close ( ) throws SQLException { if ( ( id == null ) || ( poolableConn == null ) ) { internalStmt . close ( ) ; } else { poolableConn . cachePreparedStatement ( this ) ; } }
Method close .
601
public boolean execute ( ) throws SQLException { boolean isOk = false ; try { boolean result = internalStmt . execute ( ) ; isOk = true ; return result ; } finally { poolableConn . updateLastSQLExecutionTime ( isOk ) ; } }
Method execute .
602
public ResultSet executeQuery ( String sql ) throws SQLException { boolean isOk = false ; try { final ResultSet result = wrap ( internalStmt . executeQuery ( sql ) ) ; isOk = true ; return result ; } finally { poolableConn . updateLastSQLExecutionTime ( isOk ) ; } }
Method executeQuery .
603
public void setArray ( int parameterIndex , Array x ) throws SQLException { internalStmt . setArray ( parameterIndex , x ) ; }
Method setArray .
604
public void setAsciiStream ( int parameterIndex , InputStream x , int length ) throws SQLException { internalStmt . setAsciiStream ( parameterIndex , x , length ) ; }
Method setAsciiStream .
605
public void setBigDecimal ( int parameterIndex , BigDecimal x ) throws SQLException { internalStmt . setBigDecimal ( parameterIndex , x ) ; }
Method setBigDecimal .
606
public void setBinaryStream ( int parameterIndex , InputStream x ) throws SQLException { internalStmt . setBinaryStream ( parameterIndex , x ) ; }
Method setBinaryStream .
607
public void setDate ( int parameterIndex , Date x ) throws SQLException { internalStmt . setDate ( parameterIndex , x ) ; }
Method setDate .
608
public void setNCharacterStream ( int parameterIndex , Reader value ) throws SQLException { internalStmt . setNCharacterStream ( parameterIndex , value ) ; }
Method setNCharacterStream .
609
public void setNString ( int parameterIndex , String value ) throws SQLException { internalStmt . setNString ( parameterIndex , value ) ; }
Method setNString .
610
public void setRef ( int parameterIndex , Ref x ) throws SQLException { internalStmt . setRef ( parameterIndex , x ) ; }
Method setRef .
611
public void setRowId ( int parameterIndex , RowId x ) throws SQLException { internalStmt . setRowId ( parameterIndex , x ) ; }
Method setRowId .
612
public void setSQLXML ( int parameterIndex , SQLXML xmlObject ) throws SQLException { internalStmt . setSQLXML ( parameterIndex , xmlObject ) ; }
Method setSQLXML .
613
public void setString ( int parameterIndex , String x ) throws SQLException { internalStmt . setString ( parameterIndex , x ) ; }
Method setString .
614
public void setTime ( int parameterIndex , Time x ) throws SQLException { internalStmt . setTime ( parameterIndex , x ) ; }
Method setTime .
615
public void setTimestamp ( int parameterIndex , Timestamp x ) throws SQLException { internalStmt . setTimestamp ( parameterIndex , x ) ; }
Method setTimestamp .
616
public void setURL ( int parameterIndex , URL x ) throws SQLException { internalStmt . setURL ( parameterIndex , x ) ; }
Method setURL .
617
public boolean cancelAll ( boolean mayInterruptIfRunning ) { boolean res = true ; if ( N . notNullOrEmpty ( upFutures ) ) { for ( ContinuableFuture < ? > preFuture : upFutures ) { res = res & preFuture . cancelAll ( mayInterruptIfRunning ) ; } } return cancel ( mayInterruptIfRunning ) && res ; }
Cancel this future and all the previous stage future recursively .
618
public boolean isAllCancelled ( ) { boolean res = true ; if ( N . notNullOrEmpty ( upFutures ) ) { for ( ContinuableFuture < ? > preFuture : upFutures ) { res = res & preFuture . isAllCancelled ( ) ; } } return isCancelled ( ) && res ; }
Returns true if this future and all previous stage futures have been recursively cancelled otherwise false is returned .
619
public int read ( ) throws IOException { int b = in . read ( ) ; if ( b != - 1 ) { hasher . put ( ( byte ) b ) ; } return b ; }
Reads the next byte of data from the underlying input stream and updates the hasher with the byte read .
620
public int read ( byte [ ] bytes , int off , int len ) throws IOException { int numOfBytesRead = in . read ( bytes , off , len ) ; if ( numOfBytesRead != - 1 ) { hasher . put ( bytes , off , numOfBytesRead ) ; } return numOfBytesRead ; }
Reads the specified bytes of data from the underlying input stream and updates the hasher with the bytes read .
621
public static < T > SortedSet < HBaseColumn < T > > asSortedSet ( T value , long version ) { return asSortedSet ( value , version , DESC_HBASE_COLUMN_COMPARATOR ) ; }
Returns a sorted set descended by version
622
public static < T > SortedMap < Long , HBaseColumn < T > > asSortedMap ( T value ) { return asSortedMap ( value , DESC_HBASE_VERSION_COMPARATOR ) ; }
Returns a sorted map descended by version
623
public static < T > List < T > asList ( T ... a ) { return N . isNullOrEmpty ( a ) ? N . < T > emptyList ( ) : Arrays . asList ( a ) ; }
Returns a fixed - size list backed by the specified array if it s not null or empty otherwise an immutable empty list is returned .
624
@ SuppressWarnings ( "deprecation" ) public CQLBuilder set ( final Object entity ) { if ( entity instanceof String ) { return set ( N . asArray ( ( String ) entity ) ) ; } else if ( entity instanceof Map ) { return set ( ( Map < String , Object > ) entity ) ; } else { this . entityClass = entity . getClass ( ) ; if ( N . isDirtyMarker ( entity . getClass ( ) ) ) { final DirtyMarker dirtyMarkerEntity = ( ( DirtyMarker ) entity ) ; final Set < String > updatedPropNames = dirtyMarkerEntity . dirtyPropNames ( ) ; final Map < String , Object > updateProps = new HashMap < > ( ) ; for ( String propName : updatedPropNames ) { updateProps . put ( propName , ClassUtil . getPropValue ( dirtyMarkerEntity , propName ) ) ; } return set ( updateProps ) ; } else { return set ( Maps . entity2Map ( entity ) ) ; } } }
Only the dirty properties will be set into the result CQL if the specified entity is a dirty marker entity .
625
public boolean remove ( Object key , Object value ) { final Object curValue = get ( key ) ; if ( ! Objects . equals ( curValue , value ) || ( curValue == null && ! containsKey ( key ) ) ) { return false ; } remove ( key ) ; return true ; }
Removes the entry for the specified key only if it is currently mapped to the specified value .
626
public boolean replace ( K key , V oldValue , V newValue ) { Object curValue = get ( key ) ; if ( ! Objects . equals ( curValue , oldValue ) || ( curValue == null && ! containsKey ( key ) ) ) { return false ; } put ( key , newValue ) ; return true ; }
Replaces the entry for the specified key only if currently mapped to the specified value .
627
public Stream < T > queued ( int queueSize ) { final Iterator < T > iter = iterator ( ) ; if ( iter instanceof QueuedIterator && ( ( QueuedIterator < ? extends T > ) iter ) . max ( ) >= queueSize ) { return newStream ( elements , sorted , cmp ) ; } else { return newStream ( Stream . parallelConcatt ( Arrays . asList ( iter ) , 1 , queueSize ) , sorted , cmp ) ; } }
Returns a Stream with elements from a temporary queue which is filled by reading the elements from the specified iterator asynchronously .
628
public BiIterator < K , V > iterator ( ) { final ObjIterator < Entry < K , V > > iter = s . iterator ( ) ; final BooleanSupplier hasNext = new BooleanSupplier ( ) { public boolean getAsBoolean ( ) { return iter . hasNext ( ) ; } } ; final Consumer < Pair < K , V > > output = new Consumer < Pair < K , V > > ( ) { private Entry < K , V > entry = null ; public void accept ( Pair < K , V > t ) { entry = iter . next ( ) ; t . set ( entry . getKey ( ) , entry . getValue ( ) ) ; } } ; return BiIterator . generate ( hasNext , output ) ; }
Remember to close this Stream after the iteration is done if required .
629
public static String removePattern ( final String source , final String regex ) { return replacePattern ( source , regex , N . EMPTY_STRING ) ; }
Removes each substring of the source String that matches the given regular expression using the DOTALL option .
630
static long fingerprint ( byte [ ] bytes , int offset , int length ) { if ( length <= 32 ) { if ( length <= 16 ) { return hashLength0to16 ( bytes , offset , length ) ; } else { return hashLength17to32 ( bytes , offset , length ) ; } } else if ( length <= 64 ) { return hashLength33To64 ( bytes , offset , length ) ; } else { return hashLength65Plus ( bytes , offset , length ) ; } }
End of public functions .
631
public DBSequence getDBSequence ( final String tableName , final String seqName , final long startVal , final int seqBufferSize ) { return new DBSequence ( this , tableName , seqName , startVal , seqBufferSize ) ; }
Supports global sequence by db table .
632
public void close ( ) throws IOException { try { if ( _ds != null && _ds . isClosed ( ) == false ) { _ds . close ( ) ; } } finally { if ( _dsm != null && _dsm . isClosed ( ) == false ) { _dsm . close ( ) ; } } }
Close the underline data source
633
protected void evict ( ) { lock . lock ( ) ; Map < K , E > removingObjects = null ; try { for ( Map . Entry < K , E > entry : pool . entrySet ( ) ) { if ( entry . getValue ( ) . activityPrint ( ) . isExpired ( ) ) { if ( removingObjects == null ) { removingObjects = Objectory . createMap ( ) ; } removingObjects . put ( entry . getKey ( ) , entry . getValue ( ) ) ; } } if ( N . notNullOrEmpty ( removingObjects ) ) { for ( K key : removingObjects . keySet ( ) ) { E e = pool . remove ( key ) ; if ( logger . isInfoEnabled ( ) ) { logger . info ( "Evicting expired cached object. KEY: " + key + ", VALUE: " + N . toString ( e ) + ". Activity print: " + e . activityPrint ( ) ) ; } } destroyObject ( removingObjects ) ; notFull . signalAll ( ) ; } } finally { lock . unlock ( ) ; Objectory . recycle ( removingObjects ) ; } }
scan the object pool to find the idle object which inactive time greater than permitted the inactive time for it or it s time out .
634
public static Map < String , AttributeValue > asItem ( Object ... a ) { if ( 0 != ( a . length % 2 ) ) { throw new IllegalArgumentException ( "The parameters must be the pairs of property name and value, or Map, or an entity class with getter/setter methods." ) ; } final Map < String , AttributeValue > item = new LinkedHashMap < > ( N . initHashCapacity ( a . length / 2 ) ) ; for ( int i = 0 ; i < a . length ; i ++ ) { item . put ( ( String ) a [ i ] , attrValueOf ( a [ ++ i ] ) ) ; } return item ; }
May misused with toItem
635
public static Map < String , AttributeValueUpdate > asUpdateItem ( Object ... a ) { if ( 0 != ( a . length % 2 ) ) { throw new IllegalArgumentException ( "The parameters must be the pairs of property name and value, or Map, or an entity class with getter/setter methods." ) ; } final Map < String , AttributeValueUpdate > item = new LinkedHashMap < > ( N . initHashCapacity ( a . length / 2 ) ) ; for ( int i = 0 ; i < a . length ; i ++ ) { item . put ( ( String ) a [ i ] , attrValueUpdateOf ( a [ ++ i ] ) ) ; } return item ; }
May misused with toUpdateItem
636
public static Map < String , AttributeValueUpdate > toUpdateItem ( final Object entity ) { return toUpdateItem ( entity , NamingPolicy . LOWER_CAMEL_CASE ) ; }
Only the dirty properties will be set to the result Map if the specified entity is a dirty marker entity .
637
public void moveRow ( Object rowKey , int newRowIndex ) { checkFrozen ( ) ; this . checkRowIndex ( newRowIndex ) ; final int rowIndex = this . getRowIndex ( rowKey ) ; final List < R > tmp = new ArrayList < > ( rowLength ( ) ) ; tmp . addAll ( _rowKeySet ) ; tmp . add ( newRowIndex , tmp . remove ( rowIndex ) ) ; _rowKeySet . clear ( ) ; _rowKeySet . addAll ( tmp ) ; _rowKeyIndexMap = null ; if ( _initialized && _columnList . size ( ) > 0 ) { for ( List < E > column : _columnList ) { column . add ( newRowIndex , column . remove ( rowIndex ) ) ; } } }
Move the specified row to the new position .
638
public void swapRows ( Object rowKeyA , Object rowKeyB ) { checkFrozen ( ) ; final int rowIndexA = this . getRowIndex ( rowKeyA ) ; final int rowIndexB = this . getRowIndex ( rowKeyB ) ; final List < R > tmp = new ArrayList < > ( rowLength ( ) ) ; tmp . addAll ( _rowKeySet ) ; final R tmpRowKeyA = tmp . get ( rowIndexA ) ; tmp . set ( rowIndexA , tmp . get ( rowIndexB ) ) ; tmp . set ( rowIndexB , tmpRowKeyA ) ; _rowKeySet . clear ( ) ; _rowKeySet . addAll ( tmp ) ; _rowKeyIndexMap . forcePut ( tmp . get ( rowIndexA ) , rowIndexA ) ; _rowKeyIndexMap . forcePut ( tmp . get ( rowIndexB ) , rowIndexB ) ; if ( _initialized && _columnList . size ( ) > 0 ) { E tmpVal = null ; for ( List < E > column : _columnList ) { tmpVal = column . get ( rowIndexA ) ; column . set ( rowIndexA , column . get ( rowIndexB ) ) ; column . set ( rowIndexB , tmpVal ) ; } } }
Swap the positions of the two specified rows .
639
public void moveColumn ( Object columnKey , int newColumnIndex ) { checkFrozen ( ) ; this . checkColumnIndex ( newColumnIndex ) ; final int columnIndex = this . getColumnIndex ( columnKey ) ; final List < C > tmp = new ArrayList < > ( columnLength ( ) ) ; tmp . addAll ( _columnKeySet ) ; tmp . add ( newColumnIndex , tmp . remove ( columnIndex ) ) ; _columnKeySet . clear ( ) ; _columnKeySet . addAll ( tmp ) ; _columnKeyIndexMap = null ; if ( _initialized && _columnList . size ( ) > 0 ) { _columnList . add ( newColumnIndex , _columnList . remove ( columnIndex ) ) ; } }
Move the specified column to the new position .
640
public void swapColumns ( Object columnKeyA , Object columnKeyB ) { checkFrozen ( ) ; final int columnIndexA = this . getColumnIndex ( columnKeyA ) ; final int columnIndexB = this . getColumnIndex ( columnKeyB ) ; final List < C > tmp = new ArrayList < > ( rowLength ( ) ) ; tmp . addAll ( _columnKeySet ) ; final C tmpColumnKeyA = tmp . get ( columnIndexA ) ; tmp . set ( columnIndexA , tmp . get ( columnIndexB ) ) ; tmp . set ( columnIndexB , tmpColumnKeyA ) ; _columnKeySet . clear ( ) ; _columnKeySet . addAll ( tmp ) ; _columnKeyIndexMap . forcePut ( tmp . get ( columnIndexA ) , columnIndexA ) ; _columnKeyIndexMap . forcePut ( tmp . get ( columnIndexB ) , columnIndexB ) ; if ( _initialized && _columnList . size ( ) > 0 ) { final List < E > tmpColumnA = _columnList . get ( columnIndexA ) ; _columnList . set ( columnIndexA , _columnList . get ( columnIndexB ) ) ; _columnList . set ( columnIndexB , tmpColumnA ) ; } }
Swap the positions of the two specified columns .
641
private static int mulPosAndCheck ( final int x , final int y ) { final long m = ( long ) x * ( long ) y ; if ( m > Integer . MAX_VALUE ) { throw new ArithmeticException ( "overflow: mulPos" ) ; } return ( int ) m ; }
Multiply two non - negative integers checking for overflow .
642
private static int addAndCheck ( final int x , final int y ) { final long s = ( long ) x + ( long ) y ; if ( s < Integer . MIN_VALUE || s > Integer . MAX_VALUE ) { throw new ArithmeticException ( "overflow: add" ) ; } return ( int ) s ; }
Add two integers checking for overflow .
643
private static int subAndCheck ( final int x , final int y ) { final long s = ( long ) x - ( long ) y ; if ( s < Integer . MIN_VALUE || s > Integer . MAX_VALUE ) { throw new ArithmeticException ( "overflow: add" ) ; } return ( int ) s ; }
Subtract two integers checking for overflow .
644
public int binarySearch ( final int fromIndex , final int toIndex , final int key ) { checkFromToIndex ( fromIndex , toIndex ) ; return N . binarySearch ( elementData , fromIndex , toIndex , key ) ; }
This List should be sorted first .
645
public static < K , V > boolean remove ( final Map < K , V > map , Map . Entry < ? , ? > entry ) { return remove ( map , entry . getKey ( ) , entry . getValue ( ) ) ; }
Removes the specified entry .
646
public static double asinh ( double a ) { boolean negative = false ; if ( a < 0 ) { negative = true ; a = - a ; } double absAsinh ; if ( a > 0.167 ) { absAsinh = Math . log ( Math . sqrt ( a * a + 1 ) + a ) ; } else { final double a2 = a * a ; if ( a > 0.097 ) { absAsinh = a * ( 1 - a2 * ( F_1_3 - a2 * ( F_1_5 - a2 * ( F_1_7 - a2 * ( F_1_9 - a2 * ( F_1_11 - a2 * ( F_1_13 - a2 * ( F_1_15 - a2 * F_1_17 * F_15_16 ) * F_13_14 ) * F_11_12 ) * F_9_10 ) * F_7_8 ) * F_5_6 ) * F_3_4 ) * F_1_2 ) ; } else if ( a > 0.036 ) { absAsinh = a * ( 1 - a2 * ( F_1_3 - a2 * ( F_1_5 - a2 * ( F_1_7 - a2 * ( F_1_9 - a2 * ( F_1_11 - a2 * F_1_13 * F_11_12 ) * F_9_10 ) * F_7_8 ) * F_5_6 ) * F_3_4 ) * F_1_2 ) ; } else if ( a > 0.0036 ) { absAsinh = a * ( 1 - a2 * ( F_1_3 - a2 * ( F_1_5 - a2 * ( F_1_7 - a2 * F_1_9 * F_7_8 ) * F_5_6 ) * F_3_4 ) * F_1_2 ) ; } else { absAsinh = a * ( 1 - a2 * ( F_1_3 - a2 * F_1_5 * F_3_4 ) * F_1_2 ) ; } } return negative ? - absAsinh : absAsinh ; }
Compute the inverse hyperbolic sine of a number .
647
public static double atanh ( double a ) { boolean negative = false ; if ( a < 0 ) { negative = true ; a = - a ; } double absAtanh ; if ( a > 0.15 ) { absAtanh = 0.5 * Math . log ( ( 1 + a ) / ( 1 - a ) ) ; } else { final double a2 = a * a ; if ( a > 0.087 ) { absAtanh = a * ( 1 + a2 * ( F_1_3 + a2 * ( F_1_5 + a2 * ( F_1_7 + a2 * ( F_1_9 + a2 * ( F_1_11 + a2 * ( F_1_13 + a2 * ( F_1_15 + a2 * F_1_17 ) ) ) ) ) ) ) ) ; } else if ( a > 0.031 ) { absAtanh = a * ( 1 + a2 * ( F_1_3 + a2 * ( F_1_5 + a2 * ( F_1_7 + a2 * ( F_1_9 + a2 * ( F_1_11 + a2 * F_1_13 ) ) ) ) ) ) ; } else if ( a > 0.003 ) { absAtanh = a * ( 1 + a2 * ( F_1_3 + a2 * ( F_1_5 + a2 * ( F_1_7 + a2 * F_1_9 ) ) ) ) ; } else { absAtanh = a * ( 1 + a2 * ( F_1_3 + a2 * F_1_5 ) ) ; } } return negative ? - absAtanh : absAtanh ; }
Compute the inverse hyperbolic tangent of a number .
648
public Statement createStatement ( int resultSetType , int resultSetConcurrency ) throws SQLException { return internalConn . createStatement ( resultSetType , resultSetConcurrency ) ; }
Method createStatement .
649
public boolean isClosed ( ) throws SQLException { if ( ! isClosed ) { try { if ( internalConn . isClosed ( ) ) { destroy ( ) ; } } catch ( SQLException e ) { destroy ( ) ; if ( logger . isWarnEnabled ( ) ) { logger . warn ( AbacusException . getErrorMsg ( e ) ) ; } } } return isClosed ; }
Method isClosed .
650
public void setTypeMap ( Map < String , Class < ? > > arg0 ) throws SQLException { internalConn . setTypeMap ( arg0 ) ; }
Method setTypeMap .
651
public void setClientInfo ( String name , String value ) throws SQLClientInfoException { internalConn . setClientInfo ( name , value ) ; }
Method setClientInfo .
652
public AnyDelete addFamilyVersion ( String family , final long timestamp ) { delete . addFamilyVersion ( toFamilyQualifierBytes ( family ) , timestamp ) ; return this ; }
Delete all columns of the specified family with a timestamp equal to the specified timestamp .
653
public AnyDelete addColumn ( String family , String qualifier ) { delete . addColumn ( toFamilyQualifierBytes ( family ) , toFamilyQualifierBytes ( qualifier ) ) ; return this ; }
Delete the latest version of the specified column . This is an expensive call in that on the server - side it first does a get to find the latest versions timestamp . Then it adds a delete using the fetched cells timestamp .
654
public AnyDelete addColumns ( String family , String qualifier ) { delete . addColumns ( toFamilyQualifierBytes ( family ) , toFamilyQualifierBytes ( qualifier ) ) ; return this ; }
Delete all versions of the specified column .
655
public Triple < R , M , L > reversed ( ) { return new Triple < > ( this . right , this . middle , this . left ) ; }
Returns a new instance of Triple&lt ; R M L&gt ; .
656
long freeSpaceWindows ( String path , final long timeout ) throws IOException { path = FilenameUtil . normalize ( path , false ) ; if ( path . length ( ) > 0 && path . charAt ( 0 ) != '"' ) { path = "\"" + path + "\"" ; } final String [ ] cmdAttribs = new String [ ] { "cmd.exe" , "/C" , "dir /a /-c " + path } ; final List < String > lines = performCommand ( cmdAttribs , Integer . MAX_VALUE , timeout ) ; for ( int i = lines . size ( ) - 1 ; i >= 0 ; i -- ) { final String line = lines . get ( i ) ; if ( line . length ( ) > 0 ) { return parseDir ( line , path ) ; } } throw new IOException ( "Command line 'dir /-c' did not return any info " + "for path '" + path + "'" ) ; }
Find free space on the Windows platform using the dir command .
657
long parseDir ( final String line , final String path ) throws IOException { int bytesStart = 0 ; int bytesEnd = 0 ; int j = line . length ( ) - 1 ; innerLoop1 : while ( j >= 0 ) { final char c = line . charAt ( j ) ; if ( Character . isDigit ( c ) ) { bytesEnd = j + 1 ; break innerLoop1 ; } j -- ; } innerLoop2 : while ( j >= 0 ) { final char c = line . charAt ( j ) ; if ( ! Character . isDigit ( c ) && c != ',' && c != '.' ) { bytesStart = j + 1 ; break innerLoop2 ; } j -- ; } if ( j < 0 ) { throw new IOException ( "Command line 'dir /-c' did not return valid info " + "for path '" + path + "'" ) ; } final StringBuilder buf = new StringBuilder ( line . substring ( bytesStart , bytesEnd ) ) ; for ( int k = 0 ; k < buf . length ( ) ; k ++ ) { if ( buf . charAt ( k ) == ',' || buf . charAt ( k ) == '.' ) { buf . deleteCharAt ( k -- ) ; } } return parseBytes ( buf . toString ( ) , path ) ; }
Parses the Windows dir response last line
658
long parseBytes ( final String freeSpace , final String path ) throws IOException { try { final long bytes = Long . parseLong ( freeSpace ) ; if ( bytes < 0 ) { throw new IOException ( "Command line '" + DF + "' did not find free space in response " + "for path '" + path + "'- check path is valid" ) ; } return bytes ; } catch ( final NumberFormatException ex ) { throw new IOException ( "Command line '" + DF + "' did not return numeric data as expected " + "for path '" + path + "'- check path is valid" , ex ) ; } }
Parses the bytes from a string .
659
List < String > performCommand ( final String [ ] cmdAttribs , final int max , final long timeout ) throws IOException { final List < String > lines = new ArrayList < String > ( 20 ) ; Process proc = null ; InputStream in = null ; OutputStream out = null ; InputStream err = null ; BufferedReader inr = null ; try { final Thread monitor = ThreadMonitor . start ( timeout ) ; proc = openProcess ( cmdAttribs ) ; in = proc . getInputStream ( ) ; out = proc . getOutputStream ( ) ; err = proc . getErrorStream ( ) ; inr = new BufferedReader ( new InputStreamReader ( in , Charset . defaultCharset ( ) ) ) ; String line = inr . readLine ( ) ; while ( line != null && lines . size ( ) < max ) { line = line . toLowerCase ( Locale . ENGLISH ) . trim ( ) ; lines . add ( line ) ; line = inr . readLine ( ) ; } proc . waitFor ( ) ; ThreadMonitor . stop ( monitor ) ; if ( proc . exitValue ( ) != 0 ) { throw new IOException ( "Command line returned OS error code '" + proc . exitValue ( ) + "' for command " + Arrays . asList ( cmdAttribs ) ) ; } if ( lines . isEmpty ( ) ) { throw new IOException ( "Command line did not return any info " + "for command " + Arrays . asList ( cmdAttribs ) ) ; } return lines ; } catch ( final InterruptedException ex ) { throw new IOException ( "Command line threw an InterruptedException " + "for command " + Arrays . asList ( cmdAttribs ) + " timeout=" + timeout , ex ) ; } finally { IOUtil . closeQuietly ( in ) ; IOUtil . closeQuietly ( out ) ; IOUtil . closeQuietly ( err ) ; IOUtil . closeQuietly ( inr ) ; if ( proc != null ) { proc . destroy ( ) ; } } }
Performs the os command .
660
public Set < Map . Entry < K , V > > entrySet ( ) { return new AbstractSet < Map . Entry < K , V > > ( ) { public Iterator < Map . Entry < K , V > > iterator ( ) { return new ObjIterator < Map . Entry < K , V > > ( ) { private final Iterator < Map . Entry < K , V > > keyValueEntryIter = keyMap . entrySet ( ) . iterator ( ) ; public boolean hasNext ( ) { return keyValueEntryIter . hasNext ( ) ; } public Map . Entry < K , V > next ( ) { final Map . Entry < K , V > entry = keyValueEntryIter . next ( ) ; return new Map . Entry < K , V > ( ) { public K getKey ( ) { return entry . getKey ( ) ; } public V getValue ( ) { return entry . getValue ( ) ; } public V setValue ( V value ) { throw new UnsupportedOperationException ( ) ; } } ; } } ; } public int size ( ) { return keyMap . size ( ) ; } } ; }
Returns an immutable Set of Immutable entry .
661
public BiMap < V , K > inversed ( ) { return ( inverse == null ) ? inverse = new BiMap < > ( valueMap , keyMap ) : inverse ; }
Returns the inverse view of this BiMap which maps each of this bimap s values to its associated key . The two BiMaps are backed by the same data ; any changes to one will appear in the other .
662
protected void evict ( ) { for ( int i = 0 , len = _segments . length ; i < len ; i ++ ) { if ( _segments [ i ] . blockBitSet . isEmpty ( ) ) { final Deque < Segment > queue = _segmentQueueMap . get ( i ) ; if ( queue != null ) { synchronized ( queue ) { if ( _segments [ i ] . blockBitSet . isEmpty ( ) ) { synchronized ( _segmentBitSet ) { queue . remove ( _segments [ i ] ) ; _segmentQueueMap . remove ( i ) ; _segmentBitSet . clear ( i ) ; } } } } } } }
recycle the empty Segment .
663
private void log ( String callerFQCN , Level level , String msg , Throwable t ) { LogRecord record = new LogRecord ( level , msg ) ; record . setLoggerName ( getName ( ) ) ; record . setThrown ( t ) ; fillCallerData ( callerFQCN , record ) ; loggerImpl . log ( record ) ; }
Log the message at the specified level with the specified throwable if any . This method creates a LogRecord and fills in caller date before calling this instance s JDK14 logger .
664
final private void fillCallerData ( String callerFQCN , LogRecord record ) { StackTraceElement [ ] steArray = new Throwable ( ) . getStackTrace ( ) ; int selfIndex = - 1 ; for ( int i = 0 ; i < steArray . length ; i ++ ) { final String className = steArray [ i ] . getClassName ( ) ; if ( className . equals ( callerFQCN ) || className . equals ( SUPER ) ) { selfIndex = i ; break ; } } int found = - 1 ; for ( int i = selfIndex + 1 ; i < steArray . length ; i ++ ) { final String className = steArray [ i ] . getClassName ( ) ; if ( ! ( className . equals ( callerFQCN ) || className . equals ( SUPER ) ) ) { found = i ; break ; } } if ( found != - 1 ) { StackTraceElement ste = steArray [ found ] ; record . setSourceClassName ( ste . getClassName ( ) ) ; record . setSourceMethodName ( ste . getMethodName ( ) ) ; } }
Fill in caller data if possible .
665
public boolean removeAll ( final Collection < ? > c , final long occurrences ) { checkOccurrences ( occurrences ) ; if ( N . isNullOrEmpty ( c ) || occurrences == 0 ) { return false ; } boolean result = false ; for ( Object e : c ) { if ( result == false ) { result = remove ( e , occurrences ) ; } else { remove ( e , occurrences ) ; } } return result ; }
Remove the specified occurrences from the specified elements . The elements will be removed from this set if the occurrences equals to or less than 0 after the operation .
666
public static < T > T newInstance ( final Class < T > cls ) { if ( Modifier . isAbstract ( cls . getModifiers ( ) ) ) { if ( cls . equals ( Map . class ) ) { return ( T ) new HashMap < > ( ) ; } else if ( cls . equals ( List . class ) ) { return ( T ) new ArrayList < > ( ) ; } else if ( cls . equals ( Set . class ) ) { return ( T ) new HashSet < > ( ) ; } else if ( cls . equals ( Queue . class ) ) { return ( T ) new LinkedList < > ( ) ; } else if ( cls . equals ( Deque . class ) ) { return ( T ) new LinkedList < > ( ) ; } else if ( cls . equals ( SortedSet . class ) || cls . equals ( NavigableSet . class ) ) { return ( T ) new TreeSet < > ( ) ; } else if ( cls . equals ( SortedMap . class ) || cls . equals ( NavigableMap . class ) ) { return ( T ) new TreeMap < > ( ) ; } } try { if ( Modifier . isStatic ( cls . getModifiers ( ) ) == false && ( cls . isAnonymousClass ( ) || cls . isMemberClass ( ) ) ) { final List < Class < ? > > toInstantiate = new ArrayList < > ( ) ; Class < ? > parent = cls . getEnclosingClass ( ) ; do { toInstantiate . add ( parent ) ; parent = parent . getEnclosingClass ( ) ; } while ( parent != null && Modifier . isStatic ( parent . getModifiers ( ) ) == false && ( parent . isAnonymousClass ( ) || parent . isMemberClass ( ) ) ) ; if ( parent != null ) { toInstantiate . add ( parent ) ; } N . reverse ( toInstantiate ) ; Object instance = null ; for ( Class < ? > current : toInstantiate ) { instance = instance == null ? invoke ( ClassUtil . getDeclaredConstructor ( current ) ) : invoke ( ClassUtil . getDeclaredConstructor ( current , instance . getClass ( ) ) , instance ) ; } return invoke ( ClassUtil . getDeclaredConstructor ( cls , instance . getClass ( ) ) , instance ) ; } else { return invoke ( ClassUtil . getDeclaredConstructor ( cls ) ) ; } } catch ( InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e ) { throw N . toRuntimeException ( e ) ; } }
Method newInstance .
667
@ SuppressWarnings ( "unchecked" ) public static < T > T newArray ( final Class < ? > componentType , final int length ) { return ( T ) Array . newInstance ( componentType , length ) ; }
Method newArray .
668
public static < E > Set < E > newSetFromMap ( final Map < E , Boolean > map ) { return Collections . newSetFromMap ( map ) ; }
Returns a set backed by the specified map .
669
@ SuppressWarnings ( "unchecked" ) public static Object [ ] toArray ( final Collection < ? > c ) { if ( N . isNullOrEmpty ( c ) ) { return N . EMPTY_OBJECT_ARRAY ; } return c . toArray ( new Object [ c . size ( ) ] ) ; }
Returns an empty array if the specified collection is null or empty .
670
public static int deepHashCode ( final Object obj ) { if ( obj == null ) { return 0 ; } if ( obj . getClass ( ) . isArray ( ) ) { return typeOf ( obj . getClass ( ) ) . deepHashCode ( obj ) ; } return obj . hashCode ( ) ; }
Method deepHashCode .
671
public static String deepToString ( final Object obj ) { if ( obj == null ) { return NULL_STRING ; } if ( obj . getClass ( ) . isArray ( ) ) { return typeOf ( obj . getClass ( ) ) . deepToString ( obj ) ; } return obj . toString ( ) ; }
Method deepToString .
672
public static < T > List < T > repeatEach ( final Collection < T > c , final int n ) { N . checkArgNotNegative ( n , "n" ) ; if ( n == 0 || isNullOrEmpty ( c ) ) { return new ArrayList < T > ( ) ; } final List < T > result = new ArrayList < > ( c . size ( ) * n ) ; for ( T e : c ) { for ( int i = 0 ; i < n ; i ++ ) { result . add ( e ) ; } } return result ; }
Repeats the elements in the specified Collection one by one .
673
public static < T > List < T > repeatEachToSize ( final Collection < T > c , final int size ) { N . checkArgNotNegative ( size , "size" ) ; checkArgument ( size == 0 || notNullOrEmpty ( c ) , "Collection can not be empty or null when size > 0" ) ; if ( size == 0 || isNullOrEmpty ( c ) ) { return new ArrayList < T > ( ) ; } final int n = size / c . size ( ) ; int mod = size % c . size ( ) ; final List < T > result = new ArrayList < > ( size ) ; for ( T e : c ) { for ( int i = 0 , len = mod -- > 0 ? n + 1 : n ; i < len ; i ++ ) { result . add ( e ) ; } if ( result . size ( ) == size ) { break ; } } return result ; }
Repeats the elements in the specified Collection one by one till reach the specified size .
674
public static < T > T max ( final Collection < ? extends T > c , final int from , final int to , Comparator < ? super T > cmp ) { checkFromToIndex ( from , to , size ( c ) ) ; if ( N . isNullOrEmpty ( c ) || to - from < 1 || from >= c . size ( ) ) { throw new IllegalArgumentException ( "The size of collection can not be null or empty" ) ; } cmp = cmp == null ? NULL_MIN_COMPARATOR : cmp ; T candidate = null ; T e = null ; if ( c instanceof List && c instanceof RandomAccess ) { final List < T > list = ( List < T > ) c ; candidate = list . get ( from ) ; for ( int i = from + 1 ; i < to ; i ++ ) { e = list . get ( i ) ; if ( cmp . compare ( e , candidate ) > 0 ) { candidate = e ; } if ( candidate == null && cmp == NULL_MAX_COMPARATOR ) { return null ; } } } else { final Iterator < ? extends T > it = c . iterator ( ) ; for ( int i = 0 ; i < to ; i ++ ) { if ( i < from ) { it . next ( ) ; continue ; } else if ( i == from ) { candidate = it . next ( ) ; } else { e = it . next ( ) ; if ( cmp . compare ( e , candidate ) > 0 ) { candidate = e ; } } if ( candidate == null && cmp == NULL_MAX_COMPARATOR ) { return null ; } } } return candidate ; }
Returns the maximum element in the collection .
675
private synchronized PoolableConnection newConnection ( ) { synchronized ( xpool ) { if ( xpool . size ( ) >= maxActive ) { return null ; } try { PoolableConnection conn = null ; if ( xpool . size ( ) < minIdle ) { conn = new PoolableConnection ( this , ds . getConnection ( ) , liveTime , Integer . MAX_VALUE , maxOpenPreparedStatementsPerConnection ) ; } else if ( xpool . size ( ) < maxIdle ) { conn = new PoolableConnection ( this , ds . getConnection ( ) , liveTime , maxIdleTime , maxOpenPreparedStatementsPerConnection ) ; } else { conn = new PoolableConnection ( this , ds . getConnection ( ) , liveTime , 60 * 1000L , maxOpenPreparedStatementsPerConnection ) ; } xpool . put ( conn , conn ) ; if ( logger . isWarnEnabled ( ) ) { logger . warn ( "The " + xpool . size ( ) + "th of " + maxActive + " connections is created for data source: " + url ) ; } return conn ; } catch ( SQLException e ) { String msg = "Faied to create new connection for data source '" + url + "'." + " [Active connection number]: " + ( xpool . size ( ) + 1 ) + ". " + AbacusException . getErrorMsg ( e ) ; logger . error ( msg , e ) ; throw new UncheckedSQLException ( msg , e ) ; } } }
Method newConnection .
676
private void initPool ( ) { if ( logger . isWarnEnabled ( ) ) { logger . warn ( "Start to initialize connection pool with url: " + url + " ..." ) ; } for ( int i = 0 ; ( i < initialSize ) && ( xpool . size ( ) < initialSize ) ; i ++ ) { pool . lock ( ) ; try { if ( pool . isClosed ( ) ) { break ; } if ( ( i < initialSize ) && ( xpool . size ( ) < initialSize ) ) { PoolableConnection poolableConn = newConnection ( ) ; if ( ! pool . add ( poolableConn ) ) { detroyConnection ( poolableConn ) ; } } } finally { pool . unlock ( ) ; } } if ( logger . isWarnEnabled ( ) ) { logger . warn ( "End to initialize connection pool with url: " + url + " ..." ) ; } }
Method initPool .
677
public static void registerXMLBindingClassForPropGetSetMethod ( final Class < ? > cls ) { if ( registeredXMLBindingClassList . containsKey ( cls ) ) { return ; } synchronized ( entityDeclaredPropGetMethodPool ) { registeredXMLBindingClassList . put ( cls , false ) ; if ( entityDeclaredPropGetMethodPool . containsKey ( cls ) ) { entityDeclaredPropGetMethodPool . remove ( cls ) ; entityDeclaredPropSetMethodPool . remove ( cls ) ; entityPropFieldPool . remove ( cls ) ; loadPropGetSetMethodList ( cls ) ; } } }
The property maybe only has get method if its type is collection or map by xml binding specificatio Otherwise it will be ignored if not registered by calling this method .
678
public static Set < Class < ? > > getAllInterfaces ( final Class < ? > cls ) { final Set < Class < ? > > interfacesFound = new LinkedHashSet < > ( ) ; getAllInterfaces ( cls , interfacesFound ) ; return interfacesFound ; }
Copied from Apache Commons Lang under Apache License v2 .
679
public static List < String > getPropNameList ( final Class < ? > cls ) { List < String > propNameList = entityDeclaredPropNameListPool . get ( cls ) ; if ( propNameList == null ) { loadPropGetSetMethodList ( cls ) ; propNameList = entityDeclaredPropNameListPool . get ( cls ) ; } return propNameList ; }
Returns an immutable entity property name List by the specified class .
680
public int totalCountOfValues ( ) { int count = 0 ; for ( V v : valueMap . values ( ) ) { count += v . size ( ) ; } return count ; }
Returns the total count of all the elements in all values .
681
public static long skip ( final InputStream input , final long toSkip ) throws UncheckedIOException { if ( toSkip < 0 ) { throw new IllegalArgumentException ( "Skip count must be non-negative, actual: " + toSkip ) ; } else if ( toSkip == 0 ) { return 0 ; } final byte [ ] buf = Objectory . createByteArrayBuffer ( ) ; long remain = toSkip ; try { while ( remain > 0 ) { long n = read ( input , buf , 0 , ( int ) Math . min ( remain , buf . length ) ) ; if ( n < 0 ) { break ; } remain -= n ; } return toSkip - remain ; } catch ( IOException e ) { throw new UncheckedIOException ( e ) ; } finally { Objectory . recycle ( buf ) ; } }
Return the count of skipped bytes .
682
private static long estimateLineCount ( final File file , final int byReadingLineNum ) throws UncheckedIOException { final Holder < ZipFile > outputZipFile = new Holder < > ( ) ; InputStream is = null ; BufferedReader br = null ; try { is = openFile ( outputZipFile , file ) ; br = Objectory . createBufferedReader ( is ) ; int cnt = 0 ; String line = null ; long bytes = 0 ; while ( cnt < byReadingLineNum && ( line = br . readLine ( ) ) != null ) { bytes += line . getBytes ( ) . length ; cnt ++ ; } return cnt == 0 ? 0 : ( file . length ( ) / ( bytes / cnt == 0 ? 1 : bytes / cnt ) ) ; } catch ( IOException e ) { throw new UncheckedIOException ( e ) ; } finally { closeQuietly ( is ) ; closeQuietly ( outputZipFile . value ( ) ) ; Objectory . recycle ( br ) ; } }
Estimate the total line count of the file by reading the specified line count ahead .
683
public static long merge ( final Collection < File > sourceFiles , final File destFile ) throws UncheckedIOException { final byte [ ] buf = Objectory . createByteArrayBuffer ( ) ; long totalCount = 0 ; OutputStream output = null ; try { output = new FileOutputStream ( destFile ) ; InputStream input = null ; for ( File file : sourceFiles ) { try { input = new FileInputStream ( file ) ; int count = 0 ; while ( EOF != ( count = read ( input , buf , 0 , buf . length ) ) ) { output . write ( buf , 0 , count ) ; totalCount += count ; } } finally { close ( input ) ; } } output . flush ( ) ; } catch ( IOException e ) { throw new UncheckedIOException ( e ) ; } finally { Objectory . recycle ( buf ) ; close ( output ) ; } return totalCount ; }
Merge the specified source files into the destination file .
684
private static String decodeUrl ( final String url ) { String decoded = url ; if ( url != null && url . indexOf ( '%' ) >= 0 ) { final int n = url . length ( ) ; final StringBuffer buffer = new StringBuffer ( ) ; final ByteBuffer bytes = ByteBuffer . allocate ( n ) ; for ( int i = 0 ; i < n ; ) { if ( url . charAt ( i ) == '%' ) { try { do { final byte octet = ( byte ) Integer . parseInt ( url . substring ( i + 1 , i + 3 ) , 16 ) ; bytes . put ( octet ) ; i += 3 ; } while ( i < n && url . charAt ( i ) == '%' ) ; continue ; } catch ( final RuntimeException e ) { } finally { if ( bytes . position ( ) > 0 ) { bytes . flip ( ) ; buffer . append ( Charsets . UTF_8 . decode ( bytes ) . toString ( ) ) ; bytes . clear ( ) ; } } } buffer . append ( url . charAt ( i ++ ) ) ; } decoded = buffer . toString ( ) ; } return decoded ; }
unavoidable until Java 7
685
public static < R > Stream < R > zip ( final ShortStream a , final ShortStream b , final ShortBiFunction < R > zipFunction ) { return zip ( a . iteratorEx ( ) , b . iteratorEx ( ) , zipFunction ) . onClose ( newCloseHandler ( N . asList ( a , b ) ) ) ; }
Zip together the a and b streams until one of them runs out of values . Each pair of values is combined into a single value using the supplied zipFunction function .
686
static URLSpec getReleaseDownloadUrl ( String path , MavenSettings settings ) throws IOException { String url = settings . mCentralUrl ; if ( settings . mMirrorUrl != null ) url = settings . mMirrorUrl ; return new URLSpec ( url + path , settings . mProxyHost , settings . mProxyPort ) ; }
get release download URL
687
static URLSpec getSnapshotDownloadUrl ( String path , MavenSettings settings ) throws IOException { String url = settings . mSnapshotUrl ; return new URLSpec ( url + path , settings . mProxyHost , settings . mProxyPort ) ; }
get snapshot download URL
688
static MavenSettings getMavenSettings ( ) { try { String homeDir = System . getProperty ( "user.home" ) ; return parseMavenSettings ( new File ( homeDir , ".m2/settings.xml" ) ) ; } catch ( Exception e ) { log ( e ) ; } return new MavenSettings ( ) ; }
get maven settings
689
static MavenSettings parseMavenSettings ( File settingsFile ) throws IOException { MavenSettings settings = new MavenSettings ( ) ; try { DocumentBuilder xmlBuilder = DocumentBuilderFactory . newInstance ( ) . newDocumentBuilder ( ) ; Document xmlDoc = xmlBuilder . parse ( settingsFile ) ; NodeList mirrorList = xmlDoc . getDocumentElement ( ) . getElementsByTagName ( "mirror" ) ; for ( int i = 0 ; i < mirrorList . getLength ( ) ; i ++ ) { Element mirror = ( Element ) mirrorList . item ( i ) ; String url = mirror . getElementsByTagName ( "url" ) . item ( 0 ) . getTextContent ( ) . trim ( ) ; String mirrorOf = mirror . getElementsByTagName ( "mirrorOf" ) . item ( 0 ) . getTextContent ( ) . trim ( ) ; if ( mirrorOf . equals ( "central" ) || mirrorOf . contains ( "*" ) ) settings . mMirrorUrl = url ; } NodeList proxyList = xmlDoc . getDocumentElement ( ) . getElementsByTagName ( "proxy" ) ; for ( int i = 0 ; i < proxyList . getLength ( ) ; i ++ ) { Node proxy = proxyList . item ( i ) ; Node host = null ; Node port = null ; for ( int j = 0 ; j < proxy . getChildNodes ( ) . getLength ( ) ; j ++ ) { Node n = proxy . getChildNodes ( ) . item ( j ) ; if ( n . getNodeName ( ) . equals ( "host" ) ) host = n ; if ( n . getNodeName ( ) . equals ( "port" ) ) port = n ; } if ( host != null ) { settings . mProxyHost = host . getTextContent ( ) . trim ( ) ; if ( port != null ) settings . mProxyPort = Integer . parseInt ( port . getTextContent ( ) . trim ( ) ) ; break ; } } } catch ( Exception e ) { throw new IOException ( e ) ; } return settings ; }
parse maven settings . xml
690
static String parseSnapshotExeName ( File mdFile ) throws IOException { String exeName = null ; try { String clsStr = Protoc . getPlatformClassifier ( ) ; DocumentBuilder xmlBuilder = DocumentBuilderFactory . newInstance ( ) . newDocumentBuilder ( ) ; Document xmlDoc = xmlBuilder . parse ( mdFile ) ; NodeList versions = xmlDoc . getElementsByTagName ( "snapshotVersion" ) ; for ( int i = 0 ; i < versions . getLength ( ) ; i ++ ) { Node ver = versions . item ( i ) ; Node cls = null ; Node val = null ; for ( int j = 0 ; j < ver . getChildNodes ( ) . getLength ( ) ; j ++ ) { Node n = ver . getChildNodes ( ) . item ( j ) ; if ( n . getNodeName ( ) . equals ( "classifier" ) ) cls = n ; if ( n . getNodeName ( ) . equals ( "value" ) ) val = n ; } if ( cls != null && val != null && cls . getTextContent ( ) . equals ( clsStr ) ) { exeName = "protoc-" + val . getTextContent ( ) + "-" + clsStr + ".exe" ; break ; } } } catch ( Exception e ) { throw new IOException ( e ) ; } return exeName ; }
parse snapshot exe name from maven - metadata . xml
691
public static void assertSelectCount ( long expectedSelectCount ) { QueryCount queryCount = QueryCountHolder . getGrandTotal ( ) ; long recordedSelectCount = queryCount . getSelect ( ) ; if ( expectedSelectCount != recordedSelectCount ) { throw new SQLSelectCountMismatchException ( expectedSelectCount , recordedSelectCount ) ; } }
Assert select statement count
692
public static void assertInsertCount ( long expectedInsertCount ) { QueryCount queryCount = QueryCountHolder . getGrandTotal ( ) ; long recordedInsertCount = queryCount . getInsert ( ) ; if ( expectedInsertCount != recordedInsertCount ) { throw new SQLInsertCountMismatchException ( expectedInsertCount , recordedInsertCount ) ; } }
Assert insert statement count
693
public static void assertUpdateCount ( long expectedUpdateCount ) { QueryCount queryCount = QueryCountHolder . getGrandTotal ( ) ; long recordedUpdateCount = queryCount . getUpdate ( ) ; if ( expectedUpdateCount != recordedUpdateCount ) { throw new SQLUpdateCountMismatchException ( expectedUpdateCount , recordedUpdateCount ) ; } }
Assert update statement count
694
public static void assertDeleteCount ( long expectedDeleteCount ) { QueryCount queryCount = QueryCountHolder . getGrandTotal ( ) ; long recordedDeleteCount = queryCount . getDelete ( ) ; if ( expectedDeleteCount != recordedDeleteCount ) { throw new SQLDeleteCountMismatchException ( expectedDeleteCount , recordedDeleteCount ) ; } }
Assert delete statement count
695
public void login ( String username , String passwd , String domain ) { this . login = getPerformedAction ( new PostLogin ( username , passwd , domain ) ) . getLoginData ( ) ; loginChangeUserInfo = true ; if ( getVersion ( ) == Version . UNKNOWN ) { loginChangeVersion = true ; } }
Performs a Login .
696
public void delete ( String title , String reason ) { getPerformedAction ( new PostDelete ( getUserinfo ( ) , title , reason ) ) ; }
deletes an article with a reason
697
private EditType getEditType ( String typeName ) { for ( EditType type : EditType . values ( ) ) { if ( type . toString ( ) . equals ( typeName ) ) { return type ; } } return null ; }
Create a EditType from the name type used by MW
698
protected ImmutableList < String > parseElements ( String s ) { ImmutableList . Builder < String > titles = ImmutableList . builder ( ) ; Optional < XmlElement > child = XmlConverter . getChildOpt ( s , "query" , "allpages" ) ; if ( child . isPresent ( ) ) { for ( XmlElement pageElement : child . get ( ) . getChildren ( "p" ) ) { String title = pageElement . getAttributeValue ( "title" ) ; log . debug ( "Found article title: \"{}\"" , title ) ; titles . add ( title ) ; } } return titles . build ( ) ; }
Picks the article name from a MediaWiki api response .
699
static Optional < XmlElement > getErrorElement ( XmlElement rootXmlElement ) { Optional < XmlElement > elem = rootXmlElement . getChildOpt ( "error" ) ; if ( elem . isPresent ( ) ) { ApiException error = elem . transform ( toApiException ( ) ) . get ( ) ; log . error ( error . getCode ( ) + ": " + error . getValue ( ) ) ; } return elem ; }
Determines if the given XML Document contains an error message which then would printed by the logger .