Package bm.core.io

Examples of bm.core.io.SerializerOutputStream


            pe.dispatch();
            binding.open( url );
            final DataOutputStream dos = binding.beginPost();
            final ChecksumedOutputStream cos = new ChecksumedOutputStream( dos );
            final DataOutputStream dos2 = new DataOutputStream( cos );
            final SerializerOutputStream out = new SerializerOutputStream( dos2 );
            out.writeByte( VERSION );
            out.writeByte( (byte) (encrypted ? 1 : 0) );
            out.writeString( Net.getDeviceGuid() != null ? Net.getDeviceGuid() : "" );
            out.writeLong( Net.getDeviceId() != null ? Net.getDeviceId().longValue() : 0 );
            serialize( out );
            final long crc  = cos.getCRC();
            out.writeString( "END_OF_DATA" );
            out.writeLong( crc );
            pe.setMessage( ResourceManager.getResource( "bm.net.rpc.WaitingResponse" ) );
            pe.dispatch();
            log.debug( "Call serialized" );
            final DataInputStream is = binding.endPost();
            final SerializerInputStream in = new SerializerInputStream( is );
View Full Code Here


    {
        if( currentRecord != null && currentRecord.isDirty() )
        {
//            log.debug( "flushing record: " + currentRecord );
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            SerializerOutputStream out;
            ZOutputStream zos = null;
            if( useCompression() )
            {
                log.debug( "Using compression" );
                zos = new ZOutputStream(
                        baos,
                        DeviceInfo.getDeviceInfo().getOptimalCompression()
                );
                out = new SerializerOutputStream( zos );
            }
            else
            {
                out = new SerializerOutputStream( baos );
            }
            try
            {
                open();
                currentRecord.serialize( out );
                out.flush();
                if( useCompression() )
                {
                    //noinspection ConstantConditions
                    zos.flush();
                    zos.close();
View Full Code Here

        System.out.println( "Writing index" );
        final ZOutputStream zos = new ZOutputStream(
                os,
                ZStream.Z_BEST_COMPRESSION
        );
        final SerializerOutputStream out = new SerializerOutputStream( zos );

        final int numRecords;
        try
        {
            index.getRecordStore().open();
        }
        catch( RecordStoreFullException e )
        {
            throw new RSException( 0, e );
        }
        final Store rs = index.getRecordStore();
        out.writeInt( index.getOrder() );
        out.writeByte( (byte) index.getType() );
        out.writeBoolean( index.isCaseSensitive() );
        numRecords = rs.getNumRecords();
        System.out.println( "Writing " + numRecords + " records" );
        out.writeInt( numRecords );
        for( int i = 1; i <= numRecords; i++ )
        {
            try
            {
                out.writeBlob( rs.getRecord( i ) );
            }
            catch( InvalidRecordIDException e )
            {
            }
        }
        out.flush();
        zos.flush();
        zos.close();
        System.out.println( "Done" );
    }
View Full Code Here

    public final void store( final Index index )
            throws ViewCompilerException
    {
        final ByteArrayOutputStream baos = new ByteArrayOutputStream();
        final SerializerOutputStream out = new SerializerOutputStream( baos );

        try
        {
            out.writeByte( (byte) 1 );
            out.writeInt( id );
            out.writeString( ViewCompiler.escape( title ) );
            out.writeNullableString( controller );

            int count = actions.size();
            out.writeInt( count );
            if( count > 0 )
            {
                for( int i = 0; i < count; i++ )
                {
                    final Action action = (Action) actions.get( i );
                    action.store( out );
                }
            }
            count = attachments.size();
            out.writeInt( count );
            if( count > 0 )
            {
                for( int i = 0; i < count; i++ )
                {
                    final Attachment attachment = (Attachment) attachments.get( i );
                    attachment.store( out );
                }
            }

            store( out );

            out.flush();
            out.close();
            index.insertObject( viewType + "." + name, baos.toByteArray() );
        }
        catch( Exception e )
        {
            throw new ViewCompilerException( e );
View Full Code Here

            throws ViewCompilerException
    {
        try
        {
            final ByteArrayOutputStream baos = new ByteArrayOutputStream();
            final SerializerOutputStream out = new SerializerOutputStream( baos );

            out.writeByte( (byte) 1 );
            out.writeString( source );
            out.writeInt( width );
            out.writeInt( height );
            out.flush();
            out.close();

            index.insertObject( "iconset." + id, baos.toByteArray() );
        }
        catch( Exception e )
        {
View Full Code Here

    public void testSerializeString()
    {
        try
        {
            final ByteArrayOutputStream baos = new ByteArrayOutputStream();
            final SerializerOutputStream out = new SerializerOutputStream( baos );
            final SortedIntArray array = new SortedIntArray( 1 );
            array.insert( 1 );
            final SortedIntArray array2 = new SortedIntArray( 1 );
            array.insert( 2 );
            final Index index = new Index( "sample", 2, Index.KT_STRING, true );
View Full Code Here

    public void testSerializeLong()
    {
        try
        {
            final ByteArrayOutputStream baos = new ByteArrayOutputStream();
            final SerializerOutputStream out = new SerializerOutputStream( baos );
            final SortedIntArray array = new SortedIntArray( 1 );
            array.insert( 1 );
            final SortedIntArray array2 = new SortedIntArray( 1 );
            array.insert( 2 );
            final Index index = new Index( "sample", 2, Index.KT_LONG, true );
View Full Code Here

    public void testSerialize()
    {
        try
        {
            final ByteArrayOutputStream baos = new ByteArrayOutputStream();
            final SerializerOutputStream out = new SerializerOutputStream( baos );
            array.serialize( out );
            final byte[] data = baos.toByteArray();
            final SortedIntArray newArray = new SortedIntArray( 16, 16 );
            final ByteArrayInputStream bais = new ByteArrayInputStream( data );
            final SerializerInputStream in = new SerializerInputStream( bais );
View Full Code Here

        if( getTable( info.getName() ) != null )
        {
            throw new DBException( 0, "Table already exists" );
        }
        final ByteArrayOutputStream     baos = new ByteArrayOutputStream();
        final SerializerOutputStream    out = new SerializerOutputStream( baos );

        baos.reset();
        out.writeByte( Constants.DBRT_TABLE_INFO );
        info.serialize( out );
        byte[] data = baos.toByteArray();
        int recordId = rs.addRecord( data, 0, data.length );
        info.setRecordId( recordId );
        log.debug( "saved table info in " + data.length + " bytes" );

        final TableStatus status = new TableStatus( this );
        status.setTableName( info.getName() );
        baos.reset();
        out.writeByte( Constants.DBRT_TABLE_STATUS );
        status.serialize( out );
        data = baos.toByteArray();
        recordId = rs.addRecord( data, 0, data.length );
        status.setRecordId( recordId );
        log.debug( "saved table status in " + data.length + " bytes" );
View Full Code Here

                   RSException
    {
        try
        {
            final ByteArrayOutputStream baos = new ByteArrayOutputStream();
            final SerializerOutputStream dos = new SerializerOutputStream( baos );
            dos.writeByte( Constants.DBRT_TABLE_STATUS );
            status.serialize( dos );
            open();
            final byte[] data = baos.toByteArray();
            rs.setRecord( status.getRecordId(), data, 0, data.length );
        }
View Full Code Here

TOP

Related Classes of bm.core.io.SerializerOutputStream

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.