Package ca.odell.glazedlists.impl.io

Examples of ca.odell.glazedlists.impl.io.Bufferlo


       
        this.selectionKey = selectionKey;
        this.handler = handler;
        this.manager = manager;
        this.socketChannel = (SocketChannel)selectionKey.channel();
        this.parser = new Bufferlo();
        this.writer = new Bufferlo();
    }
View Full Code Here


                    return false;
                }
           
                // load the chunk
                parser.consume("[^\\r\\n]*\\r\\n");
                Bufferlo chunkData = parser.consume(chunkSize);
                parser.consume("\\r\\n");
               
                // handle the chunk
                if(chunkData.length() > 0) {
                    handler.receiveChunk(this, chunkData);
                    return true;
                } else {
                    close();
                    return false;
                }

            } else {
                Bufferlo chunkData = parser.consume(parser.length());
           
                // handle the simulated chunk
                if(chunkData.length() > 0) {
                    handler.receiveChunk(this, chunkData);
                    return true;
                } else {
                    return false;
                }
View Full Code Here

            PersistentMap map = new PersistentMap(mapFile);

            // read the current value
            Chunk chunk = (Chunk)map.get(key);
            if(chunk != null) {
                Bufferlo valueBufferlo = chunk.getValue();
                value = Integer.valueOf(valueBufferlo.toString());
            } else {
                value = null;
            }
            assertEquals(expectedValue, value);
           
            // write the next value
            expectedValue = (expectedValue == null) ? new Integer(1) : new Integer(expectedValue.intValue() * 2);
            Bufferlo expectedValueBufferlo = new Bufferlo();
            expectedValueBufferlo.write(expectedValue.toString());
            map.put(key, new Chunk(expectedValueBufferlo));
           
            map.close();
        }
    }
View Full Code Here

   
    /**
     * Get a Chunk from a value.
     */
    public static Chunk chunkify(Object value) throws IOException {
        Bufferlo data = new Bufferlo();
        GlazedListsIO.serializableByteCoder().encode(value, data.getOutputStream());
        System.err.println("CHUNKIFIED " + data.length() + " BYTES");
        return new Chunk(data);
    }
View Full Code Here

   
    /**
     * Get a value from a Chunk.
     */
    public static Object deChunkify(Chunk chunk) throws IOException {
        Bufferlo data = chunk.getValue();
        return GlazedListsIO.serializableByteCoder().decode(data.getInputStream());
    }
View Full Code Here

        sharedFile.deleteOnExit();
        PersistentMap writer = new PersistentMap(sharedFile);

        // create a big long queue to keep the writer thread busy
        NullValueCallback callback = new NullValueCallback();
        Bufferlo data = new Bufferlo();
        GlazedListsIO.serializableByteCoder().encode(new long[4000], data.getOutputStream()); // 4000 x 8 bytes ~ 32000 bytes
        for(int i = 0; i < 50; i++) {
            Chunk chunk = new Chunk(data);
            writer.put("big data", chunk);
            chunk.fetchValue(callback);;
        }
View Full Code Here

                    if(connection == null) break;
                }

                if(dataString != null) {
                    System.out.println("read a string of length " + dataString.length());
                    Bufferlo data = new Bufferlo();
                    data.write(dataString);
                    connection.sendChunk(data);
                } else {
                    connection.close();
                }
            }
View Full Code Here

        // sequence the updates
        SortedMap sequentialUpdates = new TreeMap();
        for(Iterator k = storage.keySet().iterator(); k.hasNext(); ) {
            Integer key = (Integer)k.next();
            Bufferlo valueBuffer = ((Chunk)storage.get(key)).getValue();
            sequentialUpdates.put(key, valueBuffer);
        }

        // replay all the updates from the file
        for(Iterator u = sequentialUpdates.keySet().iterator(); u.hasNext(); ) {
            Integer key = (Integer)u.next();
            Bufferlo update = (Bufferlo)sequentialUpdates.get(key);
            ListEventToBytes.toListEvent(update, this, byteCoder);
        }

        // prepare the next update id to use
        if(!sequentialUpdates.isEmpty()) {
View Full Code Here

    /** {@inheritDoc} */
    public void listChanged(ListEvent listChanges) {
        // write the change to disc
        try {
            ListEvent listChangesCopy = listChanges.copy();
            Bufferlo listChangesBytes = ListEventToBytes.toBytes(listChangesCopy, byteCoder);
            storage.put(new Integer(nextUpdateId), new Chunk(listChangesBytes));
            nextUpdateId++;

        } catch(IOException e) {
            throw new IllegalStateException(e.getMessage());
View Full Code Here

        this.persistentMap = persistentMap;

        // save the key and take a binary snapshot of it
        this.key = key;
        try {
            keyBytes = new Bufferlo();
            persistentMap.getKeyCoder().encode(key, keyBytes.getOutputStream());
            keyBytesLength = keyBytes.length();
        } catch(IOException e) {
            persistentMap.fail(e, "Unexpected encoding exception");
        }
View Full Code Here

TOP

Related Classes of ca.odell.glazedlists.impl.io.Bufferlo

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.