signature:
public class AudioFormat { /** * Get the planar alternative form of the given sample format . < br >
 * < br >
 * If the passed sample _ fmt is already in planar format , the format returned is < br >
 * the same as the input . < br >
 * < br >
 * @ return the planar alternative form of the given sample format or < br >
 * SAMPLE _ FMT _ NONE on error . */
public static AudioFormat . Type getPlanarSampleFormat ( AudioFormat . Type sample_fmt ) { } }

implementation: return AudioFormat . Type . swigToEnum ( VideoJNI . AudioFormat_getPlanarSampleFormat ( sample_fmt . swigValue ( ) ) ) ;


signature:
public class AudioFormat { /** * Get the size of a buffer in bytes that would be required to hold the < br >
 * number of samples of audio in the given format and with the given number of channels . */
public static int getBufferSizeNeeded ( int numSamples , int numChannels , AudioFormat . Type format ) { } }

implementation: return VideoJNI . AudioFormat_getBufferSizeNeeded ( numSamples , numChannels , format . swigValue ( ) ) ;


signature:
public class AudioFormat { /** * Get the size of a plane of audio bytes that would be required to hold the < br >
 * number of samples of audio in the given format and with the given number of channels . < br >
 * < p > < br >
 * If format is packed , then this method returns the same number as # getBufferSizeNeeded ( int , int , Type ) . < br > */
public static int getDataPlaneSizeNeeded ( int numSamples , int numChannels , AudioFormat . Type format ) { } }

implementation: return VideoJNI . AudioFormat_getDataPlaneSizeNeeded ( numSamples , numChannels , format . swigValue ( ) ) ;


signature:
public class Muxer { /** * Creates a new muxer . < br >
 * < br >
 * One of the three passed in parameter must be non - null . If the muxer requires a URL to write to , < br >
 * then that must be specified . < br >
 * < br >
 * @ param format If non null , this will be the format this muxer assumes it is writting packets in . < br >
 * @ param filename The filename / url to open . If format is null , this will also be examined to guess actual format . < br >
 * @ param formatName The formatname of the muxer to use . This will only be examined if format is null . < br >
 * < br >
 * @ return a Muxer < br >
 * < br >
 * @ throws InvalidArgument if all parameters are null . */
public static Muxer make ( String filename , MuxerFormat format , String formatName ) { } }

implementation: long cPtr = VideoJNI . Muxer_make ( filename , MuxerFormat . getCPtr ( format ) , format , formatName ) ; return ( cPtr == 0 ) ? null : new Muxer ( cPtr , false ) ;


signature:
public class Muxer { /** * Get the MuxerFormat associated with this Muxer < br >
 * or null if unknown . */
public MuxerFormat getFormat ( ) { } }

implementation: long cPtr = VideoJNI . Muxer_getFormat ( swigCPtr , this ) ; return ( cPtr == 0 ) ? null : new MuxerFormat ( cPtr , false ) ;


signature:
public class Muxer { /** * Open the Muxer and write any headers . < br >
 * < br >
 * @ param inputOptions muxer - specific options to set before opening the muxer . Can be null . < br >
 * @ param outputOptions if non null , the passed in bag will be emptied , and the filled < br >
 * with any options from inputOptions that could not be set on the muxer . */
public void open ( KeyValueBag inputOptions , KeyValueBag outputOptions ) throws java . lang . InterruptedException , java . io . IOException { } }

implementation: VideoJNI . Muxer_open ( swigCPtr , this , KeyValueBag . getCPtr ( inputOptions ) , inputOptions , KeyValueBag . getCPtr ( outputOptions ) , outputOptions ) ;


signature:
public class Muxer { /** * Adds a new stream that will have packets written to it . < br >
 * < br >
 * Note on thread safety : Callers must ensure that the coder is not encoding or decoding < br >
 * packets at the same time that Muxer # open or Muxer # close is being called . < br >
 * < br >
 * @ param coder The coder that will be used for packets written to this stream . < br >
 * < br >
 * @ throws InvalidArgument if encoder is null . < br >
 * @ throws InvalidArgument if encoder is not open . */
public MuxerStream addNewStream ( Coder coder ) { } }

implementation: long cPtr = VideoJNI . Muxer_addNewStream ( swigCPtr , this , Coder . getCPtr ( coder ) , coder ) ; return ( cPtr == 0 ) ? null : new MuxerStream ( cPtr , false ) ;


signature:
public class Muxer { /** * Get the MuxerStream at the given position . */
public MuxerStream getStream ( int position ) throws java . lang . InterruptedException , java . io . IOException { } }

implementation: long cPtr = VideoJNI . Muxer_getStream ( swigCPtr , this , position ) ; return ( cPtr == 0 ) ? null : new MuxerStream ( cPtr , false ) ;


signature:
public class Muxer { /** * Writes the given packet to the Muxer . < br >
 * < br >
 * @ param packet The packet to write . < br >
 * @ param forceInterleave If true , this Muxer will ensure that all packets are interleaved across streams < br >
 * ( i . e . monotonically increasing timestamps in the Muxer container ) . If false , then the caller < br >
 * is responsible for ensuring the interleaving is valid for the container . Note this method is faster < br >
 * if forceInterleave is false . < br >
 * < br >
 * @ return true if all data has been flushed , false if data remains to be flushed . < br >
 * < br >
 * @ throws InvalidArgument if packet is null . < br >
 * @ throws InvalidArgument if packet is not complete . < br >
 * @ throws RuntimeException for other errors . */
public boolean write ( MediaPacket packet , boolean forceInterleave ) { } }

implementation: return VideoJNI . Muxer_write ( swigCPtr , this , MediaPacket . getCPtr ( packet ) , packet , forceInterleave ) ;


signature:
public class Mutex { /** * JNIHelper . swg : End generated code */
public static Mutex make ( ) { } }

implementation: long cPtr = FerryJNI . Mutex_make ( ) ; return ( cPtr == 0 ) ? null : new Mutex ( cPtr , false ) ;


signature:
public class DemuxerFormat { /** * Get the CodecId for the n ' th codec supported by this container . < br >
 * < br >
 * @ param n The n ' th codec supported by this codec . Lower n are higher priority . < br >
 * n must be & lt ; # getNumSupportedCodecs ( ) < br >
 * @ return the CodecId at the n ' th slot , or CodecId . ID _ NONE if none . */
protected Codec . ID getSupportedCodecId ( int n ) { } }

implementation: return Codec . ID . swigToEnum ( VideoJNI . DemuxerFormat_getSupportedCodecId ( swigCPtr , this , n ) ) ;


signature:
public class DemuxerFormat { /** * Find DemuxerFormat based on the short name of the input format . < br >
 * @ return An DemuxerFormat or null if none found . */
public static DemuxerFormat findFormat ( String shortName ) { } }

implementation: long cPtr = VideoJNI . DemuxerFormat_findFormat ( shortName ) ; return ( cPtr == 0 ) ? null : new DemuxerFormat ( cPtr , false ) ;


signature:
public class DemuxerFormat { /** * Return an object for the DemuxerFormats at the given index . < br >
 * < br >
 * @ param index an index for the format list we maintain < br >
 * < br >
 * @ return a format object for that input or null if < br >
 * unknown , index & lt ; 0 or index & gt ; = # getNumInstalledInputFormats ( ) */
protected static DemuxerFormat getFormat ( int index ) { } }

implementation: long cPtr = VideoJNI . DemuxerFormat_getFormat ( index ) ; return ( cPtr == 0 ) ? null : new DemuxerFormat ( cPtr , false ) ;


signature:
public class Container { /** * The number of streams in this container . < br >
 * < p > If this container is a Source this will query the stream and find out < br >
 * how many streams are in it . < / p > < p > If the current thread is interrupted while this blocking method < br >
 * is running the method will return with a negative value . < br >
 * To check if the method exited because of an interruption < br >
 * pass the return value to Error # make ( int ) and then < br >
 * check Error # getType ( ) to see if it is < br >
 * Error . Type # ERROR _ INTERRUPTED . < br >
 * < / p > < br >
 * < br >
 * @ return The number of streams in this container . */
public int getNumStreams ( ) throws java . lang . InterruptedException , java . io . IOException { } }

implementation: return VideoJNI . Container_getNumStreams ( swigCPtr , this ) ;


signature:
public class MuxerStream { /** * Get the Coder that this stream was created with . < br >
 * Note : this can be either an Encoder or a Decoder . */
public Coder getCoder ( ) { } }

implementation: long cPtr = VideoJNI . MuxerStream_getCoder ( swigCPtr , this ) ; return ( cPtr == 0 ) ? null : new Coder ( cPtr , false ) ;


signature:
public class MuxerStream { /** * Get the Muxer that this stream belongs to . */
public Muxer getMuxer ( ) { } }

implementation: long cPtr = VideoJNI . MuxerStream_getMuxer ( swigCPtr , this ) ; return ( cPtr == 0 ) ? null : new Muxer ( cPtr , false ) ;


signature:
public class Transactions { /** * Creates a signed SetScript object .
 * @ param sender the account to set the script for
 * @ param script compiled script , base64 encoded
 * @ param chainId chain ID
 * @ param fee object fee
 * @ param timestamp operation timestamp
 * @ return object object
 * @ see Account # MAINNET
 * @ see Account # TESTNET */
public static SetScriptTransaction makeScriptTx ( PrivateKeyAccount sender , String script , byte chainId , long fee , long timestamp ) { } }

implementation: return new SetScriptTransaction ( sender , script , chainId , fee , timestamp ) ;


signature:
public class Base58 { /** * Decodes the given base58 string into the original data bytes .
 * @ param input the base58 - encoded string to decode
 * @ return the decoded data bytes
 * @ throws IllegalArgumentException if the given string is not a valid base58 string */
public static byte [ ] decode ( String input ) throws IllegalArgumentException { } }

implementation:
if ( input . startsWith ( "base58:" ) ) input = input . substring ( 7 ) ; if ( input . length ( ) == 0 ) return new byte [ 0 ] ; // Convert the base58 - encoded ASCII chars to a base58 byte sequence ( base58 digits ) .
byte [ ] input58 = new byte [ input . length ( ) ] ; for ( int i = 0 ; i < input . length ( ) ; ++ i ) { char c = input . charAt ( i ) ; int digit = c < 128 ? INDEXES [ c ] : - 1 ; if ( digit < 0 ) { throw new IllegalArgumentException ( "Illegal character " + c + " at position " + i ) ; } input58 [ i ] = ( byte ) digit ; } // Count leading zeros .
int zeros = 0 ; while ( zeros < input58 . length && input58 [ zeros ] == 0 ) { ++ zeros ; } // Convert base - 58 digits to base - 256 digits .
byte [ ] decoded = new byte [ input . length ( ) ] ; int outputStart = decoded . length ; for ( int inputStart = zeros ; inputStart < input58 . length ; ) { decoded [ -- outputStart ] = divmod ( input58 , inputStart , 58 , 256 ) ; if ( input58 [ inputStart ] == 0 ) { ++ inputStart ; // optimization - skip leading zeros
} } // Ignore extra leading zeroes that were added during the calculation .
while ( outputStart < decoded . length && decoded [ outputStart ] == 0 ) { ++ outputStart ; } // Return decoded data ( including original number of leading zeros ) .
return Arrays . copyOfRange ( decoded , outputStart - zeros , decoded . length ) ;


signature:
public class PrivateKeyAccount { /** * Generates a 15 - word random seed . This method implements the BIP - 39 algorithm with 160 bits of entropy .
 * @ return the seed as a String */
public static String generateSeed ( ) { } }

implementation:
byte [ ] bytes = new byte [ 21 ] ; new SecureRandom ( ) . nextBytes ( bytes ) ; byte [ ] rhash = hash ( bytes , 0 , 20 , SHA256 ) ; bytes [ 20 ] = rhash [ 0 ] ; BigInteger rand = new BigInteger ( bytes ) ; BigInteger mask = new BigInteger ( new byte [ ] { 0 , 0 , 7 , - 1 } ) ; // 11 lower bits
StringBuilder sb = new StringBuilder ( ) ; for ( int i = 0 ; i < 15 ; i ++ ) { sb . append ( i > 0 ? ' ' : "" ) . append ( SEED_WORDS [ rand . and ( mask ) . intValue ( ) ] ) ; rand = rand . shiftRight ( 11 ) ; } return sb . toString ( ) ;


signature:
public class Node { /** * Returns object by its ID .
 * @ param txId object ID
 * @ return object object
 * @ throws IOException if no object with the given ID exists */
public Transaction getTransaction ( String txId ) throws IOException { } }

implementation: return wavesJsonMapper . convertValue ( send ( "/transactions/info/" + txId ) , Transaction . class ) ;


signature:
public class Node { /** * Returns transactions by address with limit .
 * @ param address address
 * @ param limit transactions limit
 * @ return list of transactions
 * @ throws IOException if something going wrong */
public List < Transaction > getAddressTransactions ( String address , int limit ) throws IOException { } }

implementation: return getAddressTransactions ( address , limit , null ) ;


signature:
public class Node { /** * Returns transactions by address with limit after passed transaction id .
 * @ param address address
 * @ param limit transactions limit
 * @ param after separate transaction id
 * @ return list of transactions
 * @ throws IOException if something going wrong */
public List < Transaction > getAddressTransactions ( String address , int limit , String after ) throws IOException { } }

implementation: String requestUrl = String . format ( "/transactions/address/%s/limit/%d" , address , limit ) ; if ( after != null ) { requestUrl += String . format ( "?after=%s" , after ) ; } return wavesJsonMapper . < List < List < Transaction > > > convertValue ( send ( requestUrl ) , new TypeReference < List < List < Transaction > > > ( ) { } ) . get ( 0 ) ;


signature:
public class Node { /** * Returns seq of block headers
 * @ param from start block
 * @ param to end block
 * @ return sequences of block objects without transactions
 * @ throws IOException if no block exists at the given height */
public List < BlockHeader > getBlockHeaderSeq ( int from , int to ) throws IOException { } }

implementation: String path = String . format ( "/blocks/headers/seq/%s/%s" , from , to ) ; HttpResponse r = exec ( request ( path ) ) ; return parse ( r , BLOCK_HEADER_LIST ) ;


signature:
public class Node { /** * Returns block by its signature .
 * @ param signature block signature
 * @ return block object
 * @ throws IOException if no block with the given signature exists */
public Block getBlock ( String signature ) throws IOException { } }

implementation: return wavesJsonMapper . convertValue ( send ( "/blocks/signature/" + signature ) , Block . class ) ;


signature:
public class Node { /** * Sends a signed object and returns its ID .
 * @ param tx signed object ( as created by static methods in Transaction class )
 * @ return Transaction ID
 * @ throws IOException */
public String send ( Transaction tx ) throws IOException { } }

implementation: return parse ( exec ( request ( tx ) ) , "id" ) . asText ( ) ;


signature:
public class Node { /** * Sets a validating script for an account .
 * @ param from the account
 * @ param script script text
 * @ param chainId chain ID
 * @ param fee object fee
 * @ return object ID
 * @ throws IOException if an error occurs
 * @ see Account # MAINNET
 * @ see Account # TESTNET */
public String setScript ( PrivateKeyAccount from , String script , byte chainId , long fee ) throws IOException { } }

implementation: return send ( Transactions . makeScriptTx ( from , compileScript ( script ) , chainId , fee ) ) ;


signature:
public class Node { /** * Compiles a script .
 * @ param script the script to compile
 * @ return compiled script , base64 encoded
 * @ throws IOException if the script is not well formed or some other error occurs */
public String compileScript ( String script ) throws IOException { } }

implementation: if ( script == null || script . isEmpty ( ) ) { return null ; } HttpPost request = new HttpPost ( uri . resolve ( "/utils/script/compile" ) ) ; request . setEntity ( new StringEntity ( script ) ) ; return parse ( exec ( request ) , "script" ) . asText ( ) ;


signature:
public class FSTStructSerializer { /** * write the contents of a given object */
@ Override public void writeObject ( FSTObjectOutput out , Object toWrite , FSTClazzInfo clzInfo , FSTClazzInfo . FSTFieldInfo referencedBy , int streamPosition ) throws IOException { } }

implementation:
FSTStruct str = ( FSTStruct ) toWrite ; if ( ! str . isOffHeap ( ) ) { str = str . toOffHeap ( ) ; } int byteSize = str . getByteSize ( ) ; out . writeInt ( byteSize ) ; if ( COMPRESS ) { long base = str . ___offset ; int intsiz = byteSize / 4 ; for ( int i = 0 ; i < intsiz ; i ++ ) { int value = str . getInt ( ) ; value = ( value << 1 ) ^ ( value >> 31 ) ; str . ___offset += 4 ; while ( ( value & 0xFFFFFF80 ) != 0L ) { out . writeByte ( ( value & 0x7F ) | 0x80 ) ; value >>>= 7 ; } out . writeByte ( value & 0x7F ) ; } int remainder = byteSize & 3 ; for ( int i = 0 ; i < remainder ; i ++ ) { byte aByte = str . getByte ( ) ; out . writeByte ( aByte ) ; str . ___offset ++ ; } str . ___offset = base ; } else { byte b [ ] = new byte [ byteSize ] ; // fixme : cache threadlocal
str . getBase ( ) . getArr ( str . getOffset ( ) , b , 0 , byteSize ) ; out . write ( b , 0 , byteSize ) ; }


signature:
public class FSTStreamDecoder { /** * len < 127 ! ! ! ! !
 * @ return
 * @ throws java . io . IOException */
@ Override public String readStringAsc ( ) throws IOException { } }

implementation: int len = readFInt ( ) ; if ( ascStringCache == null || ascStringCache . length < len ) ascStringCache = new byte [ len ] ; input . ensureReadAhead ( len ) ; System . arraycopy ( input . buf , input . pos , ascStringCache , 0 , len ) ; input . pos += len ; return new String ( ascStringCache , 0 , 0 , len ) ;


signature:
public class FSTStreamDecoder { /** * assumes class header + len already read
 * @ param componentType
 * @ param len
 * @ return */
@ Override public Object readFPrimitiveArray ( Object array , Class componentType , int len ) { } }

implementation:
try { if ( componentType == byte . class ) { byte [ ] arr = ( byte [ ] ) array ; ensureReadAhead ( arr . length ) ; // fixme : move this stuff to the stream !
System . arraycopy ( input . buf , input . pos , arr , 0 , len ) ; input . pos += len ; return arr ; } else if ( componentType == int . class ) { final int [ ] arr = ( int [ ] ) array ; readFIntArr ( len , arr ) ; return arr ; } else if ( componentType == long . class ) { long [ ] arr = ( long [ ] ) array ; readFLongArr ( len , arr ) ; return arr ; } else if ( componentType == char . class ) { char [ ] arr = ( char [ ] ) array ; for ( int j = 0 ; j < len ; j ++ ) { arr [ j ] = readFChar ( ) ; } return arr ; } else if ( componentType == double . class ) { double [ ] arr = ( double [ ] ) array ; ensureReadAhead ( arr . length * 8 ) ; for ( int j = 0 ; j < len ; j ++ ) { arr [ j ] = readFDouble ( ) ; } return arr ; } else if ( componentType == short . class ) { short [ ] arr = ( short [ ] ) array ; ensureReadAhead ( arr . length * 2 ) ; for ( int j = 0 ; j < len ; j ++ ) { arr [ j ] = readFShort ( ) ; } return arr ; } else if ( componentType == float . class ) { float [ ] arr = ( float [ ] ) array ; ensureReadAhead ( arr . length * 4 ) ; for ( int j = 0 ; j < len ; j ++ ) { arr [ j ] = readFFloat ( ) ; } return arr ; } else if ( componentType == boolean . class ) { boolean [ ] arr = ( boolean [ ] ) array ; ensureReadAhead ( arr . length ) ; for ( int j = 0 ; j < len ; j ++ ) { arr [ j ] = readFByte ( ) == 0 ? false : true ; } return arr ; } else { throw new RuntimeException ( "unexpected primitive type " + componentType . getName ( ) ) ; } } catch ( IOException e ) { LOGGER . log ( FSTLogger . Level . ERROR , "Failed to read primitive array" , e ) ; FSTUtil . < RuntimeException > rethrow ( e ) ; } return null ;


signature:
public class FSTStreamDecoder { /** * compressed version */
public void _readFIntArr ( int len , int [ ] arr ) throws IOException { } }

implementation:
ensureReadAhead ( 5 * len ) ; final byte buf [ ] = input . buf ; int count = input . pos ; for ( int j = 0 ; j < len ; j ++ ) { final byte head = buf [ count ++ ] ; // -128 = short byte , - 127 = = 4 byte
if ( head > - 127 && head <= 127 ) { arr [ j ] = head ; continue ; } if ( head == - 128 ) { final int ch1 = ( buf [ count ++ ] + 256 ) & 0xff ; final int ch2 = ( buf [ count ++ ] + 256 ) & 0xff ; arr [ j ] = ( short ) ( ( ch1 << 8 ) + ( ch2 << 0 ) ) ; continue ; } else { int ch1 = ( buf [ count ++ ] + 256 ) & 0xff ; int ch2 = ( buf [ count ++ ] + 256 ) & 0xff ; int ch3 = ( buf [ count ++ ] + 256 ) & 0xff ; int ch4 = ( buf [ count ++ ] + 256 ) & 0xff ; arr [ j ] = ( ( ch1 << 24 ) + ( ch2 << 16 ) + ( ch3 << 8 ) + ( ch4 << 0 ) ) ; } } input . pos = count ;


signature:
public class FSTBytezEncoder { /** * write prim array no len no tag
 * @ param array
 * @ throws IOException */
public void writePrimitiveArray ( Object array , int off , int len ) throws IOException { } }

implementation: Class < ? > componentType = array . getClass ( ) . getComponentType ( ) ; if ( componentType == byte . class ) { writeRawBytes ( ( byte [ ] ) array , off , len ) ; } else if ( componentType == char . class ) { writeFCharArr ( ( char [ ] ) array , off , len ) ; } else if ( componentType == short . class ) { writeFShortArr ( ( short [ ] ) array , off , len ) ; } else if ( componentType == int . class ) { writeFIntArr ( ( int [ ] ) array , off , len ) ; } else if ( componentType == double . class ) { writeFDoubleArr ( ( double [ ] ) array , off , len ) ; } else if ( componentType == float . class ) { writeFFloatArr ( ( float [ ] ) array , off , len ) ; } else if ( componentType == long . class ) { writeFLongArr ( ( long [ ] ) array , off , len ) ; } else if ( componentType == boolean . class ) { writeFBooleanArr ( ( boolean [ ] ) array , off , len ) ; } else { throw new RuntimeException ( "expected primitive array" ) ; }


signature:
public class FSTBytezEncoder { /** * does not write length , just plain bytes
 * @ param array
 * @ param length
 * @ throws java . io . IOException */
public void writeRawBytes ( byte [ ] array , int start , int length ) throws IOException { } }

implementation: ensureFree ( ( int ) ( pos + length ) ) ; buffout . set ( pos , array , start , length ) ; pos += length ;


signature:
public class FSTBytezEncoder { /** * used to write uncompressed int ( guaranteed length = 4 ) at a ( eventually recent ) position
 * @ param position
 * @ param v */
@ Override public void writeInt32At ( int position , int v ) { } }

implementation: try { ensureFree ( position + 4 ) ; } catch ( IOException e ) { FSTUtil . < RuntimeException > rethrow ( e ) ; } buffout . putInt ( position , v ) ;


signature:
public class FSTBytezEncoder { /** * writes current buffer to underlying output and resets buffer .
 * @ throws IOException */
@ Override public void flush ( ) throws IOException { } }

implementation: if ( outStream != null ) outStream . write ( getBuffer ( ) , 0 , ( int ) pos ) ; pos = 0 ;


signature:
public class OffHeapCoder { /** * throws FSTBufferTooSmallException in case object does not fit into given range
 * @ param o
 * @ param address
 * @ param availableSize
 * @ throws IOException
 * @ return number of bytes written to the memory region */
public int toMemory ( Object o , long address , int availableSize ) throws IOException { } }

implementation: out . resetForReUse ( ) ; writeTarget . setBase ( address , availableSize ) ; out . writeObject ( o ) ; int written = out . getWritten ( ) ; return written ;


signature:
public class KsonSerializer { /** * determines classname tagging . Overrifing can enforce class tags always or ( JSon ) write as
 * special attribute
 * @ param expectedClass
 * @ param o */
protected void writeClazzTag ( Class expectedClass , Object o ) { } }

implementation: if ( expectedClass == o . getClass ( ) ) { out . writeString ( "{" ) ; } else { String stringForType = mapper . getStringForType ( o . getClass ( ) ) ; out . writeString ( stringForType + " {" ) ; }


signature:
public class FSTJsonDecoder { /** * in case readClass already reads full minbin value */
@ Override public FSTClazzInfo readClass ( ) throws IOException , ClassNotFoundException { } }

implementation: if ( lastDirectClass != null ) { FSTClazzInfo clInfo = conf . getCLInfoRegistry ( ) . getCLInfo ( lastDirectClass , conf ) ; lastDirectClass = null ; return clInfo ; } return null ;


signature:
public class DefaultCoder { /** * will throw an FSTBufferTooSmallException if buffer is too small . */
public int toByteArray ( Object obj , byte result [ ] , int resultOffset , int avaiableSize ) { } }

implementation: output . resetForReUse ( ) ; try { output . writeObject ( obj ) ; } catch ( IOException e ) { FSTUtil . < RuntimeException > rethrow ( e ) ; } int written = output . getWritten ( ) ; if ( written > avaiableSize ) { throw FSTBufferTooSmallException . Instance ; } System . arraycopy ( output . getBuffer ( ) , 0 , result , resultOffset , written ) ; return written ;


signature:
public class FSTBytezDecoder { /** * len < 127 ! ! ! ! !
 * @ return
 * @ throws java . io . IOException */
@ Override public String readStringAsc ( ) throws IOException { } }

implementation:
int len = readFInt ( ) ; if ( ascStringCache == null || ascStringCache . length ( ) < len ) ascStringCache = new HeapBytez ( new byte [ len ] ) ; ensureReadAhead ( len ) ; // System . arraycopy ( input . buf , input . pos , ascStringCache , 0 , len ) ;
input . copyTo ( ascStringCache , 0 , pos , len ) ; pos += len ; return new String ( ascStringCache . getBase ( ) , 0 , 0 , len ) ;


signature:
public class FSTBytezDecoder { /** * assumes class header + len already read
 * @ param componentType
 * @ param len
 * @ return */
@ Override public Object readFPrimitiveArray ( Object array , Class componentType , int len ) { } }

implementation:
// FIXME : if else chaining could be avoided
if ( componentType == byte . class ) { ensureReadAhead ( len ) ; byte arr [ ] = ( byte [ ] ) array ; input . getArr ( pos , arr , 0 , len ) ; pos += len ; return arr ; } else if ( componentType == char . class ) { ensureReadAhead ( len * 2 ) ; char [ ] arr = ( char [ ] ) array ; input . getCharArr ( pos , arr , 0 , len ) ; pos += len * 2 ; return arr ; } else if ( componentType == short . class ) { ensureReadAhead ( len * 2 ) ; short [ ] arr = ( short [ ] ) array ; input . getShortArr ( pos , arr , 0 , len ) ; pos += len * 2 ; return arr ; } else if ( componentType == int . class ) { ensureReadAhead ( len * 4 ) ; int [ ] arr = ( int [ ] ) array ; input . getIntArr ( pos , arr , 0 , len ) ; pos += len * 4 ; return arr ; } else if ( componentType == float . class ) { ensureReadAhead ( len * 4 ) ; float [ ] arr = ( float [ ] ) array ; input . getFloatArr ( pos , arr , 0 , len ) ; pos += len * 4 ; return arr ; } else if ( componentType == double . class ) { ensureReadAhead ( len * 8 ) ; double [ ] arr = ( double [ ] ) array ; input . getDoubleArr ( pos , arr , 0 , len ) ; pos += len * 8 ; return arr ; } else if ( componentType == long . class ) { ensureReadAhead ( len * 8 ) ; long [ ] arr = ( long [ ] ) array ; input . getLongArr ( pos , arr , 0 , len ) ; pos += len * 8 ; return arr ; } else if ( componentType == boolean . class ) { ensureReadAhead ( len ) ; boolean [ ] arr = ( boolean [ ] ) array ; input . getBooleanArr ( pos , arr , 0 , len ) ; pos += len ; return arr ; } else { throw new RuntimeException ( "unexpected primitive type " + componentType . getName ( ) ) ; }


signature:
public class FSTUtil { /** * obsolete */
public static String getPackage ( Class clazz ) { } }

implementation: String s = clazz . getName ( ) ; int i = s . lastIndexOf ( '[' ) ; if ( i >= 0 ) { s = s . substring ( i + 2 ) ; } i = s . lastIndexOf ( '.' ) ; if ( i >= 0 ) { return s . substring ( 0 , i ) ; } return "" ;


signature:
public class MMFBytez { /** * hack to update underlying file in slices handed out to app */
public void _setMMFData ( File file , FileChannel fileChannel , Cleaner cleaner ) { } }

implementation: this . file = file ; this . fileChannel = fileChannel ; this . cleaner = cleaner ;


signature:
public class FSTClazzLineageInfo { /** * Returns the specificity of the specified class as defined above . */
public static int getSpecificity ( final Class < ? > clazz ) { } }

implementation: if ( clazz == null ) return 0 ; final LineageInfo lineageInfo = FSTClazzLineageInfo . getLineageInfo ( clazz ) ; return lineageInfo == null ? 0 : lineageInfo . specificity ;


signature:
public class FSTClazzLineageInfo { /** * Returns the lineage of the specified class ordered by specificity ( the class itself is at position 0 since it is most specific in its lineage ) . */
public static Class < ? > [ ] getLineage ( final Class < ? > clazz ) { } }

implementation: final LineageInfo lineageInfo = getLineageInfo ( clazz ) ; return lineageInfo == null ? EMPTY_CLASS_ARRAY : lineageInfo . lineage . toArray ( new Class < ? > [ lineageInfo . lineage . size ( ) ] ) ;


signature:
public class FSTBinaryOffheapMap { /** * PRIVILEGED method . You gotta know what your doing here . .
 * currently a very expensive operation . . frees everything , resize file and remap .
 * Remapping involves rebuild of index .
 * @ param required */
public void resizeStore ( long required , long maxgrowbytes ) { } }

implementation: if ( mappedFile == null ) throw new RuntimeException ( "store is full. Required: " + required ) ; if ( required <= memory . length ( ) ) return ; mutationCount ++ ; System . out . println ( "resizing underlying " + mappedFile + " to " + required + " numElem:" + numElem ) ; long tim = System . currentTimeMillis ( ) ; ( ( MMFBytez ) memory ) . freeAndClose ( ) ; memory = null ; try { File mf = new File ( mappedFile ) ; FileOutputStream f = new FileOutputStream ( mf , true ) ; long len = mf . length ( ) ; required = required + Math . min ( required , maxgrowbytes ) ; byte [ ] toWrite = new byte [ 1000 ] ; long max = ( required - len ) / 1000 ; for ( long i = 0 ; i < max + 2 ; i ++ ) { f . write ( toWrite ) ; } f . flush ( ) ; f . close ( ) ; resetMem ( mappedFile , mf . length ( ) ) ; System . out . println ( "resizing done in " + ( System . currentTimeMillis ( ) - tim ) + " numElemAfter:" + numElem ) ; } catch ( FileNotFoundException e ) { e . printStackTrace ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; }


signature:
public class FSTBinaryOffheapMap { /** * get an entry . the returned ByteSource must be processed immediately as it will be reused
 * internally on next get
 * Warning : Concurrent Modification ( e . g . add remove elements during iteration ) is NOT SUPPORTED
 * and NOT CHECKED . Collect keys to change inside iteration and perform changes after iteration is
 * finished .
 * @ param key
 * @ return */
public BytezByteSource getBinary ( ByteSource key ) { } }

implementation: checkThread ( ) ; if ( key . length ( ) != keyLen ) throw new RuntimeException ( "key must have length " + keyLen ) ; long aLong = index . get ( key ) ; if ( aLong == 0 ) { return null ; } long off = aLong ; int len = getContentLenFromHeader ( off ) ; off += getHeaderLen ( ) ; tmpValueBytez . setLen ( len ) ; tmpValueBytez . setOff ( off ) ; return tmpValueBytez ;


signature:
public class FSTBinaryOffheapMap { /** * remove the key from the binary map
 * @ param key */
public void removeBinary ( ByteSource key ) { } }

implementation: checkThread ( ) ; if ( key . length ( ) != keyLen ) throw new RuntimeException ( "key must have length " + keyLen ) ; mutationCount ++ ; long rem = index . get ( key ) ; if ( rem != 0 ) { index . remove ( key ) ; decElems ( ) ; removeEntry ( rem ) ; }


signature: public class FSTStreamEncoder { public void writeFShortArr ( short [ ] arr , int off , int len ) throws IOException { } }

implementation: buffout . ensureFree ( len * 3 ) ; for ( int i = off ; i < off + len ; i ++ ) { short c = arr [ i ] ; if ( c < 255 && c >= 0 ) { buffout . buf [ buffout . pos ++ ] = ( byte ) c ; } else { buffout . buf [ buffout . pos ] = ( byte ) 255 ; buffout . buf [ buffout . pos + 1 ] = ( byte ) ( c >>> 0 ) ; buffout . buf [ buffout . pos + 2 ] = ( byte ) ( c >>> 8 ) ; buffout . pos += 3 ; } }


signature:
public class FSTStreamEncoder { /** * uncompressed version */
public void writeFIntArr ( int [ ] arr , int off , int len ) throws IOException { } }

implementation: int byteLen = arr . length * 4 ; buffout . ensureFree ( byteLen ) ; byte buf [ ] = buffout . buf ; int count = buffout . pos ; int max = off + len ; for ( int i = off ; i < max ; i ++ ) { long anInt = arr [ i ] ; buf [ count ] = ( byte ) ( anInt >>> 0 ) ; buf [ count + 1 ] = ( byte ) ( anInt >>> 8 ) ; buf [ count + 2 ] = ( byte ) ( anInt >>> 16 ) ; buf [ count + 3 ] = ( byte ) ( anInt >>> 24 ) ; count += 4 ; } buffout . pos += byteLen ;


signature:
public class FSTStreamEncoder { /** * compressed version */
public void _writeFIntArr ( int v [ ] , int off , int len ) throws IOException { } }

implementation: final int free = 5 * len ; buffout . ensureFree ( free ) ; final byte [ ] buf = buffout . buf ; int count = buffout . pos ; for ( int i = off ; i < off + len ; i ++ ) { final int anInt = v [ i ] ; if ( anInt > - 127 && anInt <= 127 ) { buffout . buf [ count ++ ] = ( byte ) anInt ; } else if ( anInt >= Short . MIN_VALUE && anInt <= Short . MAX_VALUE ) { buf [ count ++ ] = - 128 ; buf [ count ++ ] = ( byte ) ( ( anInt >>> 0 ) & 0xFF ) ; buf [ count ++ ] = ( byte ) ( ( anInt >>> 8 ) & 0xFF ) ; } else { buf [ count ++ ] = - 127 ; buf [ count ++ ] = ( byte ) ( ( anInt >>> 0 ) & 0xFF ) ; buf [ count ++ ] = ( byte ) ( ( anInt >>> 8 ) & 0xFF ) ; buf [ count ++ ] = ( byte ) ( ( anInt >>> 16 ) & 0xFF ) ; buf [ count ++ ] = ( byte ) ( ( anInt >>> 24 ) & 0xFF ) ; } } buffout . pos = count ;


signature:
public class FSTStreamEncoder { /** * does not write length , just plain bytes
 * @ param array
 * @ param length
 * @ throws java . io . IOException */
public void writeRawBytes ( byte [ ] array , int start , int length ) throws IOException { } }

implementation: buffout . ensureFree ( length ) ; System . arraycopy ( array , start , buffout . buf , buffout . pos , length ) ; buffout . pos += length ;


signature:
public class FSTStreamEncoder { /** * length < 127 ! ! ! ! !
 * @ param name
 * @ throws java . io . IOException */
void writeStringAsc ( String name ) throws IOException { } }

implementation: int len = name . length ( ) ; if ( len >= 127 ) { throw new RuntimeException ( "Ascii String too long" ) ; } writeFByte ( ( byte ) len ) ; buffout . ensureFree ( len ) ; if ( ascStringCache == null || ascStringCache . length < len ) ascStringCache = new byte [ len ] ; name . getBytes ( 0 , len , ascStringCache , 0 ) ; writeRawBytes ( ascStringCache , 0 , len ) ;


signature:
public class FSTStreamEncoder { /** * used to write uncompressed int ( guaranteed length = 4 ) at a ( eventually recent ) position
 * @ param position
 * @ param v */
@ Override public void writeInt32At ( int position , int v ) { } }

implementation: buffout . buf [ position ] = ( byte ) ( v >>> 0 ) ; buffout . buf [ position + 1 ] = ( byte ) ( v >>> 8 ) ; buffout . buf [ position + 2 ] = ( byte ) ( v >>> 16 ) ; buffout . buf [ position + 3 ] = ( byte ) ( v >>> 24 ) ;


signature:
public class FSTStreamEncoder { /** * if output stream is null , just encode into a byte array
 * @ param outstream */
@ Override public void setOutstream ( OutputStream outstream ) { } }

implementation:
if ( buffout == null ) { // try reuse
buffout = ( FSTOutputStream ) conf . getCachedObject ( FSTOutputStream . class ) ; if ( buffout == null ) // if fail , alloc
buffout = new FSTOutputStream ( 1000 , outstream ) ; else buffout . reset ( ) ; // reset resued fstoutput
} if ( outstream == null ) buffout . setOutstream ( buffout ) ; else buffout . setOutstream ( outstream ) ;


signature:
public class FSTStructFactory { /** * allocates a StructAccessor ( " pointer " ) matching the struct data expected in the byte
 * array at given position . The resulting pointer object is not " volatile " ( not a cached instance )
 * @ param b
 * @ param index
 * @ return */
public FSTStruct createStructWrapper ( Bytez b , long index ) { } }

implementation: int clzId = b . getInt ( index + 4 ) ; return createStructPointer ( b , index , clzId ) ;


signature:
public class FSTStructFactory { /** * allocates a StructAccessor ( " pointer " ) matching the struct data expected in the byte
 * array at given position with given classId . The resulting pointer object is not " volatile " ( not a cached instance ) .
 * The class id should match the Struct stored in the byte array . ( classId must be the correct struct or a superclass of it )
 * @ param b
 * @ param index
 * @ return */
public FSTStruct createStructPointer ( Bytez b , long index , int clzId ) { } }

implementation:
// synchronized ( this ) / / FIXME FIXME FIXME : contention point
// desynced expecting class registering happens on startup
{ Class clazz = mIntToClz . get ( clzId ) ; if ( clazz == null ) throw new RuntimeException ( "unregistered class " + clzId ) ; try { return ( FSTStruct ) createWrapper ( clazz , b , index ) ; } catch ( Exception e ) { throw new RuntimeException ( e ) ; } }


signature:
public class FSTConfiguration { /** * create a json conf with given attributes . Note that shared refs = true for jason might be not as stable as for binary encodings
 * as fst relies on stream positions to identify objects within a given input , so any inbetween formatting will break proper reference
 * resolution .
 * WARNING : use of sharedrefs = true is Deprecated as its flakey
 * @ param prettyPrint
 * @ param shareReferences
 * @ return */
public static FSTConfiguration createJsonConfiguration ( boolean prettyPrint , boolean shareReferences ) { } }

implementation: if ( shareReferences && prettyPrint ) { throw new RuntimeException ( "unsupported flag combination" ) ; } return createJsonConfiguration ( prettyPrint , shareReferences , null ) ;


signature:
public class FSTConfiguration { /** * debug only , very slow ( creates config with each call ) . Creates new conf so custom serializers are ignored .
 * @ param o */
public static void prettyPrintJson ( Object o ) { } }

implementation: FSTConfiguration conf = constructJsonConf ( true , true , null ) ; System . out . println ( conf . asJsonString ( o ) ) ;


signature:
public class FSTConfiguration { /** * register a custom serializer for a given class or the class and all of its subclasses .
 * Serializers must be configured identical on read / write side and should be set before
 * actually making use of the Configuration .
 * @ param clazz
 * @ param ser
 * @ param alsoForAllSubclasses */
public void registerSerializer ( Class clazz , FSTObjectSerializer ser , boolean alsoForAllSubclasses ) { } }

implementation: serializationInfoRegistry . getSerializerRegistry ( ) . putSerializer ( clazz , ser , alsoForAllSubclasses ) ;


signature:
public class FSTConfiguration { /** * special configuration used internally for struct emulation
 * @ return */
public static FSTConfiguration createStructConfiguration ( ) { } }

implementation: FSTConfiguration conf = new FSTConfiguration ( null ) ; conf . setStructMode ( true ) ; return conf ;


signature:
public class FSTConfiguration { /** * reuse heavy weight objects . If a FSTStream is closed , objects are returned and can be reused by new stream instances .
 * the objects are held in soft references , so there should be no memory issues . FIXME : point of contention !
 * @ param cached */
public void returnObject ( Object cached ) { } }

implementation:
try { while ( ! cacheLock . compareAndSet ( false , true ) ) { // empty
} List < SoftReference > li = cachedObjects . get ( cached . getClass ( ) ) ; if ( li == null ) { li = new ArrayList < SoftReference > ( ) ; cachedObjects . put ( cached . getClass ( ) , li ) ; } if ( li . size ( ) < 5 ) li . add ( new SoftReference ( cached ) ) ; } finally { cacheLock . set ( false ) ; }


signature:
public class FSTConfiguration { /** * for optimization purposes , do not use to benchmark processing time or in a regular program as
 * this methods creates a temporary binaryoutputstream and serializes the object in order to measure the
 * size . */
public int calcObjectSizeBytesNotAUtility ( Object obj ) throws IOException { } }

implementation: ByteArrayOutputStream bout = new ByteArrayOutputStream ( 10000 ) ; FSTObjectOutput ou = new FSTObjectOutput ( bout , this ) ; ou . writeObject ( obj , obj . getClass ( ) ) ; ou . close ( ) ; return bout . toByteArray ( ) . length ;


signature:
public class FSTConfiguration { /** * clear cached softref ' s and ThreadLocal . */
public void clearCaches ( ) { } }

implementation:
try { FSTInputStream . cachedBuffer . set ( null ) ; while ( ! cacheLock . compareAndSet ( false , true ) ) { // empty
} cachedObjects . clear ( ) ; } finally { cacheLock . set ( false ) ; }


signature:
public class FSTConfiguration { /** * utility for thread safety and reuse . Do not close the resulting stream . However you should close
 * the given InputStream ' in '
 * @ param in
 * @ return */
public FSTObjectInput getObjectInput ( InputStream in ) { } }

implementation: FSTObjectInput fstObjectInput = getIn ( ) ; try { fstObjectInput . resetForReuse ( in ) ; return fstObjectInput ; } catch ( IOException e ) { FSTUtil . < RuntimeException > rethrow ( e ) ; } return null ;


signature:
public class FSTConfiguration { /** * take the given array as input . the array is NOT copied .
 * WARNING : the input streams takes over ownership and might overwrite content
 * of this array in subsequent IO operations .
 * @ param arr
 * @ param len
 * @ return */
public FSTObjectInput getObjectInput ( byte arr [ ] , int len ) { } }

implementation: FSTObjectInput fstObjectInput = getIn ( ) ; try { fstObjectInput . resetForReuseUseArray ( arr , len ) ; return fstObjectInput ; } catch ( IOException e ) { FSTUtil . < RuntimeException > rethrow ( e ) ; } return null ;


signature:
public class FSTConfiguration { /** * take the given array and copy it to input . the array IS copied
 * @ param arr
 * @ param len
 * @ return */
public FSTObjectInput getObjectInputCopyFrom ( byte arr [ ] , int off , int len ) { } }

implementation: FSTObjectInput fstObjectInput = getIn ( ) ; try { fstObjectInput . resetForReuseCopyArray ( arr , off , len ) ; return fstObjectInput ; } catch ( IOException e ) { FSTUtil . < RuntimeException > rethrow ( e ) ; } return null ;


signature:
public class FSTConfiguration { /** * utility for thread safety and reuse . Do not close the resulting stream . However you should close
 * the given OutputStream ' out '
 * @ param out - can be null ( temp bytearrays stream is created then )
 * @ return */
public FSTObjectOutput getObjectOutput ( OutputStream out ) { } }

implementation: FSTObjectOutput fstObjectOutput = getOut ( ) ; fstObjectOutput . resetForReUse ( out ) ; return fstObjectOutput ;


signature:
public class FSTConfiguration { /** * init right after creation of configuration , not during operation as it is not threadsafe regarding mutation
 * currently only for minbin serialization
 * @ param keysAndVals { { " symbolicName " , " fullQualifiedClazzName " } , . . } */
public FSTConfiguration registerCrossPlatformClassMapping ( String [ ] [ ] keysAndVals ) { } }

implementation: for ( int i = 0 ; i < keysAndVals . length ; i ++ ) { String [ ] keysAndVal = keysAndVals [ i ] ; registerCrossPlatformClassMapping ( keysAndVal [ 0 ] , keysAndVal [ 1 ] ) ; } return this ;


signature:
public class FSTConfiguration { /** * shorthand for registerCrossPlatformClassMapping ( _ , _ )
 * @ param shortName - class name in json type field
 * @ param clz - class
 * @ return */
public FSTConfiguration cpMap ( String shortName , Class clz ) { } }

implementation: return registerCrossPlatformClassMapping ( shortName , clz . getName ( ) ) ;


signature:
public class FSTConfiguration { /** * get cross platform symbolic class identifier
 * @ param cl
 * @ return */
public String getCPNameForClass ( Class cl ) { } }

implementation: String res = minbinNamesReverse . get ( cl . getName ( ) ) ; if ( res == null ) { if ( cl . isAnonymousClass ( ) ) { return getCPNameForClass ( cl . getSuperclass ( ) ) ; } return cl . getName ( ) ; } return res ;


signature:
public class FSTConfiguration { /** * convenience */
public Object asObject ( byte b [ ] ) { } }

implementation:
try { return getObjectInput ( b ) . readObject ( ) ; } catch ( Exception e ) { System . out . println ( "unable to decode:" + new String ( b , 0 , 0 , Math . min ( b . length , 100 ) ) ) ; try { String debug = new String ( b , "UTF-8" ) ; } catch ( UnsupportedEncodingException e1 ) { } try { getObjectInput ( b ) . readObject ( ) ; } catch ( Exception e1 ) { // debug hook
} FSTUtil . < RuntimeException > rethrow ( e ) ; } return null ;


signature:
public class FSTConfiguration { /** * convenience . ( object must be serializable ) */
public byte [ ] asByteArray ( Object object ) { } }

implementation:
FSTObjectOutput objectOutput = getObjectOutput ( ) ; try { objectOutput . writeObject ( object ) ; return objectOutput . getCopyOfWrittenBuffer ( ) ; } catch ( IOException e ) { try { // FSTConfiguration . prettyPrintJson ( object ) ; endless cycle !
} catch ( Exception ee ) { } FSTUtil . < RuntimeException > rethrow ( e ) ; } return null ;


signature:
public class FSTConfiguration { /** * Warning : avoids allocation + copying .
 * The returned byteArray is a direct pointer to underlying buffer .
 * the int length [ ] is expected to have at least on element .
 * The buffer can be larger than written data , therefore length [ 0 ] will contain written length .
 * The buffer content must be used ( e . g . sent to network , copied to offheap ) before doing another
 * asByteArray on the current Thread . */
public byte [ ] asSharedByteArray ( Object object , int length [ ] ) { } }

implementation: FSTObjectOutput objectOutput = getObjectOutput ( ) ; try { objectOutput . writeObject ( object ) ; length [ 0 ] = objectOutput . getWritten ( ) ; return objectOutput . getBuffer ( ) ; } catch ( IOException e ) { FSTUtil . < RuntimeException > rethrow ( e ) ; } return null ;


signature:
public class FSTConfiguration { /** * utility / debug method . Use " asByteArray " for programmatic use as the
 * byte array will already by UTF - 8 and ready to be sent on network .
 * @ param o
 * @ return */
public String asJsonString ( Object o ) { } }

implementation: if ( getCoderSpecific ( ) instanceof JsonFactory == false ) { return "can be called on JsonConfiguration only" ; } else { return new String ( asByteArray ( o ) , StandardCharsets . UTF_8 ) ; }


signature:
public class FSTConfiguration { /** * helper to write series of objects to streams / files > Integer . MAX _ VALUE .
 * it
 * - serializes the object
 * - writes the length of the serialized object to the stream
 * - the writes the serialized object data
 * on reader side ( e . g . from a blocking socketstream , the reader then
 * - reads the length
 * - reads [ length ] bytes from the stream
 * - deserializes
 * @ see decodeFromStream
 * @ param out
 * @ param toSerialize
 * @ throws IOException */
public void encodeToStream ( OutputStream out , Object toSerialize ) throws IOException { } }

implementation:
FSTObjectOutput objectOutput = getObjectOutput ( ) ; // could also do new with minor perf impact
objectOutput . writeObject ( toSerialize ) ; int written = objectOutput . getWritten ( ) ; out . write ( ( written >>> 0 ) & 0xFF ) ; out . write ( ( written >>> 8 ) & 0xFF ) ; out . write ( ( written >>> 16 ) & 0xFF ) ; out . write ( ( written >>> 24 ) & 0xFF ) ; // copy internal buffer to bufferedoutput
out . write ( objectOutput . getBuffer ( ) , 0 , written ) ; objectOutput . flush ( ) ;


signature:
public class FSTConfiguration { /** * @ see encodeToStream
 * @ param in
 * @ return
 * @ throws Exception */
public Object decodeFromStream ( InputStream in ) throws Exception { } }

implementation:
int read = in . read ( ) ; if ( read < 0 ) throw new EOFException ( "stream is closed" ) ; int ch1 = ( read + 256 ) & 0xff ; int ch2 = ( in . read ( ) + 256 ) & 0xff ; int ch3 = ( in . read ( ) + 256 ) & 0xff ; int ch4 = ( in . read ( ) + 256 ) & 0xff ; int len = ( ch4 << 24 ) + ( ch3 << 16 ) + ( ch2 << 8 ) + ( ch1 << 0 ) ; if ( len <= 0 ) throw new EOFException ( "stream is corrupted" ) ; byte buffer [ ] = new byte [ len ] ; // this could be reused !
while ( len > 0 ) { len -= in . read ( buffer , buffer . length - len , len ) ; } return getObjectInput ( buffer ) . readObject ( ) ;


signature:
public class FSTClazzInfo { /** * sideeffecting : if no ser is found , next lookup will return null immediate
 * @ return */
public FSTObjectSerializer getSer ( ) { } }

implementation: if ( ser == null ) { if ( clazz == null ) { return null ; } ser = getSerNoStore ( ) ; if ( ser == null ) { ser = FSTSerializerRegistry . NULL ; } } if ( ser == FSTSerializerRegistry . NULL ) { return null ; } return ser ;


signature:
public class MBOut { /** * write an int type with header
 * @ param type
 * @ param data */
public void writeInt ( byte type , long data ) { } }

implementation: if ( ! MinBin . isPrimitive ( type ) || MinBin . isArray ( type ) ) throw new RuntimeException ( "illegal type code" ) ; writeOut ( type ) ; writeRawInt ( type , data ) ;


signature:
public class MBOut { /** * encode int without header tag
 * @ param data */
protected void writeRawInt ( byte type , long data ) { } }

implementation: int numBytes = MinBin . extractNumBytes ( type ) ; for ( int i = 0 ; i < numBytes ; i ++ ) { writeOut ( ( byte ) ( data & 0xff ) ) ; data = data >>> 8 ; }


signature:
public class MBOut { /** * encode int using only as much bytes as needed to represent it
 * @ param data */
public void writeIntPacked ( long data ) { } }

implementation: if ( data <= Byte . MAX_VALUE && data >= Byte . MIN_VALUE ) writeInt ( MinBin . INT_8 , data ) ; else if ( data <= Short . MAX_VALUE && data >= Short . MIN_VALUE ) writeInt ( MinBin . INT_16 , data ) ; else if ( data <= Integer . MAX_VALUE && data >= Integer . MIN_VALUE ) writeInt ( MinBin . INT_32 , data ) ; else if ( data <= Long . MAX_VALUE && data >= Long . MIN_VALUE ) writeInt ( MinBin . INT_64 , data ) ;


signature:
public class MBOut { /** * write primitive array + header . no floating point or object array allowed . Just int based types
 * @ param primitiveArray
 * @ param start
 * @ param len */
public void writeArray ( Object primitiveArray , int start , int len ) { } }

implementation: byte type = MinBin . ARRAY_MASK ; Class < ? > componentType = primitiveArray . getClass ( ) . getComponentType ( ) ; if ( componentType == boolean . class ) type |= MinBin . INT_8 ; else if ( componentType == byte . class ) type |= MinBin . INT_8 ; else if ( componentType == short . class ) type |= MinBin . INT_16 ; else if ( componentType == char . class ) type |= MinBin . INT_16 | MinBin . UNSIGN_MASK ; else if ( componentType == int . class ) type |= MinBin . INT_32 ; else if ( componentType == long . class ) type |= MinBin . INT_64 ; else throw new RuntimeException ( "unsupported type " + componentType . getName ( ) ) ; writeOut ( type ) ; writeIntPacked ( len ) ; switch ( type ) { case MinBin . INT_8 | MinBin . ARRAY_MASK : { if ( componentType == boolean . class ) { boolean [ ] arr = ( boolean [ ] ) primitiveArray ; for ( int i = start ; i < start + len ; i ++ ) { writeRawInt ( type , arr [ i ] ? 1 : 0 ) ; } } else { byte [ ] arr = ( byte [ ] ) primitiveArray ; for ( int i = start ; i < start + len ; i ++ ) { writeRawInt ( type , arr [ i ] ) ; } } } break ; case MinBin . CHAR | MinBin . ARRAY_MASK : { char [ ] charArr = ( char [ ] ) primitiveArray ; for ( int i = start ; i < start + len ; i ++ ) { writeRawInt ( type , charArr [ i ] ) ; } } break ; case MinBin . INT_32 | MinBin . ARRAY_MASK : { int [ ] arr = ( int [ ] ) primitiveArray ; for ( int i = start ; i < start + len ; i ++ ) { writeRawInt ( type , arr [ i ] ) ; } } break ; case MinBin . INT_64 | MinBin . ARRAY_MASK : { long [ ] arr = ( long [ ] ) primitiveArray ; for ( int i = start ; i < start + len ; i ++ ) { writeRawInt ( type , arr [ i ] ) ; } } break ; default : { for ( int i = start ; i < start + len ; i ++ ) { if ( componentType == boolean . class ) writeRawInt ( type , Array . getBoolean ( primitiveArray , i ) ? 1 : 0 ) ; else writeRawInt ( type , Array . getLong ( primitiveArray , i ) ) ; } } }


signature:
public class MBOut { /** * allow write through to underlying byte for performance reasons
 * @ param bufferedName
 * @ param i
 * @ param length */
public void writeRaw ( byte [ ] bufferedName , int i , int length ) { } }

implementation: if ( pos + length >= bytez . length - 1 ) { resize ( ) ; } System . arraycopy ( bufferedName , i , bytez , pos , length ) ; pos += length ;


signature:
public class MBIn { /** * read into preallocated array , allows to write to different type ( e . g . boolean [ ] from byte [ ] )
 * @ param type type tag .
 * @ param len
 * @ param resultingArray
 * @ return */
public Object readArrayRaw ( byte type , int len , Object resultingArray ) { } }

implementation: Class componentType = resultingArray . getClass ( ) . getComponentType ( ) ; if ( componentType == byte . class ) { byte [ ] barr = ( byte [ ] ) resultingArray ; for ( int i = 0 ; i < len ; i ++ ) { barr [ i ] = ( byte ) readRawInt ( type ) ; } } else if ( componentType == short . class ) { short [ ] sArr = ( short [ ] ) resultingArray ; for ( int i = 0 ; i < len ; i ++ ) { sArr [ i ] = ( short ) readRawInt ( type ) ; } } else if ( componentType == char . class ) { char [ ] cArr = ( char [ ] ) resultingArray ; for ( int i = 0 ; i < len ; i ++ ) { cArr [ i ] = ( char ) readRawInt ( type ) ; } } else if ( componentType == int . class ) { int [ ] iArr = ( int [ ] ) resultingArray ; for ( int i = 0 ; i < len ; i ++ ) { iArr [ i ] = ( int ) readRawInt ( type ) ; } } else if ( componentType == long . class ) { long [ ] lArr = ( long [ ] ) resultingArray ; for ( int i = 0 ; i < len ; i ++ ) { lArr [ i ] = readRawInt ( type ) ; } } else if ( componentType == boolean . class ) { boolean [ ] boolArr = ( boolean [ ] ) resultingArray ; for ( int i = 0 ; i < len ; i ++ ) { boolArr [ i ] = readRawInt ( MinBin . INT_8 ) != 0 ; } } else throw new RuntimeException ( "unsupported array type " + resultingArray . getClass ( ) . getName ( ) ) ; return resultingArray ;


signature: public class FSTObjectOutput { public void writeObject ( Object obj , Class ... possibles ) throws IOException { } }

implementation:
if ( isCrossPlatform ) { writeObjectInternal ( obj , null ) ; // not supported cross platform
return ; } if ( possibles != null && possibles . length > 1 ) { for ( int i = 0 ; i < possibles . length ; i ++ ) { Class possible = possibles [ i ] ; getCodec ( ) . registerClass ( possible ) ; } } writeObjectInternal ( obj , null , possibles ) ;


signature:
public class FSTObjectOutput { /** * avoid creation of dummy ref */
protected FSTClazzInfo . FSTFieldInfo getCachedFI ( Class ... possibles ) { } }

implementation: if ( refs == null ) { refs = refsLocal . get ( ) ; } if ( curDepth >= refs . length ) { return new FSTClazzInfo . FSTFieldInfo ( possibles , null , true ) ; } else { FSTClazzInfo . FSTFieldInfo inf = refs [ curDepth ] ; if ( inf == null ) { inf = new FSTClazzInfo . FSTFieldInfo ( possibles , null , true ) ; refs [ curDepth ] = inf ; return inf ; } inf . setPossibleClasses ( possibles ) ; return inf ; }


signature:
public class FSTObjectOutput { /** * hook for debugging profiling . register a FSTSerialisationListener to use
 * @ param obj
 * @ param streamPosition */
protected void objectWillBeWritten ( Object obj , int streamPosition ) { } }

implementation: if ( listener != null ) { listener . objectWillBeWritten ( obj , streamPosition ) ; }


signature:
public class FSTObjectOutput { /** * hook for debugging profiling . empty impl , you need to subclass to make use of this hook
 * @ param obj
 * @ param oldStreamPosition
 * @ param streamPosition */
protected void objectHasBeenWritten ( Object obj , int oldStreamPosition , int streamPosition ) { } }

implementation: if ( listener != null ) { listener . objectHasBeenWritten ( obj , oldStreamPosition , streamPosition ) ; }


signature:
public class FSTObjectOutput { /** * splitting this slows down . . . */
protected FSTClazzInfo writeObjectWithContext ( FSTClazzInfo . FSTFieldInfo referencee , Object toWrite , FSTClazzInfo ci ) throws IOException { } }

implementation:
int startPosition = 0 ; try { if ( toWrite == null ) { getCodec ( ) . writeTag ( NULL , null , 0 , toWrite , this ) ; return null ; } startPosition = getCodec ( ) . getWritten ( ) ; objectWillBeWritten ( toWrite , startPosition ) ; final Class clazz = toWrite . getClass ( ) ; if ( clazz == String . class ) { String [ ] oneOf = referencee . getOneOf ( ) ; if ( oneOf != null ) { for ( int i = 0 ; i < oneOf . length ; i ++ ) { String s = oneOf [ i ] ; if ( s . equals ( toWrite ) ) { getCodec ( ) . writeTag ( ONE_OF , oneOf , i , toWrite , this ) ; getCodec ( ) . writeFByte ( i ) ; return null ; } } } // shortpath
if ( ! dontShare && writeHandleIfApplicable ( toWrite , stringInfo ) ) return stringInfo ; getCodec ( ) . writeTag ( STRING , toWrite , 0 , toWrite , this ) ; getCodec ( ) . writeStringUTF ( ( String ) toWrite ) ; return null ; } else if ( clazz == Integer . class ) { getCodec ( ) . writeTag ( BIG_INT , null , 0 , toWrite , this ) ; getCodec ( ) . writeFInt ( ( ( Integer ) toWrite ) . intValue ( ) ) ; return null ; } else if ( clazz == Long . class ) { getCodec ( ) . writeTag ( BIG_LONG , null , 0 , toWrite , this ) ; getCodec ( ) . writeFLong ( ( ( Long ) toWrite ) . longValue ( ) ) ; return null ; } else if ( clazz == Boolean . class ) { getCodec ( ) . writeTag ( ( ( Boolean ) toWrite ) . booleanValue ( ) ? BIG_BOOLEAN_TRUE : BIG_BOOLEAN_FALSE , null , 0 , toWrite , this ) ; return null ; } else if ( ( referencee . getType ( ) != null && referencee . getType ( ) . isEnum ( ) ) || toWrite instanceof Enum ) { return writeEnum ( referencee , toWrite ) ; } FSTClazzInfo serializationInfo = ci == null ? getFstClazzInfo ( referencee , clazz ) : ci ; // check for identical / equal objects
FSTObjectSerializer ser = serializationInfo . getSer ( ) ; if ( ! dontShare && ! referencee . isFlat ( ) && ! serializationInfo . isFlat ( ) && ( ser == null || ! ser . alwaysCopy ( ) ) ) { if ( writeHandleIfApplicable ( toWrite , serializationInfo ) ) return serializationInfo ; } if ( clazz . isArray ( ) ) { if ( getCodec ( ) . writeTag ( ARRAY , toWrite , 0 , toWrite , this ) ) return serializationInfo ; // some codecs handle primitive arrays like an primitive type
writeArray ( referencee , toWrite ) ; getCodec ( ) . writeArrayEnd ( ) ; } else if ( ser == null ) { // default write object wihtout custom serializer
// handle write replace
// if ( ! dontShare ) GIT ISSUE 80
FSTClazzInfo originalInfo = serializationInfo ; { if ( serializationInfo . getWriteReplaceMethod ( ) != null ) { Object replaced = null ; try { replaced = serializationInfo . getWriteReplaceMethod ( ) . invoke ( toWrite ) ; } catch ( Exception e ) { FSTUtil . < RuntimeException > rethrow ( e ) ; } if ( replaced != toWrite ) { toWrite = replaced ; serializationInfo = getClassInfoRegistry ( ) . getCLInfo ( toWrite . getClass ( ) , conf ) ; // fixme : update object map ?
} } // clazz uses some JDK special stuff ( frequently slow )
if ( serializationInfo . useCompatibleMode ( ) && ! serializationInfo . isExternalizable ( ) ) { writeObjectCompatible ( referencee , toWrite , serializationInfo ) ; return originalInfo ; } } if ( ! writeObjectHeader ( serializationInfo , referencee , toWrite ) ) { // skip in case codec can write object as primitive
ser = serializationInfo . getSer ( ) ; if ( ser == null ) { defaultWriteObject ( toWrite , serializationInfo ) ; if ( serializationInfo . isExternalizable ( ) ) getCodec ( ) . externalEnd ( serializationInfo ) ; } else { // handle edge case : there is a serializer registered for replaced class
// copied from below : (
int pos = getCodec ( ) . getWritten ( ) ; // write object depending on type ( custom , externalizable , serializable / java , default )
ser . writeObject ( this , toWrite , serializationInfo , referencee , pos ) ; getCodec ( ) . externalEnd ( serializationInfo ) ; } } return originalInfo ; } else { // object has custom serializer
// Object header ( nothing written till here )
if ( ! writeObjectHeader ( serializationInfo , referencee , toWrite ) ) { // skip in case code can write object as primitive
int pos = getCodec ( ) . getWritten ( ) ; // write object depending on type ( custom , externalizable , serializable / java , default )
ser . writeObject ( this , toWrite , serializationInfo , referencee , pos ) ; getCodec ( ) . externalEnd ( serializationInfo ) ; } } return serializationInfo ; } finally { objectHasBeenWritten ( toWrite , startPosition , getCodec ( ) . getWritten ( ) ) ; }


signature:
public class FSTObjectOutput { /** * if class is same as last referenced , returned cached clzinfo , else do a lookup */
protected FSTClazzInfo getFstClazzInfo ( FSTClazzInfo . FSTFieldInfo referencee , Class clazz ) { } }

implementation: FSTClazzInfo serializationInfo = null ; FSTClazzInfo lastInfo = referencee . lastInfo ; if ( lastInfo != null && lastInfo . getClazz ( ) == clazz && lastInfo . conf == conf ) { serializationInfo = lastInfo ; } else { serializationInfo = getClassInfoRegistry ( ) . getCLInfo ( clazz , conf ) ; referencee . lastInfo = serializationInfo ; } return serializationInfo ;


signature:
public class FSTObjectOutput { /** * write identical to other version , but take field values from hashmap ( because of annoying putField / getField feature ) */
protected void writeCompatibleObjectFields ( Object toWrite , Map fields , FSTClazzInfo . FSTFieldInfo [ ] fieldInfo ) throws IOException { } }

implementation:
int booleanMask = 0 ; int boolcount = 0 ; for ( int i = 0 ; i < fieldInfo . length ; i ++ ) { try { FSTClazzInfo . FSTFieldInfo subInfo = fieldInfo [ i ] ; boolean isarr = subInfo . isArray ( ) ; Class subInfType = subInfo . getType ( ) ; if ( subInfType != boolean . class || isarr ) { if ( boolcount > 0 ) { getCodec ( ) . writeFByte ( booleanMask << ( 8 - boolcount ) ) ; boolcount = 0 ; booleanMask = 0 ; } } if ( subInfo . isIntegral ( ) && ! isarr ) { if ( subInfType == boolean . class ) { if ( boolcount == 8 ) { getCodec ( ) . writeFByte ( booleanMask << ( 8 - boolcount ) ) ; boolcount = 0 ; booleanMask = 0 ; } boolean booleanValue = ( ( Boolean ) fields . get ( subInfo . getName ( ) ) ) . booleanValue ( ) ; booleanMask = booleanMask << 1 ; booleanMask = ( booleanMask | ( booleanValue ? 1 : 0 ) ) ; boolcount ++ ; } else if ( subInfType == int . class ) { getCodec ( ) . writeFInt ( ( ( Number ) fields . get ( subInfo . getName ( ) ) ) . intValue ( ) ) ; } else if ( subInfType == long . class ) { getCodec ( ) . writeFLong ( ( ( Number ) fields . get ( subInfo . getName ( ) ) ) . longValue ( ) ) ; } else if ( subInfType == byte . class ) { getCodec ( ) . writeFByte ( ( ( Number ) fields . get ( subInfo . getName ( ) ) ) . byteValue ( ) ) ; } else if ( subInfType == char . class ) { getCodec ( ) . writeFChar ( ( char ) ( ( Number ) fields . get ( subInfo . getName ( ) ) ) . intValue ( ) ) ; } else if ( subInfType == short . class ) { getCodec ( ) . writeFShort ( ( ( Number ) fields . get ( subInfo . getName ( ) ) ) . shortValue ( ) ) ; } else if ( subInfType == float . class ) { getCodec ( ) . writeFFloat ( ( ( Number ) fields . get ( subInfo . getName ( ) ) ) . floatValue ( ) ) ; } else if ( subInfType == double . class ) { getCodec ( ) . writeFDouble ( ( ( Number ) fields . get ( subInfo . getName ( ) ) ) . doubleValue ( ) ) ; } } else { // object
Object subObject = fields . get ( subInfo . getName ( ) ) ; writeObjectWithContext ( subInfo , subObject ) ; } } catch ( Exception ex ) { FSTUtil . < RuntimeException > rethrow ( ex ) ; } } if ( boolcount > 0 ) { getCodec ( ) . writeFByte ( booleanMask << ( 8 - boolcount ) ) ; }


signature:
public class FSTObjectOutput { /** * incoming array is already registered */
protected void writeArray ( FSTClazzInfo . FSTFieldInfo referencee , Object array ) throws IOException { } }

implementation:
if ( array == null ) { getCodec ( ) . writeClass ( Object . class ) ; getCodec ( ) . writeFInt ( - 1 ) ; return ; } final int len = Array . getLength ( array ) ; Class < ? > componentType = array . getClass ( ) . getComponentType ( ) ; getCodec ( ) . writeClass ( array . getClass ( ) ) ; getCodec ( ) . writeFInt ( len ) ; if ( ! componentType . isArray ( ) ) { if ( getCodec ( ) . isPrimitiveArray ( array , componentType ) ) { getCodec ( ) . writePrimitiveArray ( array , 0 , len ) ; } else { // objects
Object arr [ ] = ( Object [ ] ) array ; Class lastClz = null ; FSTClazzInfo lastInfo = null ; for ( int i = 0 ; i < len ; i ++ ) { Object toWrite = arr [ i ] ; if ( toWrite != null ) { lastInfo = writeObjectWithContext ( referencee , toWrite , lastClz == toWrite . getClass ( ) ? lastInfo : null ) ; lastClz = toWrite . getClass ( ) ; } else writeObjectWithContext ( referencee , toWrite , null ) ; } } } else { // multidim array . FIXME shared refs to subarrays are not tested ! ! !
Object [ ] arr = ( Object [ ] ) array ; FSTClazzInfo . FSTFieldInfo ref1 = new FSTClazzInfo . FSTFieldInfo ( referencee . getPossibleClasses ( ) , null , conf . getCLInfoRegistry ( ) . isIgnoreAnnotations ( ) ) ; for ( int i = 0 ; i < len ; i ++ ) { Object subArr = arr [ i ] ; boolean needsWrite = true ; if ( getCodec ( ) . isTagMultiDimSubArrays ( ) ) { if ( subArr == null ) { needsWrite = ! getCodec ( ) . writeTag ( NULL , null , 0 , null , this ) ; } else { needsWrite = ! getCodec ( ) . writeTag ( ARRAY , subArr , 0 , subArr , this ) ; } } if ( needsWrite ) { writeArray ( ref1 , subArr ) ; getCodec ( ) . writeArrayEnd ( ) ; } } }


signature:
public class FSTObjectOutput { /** * if out = = null = > automatically create / reuse a bytebuffer
 * @ param out */
public void resetForReUse ( OutputStream out ) { } }

implementation: if ( closed ) throw new RuntimeException ( "Can't reuse closed stream" ) ; getCodec ( ) . reset ( null ) ; if ( out != null ) { getCodec ( ) . setOutstream ( out ) ; } objects . clearForWrite ( conf ) ;


signature:
public class FSTObjectOutput { /** * @ return a copy of written bytes .
 * Warning : if the stream has been flushed , this will fail with an exception .
 * a flush is triggered after each 1st level writeObject .
 * note : in case of non - stream based serialization ( directbuffer , offheap mem ) getBuffer will return a copy anyways . */
public byte [ ] getCopyOfWrittenBuffer ( ) { } }

implementation: if ( ! getCodec ( ) . isByteArrayBased ( ) ) { return getBuffer ( ) ; } byte res [ ] = new byte [ getCodec ( ) . getWritten ( ) ] ; byte [ ] buffer = getBuffer ( ) ; System . arraycopy ( buffer , 0 , res , 0 , getCodec ( ) . getWritten ( ) ) ; return res ;


signature:
public class FSTObjectInput { /** * some jdk classes hash for ObjectStream , so provide the same instance always */
protected ObjectInputStream getObjectInputStream ( final Class cl , final FSTClazzInfo clInfo , final FSTClazzInfo . FSTFieldInfo referencee , final Object toRead ) throws IOException { } }

implementation:
ObjectInputStream wrapped = new ObjectInputStream ( ) { @ Override public Object readObjectOverride ( ) throws IOException , ClassNotFoundException { try { byte b = FSTObjectInput . this . readByte ( ) ; if ( b != FSTObjectOutput . SPECIAL_COMPATIBILITY_OBJECT_TAG ) { Constructor < ? > [ ] constructors = OptionalDataException . class . getDeclaredConstructors ( ) ; FSTObjectInput . this . pushBack ( 1 ) ; for ( int i = 0 ; i < constructors . length ; i ++ ) { Constructor constructor = constructors [ i ] ; Class [ ] typeParameters = constructor . getParameterTypes ( ) ; if ( typeParameters != null && typeParameters . length == 1 && typeParameters [ 0 ] == int . class ) { constructor . setAccessible ( true ) ; OptionalDataException ode ; try { ode = ( OptionalDataException ) constructor . newInstance ( 0 ) ; throw ode ; } catch ( InvocationTargetException e ) { break ; } } } throw new EOFException ( "if your code relies on this, think" ) ; } return FSTObjectInput . this . readObjectInternal ( referencee . getPossibleClasses ( ) ) ; } catch ( IllegalAccessException e ) { throw new IOException ( e ) ; } catch ( InstantiationException e ) { throw new IOException ( e ) ; } } @ Override public Object readUnshared ( ) throws IOException , ClassNotFoundException { try { return FSTObjectInput . this . readObjectInternal ( referencee . getPossibleClasses ( ) ) ; // fixme
} catch ( IllegalAccessException e ) { throw new IOException ( e ) ; } catch ( InstantiationException e ) { throw new IOException ( e ) ; } } @ Override public void defaultReadObject ( ) throws IOException , ClassNotFoundException { try { int tag = readByte ( ) ; if ( tag == 77 ) // came from writeFields
{ fieldMap = ( HashMap < String , Object > ) FSTObjectInput . this . readObjectInternal ( HashMap . class ) ; // object has been written with writeFields , is no read with defaultReadObjects ,
// need to autoapply map to object vars .
// this might be redundant in case readObject ( ) pulls a getFields ( ) . . ( see bitset testcase )
for ( Iterator < String > iterator = fieldMap . keySet ( ) . iterator ( ) ; iterator . hasNext ( ) ; ) { String key = iterator . next ( ) ; FSTClazzInfo . FSTFieldInfo fieldInfo = clInfo . getFieldInfo ( key , null ) ; // in case fieldName is not unique = > cannot recover / fix
if ( fieldInfo != null ) { fieldInfo . setObjectValue ( toRead , fieldMap . get ( key ) ) ; } } } else { FSTObjectInput . this . readObjectFields ( referencee , clInfo , clInfo . getCompInfo ( ) . get ( cl ) . getFieldArray ( ) , toRead , 0 , 0 ) ; // FIXME : only fields of current class
} } catch ( Exception e ) { throw new IOException ( e ) ; } } HashMap < String , Object > fieldMap ; @ Override public GetField readFields ( ) throws IOException , ClassNotFoundException { int tag = readByte ( ) ; try { FSTClazzInfo . FSTCompatibilityInfo fstCompatibilityInfo = clInfo . getCompInfo ( ) . get ( cl ) ; if ( tag == 99 ) { // came from defaultwriteobject
// Note : in case number and names of instance fields of reader / writer are different ,
// this fails as code below implicitely assumes , fields of writer = = fields of reader
// unfortunately one can use defaultWriteObject at writer side but use getFields at reader side
// in readObject ( ) . if then fields differ , code below reads BS and fails .
// Its impossible to fix that except by always using putField + getField for
// JDK compatibility classes , however this will waste lots of performance . As
// it would be necessary to * always * write full metainformation ( a map of fieldName = > value pairs )
// see # 53
fieldMap = new HashMap < String , Object > ( ) ; FSTObjectInput . this . readCompatibleObjectFields ( referencee , clInfo , fstCompatibilityInfo . getFieldArray ( ) , fieldMap ) ; getCodec ( ) . readVersionTag ( ) ; // consume dummy version tag as created by defaultWriteObject
} else if ( tag == 66 ) { // has been written from writeObjectCompatible without writeMethod
fieldMap = new HashMap < String , Object > ( ) ; FSTObjectInput . this . readCompatibleObjectFields ( referencee , clInfo , fstCompatibilityInfo . getFieldArray ( ) , fieldMap ) ; getCodec ( ) . readVersionTag ( ) ; // consume dummy version tag as created by defaultWriteObject
} else { fieldMap = ( HashMap < String , Object > ) FSTObjectInput . this . readObjectInternal ( HashMap . class ) ; } } catch ( Exception e ) { FSTUtil . < RuntimeException > rethrow ( e ) ; } return new GetField ( ) { @ Override public ObjectStreamClass getObjectStreamClass ( ) { return ObjectStreamClass . lookup ( cl ) ; } @ Override public boolean defaulted ( String name ) throws IOException { return fieldMap . get ( name ) == null ; } @ Override public boolean get ( String name , boolean val ) throws IOException { if ( fieldMap . get ( name ) == null ) { return val ; } return ( ( Boolean ) fieldMap . get ( name ) ) . booleanValue ( ) ; } @ Override public byte get ( String name , byte val ) throws IOException { if ( fieldMap . get ( name ) == null ) { return val ; } return ( ( Byte ) fieldMap . get ( name ) ) . byteValue ( ) ; } @ Override public char get ( String name , char val ) throws IOException { if ( fieldMap . get ( name ) == null ) { return val ; } return ( ( Character ) fieldMap . get ( name ) ) . charValue ( ) ; } @ Override public short get ( String name , short val ) throws IOException { if ( fieldMap . get ( name ) == null ) { return val ; } return ( ( Short ) fieldMap . get ( name ) ) . shortValue ( ) ; } @ Override public int get ( String name , int val ) throws IOException { if ( fieldMap . get ( name ) == null ) { return val ; } return ( ( Integer ) fieldMap . get ( name ) ) . intValue ( ) ; } @ Override public long get ( String name , long val ) throws IOException { if ( fieldMap . get ( name ) == null ) { return val ; } return ( ( Long ) fieldMap . get ( name ) ) . longValue ( ) ; } @ Override public float get ( String name , float val ) throws IOException { if ( fieldMap . get ( name ) == null ) { return val ; } return ( ( Float ) fieldMap . get ( name ) ) . floatValue ( ) ; } @ Override public double get ( String name , double val ) throws IOException { if ( fieldMap . get ( name ) == null ) { return val ; } return ( ( Double ) fieldMap . get ( name ) ) . doubleValue ( ) ; } @ Override public Object get ( String name , Object val ) throws IOException { Object res = fieldMap . get ( name ) ; if ( res == null ) { return val ; } return res ; } } ; } @ Override public void registerValidation ( ObjectInputValidation obj , int prio ) throws NotActiveException , InvalidObjectException { if ( callbacks == null ) { callbacks = new ArrayList < CallbackEntry > ( ) ; } callbacks . add ( new CallbackEntry ( obj , prio ) ) ; } @ Override public int read ( ) throws IOException { return getCodec ( ) . readFByte ( ) ; } @ Override public int read ( byte [ ] buf , int off , int len ) throws IOException { return FSTObjectInput . this . read ( buf , off , len ) ; } @ Override public int available ( ) throws IOException { return FSTObjectInput . this . available ( ) ; } @ Override public void close ( ) throws IOException { } @ Override public boolean readBoolean ( ) throws IOException { return FSTObjectInput . this . readBoolean ( ) ; } @ Override public byte readByte ( ) throws IOException { return getCodec ( ) . readFByte ( ) ; } @ Override public int readUnsignedByte ( ) throws IOException { return FSTObjectInput . this . readUnsignedByte ( ) ; } @ Override public char readChar ( ) throws IOException { return getCodec ( ) . readFChar ( ) ; } @ Override public short readShort ( ) throws IOException { return getCodec ( ) . readFShort ( ) ; } @ Override public int readUnsignedShort ( ) throws IOException { return FSTObjectInput . this . readUnsignedShort ( ) ; } @ Override public int readInt ( ) throws IOException { return getCodec ( ) . readFInt ( ) ; } @ Override public long readLong ( ) throws IOException { return getCodec ( ) . readFLong ( ) ; } @ Override public float readFloat ( ) throws IOException { return getCodec ( ) . readFFloat ( ) ; } @ Override public double readDouble ( ) throws IOException { return getCodec ( ) . readFDouble ( ) ; } @ Override public void readFully ( byte [ ] buf ) throws IOException { FSTObjectInput . this . readFully ( buf ) ; } @ Override public void readFully ( byte [ ] buf , int off , int len ) throws IOException { FSTObjectInput . this . readFully ( buf , off , len ) ; } @ Override public int skipBytes ( int len ) throws IOException { return FSTObjectInput . this . skipBytes ( len ) ; } @ Override public String readUTF ( ) throws IOException { return getCodec ( ) . readStringUTF ( ) ; } @ Override public String readLine ( ) throws IOException { return FSTObjectInput . this . readLine ( ) ; } @ Override public int read ( byte [ ] b ) throws IOException { return FSTObjectInput . this . read ( b ) ; } @ Override public long skip ( long n ) throws IOException { return FSTObjectInput . this . skip ( n ) ; } @ Override public void mark ( int readlimit ) { throw new RuntimeException ( "not implemented" ) ; } @ Override public void reset ( ) throws IOException { FSTObjectInput . this . reset ( ) ; } @ Override public boolean markSupported ( ) { return false ; } } ; if ( fakeWrapper == null ) { fakeWrapper = new MyObjectStream ( ) ; } fakeWrapper . push ( wrapped ) ; return fakeWrapper ;


signature:
public class StructString { /** * modify content of this StructString . The length of the new String must not exceed
 * the length of internal char array
 * @ param s */
public void setString ( String s ) { } }

implementation: if ( s == null ) { setLen ( 0 ) ; return ; } if ( s . length ( ) > charsLen ( ) ) { throw new RuntimeException ( "String length exceeds buffer size. String len " + s . length ( ) + " charsLen:" + charsLen ( ) ) ; } for ( int i = 0 ; i < s . length ( ) ; i ++ ) { chars ( i , s . charAt ( i ) ) ; } len = s . length ( ) ;


signature:
public class FSTMinBinEncoder { /** * does not write class tag and length
 * @ param array
 * @ param start
 * @ param length @ throws java . io . IOException */
@ Override public void writePrimitiveArray ( Object array , int start , int length ) throws IOException { } }

implementation: out . writeArray ( array , start , length ) ;


signature:
public class FSTMinBinEncoder { /** * resets stream ( positions are lost )
 * @ throws java . io . IOException */
@ Override public void flush ( ) throws IOException { } }

implementation: if ( outputStream != null ) { outputStream . write ( out . getBytez ( ) , 0 , out . getWritten ( ) ) ; offset = out . getWritten ( ) ; out . resetPosition ( ) ; }


signature:
public class FSTStruct { /** * set this struct pointer to base array at given offset ( = bufoff + index )
 * @ param base
 * @ param offset direct offset to byte array element ( = FSTStruct . bufoff + array index ) */
public void baseOn ( byte base [ ] , long offset , FSTStructFactory fac ) { } }

implementation: ___bytes = new HeapBytez ( base ) ; ___offset = offset ; ___fac = fac ;


signature:
public class FSTStruct { /** * set this struct pointer to base array at given index
 * @ param base
 * @ param index */
public void baseOn ( byte base [ ] , int index ) { } }

implementation: ___bytes = new HeapBytez ( base ) ; ___offset = index ; if ( ___fac == null ) ___fac = FSTStructFactory . getInstance ( ) ;


signature:
public class FSTStruct { /** * move offsets and memorybase to given pointer and return the pointer .
 * Eases dereferencing of nested structs without object creation .
 * If the given pointer is null , a new one will be created ( alloc )
 * < pre >
 * MyStruct st = FSTStructFactory . getInstance ( ) . createEmptyStructPointer ( FSTStruct . class ) ;
 * otherStruct . getEmbeddedMyStruct ( ) . to ( st ) ;
 * < / pre > */
public < T extends FSTStruct > T detachTo ( T pointer ) { } }

implementation: if ( pointer == null ) { return detach ( ) ; } if ( isOffHeap ( ) ) { pointer . ___fac = ___fac ; pointer . ___bytes = ___bytes ; pointer . ___elementSize = ___elementSize ; pointer . ___offset = ___offset ; return pointer ; } return ( T ) this ;


signature:
public class FSTStruct { /** * returns a complete copy of this object allocating a new Bytez capable of holding the data .
 * @ return */
public FSTStruct createCopy ( ) { } }

implementation: if ( ! isOffHeap ( ) ) { throw new RuntimeException ( "must be offheap to call this" ) ; } byte b [ ] = new byte [ getByteSize ( ) ] ; HeapBytez res = new HeapBytez ( b ) ; getBytes ( res , 0 ) ; return ___fac . createStructWrapper ( res , 0 ) ;


signature:
public class FSTStruct { /** * works only if change tracking is enabled */
public FSTStructChange finishChangeTracking ( ) { } }

implementation: tracker . snapshotChanges ( ( int ) getOffset ( ) , getBase ( ) ) ; FSTStructChange res = tracker ; tracker = null ; return res ;


signature:
public class FSTStruct { /** * @ return a temporary per thread instance of ByteBuffer pointing to this structs data . The length of the
 * buffer is same as the length of this struct .
 * The instance returned is valid until the currentThread calls this method next time .
 * Can be used to feed e . g . NIO api . Use ByteBuffer . duplicate ( ) to obtain a non - temporary instance
 * @ throws NoSuchFieldException
 * @ throws IllegalAccessException */
public ByteBuffer asByteBufferTemporary ( ) { } }

implementation:
if ( getBase ( ) instanceof MallocBytez ) { MallocBytez base = ( MallocBytez ) getBase ( ) ; ByteBuffer bb = tmpBuf . get ( ) ; try { address . setLong ( bb , base . getBaseAdress ( ) + getOffset ( ) ) ; capacity . setInt ( bb , getByteSize ( ) ) ; } catch ( IllegalAccessException e ) { FSTUtil . < RuntimeException > rethrow ( e ) ; } bb . limit ( ( int ) ( getOffset ( ) + getByteSize ( ) ) ) ; bb . position ( ( int ) getOffset ( ) ) ; return tmpBuf . get ( ) ; } else { // assume HeapBytez . Allocates
return ByteBuffer . wrap ( getBase ( ) . asByteArray ( ) , ( int ) getOffset ( ) , getByteSize ( ) ) ; }


signature:
public class FSTStructAllocator { /** * create a new struct array of same type as template
 * @ param size
 * @ return */
public < X extends FSTStruct > StructArray < X > newArray ( int size , X templ ) { } }

implementation: return newArray ( size , templ , alloc ) ;


signature:
public class FSTStructAllocator { /** * create a new struct array of same type as template
 * @ param size
 * @ return */
public < X extends FSTStruct > StructArray < X > newArray ( int size , X templ , BytezAllocator alloc ) { } }

implementation: StructArray < X > aTemplate = new StructArray < X > ( size , templ ) ; int siz = getFactory ( ) . calcStructSize ( aTemplate ) ; try { if ( siz < chunkSize ) return newStruct ( aTemplate ) ; else { return getFactory ( ) . toStruct ( aTemplate , alloc ) ; } } catch ( Throwable e ) { throw new RuntimeException ( e ) ; }


signature:
public class FSTStructChange { /** * collects all changes and rebases .
 * @ param originBase
 * @ param origin */
public void snapshotChanges ( int originBase , Bytez origin ) { } }

implementation: int sumLen = 0 ; for ( int i = 0 ; i < curIndex ; i ++ ) { sumLen += changeLength [ i ] ; } snapshot = new byte [ sumLen ] ; int targetIdx = 0 ; for ( int i = 0 ; i < curIndex ; i ++ ) { int changeOffset = changeOffsets [ i ] ; int len = changeLength [ i ] ; for ( int ii = 0 ; ii < len ; ii ++ ) { snapshot [ targetIdx ++ ] = origin . get ( changeOffset + ii ) ; } } rebase ( originBase ) ;


signature:
public class FSTObjectRegistry { /** * add an object to the register , return handle if already present . Called during write only
 * @ param o
 * @ param streamPosition
 * @ return 0 if added , handle if already present */
public int registerObjectForWrite ( Object o , int streamPosition , FSTClazzInfo clzInfo , int reUseType [ ] ) { } }

implementation:
if ( disabled ) { return Integer . MIN_VALUE ; } // System . out . println ( " REGISTER AT WRITE : " + streamPosition + " " + o . getClass ( ) . getSimpleName ( ) ) ;
// final Class clazz = o . getClass ( ) ;
if ( clzInfo == null ) { // array oder enum oder primitive
// unused ?
// clzInfo = reg . getCLInfo ( clazz ) ;
} else if ( clzInfo . isFlat ( ) ) { return Integer . MIN_VALUE ; } int handle = objects . putOrGet ( o , streamPosition ) ; if ( handle >= 0 ) { // if ( idToObject . get ( handle ) = = null ) { / / ( * ) ( can get improved )
// idToObject . add ( handle , o ) ;
reUseType [ 0 ] = 0 ; return handle ; } return Integer . MIN_VALUE ;


signature:
public class FSTCodedOffheapMap { /** * Warning : Concurrent Modification ( e . g . add remove elements during iteration ) is NOT SUPPORTED
 * and NOT CHECKED . Collect keys to change inside an iteration and perform changes on the map after iteration is
 * finished .
 * @ return an iterator on the values contained in this map . */
public Iterator < V > values ( ) { } }

implementation: final Iterator < ByteSource > iter = binaryValues ( ) ; return new Iterator ( ) { @ Override public boolean hasNext ( ) { return iter . hasNext ( ) ; } @ Override public V next ( ) { BytezByteSource next = ( BytezByteSource ) iter . next ( ) ; return decodeValue ( next ) ; } @ Override public void remove ( ) { throw new RuntimeException ( "unimplemented" ) ; } } ;


signature:
public class OnHeapCoder { /** * throws FSTBufferTooSmallExcpetion in case object does not fit into given range
 * Zero Copy method
 * @ param o
 * @ param availableSize
 * @ throws java . io . IOException
 * @ return number of bytes written to the memory region */
@ Override public int toByteArray ( Object o , byte arr [ ] , int startIndex , int availableSize ) { } }

implementation: out . resetForReUse ( ) ; writeTarget . setBase ( arr , startIndex , availableSize ) ; try { out . writeObject ( o ) ; } catch ( IOException e ) { FSTUtil . < RuntimeException > rethrow ( e ) ; } int written = out . getWritten ( ) ; return written ;


signature:
public class OnHeapCoder { /** * throws FSTBufferTooSmallExcpetion in case object does not fit into given range
 * @ param arr
 * @ param startIndex
 * @ param availableSize
 * @ return
 * @ throws Exception */
@ Override public Object toObject ( byte arr [ ] , int startIndex , int availableSize ) { } }

implementation: try { in . resetForReuse ( null ) ; readTarget . setBase ( arr , startIndex , availableSize ) ; Object o = in . readObject ( ) ; return o ; } catch ( Exception e ) { FSTUtil . < RuntimeException > rethrow ( e ) ; } return null ;


signature:
public class KsonTypeMapper { /** * map given Object to a target type .
 * ( needs support in coerceWriting also )
 * Note one could add a pluggable Serializer / Coercer pattern here if required . Skipped for now for simplicity .
 * @ param type - of target field
 * @ param readObject - object read from string
 * @ return */
public Object coerceReading ( Class type , Object readObject ) { } }

implementation:
if ( type == null ) return readObject ; // make hashmaps from arrays . warning : for optimal performance , use direct arrays [ ] only in your serialized classes
if ( Map . class . isAssignableFrom ( type ) && readObject . getClass ( ) . isArray ( ) ) { try { Map c = ( Map ) type . newInstance ( ) ; int len = Array . getLength ( readObject ) ; for ( int i = 0 ; i < len ; i += 2 ) { c . put ( Array . get ( readObject , i ) , Array . get ( readObject , i + 1 ) ) ; } return c ; } catch ( Exception e ) { logger . log ( FSTLogger . Level . INFO , "Exception thrown by newInstance" , e ) ; } } else // make collections from arrays . warning : for optimal performance , use direct arrays [ ] only in your serialized classes
if ( Collection . class . isAssignableFrom ( type ) && readObject . getClass ( ) . isArray ( ) ) { try { if ( type . isInterface ( ) ) { if ( List . class . isAssignableFrom ( type ) ) { type = ArrayList . class ; } else if ( Map . class . isAssignableFrom ( type ) ) { type = HashMap . class ; } } Collection c = ( Collection ) type . newInstance ( ) ; int len = Array . getLength ( readObject ) ; for ( int i = 0 ; i < len ; i ++ ) { c . add ( Array . get ( readObject , i ) ) ; } return c ; } catch ( Exception e ) { logger . log ( FSTLogger . Level . ERROR , "Exception thrown by newInstance" , e ) ; } } else if ( Date . class . isAssignableFrom ( type ) && readObject instanceof String ) { try { return dateTimeInstance . parse ( ( String ) readObject ) ; } catch ( ParseException pe ) { logger . log ( FSTLogger . Level . ERROR , "Failed to parse date" , pe ) ; } } else if ( ( type == char . class || Character . class . isAssignableFrom ( type ) ) && readObject instanceof String ) { return ( ( String ) readObject ) . charAt ( 0 ) ; } return readObject ;


signature:
public class BinaryQueue { /** * add bytes to the queue . Again by using ( reusable ) Wrapper classes any kind of memory
 * ( offheap , byte arrays , nio bytebuffer , memory mapped ) can be added .
 * @ param source
 * @ param sourceoff
 * @ param sourcelen */
public void add ( ByteSource source , long sourceoff , long sourcelen ) { } }

implementation:
if ( sourcelen >= remaining ( ) ) { grow ( sourcelen + 1 ) ; // issue85
add ( source , sourceoff , sourcelen ) ; return ; } for ( int i = 0 ; i < sourcelen ; i ++ ) { storage . put ( addIndex ++ , source . get ( i + sourceoff ) ) ; if ( addIndex >= storage . length ( ) ) addIndex -= storage . length ( ) ; }


signature:
public class BinaryQueue { /** * read up to destlen bytes ( if available ) .
 * Note you can use HeapBytez ( implements ByteSink ) in order to read to a regular byte array .
 * HeapBytez wrapper can be reused to avoid unnecessary allocation .
 * Also possible is ByteBufferBasicBytes to read into a ByteBuffer and MallocBytes or MMFBytes to
 * read into Unsafe alloc ' ed off heap memory or persistent mem mapped memory regions .
 * @ param destination
 * @ param destoff
 * @ param destlen
 * @ return */
public long poll ( ByteSink destination , long destoff , long destlen ) { } }

implementation: long count = 0 ; try { while ( pollIndex != addIndex && count < destlen ) { destination . put ( destoff + count ++ , storage . get ( pollIndex ++ ) ) ; if ( pollIndex >= storage . length ( ) ) { pollIndex = 0 ; } } } catch ( Exception e ) { logger . log ( FSTLogger . Level . ERROR , "Failed to poll" , e ) ; } return count ;


signature:
public class BinaryQueue { /** * convenience method to read len byte array . Throws an excpetion if not enough data is present
 * @ param len
 * @ return */
public byte [ ] readByteArray ( int len ) { } }

implementation: if ( available ( ) < len ) { throw new RuntimeException ( "not enough data available, check available() > len before calling" ) ; } byte b [ ] = new byte [ len ] ; int count = 0 ; while ( pollIndex != addIndex && count < len ) { b [ count ++ ] = storage . get ( pollIndex ++ ) ; if ( pollIndex >= storage . length ( ) ) { pollIndex = 0 ; } } return b ;


signature:
public class BinaryQueue { /** * read an int . throws an exception if not enough data is present
 * @ return */
public int readInt ( ) { } }

implementation: if ( available ( ) < 4 ) { throw new RuntimeException ( "not enough data available, check available() > 4 before calling" ) ; } int ch1 = poll ( ) ; int ch2 = poll ( ) ; int ch3 = poll ( ) ; int ch4 = poll ( ) ; return ( ch4 << 24 ) + ( ch3 << 16 ) + ( ch2 << 8 ) + ( ch1 << 0 ) ;


signature:
public class BinaryQueue { /** * ' unread ' len bytes
 * @ param len */
public void back ( int len ) { } }

implementation: if ( pollIndex >= len ) pollIndex -= len ; else pollIndex = pollIndex + capacity ( ) - len ;


signature:
public class FSTClazzNameRegistry { /** * for read = > always increase handle ( wg . replaceObject ) */
public void registerClass ( Class c , FSTConfiguration conf ) { } }

implementation: if ( getIdFromClazz ( c ) != Integer . MIN_VALUE ) { return ; } registerClassNoLookup ( c , null , conf ) ;


signature:
public class HproseTcpServer { /** * Set thread pool enabled .
 * This thread pool is not for the service threads , it is for the user service method .
 * If your service method takes a long time , or will be blocked , please set this property to be true .
 * @ param value is thread pool enabled */
public void setThreadPoolEnabled ( boolean value ) { } }

implementation: if ( value && ( threadPool == null ) ) { threadPool = Executors . newCachedThreadPool ( ) ; } threadPoolEnabled = value ;


signature:
public class EmbeddedCassandraServerHelper { /** * Set embedded cassandra up and spawn it in a new thread .
 * @ throws TTransportException
 * @ throws IOException
 * @ throws ConfigurationException */
public static void startEmbeddedCassandra ( File file , String tmpDir , long timeout ) throws IOException , ConfigurationException { } }

implementation:
if ( cassandraDaemon != null ) { /* nothing to do Cassandra is already started */
return ; } checkConfigNameForRestart ( file . getAbsolutePath ( ) ) ; log . debug ( "Starting cassandra..." ) ; log . debug ( "Initialization needed" ) ; System . setProperty ( "cassandra.config" , "file:" + file . getAbsolutePath ( ) ) ; System . setProperty ( "cassandra-foreground" , "true" ) ; System . setProperty ( "cassandra.native.epoll.enabled" , "false" ) ; // JNA doesnt cope with relocated netty
System . setProperty ( "cassandra.unsafesystem" , "true" ) ; // disable fsync for a massive speedup on old platters
// If there is no log4j config set already , set the default config
if ( System . getProperty ( "log4j.configuration" ) == null ) { copy ( DEFAULT_LOG4J_CONFIG_FILE , tmpDir ) ; System . setProperty ( "log4j.configuration" , "file:" + tmpDir + DEFAULT_LOG4J_CONFIG_FILE ) ; } DatabaseDescriptor . daemonInitialization ( ) ; cleanupAndLeaveDirs ( ) ; final CountDownLatch startupLatch = new CountDownLatch ( 1 ) ; ExecutorService executor = Executors . newSingleThreadExecutor ( ) ; executor . execute ( ( ) -> { cassandraDaemon = new CassandraDaemon ( ) ; cassandraDaemon . activate ( ) ; startupLatch . countDown ( ) ; } ) ; try { if ( ! startupLatch . await ( timeout , MILLISECONDS ) ) { log . error ( "Cassandra daemon did not start after " + timeout + " ms. Consider increasing the timeout" ) ; throw new AssertionError ( "Cassandra daemon did not start within timeout" ) ; } Runtime . getRuntime ( ) . addShutdownHook ( new Thread ( ( ) -> { if ( session != null ) session . close ( ) ; if ( cluster != null ) cluster . close ( ) ; } ) ) ; } catch ( InterruptedException e ) { log . error ( "Interrupted waiting for Cassandra daemon to start:" , e ) ; throw new AssertionError ( e ) ; } finally { executor . shutdown ( ) ; }


signature:
public class EmbeddedCassandraServerHelper { /** * truncate data in keyspace , except specified tables */
public static void cleanDataEmbeddedCassandra ( String keyspace , String ... excludedTables ) { } }

implementation: if ( session != null ) { cleanDataWithNativeDriver ( keyspace , excludedTables ) ; }


signature:
public class EmbeddedCassandraServerHelper { /** * Copies a resource from within the jar to a directory .
 * @ param resource
 * @ param directory
 * @ throws IOException */
private static Path copy ( String resource , String directory ) throws IOException { } }

implementation: mkdir ( directory ) ; String fileName = resource . substring ( resource . lastIndexOf ( "/" ) + 1 ) ; InputStream from = EmbeddedCassandraServerHelper . class . getResourceAsStream ( resource ) ; Path copyName = Paths . get ( directory , fileName ) ; Files . copy ( from , copyName ) ; return copyName ;


signature:
public class ReflectionUtils { /** * Print all of the thread ' s information and stack traces .
 * @ param stream the stream to
 * @ param title a string title for the stack trace */
public static void printThreadInfo ( PrintWriter stream , String title ) { } }

implementation: final int STACK_DEPTH = 20 ; boolean contention = threadBean . isThreadContentionMonitoringEnabled ( ) ; long [ ] threadIds = threadBean . getAllThreadIds ( ) ; stream . println ( "Process Thread Dump: " + title ) ; stream . println ( threadIds . length + " active threads" ) ; for ( long tid : threadIds ) { ThreadInfo info = threadBean . getThreadInfo ( tid , STACK_DEPTH ) ; if ( info == null ) { stream . println ( "  Inactive" ) ; continue ; } stream . println ( "Thread " + getTaskName ( info . getThreadId ( ) , info . getThreadName ( ) ) + ":" ) ; Thread . State state = info . getThreadState ( ) ; stream . println ( "  State: " + state ) ; stream . println ( "  Blocked count: " + info . getBlockedCount ( ) ) ; stream . println ( "  Waited count: " + info . getWaitedCount ( ) ) ; if ( contention ) { stream . println ( "  Blocked time: " + info . getBlockedTime ( ) ) ; stream . println ( "  Waited time: " + info . getWaitedTime ( ) ) ; } if ( state == Thread . State . WAITING ) { stream . println ( "  Waiting on " + info . getLockName ( ) ) ; } else if ( state == Thread . State . BLOCKED ) { stream . println ( "  Blocked on " + info . getLockName ( ) ) ; stream . println ( "  Blocked by " + getTaskName ( info . getLockOwnerId ( ) , info . getLockOwnerName ( ) ) ) ; } stream . println ( "  Stack:" ) ; for ( StackTraceElement frame : info . getStackTrace ( ) ) { stream . println ( "    " + frame . toString ( ) ) ; } } stream . flush ( ) ;


signature:
public class ReflectionUtils { /** * Return the correctly - typed { @ link Class } of the given object .
 * @ param o object whose correctly - typed < code > Class < / code > is to be obtained
 * @ return the correctly typed < code > Class < / code > of the given object . */
@ SuppressWarnings ( "unchecked" ) public static < T > Class < T > getClass ( T o ) { } }

implementation: return ( Class < T > ) o . getClass ( ) ;


signature:
public class CheckSocket { /** * Check if a remote port is taken
 * @ param node the host to check
 * @ param port the port to check
 * @ param timeout the timeout for the connection
 * @ return true if the port is taken false otherwise */
public static boolean remotePortTaken ( String node , int port , int timeout ) { } }

implementation: Socket s = null ; try { s = new Socket ( ) ; s . setReuseAddress ( true ) ; SocketAddress sa = new InetSocketAddress ( node , port ) ; s . connect ( sa , timeout * 1000 ) ; } catch ( IOException e ) { if ( e . getMessage ( ) . equals ( "Connection refused" ) ) { return false ; } if ( e instanceof SocketTimeoutException || e instanceof UnknownHostException ) { throw e ; } } finally { if ( s != null ) { if ( s . isConnected ( ) ) { return true ; } else { } try { s . close ( ) ; } catch ( IOException e ) { } } return false ; }


signature:
public class SubscriberState { /** * Returns an empty subscriber state
 * with - 1 as total updates , master as false
 * and server state as empty
 * @ return an empty subscriber state */
public static SubscriberState empty ( ) { } }

implementation: return SubscriberState . builder ( ) . serverState ( "empty" ) . streamId ( - 1 ) . parameterUpdaterStatus ( Collections . emptyMap ( ) ) . totalUpdates ( - 1 ) . isMaster ( false ) . build ( ) ;