idx int64 0 41.2k | question stringlengths 73 5.81k | target stringlengths 5 918 |
|---|---|---|
31,600 | public < S extends Model , R > AnimaQuery < T > where ( TypeFunction < S , R > function , Object value ) { String columnName = AnimaUtils . getLambdaColumnName ( function ) ; conditionSQL . append ( " AND " ) . append ( columnName ) . append ( " = ?" ) ; paramValues . add ( value ) ; return this ; } | Set the column name using lambda at the same time setting the value the SQL generated is column = ? |
31,601 | public AnimaQuery < T > where ( T model ) { Field [ ] declaredFields = model . getClass ( ) . getDeclaredFields ( ) ; for ( Field declaredField : declaredFields ) { Object value = AnimaUtils . invokeMethod ( model , getGetterName ( declaredField . getName ( ) ) , AnimaUtils . EMPTY_ARG ) ; if ( null == value ) { contin... | Set the where parameter according to model and generate sql like where where age = ? and name = ? |
31,602 | public AnimaQuery < T > and ( String statement , Object value ) { return this . where ( statement , value ) ; } | generate AND statement simultaneous setting value |
31,603 | public < R > AnimaQuery < T > and ( TypeFunction < T , R > function ) { return this . where ( function ) ; } | generate AND statement with lambda |
31,604 | public < R > AnimaQuery < T > and ( TypeFunction < T , R > function , Object value ) { return this . where ( function , value ) ; } | generate AND statement with lambda simultaneous setting value |
31,605 | public AnimaQuery < T > or ( String statement , Object value ) { conditionSQL . append ( " OR (" ) . append ( statement ) ; if ( ! statement . contains ( "?" ) ) { conditionSQL . append ( " = ?" ) ; } conditionSQL . append ( ')' ) ; paramValues . add ( value ) ; return this ; } | generate OR statement simultaneous setting value |
31,606 | public AnimaQuery < T > notEmpty ( String columnName ) { conditionSQL . append ( " AND " ) . append ( columnName ) . append ( " != ''" ) ; return this ; } | generate ! = statement |
31,607 | public < R > AnimaQuery < T > notEmpty ( TypeFunction < T , R > function ) { String columnName = AnimaUtils . getLambdaColumnName ( function ) ; return this . notEmpty ( columnName ) ; } | generate ! = statement with lambda |
31,608 | public AnimaQuery < T > notNull ( String columnName ) { conditionSQL . append ( " AND " ) . append ( columnName ) . append ( " IS NOT NULL" ) ; return this ; } | generate IS NOT NULL statement |
31,609 | public AnimaQuery < T > like ( String columnName , Object value ) { conditionSQL . append ( " AND " ) . append ( columnName ) . append ( " LIKE ?" ) ; paramValues . add ( value ) ; return this ; } | generate like statement simultaneous setting value |
31,610 | public < R > AnimaQuery < T > like ( TypeFunction < T , R > function , Object value ) { String columnName = AnimaUtils . getLambdaColumnName ( function ) ; return this . like ( columnName , value ) ; } | generate like statement with lambda simultaneous setting value |
31,611 | public AnimaQuery < T > between ( String columnName , Object a , Object b ) { conditionSQL . append ( " AND " ) . append ( columnName ) . append ( " BETWEEN ? and ?" ) ; paramValues . add ( a ) ; paramValues . add ( b ) ; return this ; } | generate between statement simultaneous setting value |
31,612 | public < R > AnimaQuery < T > between ( TypeFunction < T , R > function , Object a , Object b ) { String columnName = AnimaUtils . getLambdaColumnName ( function ) ; return this . between ( columnName , a , b ) ; } | generate between statement with lambda simultaneous setting value |
31,613 | public < S extends Model , R > AnimaQuery < T > gte ( TypeFunction < S , R > function , Object value ) { String columnName = AnimaUtils . getLambdaColumnName ( function ) ; return this . gte ( columnName , value ) ; } | generate > = statement with lambda simultaneous setting value |
31,614 | public AnimaQuery < T > lt ( String column , Object value ) { conditionSQL . append ( " AND " ) . append ( column ) . append ( " < ?" ) ; paramValues . add ( value ) ; return this ; } | generate < statement simultaneous setting value |
31,615 | public < S > AnimaQuery < T > in ( List < S > list ) { return this . in ( list . toArray ( ) ) ; } | Set in params |
31,616 | public < R > AnimaQuery < T > order ( TypeFunction < T , R > function , OrderBy orderBy ) { String columnName = AnimaUtils . getLambdaColumnName ( function ) ; return order ( columnName , orderBy ) ; } | generate order by statement with lambda |
31,617 | public T byId ( Object id ) { this . beforeCheck ( ) ; this . where ( primaryKeyColumn , id ) ; String sql = this . buildSelectSQL ( false ) ; T model = this . queryOne ( modelClass , sql , paramValues ) ; ifNotNullThen ( model , ( ) -> this . setJoin ( Collections . singletonList ( model ) ) ) ; return model ; } | query model by primary key |
31,618 | public T one ( ) { this . beforeCheck ( ) ; String sql = this . buildSelectSQL ( true ) ; T model = this . queryOne ( modelClass , sql , paramValues ) ; ifThen ( null != model && null != joinParams , ( ) -> this . setJoin ( Collections . singletonList ( model ) ) ) ; return model ; } | query and find one model |
31,619 | public List < T > all ( ) { this . beforeCheck ( ) ; String sql = this . buildSelectSQL ( true ) ; List < T > models = this . queryList ( modelClass , sql , paramValues ) ; this . setJoin ( models ) ; return models ; } | query and find all model |
31,620 | public < R > Stream < R > map ( Function < T , R > function ) { return stream ( ) . map ( function ) ; } | Transform the results of the model . |
31,621 | public List < T > limit ( int limit ) { return ifReturn ( Anima . of ( ) . isUseSQLLimit ( ) , ( ) -> { isSQLLimit = true ; paramValues . add ( limit ) ; return all ( ) ; } , ( ) -> { List < T > all = all ( ) ; return ifReturn ( all . size ( ) > limit , all . stream ( ) . limit ( limit ) . collect ( toList ( ) ) , all ... | Take the data of the fixed number from the result . |
31,622 | public Page < T > page ( PageRow pageRow ) { String sql = this . buildSelectSQL ( false ) ; return this . page ( sql , pageRow ) ; } | Paging query results |
31,623 | public AnimaQuery < T > set ( String column , Object value ) { updateColumns . put ( column , value ) ; return this ; } | Update columns set value |
31,624 | public < S extends Model , R > AnimaQuery < T > set ( TypeFunction < S , R > function , Object value ) { return this . set ( AnimaUtils . getLambdaColumnName ( function ) , value ) ; } | Update the model sets column . |
31,625 | public AnimaQuery < T > join ( JoinParam joinParam ) { ifNullThrow ( joinParam , new AnimaException ( "Join param not null" ) ) ; ifNullThrow ( joinParam . getJoinModel ( ) , new AnimaException ( "Join param [model] not null" ) ) ; ifNullThrow ( AnimaUtils . isEmpty ( joinParam . getFieldName ( ) ) , new AnimaException... | Add a cascading query . |
31,626 | public < S extends Model > ResultKey save ( S model ) { List < Object > columnValues = AnimaUtils . toColumnValues ( model , true ) ; String sql = this . buildInsertSQL ( model , columnValues ) ; Connection conn = getConn ( ) ; try { List < Object > params = columnValues . stream ( ) . filter ( Objects :: nonNull ) . c... | Save a model |
31,627 | public < S extends Model > int updateById ( S model , Serializable id ) { this . where ( primaryKeyColumn , id ) ; String sql = this . buildUpdateSQL ( model , null ) ; List < Object > columnValueList = AnimaUtils . toColumnValues ( model , false ) ; columnValueList . add ( id ) ; return this . execute ( sql , columnVa... | Update model by primary key |
31,628 | public < S extends Model > int updateByModel ( S model ) { this . beforeCheck ( ) ; Object primaryKey = AnimaUtils . getAndRemovePrimaryKey ( model ) ; StringBuilder sql = new StringBuilder ( this . buildUpdateSQL ( model , null ) ) ; List < Object > columnValueList = AnimaUtils . toColumnValues ( model , false ) ; ifN... | Update a model |
31,629 | private String buildSelectSQL ( boolean addOrderBy ) { SQLParams sqlParams = SQLParams . builder ( ) . modelClass ( this . modelClass ) . selectColumns ( this . selectColumns ) . tableName ( this . tableName ) . pkName ( this . primaryKeyColumn ) . conditionSQL ( this . conditionSQL ) . excludedColumns ( this . exclude... | Build a select statement . |
31,630 | private String buildCountSQL ( ) { SQLParams sqlParams = SQLParams . builder ( ) . modelClass ( this . modelClass ) . tableName ( this . tableName ) . pkName ( this . primaryKeyColumn ) . conditionSQL ( this . conditionSQL ) . build ( ) ; return Anima . of ( ) . dialect ( ) . count ( sqlParams ) ; } | Build a count statement . |
31,631 | private String buildPageSQL ( String sql , PageRow pageRow ) { SQLParams sqlParams = SQLParams . builder ( ) . modelClass ( this . modelClass ) . selectColumns ( this . selectColumns ) . tableName ( this . tableName ) . pkName ( this . primaryKeyColumn ) . conditionSQL ( this . conditionSQL ) . excludedColumns ( this .... | Build a paging statement |
31,632 | private < S extends Model > String buildInsertSQL ( S model , List < Object > columnValues ) { SQLParams sqlParams = SQLParams . builder ( ) . model ( model ) . columnValues ( columnValues ) . modelClass ( this . modelClass ) . tableName ( this . tableName ) . pkName ( this . primaryKeyColumn ) . build ( ) ; return Ani... | Build a insert statement . |
31,633 | private < S extends Model > String buildUpdateSQL ( S model , Map < String , Object > updateColumns ) { SQLParams sqlParams = SQLParams . builder ( ) . model ( model ) . modelClass ( this . modelClass ) . tableName ( this . tableName ) . pkName ( this . primaryKeyColumn ) . updateColumns ( updateColumns ) . conditionSQ... | Build a update statement . |
31,634 | private < S extends Model > String buildDeleteSQL ( S model ) { SQLParams sqlParams = SQLParams . builder ( ) . model ( model ) . modelClass ( this . modelClass ) . tableName ( this . tableName ) . pkName ( this . primaryKeyColumn ) . conditionSQL ( this . conditionSQL ) . build ( ) ; return Anima . of ( ) . dialect ( ... | Build a delete statement . |
31,635 | private Connection getConn ( ) { Connection connection = localConnection . get ( ) ; return ifNotNullReturn ( connection , connection , this . getSql2o ( ) . open ( ) ) ; } | Get a database connection . |
31,636 | public static void beginTransaction ( ) { ifNullThen ( localConnection . get ( ) , ( ) -> { Connection connection = getSql2o ( ) . beginTransaction ( ) ; localConnection . set ( connection ) ; } ) ; } | Begin a transaction . |
31,637 | public static void endTransaction ( ) { ifNotNullThen ( localConnection . get ( ) , ( ) -> { Connection connection = localConnection . get ( ) ; ifThen ( connection . isRollbackOnClose ( ) , connection :: close ) ; localConnection . remove ( ) ; } ) ; } | End a transaction . |
31,638 | private void setJoin ( List < T > models ) { if ( null == models || models . isEmpty ( ) || joinParams . size ( ) == 0 ) { return ; } models . stream ( ) . filter ( Objects :: nonNull ) . forEach ( this :: setJoin ) ; } | Set models join fields |
31,639 | private void setJoin ( T model ) { for ( JoinParam joinParam : joinParams ) { try { Object leftValue = AnimaUtils . invokeMethod ( model , getGetterName ( joinParam . getOnLeft ( ) ) , AnimaUtils . EMPTY_ARG ) ; String sql = "SELECT * FROM " + AnimaCache . getTableName ( joinParam . getJoinModel ( ) ) + " WHERE " + joi... | Set model join fields |
31,640 | private void clean ( Connection conn ) { this . selectColumns = null ; this . isSQLLimit = false ; this . orderBySQL = new StringBuilder ( ) ; this . conditionSQL = new StringBuilder ( ) ; this . paramValues . clear ( ) ; this . excludedColumns . clear ( ) ; this . updateColumns . clear ( ) ; ifThen ( localConnection .... | Clear the battlefield after a database operation . |
31,641 | public static < S extends Model > Object getAndRemovePrimaryKey ( S model ) { String fieldName = getPKField ( model . getClass ( ) ) ; Object value = invokeMethod ( model , getGetterName ( fieldName ) , EMPTY_ARG ) ; if ( null != value ) { invokeMethod ( model , getSetterName ( fieldName ) , NULL_ARG ) ; } return value... | Return the primary key of the model and set it to null |
31,642 | public static < T > T [ ] toArray ( List < T > list ) { T [ ] toR = ( T [ ] ) Array . newInstance ( list . get ( 0 ) . getClass ( ) , list . size ( ) ) ; for ( int i = 0 ; i < list . size ( ) ; i ++ ) { toR [ i ] = list . get ( i ) ; } return toR ; } | Convert a List to a generic array |
31,643 | public AnimaQuery < ? extends Model > set ( String column , Object value ) { return query . set ( column , value ) ; } | Update set statement |
31,644 | public < T extends Model , R > AnimaQuery < ? extends Model > set ( TypeFunction < T , R > function , Object value ) { return query . set ( function , value ) ; } | Update set statement with lambda |
31,645 | public static Anima open ( Sql2o sql2o ) { Anima anima = new Anima ( ) ; anima . setSql2o ( sql2o ) ; instance = anima ; return anima ; } | Create anima with Sql2o |
31,646 | public static Anima open ( String url , Quirks quirks ) { return open ( url , null , null , quirks ) ; } | Create anima with url like Sqlite or h2 |
31,647 | public static Anima open ( DataSource dataSource , Quirks quirks ) { return open ( new Sql2o ( dataSource , quirks ) ) ; } | Create anima with datasource and quirks |
31,648 | public static Atomic atomic ( Runnable runnable ) { try { AnimaQuery . beginTransaction ( ) ; runnable . run ( ) ; AnimaQuery . commit ( ) ; return Atomic . ok ( ) ; } catch ( Exception e ) { boolean isRollback = ifReturn ( of ( ) . rollbackException . isInstance ( e ) , ( ) -> { AnimaQuery . rollback ( ) ; return true... | Code that performs a transaction operation . |
31,649 | public Anima addConverter ( Converter < ? > ... converters ) { ifThrow ( null == converters || converters . length == 0 , new AnimaException ( "converters not be null." ) ) ; for ( Converter < ? > converter : converters ) { Class < ? > type = AnimaUtils . getConverterType ( converter ) ; sql2o . getQuirks ( ) . addConv... | Add custom Type converter |
31,650 | public static < T extends Model , R > Select select ( TypeFunction < T , R > ... functions ) { return select ( Arrays . stream ( functions ) . map ( AnimaUtils :: getLambdaColumnName ) . collect ( joining ( ", " ) ) ) ; } | Set the query to fix columns with lambda |
31,651 | public static < T extends Model > void saveBatch ( List < T > models ) { atomic ( ( ) -> models . forEach ( Anima :: save ) ) . catchException ( e -> log . error ( "Batch save model error, message: {}" , e ) ) ; } | Batch save model |
31,652 | public static < T extends Model , S extends Serializable > void deleteBatch ( Class < T > model , S ... ids ) { atomic ( ( ) -> Arrays . stream ( ids ) . forEach ( new AnimaQuery < > ( model ) :: deleteById ) ) . catchException ( e -> log . error ( "Batch save model error, message: {}" , e ) ) ; } | Batch delete model |
31,653 | public static < T extends Model , S extends Serializable > void deleteBatch ( Class < T > model , List < S > idList ) { deleteBatch ( model , AnimaUtils . toArray ( idList ) ) ; } | Batch delete model with List |
31,654 | public static < T extends Model > int deleteById ( Class < T > model , Serializable id ) { return new AnimaQuery < > ( model ) . deleteById ( id ) ; } | Delete model by id |
31,655 | public Map < String , Object > asMap ( ) { Map < String , Object > map = new HashMap < > ( ) ; Set < String > keys = columnNameToIdxMap . keySet ( ) ; Iterator < String > iterator = keys . iterator ( ) ; while ( iterator . hasNext ( ) ) { String colum = iterator . next ( ) . toString ( ) ; int index = columnNameToIdxMa... | View row as a simple map . |
31,656 | public static String getTableName ( String className , String prefix ) { boolean hasPrefix = prefix != null && prefix . trim ( ) . length ( ) > 0 ; return hasPrefix ? English . plural ( prefix + "_" + AnimaUtils . toUnderline ( className ) , 2 ) : English . plural ( AnimaUtils . toUnderline ( className ) , 2 ) ; } | User - > users User - > t_users |
31,657 | X509Certificate selectCertificate ( final CertStore store , final Collection < X509CertSelector > selectors ) throws CertStoreException { for ( CertSelector selector : selectors ) { LOGGER . debug ( "Selecting certificate using {}" , selector ) ; Collection < ? extends Certificate > certs = store . getCertificates ( se... | Finds the certificate of the SCEP message object recipient . |
31,658 | private void validateInput ( ) { if ( url == null ) { throw new NullPointerException ( "URL should not be null" ) ; } if ( ! url . getProtocol ( ) . matches ( "^https?$" ) ) { throw new IllegalArgumentException ( "URL protocol should be HTTP or HTTPS" ) ; } if ( url . getRef ( ) != null ) { throw new IllegalArgumentExc... | Validates all the input to this client . |
31,659 | private Transport createTransport ( final String profile ) { if ( getCaCapabilities ( profile ) . isPostSupported ( ) ) { return transportFactory . forMethod ( Method . POST , url ) ; } else { return transportFactory . forMethod ( Method . GET , url ) ; } } | Creates a new transport based on the capabilities of the server . |
31,660 | public boolean verify ( final X509Certificate cert ) { final List < String > algs = new ArrayList < String > ( getAlgorithms ( MessageDigest . class . getSimpleName ( ) ) ) ; Collections . sort ( algs ) ; int max = 0 ; for ( final String alg : algs ) { if ( alg . length ( ) > max ) { max = alg . length ( ) ; } } for ( ... | Use the system console to prompt the user with each available hash . |
31,661 | public CMSEnvelopedData encode ( final byte [ ] messageData ) throws MessageEncodingException { LOGGER . debug ( "Encoding pkcsPkiEnvelope" ) ; CMSEnvelopedDataGenerator edGenerator = new CMSEnvelopedDataGenerator ( ) ; CMSTypedData envelopable = new CMSProcessableByteArray ( messageData ) ; RecipientInfoGenerator reci... | Encrypts and envelops the provided messageData . |
31,662 | public String getStrongestCipher ( ) { final String cipher ; if ( cipherExists ( "AES" ) && caps . contains ( Capability . AES ) ) { cipher = "AES" ; } else if ( cipherExists ( "DESede" ) && caps . contains ( Capability . TRIPLE_DES ) ) { cipher = "DESede" ; } else { cipher = "DES" ; } return cipher ; } | Returns the strongest cipher algorithm supported by the server and client . |
31,663 | public MessageDigest getStrongestMessageDigest ( ) { if ( digestExists ( "SHA-512" ) && caps . contains ( Capability . SHA_512 ) ) { return getDigest ( "SHA-512" ) ; } else if ( digestExists ( "SHA-256" ) && caps . contains ( Capability . SHA_256 ) ) { return getDigest ( "SHA-256" ) ; } else if ( digestExists ( "SHA-1"... | Returns the strongest message digest algorithm supported by the server and client . |
31,664 | public static boolean isSignedBy ( final CMSSignedData sd , final X509Certificate signer ) { SignerInformationStore store = sd . getSignerInfos ( ) ; SignerInformation signerInfo = store . get ( new JcaSignerId ( signer ) ) ; if ( signerInfo == null ) { return false ; } CMSSignatureAlgorithmNameGenerator sigNameGenerat... | Checks if the provided signedData was signed by the entity represented by the provided certificate . |
31,665 | public static X500Name toX500Name ( final X500Principal principal ) { byte [ ] bytes = principal . getEncoded ( ) ; return X500Name . getInstance ( bytes ) ; } | Converts a Java SE X500Principal to a Bouncy Castle X500Name . |
31,666 | private String provideRepresentation ( int number ) { String key ; if ( number == 0 ) key = "zero" ; else if ( number < 20 ) key = numNames [ number ] ; else if ( number < 100 ) { int unit = number % 10 ; key = tensNames [ number / 10 ] + numNames [ unit ] ; } else { int unit = number % 10 ; int ten = number % 100 - un... | Provides a string representation for the number passed . This method works for limited set of numbers as parsing will only be done at maximum for 2400 which will be used in military time format . |
31,667 | private void flushBuffer ( ) throws IOException { if ( buffer . position ( ) > 0 ) { buffer . flip ( ) ; writeCompressed ( buffer ) ; buffer . clear ( ) ; } } | Compresses and writes out any buffered data . This does nothing if there is no currently buffered data . |
31,668 | public static void arrayCopy ( Object src , int offset , int byteLength , Object dest , int dest_offset ) throws IOException { impl . arrayCopy ( src , offset , byteLength , dest , dest_offset ) ; } | Copy bytes from source to destination |
31,669 | public static int compress ( byte [ ] input , int inputOffset , int inputLength , byte [ ] output , int outputOffset ) throws IOException { return rawCompress ( input , inputOffset , inputLength , output , outputOffset ) ; } | Compress the input buffer content in [ inputOffset ... inputOffset + inputLength ) then output to the specified output buffer . |
31,670 | public static String getNativeLibraryVersion ( ) { URL versionFile = SnappyLoader . class . getResource ( "/org/xerial/snappy/VERSION" ) ; String version = "unknown" ; try { if ( versionFile != null ) { InputStream in = null ; try { Properties versionData = new Properties ( ) ; in = versionFile . openStream ( ) ; versi... | Get the native library version of the snappy |
31,671 | public static long rawCompress ( long inputAddr , long inputSize , long destAddr ) throws IOException { return impl . rawCompress ( inputAddr , inputSize , destAddr ) ; } | Zero - copy compress using memory addresses . |
31,672 | public static long rawUncompress ( long inputAddr , long inputSize , long destAddr ) throws IOException { return impl . rawUncompress ( inputAddr , inputSize , destAddr ) ; } | Zero - copy decompress using memory addresses . |
31,673 | public static byte [ ] rawCompress ( Object data , int byteSize ) throws IOException { byte [ ] buf = new byte [ Snappy . maxCompressedLength ( byteSize ) ] ; int compressedByteSize = impl . rawCompress ( data , 0 , byteSize , buf , 0 ) ; byte [ ] result = new byte [ compressedByteSize ] ; System . arraycopy ( buf , 0 ... | Compress the input data and produce a byte array of the uncompressed data |
31,674 | public static int rawCompress ( Object input , int inputOffset , int inputLength , byte [ ] output , int outputOffset ) throws IOException { if ( input == null || output == null ) { throw new NullPointerException ( "input or output is null" ) ; } int compressedSize = impl . rawCompress ( input , inputOffset , inputLeng... | Compress the input buffer [ offset ... offset + length ) contents then write the compressed data to the output buffer [ offset ... ) |
31,675 | public static byte [ ] uncompress ( byte [ ] input ) throws IOException { byte [ ] result = new byte [ Snappy . uncompressedLength ( input ) ] ; Snappy . uncompress ( input , 0 , input . length , result , 0 ) ; return result ; } | High - level API for uncompressing the input byte array . |
31,676 | public static double [ ] uncompressDoubleArray ( byte [ ] input ) throws IOException { int uncompressedLength = Snappy . uncompressedLength ( input , 0 , input . length ) ; double [ ] result = new double [ uncompressedLength / 8 ] ; impl . rawUncompress ( input , 0 , input . length , result , 0 ) ; return result ; } | Uncompress the input as a double array |
31,677 | public static float [ ] uncompressFloatArray ( byte [ ] input , int offset , int length ) throws IOException { int uncompressedLength = Snappy . uncompressedLength ( input , offset , length ) ; float [ ] result = new float [ uncompressedLength / 4 ] ; impl . rawUncompress ( input , offset , length , result , 0 ) ; retu... | Uncompress the input [ offset offset + length ) as a float array |
31,678 | public static String uncompressString ( byte [ ] input , int offset , int length ) throws IOException { try { return uncompressString ( input , offset , length , "UTF-8" ) ; } catch ( UnsupportedEncodingException e ) { throw new IllegalStateException ( "UTF-8 decoder is not found" ) ; } } | Uncompress the input [ offset offset + length ) as a String |
31,679 | public static String uncompressString ( byte [ ] input , int offset , int length , String encoding ) throws IOException , UnsupportedEncodingException { byte [ ] uncompressed = new byte [ uncompressedLength ( input , offset , length ) ] ; uncompress ( input , offset , length , uncompressed , 0 ) ; return new String ( u... | Uncompress the input [ offset offset + length ) as a String of the given encoding |
31,680 | public static String uncompressString ( byte [ ] input , String encoding ) throws IOException , UnsupportedEncodingException { byte [ ] uncompressed = uncompress ( input ) ; return new String ( uncompressed , encoding ) ; } | Uncompress the input as a String of the given encoding |
31,681 | public int rawRead ( Object array , int byteOffset , int byteLength ) throws IOException { int writtenBytes = 0 ; for ( ; writtenBytes < byteLength ; ) { if ( uncompressedCursor >= uncompressedLimit ) { if ( hasNextChunk ( ) ) { continue ; } else { return writtenBytes == 0 ? - 1 : writtenBytes ; } } int bytesToWrite = ... | Read uncompressed data into the specified array |
31,682 | private int readNext ( byte [ ] dest , int offset , int len ) throws IOException { int readBytes = 0 ; while ( readBytes < len ) { int ret = in . read ( dest , readBytes + offset , len - readBytes ) ; if ( ret == - 1 ) { finishedReading = true ; return readBytes ; } readBytes += ret ; } return readBytes ; } | Read next len bytes |
31,683 | public static byte [ ] shuffle ( short [ ] input ) throws IOException { byte [ ] output = new byte [ input . length * 2 ] ; int numProcessed = impl . shuffle ( input , 0 , 2 , input . length * 2 , output , 0 ) ; assert ( numProcessed == input . length * 2 ) ; return output ; } | Apply a bit - shuffling filter into the input short array . |
31,684 | public static int unshuffle ( ByteBuffer shuffled , BitShuffleType type , ByteBuffer output ) throws IOException { if ( ! shuffled . isDirect ( ) ) { throw new SnappyError ( SnappyErrorCode . NOT_A_DIRECT_BUFFER , "input is not a direct buffer" ) ; } if ( ! output . isDirect ( ) ) { throw new SnappyError ( SnappyErrorC... | Convert the input bit - shuffled byte array into an original array . The result is dumped to the specified output buffer . |
31,685 | public static short [ ] unshuffleShortArray ( byte [ ] input ) throws IOException { short [ ] output = new short [ input . length / 2 ] ; int numProcessed = impl . unshuffle ( input , 0 , 2 , input . length , output , 0 ) ; assert ( numProcessed == input . length ) ; return output ; } | Convert the input bit - shuffled byte array into an original short array . |
31,686 | public static int [ ] unshuffleIntArray ( byte [ ] input ) throws IOException { int [ ] output = new int [ input . length / 4 ] ; int numProcessed = impl . unshuffle ( input , 0 , 4 , input . length , output , 0 ) ; assert ( numProcessed == input . length ) ; return output ; } | Convert the input bit - shuffled byte array into an original int array . |
31,687 | public static long [ ] unshuffleLongArray ( byte [ ] input ) throws IOException { long [ ] output = new long [ input . length / 8 ] ; int numProcessed = impl . unshuffle ( input , 0 , 8 , input . length , output , 0 ) ; assert ( numProcessed == input . length ) ; return output ; } | Convert the input bit - shuffled byte array into an original long array . |
31,688 | public static float [ ] unshuffleFloatArray ( byte [ ] input ) throws IOException { float [ ] output = new float [ input . length / 4 ] ; int numProcessed = impl . unshuffle ( input , 0 , 4 , input . length , output , 0 ) ; assert ( numProcessed == input . length ) ; return output ; } | Convert the input bit - shuffled byte array into an original float array . |
31,689 | public static double [ ] unshuffleDoubleArray ( byte [ ] input ) throws IOException { double [ ] output = new double [ input . length / 8 ] ; int numProcessed = impl . unshuffle ( input , 0 , 8 , input . length , output , 0 ) ; assert ( numProcessed == input . length ) ; return output ; } | Convert the input bit - shuffled byte array into an original double array . |
31,690 | public void rawWrite ( Object array , int byteOffset , int byteLength ) throws IOException { if ( closed ) { throw new IOException ( "Stream is closed" ) ; } int cursor = 0 ; while ( cursor < byteLength ) { int readLen = Math . min ( byteLength - cursor , blockSize - inputCursor ) ; if ( readLen > 0 ) { Snappy . arrayC... | Compress the raw byte array data . |
31,691 | private synchronized static void loadNativeLibrary ( ) { if ( ! isLoaded ) { try { nativeLibFile = findNativeLibrary ( ) ; if ( nativeLibFile != null ) { System . load ( nativeLibFile . getAbsolutePath ( ) ) ; } else { System . loadLibrary ( "snappyjava" ) ; } } catch ( Exception e ) { e . printStackTrace ( ) ; throw n... | Load a native library of snappy - java |
31,692 | private static File extractLibraryFile ( String libFolderForCurrentOS , String libraryFileName , String targetFolder ) { String nativeLibraryFilePath = libFolderForCurrentOS + "/" + libraryFileName ; String uuid = UUID . randomUUID ( ) . toString ( ) ; String extractedLibFileName = String . format ( "snappy-%s-%s-%s" ,... | Extract the specified library file to the target folder |
31,693 | public static String getVersion ( ) { URL versionFile = SnappyLoader . class . getResource ( "/META-INF/maven/org.xerial.snappy/snappy-java/pom.properties" ) ; if ( versionFile == null ) { versionFile = SnappyLoader . class . getResource ( "/org/xerial/snappy/VERSION" ) ; } String version = "unknown" ; try { if ( versi... | Get the snappy - java version by reading pom . properties embedded in jar . This version data is used as a suffix of a dll file extracted from the jar . |
31,694 | public boolean run ( ) { otherApks . forEach ( otherApk -> { checkArgument ( otherApk . exists ( ) , "Could not find other APK: " + otherApk ) ; } ) ; checkArgument ( testApk . exists ( ) , "Could not find test APK: " + testApk ) ; AndroidDebugBridge adb = SpoonUtils . initAdb ( androidSdk , adbTimeout ) ; try { final ... | Install and execute the tests on all specified devices . |
31,695 | static String scrubModel ( String manufacturer , String model ) { if ( manufacturer == null || model == null ) { return model ; } if ( model . regionMatches ( true , 0 , manufacturer , 0 , manufacturer . length ( ) ) ) { model = model . substring ( manufacturer . length ( ) ) ; } if ( model . length ( ) > 0 && ( model ... | Scrub the model so that it does not contain redundant data . |
31,696 | static String scrubLanguage ( String language ) { if ( "ldpi" . equals ( language ) || "mdpi" . equals ( language ) || "hdpi" . equals ( language ) || "xhdpi" . equals ( language ) ) { return null ; } return language ; } | Scrub the language so it does not contain bad data . |
31,697 | public int find ( String string ) { if ( m_strings == null ) { return - 1 ; } for ( int i = 0 ; i < m_strings . length - 1 ; i ++ ) { if ( m_strings [ i ] . equals ( string ) ) { return i ; } } return - 1 ; } | Finds index of the string . Returns - 1 if the string was not found . |
31,698 | private String stringAt ( int index ) { int offset = m_stringOffsets [ index ] ; ByteBuffer buffer = ByteBuffer . wrap ( m_stringPool , offset , m_stringPool . length - offset ) . order ( ByteOrder . BIG_ENDIAN ) ; int length = decodeLength ( buffer ) ; StringBuilder stringBuilder = new StringBuilder ( ) ; for ( int i ... | Extracts a string from the string pool at the given index . |
31,699 | static SpoonInstrumentationInfo parseFromFile ( File apkTestFile ) { try ( ZipFile zip = new ZipFile ( apkTestFile ) ) { ZipEntry entry = zip . getEntry ( "AndroidManifest.xml" ) ; InputStream is = zip . getInputStream ( entry ) ; AXMLParser parser = new AXMLParser ( is ) ; int eventType = parser . getType ( ) ; String... | Parse key information from an instrumentation APK s manifest . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.