idx int64 0 165k | question stringlengths 73 4.15k | target stringlengths 5 918 | len_question int64 21 890 | len_target int64 3 255 |
|---|---|---|---|---|
21,400 | @ Nonnull public static String extractClassName ( @ Nonnull final String canonicalJavaClassName ) { final int lastDot = canonicalJavaClassName . lastIndexOf ( ' ' ) ; if ( lastDot < 0 ) { return canonicalJavaClassName . trim ( ) ; } return canonicalJavaClassName . substring ( lastDot + 1 ) . trim ( ) ; } | Extract class name from canonical Java class name | 81 | 9 |
21,401 | @ Nonnull public static String extractPackageName ( @ Nonnull final String fileNameWithoutExtension ) { final int lastDot = fileNameWithoutExtension . lastIndexOf ( ' ' ) ; if ( lastDot < 0 ) { return "" ; } return fileNameWithoutExtension . substring ( 0 , lastDot ) . trim ( ) ; } | Extract package name from canonical Java class name | 77 | 9 |
21,402 | @ Nonnull public static File scriptFileToJavaFile ( @ Nullable final File targetDir , @ Nullable final String classPackage , @ Nonnull final File scriptFile ) { final String rawFileName = FilenameUtils . getBaseName ( scriptFile . getName ( ) ) ; final String className = CommonUtils . extractClassName ( rawFileName ) ; final String packageName = classPackage == null ? CommonUtils . extractPackageName ( rawFileName ) : classPackage ; String fullClassName = packageName . isEmpty ( ) ? className : packageName + ' ' + className ; fullClassName = fullClassName . replace ( ' ' , File . separatorChar ) + ".java" ; return new File ( targetDir , fullClassName ) ; } | Convert script file into path to Java class file . | 167 | 11 |
21,403 | public static byte [ ] strToUtf8 ( final String str ) { final ByteBuffer buffer = CHARSET_UTF8 . encode ( str ) ; final byte [ ] bytesArray = new byte [ buffer . remaining ( ) ] ; buffer . get ( bytesArray , 0 , bytesArray . length ) ; return bytesArray ; } | Convert a string into its UTF8 representation . | 70 | 10 |
21,404 | public static boolean isNumber ( final String num ) { if ( num == null || num . length ( ) == 0 ) { return false ; } final boolean firstIsDigit = Character . isDigit ( num . charAt ( 0 ) ) ; if ( ! firstIsDigit && num . charAt ( 0 ) != ' ' ) { return false ; } boolean dig = firstIsDigit ; for ( int i = 1 ; i < num . length ( ) ; i ++ ) { if ( ! Character . isDigit ( num . charAt ( i ) ) ) { return false ; } dig = true ; } return dig ; } | Check that a string is a number . | 135 | 8 |
21,405 | public static byte [ ] packInt ( final int value ) { if ( ( value & 0xFFFFFF80 ) == 0 ) { return new byte [ ] { ( byte ) value } ; } else if ( ( value & 0xFFFF0000 ) == 0 ) { return new byte [ ] { ( byte ) 0x80 , ( byte ) ( value >>> 8 ) , ( byte ) value } ; } else { return new byte [ ] { ( byte ) 0x81 , ( byte ) ( value >>> 24 ) , ( byte ) ( value >>> 16 ) , ( byte ) ( value >>> 8 ) , ( byte ) value } ; } } | Pack an integer value as a byte array . | 135 | 9 |
21,406 | public static int packInt ( final byte [ ] array , final JBBPIntCounter position , final int value ) { if ( ( value & 0xFFFFFF80 ) == 0 ) { array [ position . getAndIncrement ( ) ] = ( byte ) value ; return 1 ; } else if ( ( value & 0xFFFF0000 ) == 0 ) { array [ position . getAndIncrement ( ) ] = ( byte ) 0x80 ; array [ position . getAndIncrement ( ) ] = ( byte ) ( value >>> 8 ) ; array [ position . getAndIncrement ( ) ] = ( byte ) value ; return 3 ; } array [ position . getAndIncrement ( ) ] = ( byte ) 0x81 ; array [ position . getAndIncrement ( ) ] = ( byte ) ( value >>> 24 ) ; array [ position . getAndIncrement ( ) ] = ( byte ) ( value >>> 16 ) ; array [ position . getAndIncrement ( ) ] = ( byte ) ( value >>> 8 ) ; array [ position . getAndIncrement ( ) ] = ( byte ) value ; return 5 ; } | Pack an integer value and save that into a byte array since defined position . | 240 | 15 |
21,407 | public static int unpackInt ( final byte [ ] array , final JBBPIntCounter position ) { final int code = array [ position . getAndIncrement ( ) ] & 0xFF ; if ( code < 0x80 ) { return code ; } final int result ; switch ( code ) { case 0x80 : { result = ( ( array [ position . getAndIncrement ( ) ] & 0xFF ) << 8 ) | ( array [ position . getAndIncrement ( ) ] & 0xFF ) ; } break ; case 0x81 : { result = ( ( array [ position . getAndIncrement ( ) ] & 0xFF ) << 24 ) | ( ( array [ position . getAndIncrement ( ) ] & 0xFF ) << 16 ) | ( ( array [ position . getAndIncrement ( ) ] & 0xFF ) << 8 ) | ( array [ position . getAndIncrement ( ) ] & 0xFF ) ; } break ; default : throw new IllegalArgumentException ( "Unsupported packed integer prefix [0x" + Integer . toHexString ( code ) . toUpperCase ( Locale . ENGLISH ) + ' ' ) ; } return result ; } | Unpack an integer value from defined position in a byte array . | 262 | 13 |
21,408 | public static String byteArray2String ( final byte [ ] array , final String prefix , final String delimiter , final boolean brackets , final int radix ) { if ( array == null ) { return null ; } final int maxlen = Integer . toString ( 0xFF , radix ) . length ( ) ; final String zero = "00000000" ; final String normDelim = delimiter == null ? " " : delimiter ; final String normPrefix = prefix == null ? "" : prefix ; final StringBuilder result = new StringBuilder ( array . length * 4 ) ; if ( brackets ) { result . append ( ' ' ) ; } boolean nofirst = false ; for ( final byte b : array ) { if ( nofirst ) { result . append ( normDelim ) ; } else { nofirst = true ; } result . append ( normPrefix ) ; final String v = Integer . toString ( b & 0xFF , radix ) ; if ( v . length ( ) < maxlen ) { result . append ( zero , 0 , maxlen - v . length ( ) ) ; } result . append ( v . toUpperCase ( Locale . ENGLISH ) ) ; } if ( brackets ) { result . append ( ' ' ) ; } return result . toString ( ) ; } | Convert a byte array into string representation | 277 | 8 |
21,409 | public static byte reverseBitsInByte ( final JBBPBitNumber bitNumber , final byte value ) { final byte reversed = reverseBitsInByte ( value ) ; return ( byte ) ( ( reversed >>> ( 8 - bitNumber . getBitNumber ( ) ) ) & bitNumber . getMask ( ) ) ; } | Reverse lower part of a byte defined by bits number constant . | 68 | 14 |
21,410 | public static String bin2str ( final byte [ ] values , final JBBPBitOrder bitOrder , final boolean separateBytes ) { if ( values == null ) { return null ; } final StringBuilder result = new StringBuilder ( values . length * ( separateBytes ? 9 : 8 ) ) ; boolean nofirst = false ; for ( final byte b : values ) { if ( separateBytes ) { if ( nofirst ) { result . append ( ' ' ) ; } else { nofirst = true ; } } int a = b ; if ( bitOrder == JBBPBitOrder . MSB0 ) { for ( int i = 0 ; i < 8 ; i ++ ) { result . append ( ( a & 0x1 ) == 0 ? ' ' : ' ' ) ; a >>= 1 ; } } else { for ( int i = 0 ; i < 8 ; i ++ ) { result . append ( ( a & 0x80 ) == 0 ? ' ' : ' ' ) ; a <<= 1 ; } } } return result . toString ( ) ; } | Convert a byte array into string binary representation with defined bit order and possibility to separate bytes . | 226 | 19 |
21,411 | public static List < JBBPAbstractField > fieldsAsList ( final JBBPAbstractField ... fields ) { final List < JBBPAbstractField > result = new ArrayList <> ( ) ; Collections . addAll ( result , fields ) ; return result ; } | Convert array of JBBP fields into a list . | 60 | 12 |
21,412 | public static String [ ] splitString ( final String str , final char splitChar ) { final int length = str . length ( ) ; final StringBuilder bulder = new StringBuilder ( Math . max ( 8 , length ) ) ; int counter = 1 ; for ( int i = 0 ; i < length ; i ++ ) { if ( str . charAt ( i ) == splitChar ) { counter ++ ; } } final String [ ] result = new String [ counter ] ; int position = 0 ; for ( int i = 0 ; i < length ; i ++ ) { final char chr = str . charAt ( i ) ; if ( chr == splitChar ) { result [ position ++ ] = bulder . toString ( ) ; bulder . setLength ( 0 ) ; } else { bulder . append ( chr ) ; } } if ( position < result . length ) { result [ position ] = bulder . toString ( ) ; } return result ; } | Split a string for a char used as the delimeter . | 205 | 12 |
21,413 | public static void assertNotNull ( final Object object , final String message ) { if ( object == null ) { throw new NullPointerException ( message == null ? "Object is null" : message ) ; } } | Check that an object is null and throw NullPointerException in the case . | 45 | 16 |
21,414 | public static String int2msg ( final int number ) { return number + " (0x" + Long . toHexString ( ( long ) number & 0xFFFFFFFF L ) . toUpperCase ( Locale . ENGLISH ) + ' ' ; } | Convert an integer number into human readable hexadecimal format . | 57 | 14 |
21,415 | public static String normalizeFieldNameOrPath ( final String nameOrPath ) { assertNotNull ( nameOrPath , "Name of path must not be null" ) ; return nameOrPath . trim ( ) . toLowerCase ( Locale . ENGLISH ) ; } | Normalize field name or path . | 58 | 7 |
21,416 | public static byte [ ] str2UnicodeByteArray ( final JBBPByteOrder byteOrder , final String str ) { final byte [ ] result = new byte [ str . length ( ) << 1 ] ; int index = 0 ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { final int val = str . charAt ( i ) ; switch ( byteOrder ) { case BIG_ENDIAN : { result [ index ++ ] = ( byte ) ( val >> 8 ) ; result [ index ++ ] = ( byte ) val ; } break ; case LITTLE_ENDIAN : { result [ index ++ ] = ( byte ) val ; result [ index ++ ] = ( byte ) ( val >> 8 ) ; } break ; default : throw new Error ( "Unexpected byte order [" + byteOrder + ' ' ) ; } } return result ; } | Convert chars of a string into a byte array contains the unicode codes . | 187 | 16 |
21,417 | public static byte [ ] reverseArray ( final byte [ ] nullableArrayToBeInverted ) { if ( nullableArrayToBeInverted != null && nullableArrayToBeInverted . length > 0 ) { int indexStart = 0 ; int indexEnd = nullableArrayToBeInverted . length - 1 ; while ( indexStart < indexEnd ) { final byte a = nullableArrayToBeInverted [ indexStart ] ; nullableArrayToBeInverted [ indexStart ] = nullableArrayToBeInverted [ indexEnd ] ; nullableArrayToBeInverted [ indexEnd ] = a ; indexStart ++ ; indexEnd -- ; } } return nullableArrayToBeInverted ; } | Reverse order of bytes in a byte array . | 151 | 11 |
21,418 | public static byte [ ] splitInteger ( final int value , final boolean valueInLittleEndian , final byte [ ] buffer ) { final byte [ ] result ; if ( buffer == null || buffer . length < 4 ) { result = new byte [ 4 ] ; } else { result = buffer ; } int tmpvalue = value ; if ( valueInLittleEndian ) { for ( int i = 0 ; i < 4 ; i ++ ) { result [ i ] = ( byte ) tmpvalue ; tmpvalue >>>= 8 ; } } else { for ( int i = 3 ; i >= 0 ; i -- ) { result [ i ] = ( byte ) tmpvalue ; tmpvalue >>>= 8 ; } } return result ; } | Split an integer value to bytes and returns as a byte array . | 151 | 13 |
21,419 | public static byte [ ] concat ( final byte [ ] ... arrays ) { int len = 0 ; for ( final byte [ ] arr : arrays ) { len += arr . length ; } final byte [ ] result = new byte [ len ] ; int pos = 0 ; for ( final byte [ ] arr : arrays ) { System . arraycopy ( arr , 0 , result , pos , arr . length ) ; pos += arr . length ; } return result ; } | Concatenate byte arrays into one byte array sequentially . | 96 | 13 |
21,420 | public static long reverseByteOrder ( long value , int numOfLowerBytesToInvert ) { if ( numOfLowerBytesToInvert < 1 || numOfLowerBytesToInvert > 8 ) { throw new IllegalArgumentException ( "Wrong number of bytes [" + numOfLowerBytesToInvert + ' ' ) ; } long result = 0 ; int offsetInResult = ( numOfLowerBytesToInvert - 1 ) * 8 ; while ( numOfLowerBytesToInvert -- > 0 ) { final long thebyte = value & 0xFF ; value >>>= 8 ; result |= ( thebyte << offsetInResult ) ; offsetInResult -= 8 ; } return result ; } | Revert order for defined number of bytes in a value . | 148 | 13 |
21,421 | public static String double2str ( final double doubleValue , final int radix ) { if ( radix != 10 && radix != 16 ) { throw new IllegalArgumentException ( "Illegal radix [" + radix + ' ' ) ; } final String result ; if ( radix == 16 ) { String converted = Double . toHexString ( doubleValue ) ; boolean minus = converted . startsWith ( "-" ) ; if ( minus ) { converted = converted . substring ( 1 ) ; } if ( converted . startsWith ( "0x" ) ) { converted = converted . substring ( 2 ) ; } result = ( minus ? ' ' + converted : converted ) . toUpperCase ( Locale . ENGLISH ) ; } else { result = Double . toString ( doubleValue ) ; } return result ; } | Convert double value into string representation with defined radix base . | 177 | 13 |
21,422 | public static String float2str ( final float floatValue , final int radix ) { if ( radix != 10 && radix != 16 ) { throw new IllegalArgumentException ( "Illegal radix [" + radix + ' ' ) ; } final String result ; if ( radix == 16 ) { String converted = Double . toHexString ( floatValue ) ; boolean minus = converted . startsWith ( "-" ) ; if ( minus ) { converted = converted . substring ( 1 ) ; } if ( converted . startsWith ( "0x" ) ) { converted = converted . substring ( 2 ) ; } result = ( minus ? ' ' + converted : converted ) . toUpperCase ( Locale . ENGLISH ) ; } else { result = Double . toString ( floatValue ) ; } return result ; } | Convert float value into string representation with defined radix base . | 177 | 13 |
21,423 | public static String ulong2str ( final long ulongValue , final int radix , final char [ ] charBuffer ) { if ( radix < 2 || radix > 36 ) { throw new IllegalArgumentException ( "Illegal radix [" + radix + ' ' ) ; } if ( ulongValue == 0 ) { return "0" ; } else { final String result ; if ( ulongValue > 0 ) { result = Long . toString ( ulongValue , radix ) . toUpperCase ( Locale . ENGLISH ) ; } else { final char [ ] buffer = charBuffer == null || charBuffer . length < 64 ? new char [ 64 ] : charBuffer ; int pos = buffer . length ; long topPart = ulongValue >>> 32 ; long bottomPart = ( ulongValue & 0xFFFFFFFF L ) + ( ( topPart % radix ) << 32 ) ; topPart /= radix ; while ( ( bottomPart | topPart ) > 0 ) { final int val = ( int ) ( bottomPart % radix ) ; buffer [ -- pos ] = ( char ) ( val < 10 ? ' ' + val : ' ' + val - 10 ) ; bottomPart = ( bottomPart / radix ) + ( ( topPart % radix ) << 32 ) ; topPart /= radix ; } result = new String ( buffer , pos , buffer . length - pos ) ; } return result ; } } | Convert unsigned long value into string representation with defined radix base . | 310 | 14 |
21,424 | public static String ensureMinTextLength ( final String text , final int neededLen , final char ch , final int mode ) { final int number = neededLen - text . length ( ) ; if ( number <= 0 ) { return text ; } final StringBuilder result = new StringBuilder ( neededLen ) ; switch ( mode ) { case 0 : { for ( int i = 0 ; i < number ; i ++ ) { result . append ( ch ) ; } result . append ( text ) ; } break ; case 1 : { result . append ( text ) ; for ( int i = 0 ; i < number ; i ++ ) { result . append ( ch ) ; } } break ; default : { int leftField = number / 2 ; int rightField = number - leftField ; while ( leftField -- > 0 ) { result . append ( ch ) ; } result . append ( text ) ; while ( rightField -- > 0 ) { result . append ( ch ) ; } } break ; } return result . toString ( ) ; } | Extend text by chars to needed length . | 216 | 9 |
21,425 | public static String removeLeadingZeros ( final String str ) { String result = str ; if ( str != null && str . length ( ) != 0 ) { int startIndex = 0 ; while ( startIndex < str . length ( ) - 1 ) { final char ch = str . charAt ( startIndex ) ; if ( ch != ' ' ) { break ; } startIndex ++ ; } if ( startIndex > 0 ) { result = str . substring ( startIndex ) ; } } return result ; } | Remove leading zeros from string . | 108 | 7 |
21,426 | public static String removeTrailingZeros ( final String str ) { String result = str ; if ( str != null && str . length ( ) != 0 ) { int endIndex = str . length ( ) ; while ( endIndex > 1 ) { final char ch = str . charAt ( endIndex - 1 ) ; if ( ch != ' ' ) { break ; } endIndex -- ; } if ( endIndex < str . length ( ) ) { result = str . substring ( 0 , endIndex ) ; } } return result ; } | Remove trailing zeros from string . | 114 | 7 |
21,427 | public static boolean arrayStartsWith ( final byte [ ] array , final byte [ ] str ) { boolean result = false ; if ( array . length >= str . length ) { result = true ; int index = str . length ; while ( -- index >= 0 ) { if ( array [ index ] != str [ index ] ) { result = false ; break ; } } } return result ; } | Check that a byte array starts with some byte values . | 82 | 11 |
21,428 | public static boolean arrayEndsWith ( final byte [ ] array , final byte [ ] str ) { boolean result = false ; if ( array . length >= str . length ) { result = true ; int index = str . length ; int arrindex = array . length ; while ( -- index >= 0 ) { if ( array [ -- arrindex ] != str [ index ] ) { result = false ; break ; } } } return result ; } | Check that a byte array ends with some byte values . | 92 | 11 |
21,429 | private JBBPTokenizerException checkFieldName ( final String name , final int position ) { if ( name != null ) { final String normalized = JBBPUtils . normalizeFieldNameOrPath ( name ) ; if ( normalized . indexOf ( ' ' ) >= 0 ) { return new JBBPTokenizerException ( "Field name must not contain '.' char" , position ) ; } if ( normalized . length ( ) > 0 ) { if ( normalized . equals ( "_" ) || normalized . equals ( "$$" ) || normalized . startsWith ( "$" ) || Character . isDigit ( normalized . charAt ( 0 ) ) ) { return new JBBPTokenizerException ( "'" + name + "' can't be field name" , position ) ; } for ( int i = 1 ; i < normalized . length ( ) ; i ++ ) { final char chr = normalized . charAt ( i ) ; if ( chr != ' ' && ! Character . isLetterOrDigit ( chr ) ) { return new JBBPTokenizerException ( "Char '" + chr + "' not allowed in name" , position ) ; } } } } return null ; } | Check a field name | 255 | 4 |
21,430 | public static int findIndexForFieldPath ( final String fieldPath , final List < JBBPNamedFieldInfo > namedFields ) { final String normalized = JBBPUtils . normalizeFieldNameOrPath ( fieldPath ) ; int result = - 1 ; for ( int i = namedFields . size ( ) - 1 ; i >= 0 ; i -- ) { final JBBPNamedFieldInfo f = namedFields . get ( i ) ; if ( normalized . equals ( f . getFieldPath ( ) ) ) { result = i ; break ; } } return result ; } | Find a named field info index in a list for its path . | 125 | 13 |
21,431 | public static void assertFieldIsNotArrayOrInArray ( final JBBPNamedFieldInfo fieldToCheck , final List < JBBPNamedFieldInfo > namedFieldList , final byte [ ] compiledScript ) { // check that the field is not array if ( ( compiledScript [ fieldToCheck . getFieldOffsetInCompiledBlock ( ) ] & FLAG_ARRAY ) != 0 ) { throw new JBBPCompilationException ( "An Array field can't be used as array size [" + fieldToCheck . getFieldPath ( ) + ' ' ) ; } if ( fieldToCheck . getFieldPath ( ) . indexOf ( ' ' ) >= 0 ) { // the field in structure, check that the structure is not an array or not in an array final String [ ] splittedFieldPath = JBBPUtils . splitString ( fieldToCheck . getFieldPath ( ) , ' ' ) ; final StringBuilder fieldPath = new StringBuilder ( ) ; // process till the field name because we have already checked the field for ( int i = 0 ; i < splittedFieldPath . length - 1 ; i ++ ) { if ( fieldPath . length ( ) != 0 ) { fieldPath . append ( ' ' ) ; } fieldPath . append ( splittedFieldPath [ i ] ) ; final JBBPNamedFieldInfo structureEnd = JBBPCompilerUtils . findForFieldPath ( fieldPath . toString ( ) , namedFieldList ) ; if ( ( compiledScript [ structureEnd . getFieldOffsetInCompiledBlock ( ) ] & FLAG_ARRAY ) != 0 ) { throw new JBBPCompilationException ( "Field from structure array can't be use as array size [" + fieldToCheck . getFieldPath ( ) + ' ' + structureEnd . getFieldPath ( ) + ' ' ) ; } } } } | Check a field in a compiled list defined by its named field info that the field is not an array and it is not inside a structure array . | 396 | 29 |
21,432 | private static int codeToUnary ( final int code ) { final int result ; switch ( code ) { case CODE_MINUS : result = CODE_UNARYMINUS ; break ; case CODE_ADD : result = CODE_UNARYPLUS ; break ; default : result = code ; break ; } return result ; } | Encode code of an operator to code of similar unary operator . | 68 | 14 |
21,433 | public static boolean hasExpressionOperators ( final String str ) { boolean result = false ; for ( final char chr : OPERATOR_FIRST_CHARS ) { if ( str . indexOf ( chr ) >= 0 ) { result = true ; break ; } } return result ; } | Check that a string has a char of operators . | 62 | 10 |
21,434 | private void assertUnaryOperator ( final String operator ) { if ( ! ( "+" . equals ( operator ) || "-" . equals ( operator ) || "~" . equals ( operator ) ) ) { throw new JBBPCompilationException ( "Wrong unary operator '" + operator + "' [" + this . expressionSource + ' ' ) ; } } | Check that a string represents a unary operator . | 78 | 10 |
21,435 | public JavaSrcTextBuffer printf ( final String text , final Object ... args ) { this . buffer . append ( String . format ( text , args ) ) ; return this ; } | Formatted print . | 38 | 4 |
21,436 | public JavaSrcTextBuffer printLinesWithIndent ( final String text ) { final String [ ] splitted = text . split ( "\n" , - 1 ) ; for ( final String aSplitted : splitted ) { this . indent ( ) . println ( aSplitted ) ; } return this ; } | Parse string to lines and print each line with current indent | 67 | 12 |
21,437 | public Integer getArraySizeAsInt ( ) { if ( this . arraySize == null ) { throw new NullPointerException ( "Array size is not defined" ) ; } try { return Integer . valueOf ( this . arraySize . trim ( ) ) ; } catch ( NumberFormatException ex ) { return null ; } } | Get numeric representation of the array size . | 69 | 8 |
21,438 | public Object extractFieldValue ( final Object instance , final Field field ) { JBBPUtils . assertNotNull ( field , "Field must not be null" ) ; try { return ReflectUtils . makeAccessible ( field ) . get ( instance ) ; } catch ( Exception ex ) { throw new JBBPException ( "Can't extract value from field for exception" , ex ) ; } } | Auxiliary method to extract field value . | 85 | 9 |
21,439 | public JBBPClassInstantiator make ( final JBBPClassInstantiatorType type ) { JBBPUtils . assertNotNull ( type , "Type must not be null" ) ; String className = "com.igormaznitsa.jbbp.mapper.instantiators.JBBPSafeInstantiator" ; switch ( type ) { case AUTO : { final String customClassName = JBBPSystemProperty . PROPERTY_INSTANTIATOR_CLASS . getAsString ( null ) ; if ( customClassName == null ) { try { final Class < ? > unsafeclazz = Class . forName ( "sun.misc.Unsafe" ) ; unsafeclazz . getDeclaredField ( "theUnsafe" ) ; className = "com.igormaznitsa.jbbp.mapper.instantiators.JBBPUnsafeInstantiator" ; } catch ( ClassNotFoundException | NoSuchFieldException | SecurityException ex ) { // do nothing } } else { className = customClassName ; } } break ; case SAFE : { className = "com.igormaznitsa.jbbp.mapper.instantiators.JBBPSafeInstantiator" ; } break ; case UNSAFE : { className = "com.igormaznitsa.jbbp.mapper.instantiators.JBBPUnsafeInstantiator" ; } break ; default : throw new Error ( "Unexpected type, contact developer! [" + type + ' ' ) ; } return ( JBBPClassInstantiator ) ReflectUtils . newInstanceForClassName ( className ) ; } | Make an instantiator for defined type . | 370 | 8 |
21,440 | public void writeShort ( final int value , final JBBPByteOrder byteOrder ) throws IOException { if ( byteOrder == JBBPByteOrder . BIG_ENDIAN ) { this . write ( value >>> 8 ) ; this . write ( value ) ; } else { this . write ( value ) ; this . write ( value >>> 8 ) ; } } | Write a signed short value into the output stream . | 76 | 10 |
21,441 | public void writeInt ( final int value , final JBBPByteOrder byteOrder ) throws IOException { if ( byteOrder == JBBPByteOrder . BIG_ENDIAN ) { this . writeShort ( value >>> 16 , byteOrder ) ; this . writeShort ( value , byteOrder ) ; } else { this . writeShort ( value , byteOrder ) ; this . writeShort ( value >>> 16 , byteOrder ) ; } } | Write an integer value into the output stream . | 92 | 9 |
21,442 | public void writeFloat ( final float value , final JBBPByteOrder byteOrder ) throws IOException { final int intValue = Float . floatToIntBits ( value ) ; if ( byteOrder == JBBPByteOrder . BIG_ENDIAN ) { this . writeShort ( intValue >>> 16 , byteOrder ) ; this . writeShort ( intValue , byteOrder ) ; } else { this . writeShort ( intValue , byteOrder ) ; this . writeShort ( intValue >>> 16 , byteOrder ) ; } } | Write an float value into the output stream . | 112 | 9 |
21,443 | public void writeLong ( final long value , final JBBPByteOrder byteOrder ) throws IOException { if ( byteOrder == JBBPByteOrder . BIG_ENDIAN ) { this . writeInt ( ( int ) ( value >>> 32 ) , byteOrder ) ; this . writeInt ( ( int ) value , byteOrder ) ; } else { this . writeInt ( ( int ) value , byteOrder ) ; this . writeInt ( ( int ) ( value >>> 32 ) , byteOrder ) ; } } | Write a long value into the output stream . | 108 | 9 |
21,444 | public void writeDouble ( final double value , final JBBPByteOrder byteOrder ) throws IOException { final long longValue = Double . doubleToLongBits ( value ) ; if ( byteOrder == JBBPByteOrder . BIG_ENDIAN ) { this . writeInt ( ( int ) ( longValue >>> 32 ) , byteOrder ) ; this . writeInt ( ( int ) longValue , byteOrder ) ; } else { this . writeInt ( ( int ) longValue , byteOrder ) ; this . writeInt ( ( int ) ( longValue >>> 32 ) , byteOrder ) ; } } | Write a double value into the output stream . | 128 | 9 |
21,445 | public void writeBits ( final int value , final JBBPBitNumber bitNumber ) throws IOException { if ( this . bitBufferCount == 0 && bitNumber == JBBPBitNumber . BITS_8 ) { write ( value ) ; } else { final int initialMask ; int mask ; initialMask = 1 ; mask = initialMask << this . bitBufferCount ; int accum = value ; int i = bitNumber . getBitNumber ( ) ; while ( i > 0 ) { this . bitBuffer = this . bitBuffer | ( ( accum & 1 ) == 0 ? 0 : mask ) ; accum >>= 1 ; mask = mask << 1 ; i -- ; this . bitBufferCount ++ ; if ( this . bitBufferCount == 8 ) { this . bitBufferCount = 0 ; writeByte ( this . bitBuffer ) ; mask = initialMask ; this . bitBuffer = 0 ; } } } } | Write bits into the output stream . | 193 | 7 |
21,446 | public void align ( final long alignByteNumber ) throws IOException { if ( this . bitBufferCount > 0 ) { this . writeBits ( 0 , JBBPBitNumber . decode ( 8 - this . bitBufferCount ) ) ; } if ( alignByteNumber > 0 ) { long padding = ( alignByteNumber - ( this . byteCounter % alignByteNumber ) ) % alignByteNumber ; while ( padding > 0 ) { this . out . write ( 0 ) ; this . byteCounter ++ ; padding -- ; } } } | Write padding bytes to align the stream counter for the border . | 113 | 12 |
21,447 | private void writeByte ( int value ) throws IOException { if ( this . msb0 ) { value = JBBPUtils . reverseBitsInByte ( ( byte ) value ) & 0xFF ; } this . out . write ( value ) ; this . byteCounter ++ ; } | Inside method to write a byte into wrapped stream . | 62 | 10 |
21,448 | public void writeBytes ( final byte [ ] array , final int length , final JBBPByteOrder byteOrder ) throws IOException { if ( byteOrder == JBBPByteOrder . LITTLE_ENDIAN ) { int i = length < 0 ? array . length - 1 : length - 1 ; while ( i >= 0 ) { this . write ( array [ i -- ] ) ; } } else { this . write ( array , 0 , length < 0 ? array . length : length ) ; } } | Write number of items from byte array into stream | 107 | 9 |
21,449 | public Object mapTo ( final Object objectToMap , final JBBPMapperCustomFieldProcessor customFieldProcessor ) { return JBBPMapper . map ( this , objectToMap , customFieldProcessor ) ; } | Map the structure fields to object fields . | 47 | 8 |
21,450 | public String getExtraDataExpression ( ) { String result = null ; if ( hasExpressionAsExtraData ( ) ) { result = this . extraData . substring ( 1 , this . extraData . length ( ) - 1 ) ; } return result ; } | Extract expression for extra data . | 56 | 7 |
21,451 | public void putField ( final JBBPNumericField field ) { JBBPUtils . assertNotNull ( field , "Field must not be null" ) ; final JBBPNamedFieldInfo fieldName = field . getNameInfo ( ) ; JBBPUtils . assertNotNull ( fieldName , "Field name info must not be null" ) ; this . fieldMap . put ( fieldName , field ) ; } | Put a numeric field into map . | 91 | 7 |
21,452 | public JBBPNumericField remove ( final JBBPNamedFieldInfo nameInfo ) { JBBPUtils . assertNotNull ( nameInfo , "Name info must not be null" ) ; return this . fieldMap . remove ( nameInfo ) ; } | Remove a field for its field name info descriptor . | 55 | 10 |
21,453 | public JBBPNumericField findForFieldOffset ( final int offset ) { JBBPNumericField result = null ; for ( final Map . Entry < JBBPNamedFieldInfo , JBBPNumericField > f : fieldMap . entrySet ( ) ) { if ( f . getKey ( ) . getFieldOffsetInCompiledBlock ( ) == offset ) { result = f . getValue ( ) ; break ; } } return result ; } | Find a registered field for its field offset in compiled script . | 95 | 12 |
21,454 | public int getExternalFieldValue ( final String externalFieldName , final JBBPCompiledBlock compiledBlock , final JBBPIntegerValueEvaluator evaluator ) { final String normalizedName = JBBPUtils . normalizeFieldNameOrPath ( externalFieldName ) ; if ( this . externalValueProvider == null ) { throw new JBBPEvalException ( "Request for '" + externalFieldName + "' but there is not any value provider" , evaluator ) ; } else { return this . externalValueProvider . provideArraySize ( normalizedName , this , compiledBlock ) ; } } | Ask the registered external value provider for a field value . | 130 | 11 |
21,455 | private static Object readFieldValue ( final Object obj , final Field field ) { try { return field . get ( obj ) ; } catch ( Exception ex ) { throw new JBBPException ( "Can't get value from field [" + field + ' ' , ex ) ; } } | Inside auxiliary method to read object field value . | 59 | 9 |
21,456 | protected void onFieldCustom ( final Object obj , final Field field , final Bin annotation , final Object customFieldProcessor , final Object value ) { } | Notification about custom field . | 31 | 6 |
21,457 | protected void onFieldBits ( final Object obj , final Field field , final Bin annotation , final JBBPBitNumber bitNumber , final int value ) { } | Notification about bit field . | 34 | 6 |
21,458 | public void resetInsideClassCache ( ) { final Map < Class < ? > , Field [ ] > fieldz = cachedClasses ; if ( fieldz != null ) { synchronized ( fieldz ) { fieldz . clear ( ) ; } } } | Inside JBBPOut . Bin command creates cached list of fields of a saved class the method allows to reset the inside cache . | 52 | 26 |
21,459 | public static JBBPTextWriter makeStrWriter ( ) { final String lineSeparator = System . setProperty ( "line.separator" , "\n" ) ; return new JBBPTextWriter ( new StringWriter ( ) , JBBPByteOrder . BIG_ENDIAN , lineSeparator , 16 , "0x" , "." , ";" , "~" , "," ) ; } | Auxiliary method allows to build writer over StringWriter with system - depended next line and hex radix . The Method allows fast instance create . | 89 | 29 |
21,460 | private void ensureValueMode ( ) throws IOException { switch ( this . mode ) { case MODE_START_LINE : { changeMode ( MODE_VALUES ) ; for ( final Extra e : extras ) { e . onBeforeFirstValue ( this ) ; } writeIndent ( ) ; this . write ( this . prefixFirtValueAtLine ) ; } break ; case MODE_COMMENTS : { this . BR ( ) ; writeIndent ( ) ; changeMode ( MODE_VALUES ) ; for ( final Extra e : extras ) { e . onBeforeFirstValue ( this ) ; } this . write ( this . prefixFirtValueAtLine ) ; } break ; case MODE_VALUES : break ; default : throw new Error ( "Unexpected state" ) ; } } | Ensure the value mode . | 172 | 6 |
21,461 | private void ensureCommentMode ( ) throws IOException { switch ( this . mode ) { case MODE_START_LINE : writeIndent ( ) ; this . prevLineCommentsStartPosition = this . linePosition ; this . write ( this . prefixComment ) ; changeMode ( MODE_COMMENTS ) ; break ; case MODE_VALUES : { this . prevLineCommentsStartPosition = this . linePosition ; this . write ( this . prefixComment ) ; changeMode ( MODE_COMMENTS ) ; } break ; case MODE_COMMENTS : { BR ( ) ; writeIndent ( ) ; while ( this . linePosition < this . prevLineCommentsStartPosition ) { this . write ( ' ' ) ; } this . write ( this . prefixComment ) ; } break ; default : throw new Error ( "Unexpected state" ) ; } } | Ensure the comment mode . | 183 | 6 |
21,462 | private void printValueString ( final String value ) throws IOException { if ( this . valuesLineCounter > 0 && this . valueSeparator . length ( ) > 0 ) { this . write ( this . valueSeparator ) ; } if ( this . prefixValue . length ( ) > 0 ) { this . write ( this . prefixValue ) ; } this . write ( value ) ; if ( this . postfixValue . length ( ) > 0 ) { this . write ( this . postfixValue ) ; } this . valuesLineCounter ++ ; if ( this . maxValuesPerLine > 0 && this . valuesLineCounter >= this . maxValuesPerLine ) { for ( final Extra e : this . extras ) { e . onReachedMaxValueNumberForLine ( this ) ; } ensureNewLineMode ( ) ; } } | Print a value represented by its string . | 177 | 8 |
21,463 | public JBBPTextWriter Str ( final String ... str ) throws IOException { JBBPUtils . assertNotNull ( str , "String must not be null" ) ; final String oldPrefix = this . prefixValue ; final String oldPostfix = this . postfixValue ; this . prefixValue = "" ; this . postfixValue = "" ; for ( final String s : str ) { ensureValueMode ( ) ; printValueString ( s == null ? "<NULL>" : s ) ; } this . prefixValue = oldPrefix ; this . postfixValue = oldPostfix ; return this ; } | Print string values . | 130 | 4 |
21,464 | public JBBPTextWriter Byte ( final int value ) throws IOException { ensureValueMode ( ) ; String convertedByExtras = null ; for ( final Extra e : this . extras ) { convertedByExtras = e . doConvertByteToStr ( this , value & 0xFF ) ; if ( convertedByExtras != null ) { break ; } } if ( convertedByExtras == null ) { printValueString ( JBBPUtils . ensureMinTextLength ( JBBPUtils . ulong2str ( value & 0xFF , this . radix , CHAR_BUFFER ) , this . maxCharsRadixForByte , ' ' , 0 ) ) ; } else { printValueString ( convertedByExtras ) ; } return this ; } | Print byte value . | 166 | 4 |
21,465 | public JBBPTextWriter Byte ( final String value ) throws IOException { for ( int i = 0 ; i < value . length ( ) ; i ++ ) { this . Byte ( value . charAt ( i ) ) ; } return this ; } | Print byte array defined as string . | 53 | 7 |
21,466 | public JBBPTextWriter Byte ( final byte [ ] array , int off , int len ) throws IOException { ensureValueMode ( ) ; while ( len -- > 0 ) { Byte ( array [ off ++ ] ) ; } return this ; } | Print values from byte array . | 52 | 6 |
21,467 | public JBBPTextWriter AddExtras ( final Extra ... extras ) { JBBPUtils . assertNotNull ( extras , "Extras must not be null" ) ; for ( final Extra e : extras ) { JBBPUtils . assertNotNull ( e , "Extras must not be null" ) ; this . extras . add ( 0 , e ) ; } return this ; } | Add extras to context . | 85 | 5 |
21,468 | public JBBPTextWriter DelExtras ( final Extra ... extras ) { JBBPUtils . assertNotNull ( extras , "Extras must not be null" ) ; for ( final Extra e : extras ) { JBBPUtils . assertNotNull ( e , "Extras must not be null" ) ; this . extras . remove ( e ) ; } return this ; } | Remove extras from context | 83 | 4 |
21,469 | public JBBPTextWriter SetTabSpaces ( final int numberOfSpacesPerTab ) { if ( numberOfSpacesPerTab <= 0 ) { throw new IllegalArgumentException ( "Tab must contains positive number of space chars [" + numberOfSpacesPerTab + ' ' ) ; } final int currentIdentSteps = this . indent / this . spacesInTab ; this . spacesInTab = numberOfSpacesPerTab ; this . indent = currentIdentSteps * this . spacesInTab ; return this ; } | Set number of spaces per tab . | 112 | 7 |
21,470 | public final JBBPTextWriter Radix ( final int radix ) { if ( radix < 2 || radix > 36 ) { throw new IllegalArgumentException ( "Unsupported radix value [" + radix + ' ' ) ; } this . radix = radix ; this . maxCharsRadixForByte = JBBPUtils . ulong2str ( 0xFF L , this . radix , CHAR_BUFFER ) . length ( ) ; this . maxCharsRadixForShort = JBBPUtils . ulong2str ( 0xFFFF L , this . radix , CHAR_BUFFER ) . length ( ) ; this . maxCharsRadixForInt = JBBPUtils . ulong2str ( 0xFFFFFFFF L , this . radix , CHAR_BUFFER ) . length ( ) ; this . maxCharsRadixForLong = JBBPUtils . ulong2str ( 0xFFFFFFFFFFFFFFFF L , this . radix , CHAR_BUFFER ) . length ( ) ; return this ; } | Set radix . | 232 | 4 |
21,471 | public JBBPTextWriter Short ( final int value ) throws IOException { ensureValueMode ( ) ; String convertedByExtras = null ; for ( final Extra e : this . extras ) { convertedByExtras = e . doConvertShortToStr ( this , value & 0xFFFF ) ; if ( convertedByExtras != null ) { break ; } } if ( convertedByExtras == null ) { final long valueToWrite ; if ( this . byteOrder == JBBPByteOrder . LITTLE_ENDIAN ) { valueToWrite = JBBPUtils . reverseByteOrder ( value , 2 ) ; } else { valueToWrite = value ; } printValueString ( JBBPUtils . ensureMinTextLength ( JBBPUtils . ulong2str ( valueToWrite & 0xFFFF L , this . radix , CHAR_BUFFER ) , this . maxCharsRadixForShort , ' ' , 0 ) ) ; } else { printValueString ( convertedByExtras ) ; } return this ; } | Print short value . | 225 | 4 |
21,472 | public JBBPTextWriter Float ( final float value ) throws IOException { ensureValueMode ( ) ; String convertedByExtras = null ; for ( final Extra e : this . extras ) { convertedByExtras = e . doConvertFloatToStr ( this , value ) ; if ( convertedByExtras != null ) { break ; } } if ( convertedByExtras == null ) { final float valueToWrite ; if ( this . byteOrder == JBBPByteOrder . LITTLE_ENDIAN ) { valueToWrite = Float . intBitsToFloat ( ( int ) JBBPFieldInt . reverseBits ( Float . floatToIntBits ( value ) ) ) ; } else { valueToWrite = value ; } printValueString ( JBBPUtils . ensureMinTextLength ( JBBPUtils . float2str ( valueToWrite , this . radix ) , this . maxCharsRadixForShort , ' ' , 0 ) ) ; } else { printValueString ( convertedByExtras ) ; } return this ; } | Print float value . | 229 | 4 |
21,473 | public JBBPTextWriter Double ( final double value ) throws IOException { ensureValueMode ( ) ; String convertedByExtras = null ; for ( final Extra e : this . extras ) { convertedByExtras = e . doConvertDoubleToStr ( this , value ) ; if ( convertedByExtras != null ) { break ; } } if ( convertedByExtras == null ) { final double valueToWrite ; if ( this . byteOrder == JBBPByteOrder . LITTLE_ENDIAN ) { valueToWrite = Double . longBitsToDouble ( JBBPFieldLong . reverseBits ( Double . doubleToLongBits ( value ) ) ) ; } else { valueToWrite = value ; } printValueString ( JBBPUtils . ensureMinTextLength ( JBBPUtils . double2str ( valueToWrite , this . radix ) , this . maxCharsRadixForShort , ' ' , 0 ) ) ; } else { printValueString ( convertedByExtras ) ; } return this ; } | Print double value . | 226 | 4 |
21,474 | public JBBPTextWriter Short ( final String value ) throws IOException { for ( int i = 0 ; i < value . length ( ) ; i ++ ) { this . Short ( value . charAt ( i ) ) ; } return this ; } | Print char codes of string as short array . | 53 | 9 |
21,475 | public JBBPTextWriter Short ( final short [ ] values , int off , int len ) throws IOException { while ( len -- > 0 ) { this . Short ( values [ off ++ ] ) ; } return this ; } | Print values from short array | 48 | 5 |
21,476 | public JBBPTextWriter Float ( final float [ ] values , int off , int len ) throws IOException { while ( len -- > 0 ) { this . Float ( values [ off ++ ] ) ; } return this ; } | Print values from float array | 48 | 5 |
21,477 | public JBBPTextWriter Double ( final double [ ] values , int off , int len ) throws IOException { while ( len -- > 0 ) { this . Double ( values [ off ++ ] ) ; } return this ; } | Print values from double array | 48 | 5 |
21,478 | public JBBPTextWriter Int ( final int value ) throws IOException { ensureValueMode ( ) ; String convertedByExtras = null ; for ( final Extra e : this . extras ) { convertedByExtras = e . doConvertIntToStr ( this , value ) ; if ( convertedByExtras != null ) { break ; } } if ( convertedByExtras == null ) { final long valueToWrite ; if ( this . byteOrder == JBBPByteOrder . LITTLE_ENDIAN ) { valueToWrite = JBBPUtils . reverseByteOrder ( value , 4 ) ; } else { valueToWrite = value ; } printValueString ( JBBPUtils . ensureMinTextLength ( JBBPUtils . ulong2str ( valueToWrite & 0xFFFFFFFF L , this . radix , CHAR_BUFFER ) , this . maxCharsRadixForInt , ' ' , 0 ) ) ; } else { printValueString ( convertedByExtras ) ; } return this ; } | Print integer value | 222 | 3 |
21,479 | public JBBPTextWriter Int ( final int [ ] values , int off , int len ) throws IOException { while ( len -- > 0 ) { this . Int ( values [ off ++ ] ) ; } return this ; } | Print values from integer array . | 48 | 6 |
21,480 | public JBBPTextWriter Long ( final long value ) throws IOException { ensureValueMode ( ) ; String convertedByExtras = null ; for ( final Extra e : this . extras ) { convertedByExtras = e . doConvertLongToStr ( this , value ) ; if ( convertedByExtras != null ) { break ; } } if ( convertedByExtras == null ) { final long valueToWrite ; if ( this . byteOrder == JBBPByteOrder . LITTLE_ENDIAN ) { valueToWrite = JBBPUtils . reverseByteOrder ( value , 8 ) ; } else { valueToWrite = value ; } printValueString ( JBBPUtils . ensureMinTextLength ( JBBPUtils . ulong2str ( valueToWrite , this . radix , CHAR_BUFFER ) , this . maxCharsRadixForLong , ' ' , 0 ) ) ; } else { printValueString ( convertedByExtras ) ; } return this ; } | Print long value | 216 | 3 |
21,481 | public JBBPTextWriter Long ( final long [ ] values , int off , int len ) throws IOException { while ( len -- > 0 ) { this . Long ( values [ off ++ ] ) ; } return this ; } | print values from long array . | 48 | 6 |
21,482 | public JBBPTextWriter SetHR ( final String prefix , final int length , final char ch ) { this . prefixHR = prefix == null ? "" : prefix ; this . hrChar = ch ; this . hrLength = length ; return this ; } | Change parameters for horizontal rule . | 53 | 6 |
21,483 | public JBBPTextWriter HR ( ) throws IOException { if ( this . flagCommentsAllowed ) { this . ensureNewLineMode ( ) ; this . writeIndent ( ) ; this . write ( this . prefixHR ) ; for ( int i = 0 ; i < this . hrLength ; i ++ ) { this . write ( this . hrChar ) ; } } this . BR ( ) ; return this ; } | Print horizontal rule . If comments are disabled then only next line will be added . | 90 | 16 |
21,484 | public JBBPTextWriter Comment ( final String ... comment ) throws IOException { if ( this . flagCommentsAllowed ) { if ( comment != null ) { for ( final String c : comment ) { if ( c == null ) { continue ; } if ( c . indexOf ( ' ' ) >= 0 ) { final String [ ] splitted = c . split ( "\\n" , - 1 ) ; for ( final String s : splitted ) { this . ensureCommentMode ( ) ; this . write ( s ) ; } } else { this . ensureCommentMode ( ) ; this . write ( c ) ; } } this . prevLineCommentsStartPosition = 0 ; } } else { ensureNewLineMode ( ) ; } return this ; } | Print comments . Wilt aligning of line start for multi - line comment . Comments will be printed only if they are allowed . | 159 | 26 |
21,485 | public JBBPTextWriter Obj ( final int objId , final Object ... obj ) throws IOException { if ( this . extras . isEmpty ( ) ) { throw new IllegalStateException ( "There is not any registered extras" ) ; } for ( final Object c : obj ) { String str = null ; for ( final Extra e : this . extras ) { str = e . doConvertObjToStr ( this , objId , c ) ; if ( str != null ) { break ; } } if ( str != null ) { ensureValueMode ( ) ; printValueString ( str ) ; } } return this ; } | Print objects . | 132 | 3 |
21,486 | public JBBPTextWriter Obj ( final int objId , final Object [ ] array , int off , int len ) throws IOException { while ( len -- > 0 ) { this . Obj ( objId , array [ off ++ ] ) ; } return this ; } | Print objects from array . | 56 | 5 |
21,487 | private void writeChar ( final char chr ) throws IOException { switch ( chr ) { case ' ' : this . Tab ( ) ; break ; case ' ' : { this . out . write ( this . lineSeparator ) ; this . lineNumber ++ ; this . prevMode = this . mode ; this . mode = MODE_START_LINE ; this . linePosition = 0 ; for ( final Extra e : extras ) { e . onNewLine ( this , this . lineNumber ) ; } } break ; case ' ' : break ; default : { if ( ! Character . isISOControl ( chr ) ) { this . out . write ( chr ) ; this . linePosition ++ ; if ( this . mode == MODE_START_LINE ) { this . mode = this . prevMode ; } } } break ; } } | Main method writing a char into wrapped writer . | 182 | 9 |
21,488 | public static JBBPOut BeginBin ( final JBBPByteOrder byteOrder , final JBBPBitOrder bitOrder ) { return new JBBPOut ( new ByteArrayOutputStream ( ) , byteOrder , bitOrder ) ; } | Start a DSL session for defined both byte outOrder and bit outOrder parameters . | 52 | 16 |
21,489 | public static JBBPOut BeginBin ( final OutputStream out , final JBBPByteOrder byteOrder , final JBBPBitOrder bitOrder ) { return new JBBPOut ( out , byteOrder , bitOrder ) ; } | Start a DSL session for a defined stream with defined parameters . | 51 | 12 |
21,490 | public JBBPOut Skip ( int numberOfBytes ) throws IOException { assertNotEnded ( ) ; if ( this . processCommands ) { if ( numberOfBytes < 0 ) { throw new IllegalArgumentException ( "Value is negative" ) ; } this . Align ( ) ; while ( numberOfBytes > 0 ) { this . outStream . write ( 0 ) ; numberOfBytes -- ; } } return this ; } | Skip number of bytes in the stream zero bytes will be written and also will be aligned inside bit cache even if the value is 0 . | 93 | 27 |
21,491 | public JBBPOut ByteOrder ( final JBBPByteOrder value ) throws IOException { assertNotEnded ( ) ; JBBPUtils . assertNotNull ( value , "Byte order must not be null" ) ; if ( this . processCommands ) { this . byteOrder = value ; } return this ; } | Define the byte outOrder for next session operations . | 70 | 11 |
21,492 | public JBBPOut Bit ( final boolean value ) throws IOException { assertNotEnded ( ) ; if ( this . processCommands ) { this . outStream . writeBits ( value ? 1 : 0 , JBBPBitNumber . BITS_1 ) ; } return this ; } | Write a bit into the session . | 63 | 7 |
21,493 | public JBBPOut Bit ( final byte value ) throws IOException { assertNotEnded ( ) ; if ( this . processCommands ) { this . _writeBits ( JBBPBitNumber . BITS_1 , value ) ; } return this ; } | Write the lowest bit from a byte value . | 57 | 9 |
21,494 | public JBBPOut Bits ( final JBBPBitNumber numberOfBits , final int value ) throws IOException { assertNotEnded ( ) ; JBBPUtils . assertNotNull ( numberOfBits , "Number of bits must not be null" ) ; if ( this . processCommands ) { _writeBits ( numberOfBits , value ) ; } return this ; } | Write bits from a value into the output stream | 86 | 9 |
21,495 | public JBBPOut Byte ( final int ... value ) throws IOException { assertNotEnded ( ) ; assertArrayNotNull ( value ) ; if ( this . processCommands ) { for ( final int v : value ) { _writeByte ( v ) ; } } return this ; } | Write the lower byte of an integer value into the session stream . | 62 | 13 |
21,496 | public JBBPOut Byte ( final byte [ ] value ) throws IOException { assertNotEnded ( ) ; assertArrayNotNull ( value ) ; if ( this . processCommands ) { this . outStream . write ( value ) ; } return this ; } | Write a byte array into the session stream . | 56 | 9 |
21,497 | public JBBPOut Utf8 ( final String str ) throws IOException { assertNotEnded ( ) ; assertStringNotNull ( str ) ; if ( this . processCommands ) { this . outStream . write ( JBBPUtils . strToUtf8 ( str ) ) ; } return this ; } | Write chars of a String as encoded Utf8 byte array . There will not be aby information about string length . | 69 | 24 |
21,498 | public JBBPOut Bool ( final boolean value , final JBBPBitOrder bitOrder ) throws IOException { assertNotEnded ( ) ; if ( this . processCommands ) { this . outStream . write ( value ? bitOrder == JBBPBitOrder . MSB0 ? 0x80 : 1 : 0 ) ; } return this ; } | Write a boolean value into the session stream as a byte . | 77 | 12 |
21,499 | public JBBPOut Bool ( final boolean ... value ) throws IOException { assertNotEnded ( ) ; assertArrayNotNull ( value ) ; if ( this . processCommands ) { for ( final boolean b : value ) { this . outStream . write ( b ? 1 : 0 ) ; } } return this ; } | Write boolean values from an array into the session stream as bytes . | 70 | 13 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.