Package bm.core.io

Examples of bm.core.io.SerializerInputStream


        try
        {
            open();
            final byte[] data = rs.getRecord( 1 );
            header.deserialize(
                    new SerializerInputStream(
                            new ByteArrayInputStream( data )
                    )
            );
        }
        catch( InvalidRecordIDException e )
View Full Code Here


            {
                final ByteArrayInputStream bais = new ByteArrayInputStream(
                        rs.getRecord( index )
                );
                final DataInputStream dis = new DataInputStream( bais );
                final SerializerInputStream in =
                        new SerializerInputStream( dis );
                buffer.append( in.readString() ).append( '\n' );
                pe.increment();
                pe.dispatch();
            }
            return buffer.toString();
        }
View Full Code Here

            final Row row2 = new Row( table );

            ByteArrayInputStream bais = new ByteArrayInputStream(
                    baos.toByteArray()
            );
            SerializerInputStream in = new SerializerInputStream( bais );
            row2.deserialize( in );

            assertNotNull( row2.getField( "tString" ) );
            assertEquals( "Hola", row2.getField( "tString" ) );
            assertNotNull( row2.getField( "tBoolean" ) );
            assertEquals( new Boolean( true ), row2.getField( "tBoolean" ) );
            assertNotNull( row2.getField( "tDate" ) );
            assertEquals( date, row2.getField( "tDate" ) );
            assertNotNull( row2.getField( "tInt" ) );
            assertEquals( new Integer( 10 ), row2.getField( "tInt" ) );
            assertNotNull( row2.getField( "tLong" ) );
            assertEquals( new Long( 15 ), row2.getField( "tLong" ) );
            assertNotNull( row2.getField( "tShort" ) );
            assertEquals( new Short( (short) 40 ), row2.getField( "tShort" ) );
            assertNotNull( row2.getField( "tBlob" ) );
            assertTrue( row2.getField( "tBlob" ).getClass().isArray() );
            final byte[] testData = (byte[]) row2.getField( "tBlob" );
            assertEquals( "HelloWorld", new String( testData ) );

            row.setField( "tString", "012345678A012345678B012345678C0123" );
            baos.reset();
            row.serialize( out );

            bais = new ByteArrayInputStream(
                    baos.toByteArray()
            );
            in = new SerializerInputStream( bais );
            row2.deserialize( in );

            assertNotNull( row2.getField( "tString" ) );
            assertEquals( "012345678A012345678B012345678C", row2.getField( "tString" ) );
        }
View Full Code Here

        ByteArrayOutputStream baos = null;
        ByteArrayInputStream bais = null;
        DataOutputStream dos = null;
        DataInputStream dis = null;
        SerializerOutputStream out = null;
        SerializerInputStream in = null;
        try
        {
            baos = new ByteArrayOutputStream();
            dos = new DataOutputStream( baos );
            out = new SerializerOutputStream( dos );
            FixedPoint.serialize( out, fp, false );
            FixedPoint.serialize( out, fp, true );
            FixedPoint.serialize( out, null, true );
            bais = new ByteArrayInputStream( baos.toByteArray() );
            dis = new DataInputStream( bais );
            in = new SerializerInputStream( dis );
            final FixedPoint fp1 = FixedPoint.deserialize( in, false );
            assertTrue( fp.equals( fp1 ) );
            final FixedPoint fp2 = FixedPoint.deserialize( in, true );
            assertTrue( fp.equals( fp2 ) );
            final FixedPoint fp3 = FixedPoint.deserialize( in, true );
            assertNull( fp3 );
        }
        catch( SerializationException e )
        {
            fail( e.getMessage() );
        }
        finally
        {
            try{ out.close(); }catch( Exception e ){}
            try{ dos.close(); }catch( Exception e ){}
            try{ baos.close(); }catch( Exception e ){}
            try{ in.close(); }catch( Exception e ){}
            try{ dis.close(); }catch( Exception e ){}
            try{ bais.close(); }catch( Exception e ){}
        }
    }
View Full Code Here

                        Integer.toString( recordId )
                );
            }
            final Row row = new Row( this );
            row.setRecordId( recordId );
            row.deserialize( new SerializerInputStream( new ByteArrayInputStream(
                    data
            ) ) );
            return row;
        }
        catch( SerializationException e )
View Full Code Here

            {
                rs = RecordStore.openRecordStore( RS_NAME, false );
                final ByteArrayInputStream bais = new ByteArrayInputStream(
                        rs.getRecord( 1 )
                );
                final SerializerInputStream in = new SerializerInputStream(
                        bais
                );
                deserialize( in );
            }
            catch( RecordStoreNotFoundException e )
View Full Code Here

            {
                event.dispatch();
            }
            node = new Node( this, order, parent );
            node.setRecordId( new Integer( recordId ) );
            node.deserialize( new SerializerInputStream( new ByteArrayInputStream(
                    buffer,
                    0,
                    recordSize
            )));
        }
View Full Code Here

                {
                    buffer = new byte[ recordSize + 64 ];
                }
                rs.getRecord( recordId, buffer, 0 );
                final StoreInfo info = new StoreInfo();
                info.deserialize( new SerializerInputStream(
                        new ByteArrayInputStream( buffer )
                ) );
                info.recordId = new Integer( recordId );
                cache.put( info.name, info );
            }
View Full Code Here

            final byte[] data = baos.toByteArray();
            assertNotNull( data );
            assertEquals( 19, data.length );
            ByteArrayInputStream bais = new ByteArrayInputStream( data );
            SerializerInputStream in = new SerializerInputStream( bais );

            final Record record2 = new Record( 1, 20 );
            record2.deserialize( in );
            assertEquals( 10, record2.multiplexer );
            assertNotNull( record2.items );
View Full Code Here

            final SerializerOutputStream out = new SerializerOutputStream( baos );
            record.serialize( out );

            final byte[] data = baos.toByteArray();
            final ByteArrayInputStream bais = new ByteArrayInputStream( data );
            final SerializerInputStream in = new SerializerInputStream( bais );
            final Record record2 = new Record( 1, record.multiplexer );
            record2.deserialize( in );
            assertEquals( record, record2 );
        }
        catch( Exception e )
View Full Code Here

TOP

Related Classes of bm.core.io.SerializerInputStream

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.