idx int64 0 165k | question stringlengths 73 5.81k | target stringlengths 5 918 |
|---|---|---|
120,000 | public static String docToString1 ( Document dom ) { StringWriter sw = new StringWriter ( ) ; DOM2Writer . serializeAsXML ( dom , sw ) ; return sw . toString ( ) ; } | Convert a DOM tree into a String using Dom2Writer |
120,001 | public static String docToString2 ( Document domDoc ) throws IOException { try { TransformerFactory transFact = TransformerFactory . newInstance ( ) ; Transformer trans = transFact . newTransformer ( ) ; trans . setOutputProperty ( OutputKeys . INDENT , "no" ) ; StringWriter sw = new StringWriter ( ) ; Result result = ... | Convert a DOM tree into a String using transform |
120,002 | @ SuppressWarnings ( { "unchecked" , "rawtypes" } ) public static Object convert ( Object source , Class < ? > target ) throws ConversionException { if ( target == null ) { throw new ConversionException ( "Unable to perform conversion, target was null" ) ; } if ( source == null ) { if ( target . isPrimitive ( ) ) { thr... | Convert source to given class |
120,003 | public static Object convertToArray ( Object source , Class < ? > target ) throws ConversionException { try { Class < ? > targetType = target . getComponentType ( ) ; if ( source . getClass ( ) . isArray ( ) ) { Object targetInstance = Array . newInstance ( targetType , Array . getLength ( source ) ) ; for ( int i = 0 ... | Convert to array |
120,004 | public static Object convertToWrappedPrimitive ( Object source , Class < ? > wrapper ) { if ( source == null || wrapper == null ) { return null ; } if ( wrapper . isInstance ( source ) ) { return source ; } if ( wrapper . isAssignableFrom ( source . getClass ( ) ) ) { return source ; } if ( source instanceof Number ) {... | Convert to wrapped primitive |
120,005 | public static Object convertStringToWrapper ( String str , Class < ? > wrapper ) { log . trace ( "String: {} to wrapper: {}" , str , wrapper ) ; if ( wrapper . equals ( String . class ) ) { return str ; } else if ( wrapper . equals ( Boolean . class ) ) { return Boolean . valueOf ( str ) ; } else if ( wrapper . equals ... | Convert string to primitive wrapper like Boolean or Float |
120,006 | public static Object convertNumberToWrapper ( Number num , Class < ? > wrapper ) { if ( wrapper . equals ( String . class ) ) { return num . toString ( ) ; } else if ( wrapper . equals ( Boolean . class ) ) { return Boolean . valueOf ( num . intValue ( ) == 1 ) ; } else if ( wrapper . equals ( Double . class ) ) { retu... | Convert number to primitive wrapper like Boolean or Float |
120,007 | public static List < Method > findMethodsByNameAndNumParams ( Object object , String method , int numParam ) { LinkedList < Method > list = new LinkedList < Method > ( ) ; Method [ ] methods = object . getClass ( ) . getMethods ( ) ; for ( Method m : methods ) { String methodName = m . getName ( ) ; if ( ignoredMethodN... | Find method by name and number of parameters |
120,008 | public static Object [ ] convertParams ( Object [ ] source , Class < ? > [ ] target ) throws ConversionException { Object [ ] converted = new Object [ target . length ] ; for ( int i = 0 ; i < target . length ; i ++ ) { converted [ i ] = convert ( source [ i ] , target [ i ] ) ; } return converted ; } | Convert parameters using methods of this utility class |
120,009 | public static Class < ? > [ ] convertParams ( Object [ ] source ) { Class < ? > [ ] converted = null ; if ( source != null ) { converted = new Class < ? > [ source . length ] ; for ( int i = 0 ; i < source . length ; i ++ ) { if ( source [ i ] != null ) { converted [ i ] = source [ i ] . getClass ( ) ; } else { convert... | Convert parameters using methods of this utility class . Special handling is afforded to classes that implement IConnection . |
120,010 | public static Object convertMapToBean ( Map < String , ? extends Object > source , Class < ? > target ) throws ConversionException { Object bean = newInstance ( target ) ; if ( bean == null ) { bean = newInstance ( target . getName ( ) ) ; if ( bean == null ) { throw new ConversionException ( "Unable to create bean usi... | Convert map to bean |
120,011 | public static Set < ? > convertArrayToSet ( Object [ ] source ) { Set < Object > set = new HashSet < Object > ( ) ; for ( Object element : source ) { set . add ( element ) ; } return set ; } | Convert array to set removing duplicates |
120,012 | private ITag createFileMeta ( ) { log . debug ( "createFileMeta" ) ; IoBuffer in = IoBuffer . allocate ( 1024 ) ; in . setAutoExpand ( true ) ; Output out = new Output ( in ) ; out . writeString ( "onMetaData" ) ; Map < Object , Object > props = new HashMap < Object , Object > ( ) ; props . put ( "audiocodecid" , IoCon... | Creates file metadata object |
120,013 | protected void writeArbitraryObject ( Object object ) { log . debug ( "writeObject" ) ; Class < ? > objectClass = object . getClass ( ) ; if ( ! objectClass . isAnnotationPresent ( Anonymous . class ) ) { buf . put ( AMF . TYPE_CLASS_OBJECT ) ; putString ( buf , Serializer . getClassName ( objectClass ) ) ; } else { bu... | Writes an arbitrary object to the output . |
120,014 | protected static byte [ ] encodeString ( String string ) { Element element = getStringCache ( ) . get ( string ) ; byte [ ] encoded = ( element == null ? null : ( byte [ ] ) element . getObjectValue ( ) ) ; if ( encoded == null ) { ByteBuffer buf = AMF . CHARSET . encode ( string ) ; encoded = new byte [ buf . limit ( ... | Encode string . |
120,015 | public static void putString ( IoBuffer buf , String string ) { final byte [ ] encoded = encodeString ( string ) ; if ( encoded . length < AMF . LONG_STRING_LENGTH ) { buf . put ( ( byte ) ( ( encoded . length >> 8 ) & 0xff ) ) ; buf . put ( ( byte ) ( encoded . length & 0xff ) ) ; } else { buf . putInt ( encoded . len... | Write out string |
120,016 | public void writeHeader ( ) throws IOException , ConverterException { if ( append ) { return ; } try { CompoundTag ebml = TagFactory . < CompoundTag > create ( "EBML" ) . add ( TagFactory . < UnsignedIntegerTag > create ( "EBMLVersion" ) . setValue ( 1 ) ) . add ( TagFactory . < UnsignedIntegerTag > create ( "EBMLReadV... | method to write webm header to the new file |
120,017 | public void writeTag ( Tag tag ) throws IOException { byte [ ] hb = tag . encode ( ) ; bytesWritten += hb . length ; dataFile . write ( hb ) ; } | will write tag bytesWritten counter will be increased by the number of bytes actually written |
120,018 | public void close ( ) throws IOException { if ( dataFile != null ) { if ( ! append ) { dataFile . seek ( 0 ) ; try ( RandomAccessFile rf = new RandomAccessFile ( file , "rw" ) ) { rf . getChannel ( ) . transferFrom ( dataFile . getChannel ( ) , 0 , dataFile . length ( ) ) ; } } try { dataFile . close ( ) ; dataFile = n... | Will close all opened resources and finalize the write process |
120,019 | private void createPreStreamingTags ( ) { log . debug ( "Creating pre-streaming tags" ) ; if ( audioDecoderBytes != null ) { IoBuffer body = IoBuffer . allocate ( audioDecoderBytes . length + 3 ) ; body . put ( new byte [ ] { ( byte ) 0xaf , ( byte ) 0 } ) ; if ( log . isDebugEnabled ( ) ) { log . debug ( "Audio decode... | Tag sequence MetaData Audio config remaining audio |
120,020 | public ITag readTag ( ) { ITag tag = null ; try { lock . acquire ( ) ; if ( ! firstTags . isEmpty ( ) ) { log . debug ( "Returning pre-tag" ) ; return firstTags . removeFirst ( ) ; } MP4Frame frame = frames . get ( currentFrame ) ; log . debug ( "Playback {}" , frame ) ; int sampleSize = frame . getSize ( ) ; int time ... | Packages media data for return to providers . |
120,021 | public static void serializeAsXML ( Node node , Writer writer ) { PrintWriter out = new PrintWriter ( writer ) ; print ( node , out ) ; out . flush ( ) ; } | Serialize this node into the writer as XML . |
120,022 | private static void print ( Node node , PrintWriter out ) { if ( node == null ) { return ; } boolean hasChildren = false ; int type = node . getNodeType ( ) ; NodeList children = null ; switch ( type ) { case Node . DOCUMENT_NODE : children = node . getChildNodes ( ) ; if ( children != null ) { int numChildren = childr... | Dumps DOM node |
120,023 | @ SuppressWarnings ( "rawtypes" ) protected static boolean writeBasic ( Output out , Object basic ) { if ( basic == null ) { out . writeNull ( ) ; } else if ( basic instanceof Boolean ) { out . writeBoolean ( ( Boolean ) basic ) ; } else if ( basic instanceof Number ) { out . writeNumber ( ( Number ) basic ) ; } else i... | Writes a primitive out as an object |
120,024 | public static boolean writeComplex ( Output out , Object complex ) { log . trace ( "writeComplex" ) ; if ( writeListType ( out , complex ) ) { return true ; } else if ( writeArrayType ( out , complex ) ) { return true ; } else if ( writeXMLType ( out , complex ) ) { return true ; } else if ( writeCustomType ( out , com... | Writes a complex type object out |
120,025 | protected static boolean writeListType ( Output out , Object listType ) { log . trace ( "writeListType" ) ; if ( listType instanceof List < ? > ) { writeList ( out , ( List < ? > ) listType ) ; } else { return false ; } return true ; } | Writes Lists out as a data type |
120,026 | protected static void writeList ( Output out , List < ? > list ) { if ( ! list . isEmpty ( ) ) { int size = list . size ( ) ; if ( size < 100 ) { out . writeArray ( list ) ; return ; } int nullCount = 0 ; for ( int i = 0 ; i < size ; i ++ ) { if ( list . get ( i ) == null ) { nullCount ++ ; } } if ( nullCount > ( size ... | Writes a List out as an Object |
120,027 | protected static void writeIterator ( Output out , Iterator < Object > it ) { log . trace ( "writeIterator" ) ; LinkedList < Object > list = new LinkedList < Object > ( ) ; while ( it . hasNext ( ) ) { list . addLast ( it . next ( ) ) ; } out . writeArray ( list ) ; } | Writes an iterator out to the output |
120,028 | protected static boolean writeXMLType ( Output out , Object xml ) { log . trace ( "writeXMLType" ) ; if ( xml instanceof Document ) { writeDocument ( out , ( Document ) xml ) ; } else { return false ; } return true ; } | Writes an xml type out to the output |
120,029 | @ SuppressWarnings ( "all" ) protected static boolean writeObjectType ( Output out , Object obj ) { if ( obj instanceof ObjectMap || obj instanceof BeanMap ) { out . writeObject ( ( Map ) obj ) ; } else if ( obj instanceof Map ) { out . writeMap ( ( Map ) obj ) ; } else if ( obj instanceof RecordSet ) { out . writeReco... | Write typed object to the output |
120,030 | protected static boolean writeCustomType ( Output out , Object obj ) { if ( out . isCustom ( obj ) ) { out . writeCustom ( obj ) ; return true ; } else { return false ; } } | Writes a custom data to the output |
120,031 | public static boolean serializeField ( String keyName , Field field , Method getter ) { log . trace ( "serializeField - keyName: {} field: {} method: {}" , new Object [ ] { keyName , field , getter } ) ; if ( "class" . equals ( keyName ) ) { return false ; } if ( field != null ) { if ( Modifier . isTransient ( field . ... | Checks whether the field should be serialized or not |
120,032 | public static String getClassName ( Class < ? > objectClass ) { RemoteClass annotation = objectClass . getAnnotation ( RemoteClass . class ) ; if ( annotation != null ) { return annotation . alias ( ) ; } String className = objectClass . getName ( ) ; if ( className . startsWith ( "org.red5.compatibility." ) ) { classN... | Handles classes by name also provides shortened class aliases where appropriate . |
120,033 | protected void storeReference ( Object obj ) { refMap . put ( new IdentityWrapper ( obj ) , Short . valueOf ( refId ++ ) ) ; } | Store an object into a map |
120,034 | private void updateSize ( IoBuffer data ) { this . widthInfo = data . getShort ( ) ; this . heightInfo = data . getShort ( ) ; this . width = this . widthInfo & 0xfff ; this . height = this . heightInfo & 0xfff ; this . blockWidth = this . widthInfo & 0xf000 ; this . blockWidth = ( this . blockWidth >> 12 ) + 1 ; this ... | Update total block size |
120,035 | public byte readDataType ( ) { if ( buf . hasRemaining ( ) ) { do { currentDataType = buf . get ( ) ; log . trace ( "Data type: {}" , currentDataType ) ; switch ( currentDataType ) { case AMF . TYPE_NULL : case AMF . TYPE_UNDEFINED : return DataTypes . CORE_NULL ; case AMF . TYPE_NUMBER : return DataTypes . CORE_NUMBER... | Reads the data type . |
120,036 | public Boolean readBoolean ( ) { return ( buf . get ( ) == AMF . VALUE_TRUE ) ? Boolean . TRUE : Boolean . FALSE ; } | Reads a boolean . |
120,037 | public Number readNumber ( ) { int remaining = buf . remaining ( ) ; log . debug ( "readNumber from {} bytes" , remaining ) ; if ( remaining >= 8 ) { double d = buf . getDouble ( ) ; log . debug ( "Number: {}" , d ) ; return d ; } if ( log . isDebugEnabled ( ) ) { log . debug ( "Remaining not big enough for number - of... | Reads a Number . In ActionScript 1 and 2 Number type represents all numbers both floats and integers . |
120,038 | public String getString ( ) { log . trace ( "getString - currentDataType: {}" , currentDataType ) ; byte lastDataType = currentDataType ; if ( currentDataType != AMF . TYPE_STRING ) { currentDataType = AMF . TYPE_STRING ; } String result = readString ( ) ; currentDataType = lastDataType ; return result ; } | Reads string from buffer |
120,039 | private final String bufferToString ( byte [ ] str ) { String string = null ; if ( str != null ) { string = AMF . CHARSET . decode ( ByteBuffer . wrap ( str ) ) . toString ( ) ; log . debug ( "String: {}" , string ) ; } else { log . warn ( "ByteBuffer was null attempting to read String" ) ; } return string ; } | Converts the bytes into a string . |
120,040 | public Map < String , Object > readKeyValues ( ) { Map < String , Object > result = new HashMap < String , Object > ( ) ; readKeyValues ( result ) ; return result ; } | Read key - value pairs . This is required for the RecordSet deserializer . |
120,041 | protected void readKeyValues ( Map < String , Object > result ) { while ( hasMoreProperties ( ) ) { String name = readPropertyName ( ) ; log . debug ( "property: {}" , name ) ; Object property = Deserializer . deserialize ( this , Object . class ) ; log . debug ( "val: {}" , property ) ; result . put ( name , property ... | Read key - value pairs into Map object |
120,042 | @ SuppressWarnings ( "all" ) protected Object newInstance ( String className ) { log . debug ( "Loading class: {}" , className ) ; Object instance = null ; Class < ? > clazz = null ; if ( "" . equals ( className ) || className == null ) return instance ; try { if ( className . length ( ) == 3 ) { className = classAlias... | Creates a new instance of the className parameter and returns as an Object |
120,043 | @ SuppressWarnings ( { "unchecked" , "rawtypes" } ) protected Object readBean ( Object bean ) { log . debug ( "readBean: {}" , bean ) ; storeReference ( bean ) ; Class theClass = bean . getClass ( ) ; while ( hasMoreProperties ( ) ) { String name = readPropertyName ( ) ; Type type = getPropertyType ( bean , name ) ; lo... | Reads the input as a bean and returns an object |
120,044 | protected Map < String , Object > readSimpleObject ( ) { log . debug ( "readSimpleObject" ) ; Map < String , Object > result = new ObjectMap < > ( ) ; readKeyValues ( result ) ; storeReference ( result ) ; return result ; } | Reads the input as a map and returns a Map |
120,045 | public Object readObject ( ) { String className ; if ( currentDataType == AMF . TYPE_CLASS_OBJECT ) { className = getString ( ) ; log . debug ( "readObject: {}" , className ) ; if ( className != null ) { log . debug ( "read class object" ) ; Object result = null ; Object instance ; if ( className . equals ( "RecordSet"... | Reads start object |
120,046 | public boolean hasMoreProperties ( ) { if ( buf . remaining ( ) >= 3 ) { byte [ ] threeBytes = new byte [ 3 ] ; int pos = buf . position ( ) ; buf . get ( threeBytes ) ; if ( Arrays . equals ( AMF . END_OF_OBJECT_SEQUENCE , threeBytes ) ) { log . trace ( "End of object" ) ; return false ; } buf . position ( pos ) ; ret... | Returns a boolean stating whether there are more properties |
120,047 | @ SuppressWarnings ( { "unchecked" } ) public static IMeta mergeMeta ( IMetaData < ? , ? > metaData1 , IMetaData < ? , ? > metaData2 ) { Map < String , Object > map1 = ( ( Map < String , Object > ) metaData1 ) ; Set < Entry < String , Object > > set1 = map1 . entrySet ( ) ; Map < String , Object > map2 = ( ( Map < Stri... | Merges the two Meta objects |
120,048 | public void readData ( InputStream inputStream ) throws IOException { if ( inputStream == null ) { return ; } data = ParserUtils . parseBinary ( inputStream , ( int ) size . getValue ( ) ) ; } | method to read tag data from inputStream given |
120,049 | protected void addParameters ( StringBuilder result ) { result . append ( "ts=" ) ; result . append ( timestamp ) ; result . append ( ",headers=" ) ; result . append ( headers ) ; result . append ( ",body=" ) ; result . append ( body ) ; result . append ( ",messageId=" ) ; result . append ( messageId ) ; result . appen... | Add message properties to string . |
120,050 | public void writeHeader ( ) throws IOException { ByteBuffer buf = ByteBuffer . allocate ( HEADER_LENGTH + 4 ) ; FLVHeader flvHeader = new FLVHeader ( ) ; flvHeader . setFlagAudio ( audioCodecId != - 1 ? true : false ) ; flvHeader . setFlagVideo ( videoCodecId != - 1 ? true : false ) ; flvHeader . write ( buf ) ; create... | Writes the header bytes |
120,051 | private void createOutputFile ( ) throws IOException { this . fileChannel = Files . newByteChannel ( Paths . get ( filePath ) , StandardOpenOption . CREATE , StandardOpenOption . WRITE , StandardOpenOption . TRUNCATE_EXISTING ) ; } | Create the stream output file ; the flv itself . |
120,052 | private void createDataFile ( ) throws IOException { Path path = Paths . get ( filePath + ".ser" ) ; if ( Files . deleteIfExists ( path ) ) { log . debug ( "Previous flv data file existed and was removed" ) ; } this . dataChannel = Files . newByteChannel ( path , StandardOpenOption . CREATE_NEW , StandardOpenOption . W... | Create the stream data file . |
120,053 | private void createRepairDataFile ( ) throws IOException { Path path = Paths . get ( filePath + ".ser" ) ; this . dataChannel = Files . newByteChannel ( path , StandardOpenOption . READ ) ; } | Create the stream data file for repair . |
120,054 | private static int [ ] readInfoFile ( File tmpFile ) { int [ ] info = new int [ 8 ] ; try ( RandomAccessFile infoFile = new RandomAccessFile ( tmpFile , "r" ) ) { info [ 0 ] = infoFile . readInt ( ) ; info [ 1 ] = infoFile . readInt ( ) ; info [ 2 ] = infoFile . readInt ( ) ; info [ 3 ] = infoFile . readInt ( ) ; info ... | Read flv file information from pre - finalization file . |
120,055 | private void updateInfoFile ( ) { try ( RandomAccessFile infoFile = new RandomAccessFile ( filePath + ".info" , "rw" ) ) { infoFile . writeInt ( audioCodecId ) ; infoFile . writeInt ( videoCodecId ) ; infoFile . writeInt ( duration ) ; infoFile . writeInt ( audioDataSize ) ; infoFile . writeInt ( soundRate ) ; infoFile... | Write or update flv file information into the pre - finalization file . |
120,056 | public void close ( ) { log . debug ( "close" ) ; boolean locked = false ; try { locked = lock . tryAcquire ( 500L , TimeUnit . MILLISECONDS ) ; if ( locked ) { finalizeFlv ( ) ; } } catch ( InterruptedException e ) { log . warn ( "Exception acquiring lock" , e ) ; } finally { if ( locked ) { lock . release ( ) ; } if ... | Ends the writing process then merges the data file with the flv file header and metadata . |
120,057 | public static boolean repair ( String path , Integer audioId , Integer videoId ) throws InterruptedException { boolean result = false ; FLVWriter writer = null ; log . debug ( "Serial file path: " + path ) ; System . out . println ( "Serial file path: " + path ) ; if ( path . endsWith ( ".ser" ) ) { File ser = new File... | Allows repair of flv files if . info and . ser files still exist . |
120,058 | private Future < ? > submit ( FLVFinalizer flvFinalizer ) { if ( executor != null && ! executor . isTerminated ( ) ) { return executor . submit ( flvFinalizer ) ; } return null ; } | Submits a finalizer internally . |
120,059 | public static void main ( String [ ] args ) throws InterruptedException { if ( args == null || args [ 0 ] == null ) { System . err . println ( "Provide the path to your .ser file" ) ; } else { repair ( args [ 0 ] , args . length > 1 && args [ 1 ] != null ? Integer . valueOf ( args [ 1 ] ) : null , args . length > 2 && ... | Exposed to allow repair of flv files if . info and . ser files still exist . |
120,060 | protected int storeReference ( Object obj ) { int newRefId = refId . getAndIncrement ( ) ; refMap . put ( Integer . valueOf ( newRefId ) , obj ) ; return newRefId ; } | Store an object into a map . |
120,061 | protected void storeReference ( int refId , Object newRef ) { refMap . put ( Integer . valueOf ( refId ) , newRef ) ; } | Replace a referenced object with another one . This is used by the AMF3 deserializer to handle circular references . |
120,062 | private HeaderBitField createHeaderField ( ) throws IOException { HeaderBitField field = new HeaderBitField ( ) ; field . add ( nextByte ( ) ) ; field . add ( nextByte ( ) ) ; field . add ( nextByte ( ) ) ; return field ; } | Creates a bit field for the MPEG frame header . |
120,063 | private static void skipStream ( InputStream in , long count ) throws IOException { long size = count ; long skipped = 0 ; while ( size > 0 && skipped >= 0 ) { skipped = in . skip ( size ) ; if ( skipped != - 1 ) { size -= skipped ; } } } | Skips the given number of bytes from the specified input stream . |
120,064 | private static int calculateBitRate ( int mpegVer , int layer , int code ) { int [ ] arr = null ; if ( mpegVer == AudioFrame . MPEG_V1 ) { switch ( layer ) { case AudioFrame . LAYER_1 : arr = BIT_RATE_MPEG1_L1 ; break ; case AudioFrame . LAYER_2 : arr = BIT_RATE_MPEG1_L2 ; break ; case AudioFrame . LAYER_3 : arr = BIT_... | Calculates the bit rate based on the given parameters . |
120,065 | private static int calculateFrameLength ( int layer , int bitRate , int sampleRate , int padding ) { if ( layer == AudioFrame . LAYER_1 ) { return ( 12 * bitRate / sampleRate + padding ) * 4 ; } else { return 144 * bitRate / sampleRate + padding ; } } | Calculates the length of an MPEG frame based on the given parameters . |
120,066 | private static float calculateDuration ( int layer , int sampleRate ) { int sampleCount = ( layer == AudioFrame . LAYER_1 ) ? SAMPLE_COUNT_L1 : SAMPLE_COUNT_L2 ; return ( 1000.0f / sampleRate ) * sampleCount ; } | Calculates the duration of a MPEG frame based on the given parameters . |
120,067 | private static int [ ] [ ] createSampleRateTable ( ) { int [ ] [ ] arr = new int [ 4 ] [ ] ; arr [ AudioFrame . MPEG_V1 ] = SAMPLE_RATE_MPEG1 ; arr [ AudioFrame . MPEG_V2 ] = SAMPLE_RATE_MPEG2 ; arr [ AudioFrame . MPEG_V2_5 ] = SAMPLE_RATE_MPEG2_5 ; return arr ; } | Creates the complete array for the sample rate mapping . |
120,068 | public void write ( IoBuffer buffer ) { buffer . put ( signature ) ; buffer . put ( version ) ; buffer . put ( ( byte ) ( FLV_HEADER_FLAG_HAS_AUDIO * ( flagAudio ? 1 : 0 ) + FLV_HEADER_FLAG_HAS_VIDEO * ( flagVideo ? 1 : 0 ) ) ) ; buffer . putInt ( 9 ) ; buffer . putInt ( 0 ) ; buffer . flip ( ) ; } | Writes the FLVHeader to IoBuffer . |
120,069 | public byte readDataType ( ) { log . trace ( "readDataType - amf3_mode: {}" , amf3_mode ) ; byte coreType = AMF3 . TYPE_UNDEFINED ; if ( buf != null ) { currentDataType = buf . get ( ) ; log . debug ( "Current data type: {}" , currentDataType ) ; switch ( currentDataType ) { case AMF . TYPE_AMF3_OBJECT : log . trace ( ... | Reads the data type |
120,070 | public Number readNumber ( ) { if ( buf . hasRemaining ( ) ) { int remaining = buf . remaining ( ) ; if ( log . isTraceEnabled ( ) ) { log . trace ( "Remaining bytes for Number: {}" , remaining ) ; } Number v ; if ( currentDataType == AMF3 . TYPE_NUMBER ) { if ( remaining >= 8 ) { v = buf . getDouble ( ) ; } else { v =... | Reads a Number |
120,071 | public String readString ( int length ) { log . debug ( "readString - length: {}" , length ) ; int limit = buf . limit ( ) ; final ByteBuffer strBuf = buf . buf ( ) ; strBuf . limit ( strBuf . position ( ) + length ) ; final String string = AMF . CHARSET . decode ( strBuf ) . toString ( ) ; log . debug ( "String: {}" ,... | Reads a string of a set length . This does not use the string reference table . |
120,072 | public ByteArray readByteArray ( ) { int type = readInteger ( ) ; if ( ( type & 1 ) == 0 ) { return ( ByteArray ) getReference ( type >> 1 ) ; } type >>= 1 ; ByteArray result = new ByteArray ( buf , type ) ; storeReference ( result ) ; return result ; } | Read ByteArray object . |
120,073 | @ SuppressWarnings ( "unchecked" ) public Vector < Integer > readVectorInt ( ) { log . debug ( "readVectorInt" ) ; int type = readInteger ( ) ; if ( ( type & 1 ) == 0 ) { return ( Vector < Integer > ) getReference ( type >> 1 ) ; } int len = type >> 1 ; Vector < Integer > array = new Vector < Integer > ( len ) ; storeR... | Read Vector< ; Integer> ; object . |
120,074 | @ SuppressWarnings ( "unchecked" ) public Vector < Long > readVectorUInt ( ) { log . debug ( "readVectorUInt" ) ; int type = readInteger ( ) ; if ( ( type & 1 ) == 0 ) { return ( Vector < Long > ) getReference ( type >> 1 ) ; } int len = type >> 1 ; Vector < Long > array = new Vector < Long > ( len ) ; storeReference (... | Read Vector< ; uint> ; object . |
120,075 | @ SuppressWarnings ( "unchecked" ) public Vector < Double > readVectorNumber ( ) { log . debug ( "readVectorNumber" ) ; int type = readInteger ( ) ; log . debug ( "Type: {}" , type ) ; if ( ( type & 1 ) == 0 ) { return ( Vector < Double > ) getReference ( type >> 1 ) ; } int len = type >> 1 ; log . debug ( "Length: {}"... | Read Vector< ; Number> ; object . |
120,076 | @ SuppressWarnings ( "unchecked" ) public Vector < Object > readVectorObject ( ) { log . debug ( "readVectorObject" ) ; int type = readInteger ( ) ; log . debug ( "Type: {}" , type ) ; if ( ( type & 1 ) == 0 ) { return ( Vector < Object > ) getReference ( type >> 1 ) ; } int len = type >> 1 ; log . debug ( "Length: {}"... | Read Vector< ; Object> ; object . |
120,077 | private int readInteger ( ) { int b = buf . get ( ) ; if ( buf . hasRemaining ( ) ) { int n = 0 ; int result = 0 ; while ( ( b & 0x80 ) != 0 && n < 3 ) { result <<= 7 ; result |= ( b & 0x7f ) ; b = buf . get ( ) ; n ++ ; } if ( n < 3 ) { result <<= 7 ; result |= b ; } else { result <<= 8 ; result |= b & 0x0ff ; if ( ( ... | Parser of AMF3 compressed integer data type |
120,078 | @ SuppressWarnings ( "unused" ) private int readAMF3IntegerNew ( ) { int b = buf . get ( ) & 0xFF ; if ( b < 128 ) { return b ; } int value = ( b & 0x7F ) << 7 ; b = buf . get ( ) & 0xFF ; if ( b < 128 ) { return ( value | b ) ; } value = ( value | b & 0x7F ) << 7 ; b = buf . get ( ) & 0xFF ; if ( b < 128 ) { return ( ... | Read UInt29 style |
120,079 | public void process ( InputStream input ) throws IOException , ConverterException { while ( 0 != input . available ( ) ) { Tag tag = ParserUtils . parseTag ( input ) ; TagHandler handler = getHandler ( tag ) ; if ( null == handler ) { skipHandler . handle ( tag , input ) ; } else { handler . handle ( tag , input ) ; } ... | Method to process the input stream given will stop as soon as input stream will be empty |
120,080 | public final static void writeReverseInt ( IoBuffer out , int value ) { out . putInt ( ( int ) ( ( value & 0xFF ) << 24 | ( ( value >> 8 ) & 0x00FF ) << 16 | ( ( value >>> 16 ) & 0x000000FF ) << 8 | ( ( value >>> 24 ) & 0x000000FF ) ) ) ; } | Writes integer in reverse order |
120,081 | public final static void writeMediumInt ( ByteBuffer out , int value ) { out . put ( ( byte ) ( ( value >>> 16 ) & 0xff ) ) ; out . put ( ( byte ) ( ( value >>> 8 ) & 0xff ) ) ; out . put ( ( byte ) ( value & 0xff ) ) ; } | Writes medium integer |
120,082 | public final static int readReverseInt ( IoBuffer in ) { int value = in . getInt ( ) ; value = ( ( value & 0xFF ) << 24 | ( ( value >> 8 ) & 0x00FF ) << 16 | ( ( value >>> 16 ) & 0x000000FF ) << 8 | ( ( value >>> 24 ) & 0x000000FF ) ) ; return value ; } | Reads reverse int |
120,083 | public final static void debug ( Logger log , String msg , IoBuffer buf ) { if ( log . isDebugEnabled ( ) ) { log . debug ( msg ) ; log . debug ( "Size: {}" , buf . remaining ( ) ) ; log . debug ( "Data:\n{}" , HexDump . formatHexDump ( buf . getHexDump ( ) ) ) ; log . debug ( "\n{}\n" , toString ( buf ) ) ; } } | Format debug message |
120,084 | public V put ( T name , V value ) { return item . put ( name , value ) ; } | Change a property of the proxied object . |
120,085 | public static String parseString ( InputStream inputStream , final int size ) throws IOException { if ( 0 == size ) { return "" ; } byte [ ] buffer = new byte [ size ] ; int numberOfReadsBytes = inputStream . read ( buffer , 0 , size ) ; assert numberOfReadsBytes == size ; return new String ( buffer , "UTF-8" ) ; } | method used to parse string |
120,086 | public static double parseFloat ( InputStream inputStream , final int size ) throws IOException { byte [ ] buffer = new byte [ size ] ; int numberOfReadsBytes = inputStream . read ( buffer , 0 , size ) ; assert numberOfReadsBytes == size ; ByteBuffer byteBuffer = ByteBuffer . wrap ( buffer ) . order ( ByteOrder . BIG_E... | method used to parse float and double |
120,087 | public static byte [ ] parseBinary ( InputStream inputStream , final int size ) throws IOException { byte value [ ] = new byte [ size ] ; int i = value . length ; while ( i != 0 ) { i -= inputStream . read ( value , value . length - i , i ) ; } return value ; } | method to parse byte array |
120,088 | public static byte [ ] getBytes ( long val , long size ) { byte [ ] res = new byte [ ( int ) size ] ; long bv = val ; for ( int i = ( int ) size - 1 ; i >= 0 ; -- i ) { res [ i ] = ( byte ) ( bv & 0xFF ) ; bv >>= BIT_IN_BYTE ; } return res ; } | method to encode long as byte array of given size |
120,089 | public static void skip ( long size , InputStream input ) throws IOException { while ( size > 0 ) { size -= input . skip ( size ) ; } } | method to skip given amount of bytes in stream |
120,090 | public static void writeMediumInt ( IoBuffer out , int value ) { byte [ ] bytes = new byte [ 3 ] ; bytes [ 0 ] = ( byte ) ( ( value >>> 16 ) & 0x000000FF ) ; bytes [ 1 ] = ( byte ) ( ( value >>> 8 ) & 0x000000FF ) ; bytes [ 2 ] = ( byte ) ( value & 0x00FF ) ; out . put ( bytes ) ; } | Writes a Medium Int to the output buffer |
120,091 | public static int readUnsignedMediumInt ( IoBuffer in ) { byte [ ] bytes = new byte [ 3 ] ; in . get ( bytes ) ; int val = 0 ; val += ( bytes [ 0 ] & 0xFF ) * 256 * 256 ; val += ( bytes [ 1 ] & 0xFF ) * 256 ; val += ( bytes [ 2 ] & 0xFF ) ; return val ; } | Reads an unsigned Medium Int from the in buffer |
120,092 | public static int readMediumInt ( IoBuffer in ) { byte [ ] bytes = new byte [ 3 ] ; in . get ( bytes ) ; int val = 0 ; val += bytes [ 0 ] * 256 * 256 ; val += bytes [ 1 ] * 256 ; val += bytes [ 2 ] ; if ( val < 0 ) { val += 256 ; } return val ; } | Reads a Medium Int to the in buffer |
120,093 | public final static int put ( IoBuffer out , IoBuffer in , int numBytesMax ) { if ( log . isTraceEnabled ( ) ) { log . trace ( "Put\nin buffer: {}\nout buffer: {}\nmax bytes: {}" , new Object [ ] { out , in , numBytesMax } ) ; } int numBytesRead = 0 ; if ( in != null ) { int limit = Math . min ( in . limit ( ) , numByt... | Puts an input buffer in an output buffer and returns number of bytes written . |
120,094 | public final static byte [ ] consumeBytes ( byte [ ] in , int numBytesMax ) { int limit = Math . min ( in . length , numBytesMax ) ; byte [ ] out = new byte [ limit ] ; System . arraycopy ( in , 0 , out , 0 , limit ) ; return out ; } | Consumes bytes from an input buffer and returns them in an output buffer . |
120,095 | protected void prepareIO ( ) { Input input = new Input ( data ) ; input . enforceAMF3 ( ) ; dataInput = new DataInput ( input ) ; Output output = new Output ( data ) ; output . enforceAMF3 ( ) ; dataOutput = new DataOutput ( output ) ; } | Create internal objects used for reading and writing . |
120,096 | public void compress ( ) { IoBuffer tmp = IoBuffer . allocate ( 0 ) ; tmp . setAutoExpand ( true ) ; byte [ ] tmpData = new byte [ data . limit ( ) ] ; data . position ( 0 ) ; data . get ( tmpData ) ; try ( DeflaterOutputStream deflater = new DeflaterOutputStream ( tmp . asOutputStream ( ) , new Deflater ( Deflater . B... | Compress contents using zlib . |
120,097 | public void uncompress ( ) { data . position ( 0 ) ; byte [ ] buffer = new byte [ 8192 ] ; IoBuffer tmp = IoBuffer . allocate ( 0 ) ; tmp . setAutoExpand ( true ) ; try ( InflaterInputStream inflater = new InflaterInputStream ( data . asInputStream ( ) ) ) { while ( inflater . available ( ) > 0 ) { int decompressed = i... | Decompress contents using zlib . |
120,098 | @ SuppressWarnings ( { "unchecked" , "rawtypes" } ) public static < T > T deserialize ( Input in , Type target ) { if ( BLACK_LIST == null ) { try { loadBlackList ( ) ; } catch ( IOException e ) { throw new RuntimeException ( "Failed to init black-list" ) ; } } byte type = in . readDataType ( ) ; if ( log . isTraceEnab... | Deserializes the input parameter and returns an Object which must then be cast to a core data type |
120,099 | public static boolean classAllowed ( String className ) { for ( String name : BLACK_LIST ) { if ( className . startsWith ( name ) ) { return false ; } } return true ; } | Checks to see if a given class is blacklisted or not . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.