Package com.sleepycat.util

Examples of com.sleepycat.util.FastOutputStream


    void initSerialShared()
        throws Exception {

        jtc = new TestClassCatalog();
        fo = new FastOutputStream();
    }
View Full Code Here


    void initXmlSax()
        throws Exception {

        buf = new byte[500];
        fo = new FastOutputStream();
        SAXParserFactory saxFactory = SAXParserFactory.newInstance();
        saxFactory.setNamespaceAware(true);
        parser = saxFactory.newSAXParser().getXMLReader();
    }
View Full Code Here

     * @see #setSerialBufferSize
     */
    protected FastOutputStream getSerialOutput(Object object) {
        int byteSize = getSerialBufferSize();
        if (byteSize != 0) {
            return new FastOutputStream(byteSize);
        } else {
            return new FastOutputStream();
        }
    }
View Full Code Here

            throw new IllegalArgumentException(
                        "Data object class (" + object.getClass() +
                        ") not an instance of binding's base class (" +
                        baseClass + ')');
        }
        FastOutputStream fo = getSerialOutput(object);
        try {
            SerialOutput jos = new SerialOutput(fo, classCatalog);
            jos.writeObject(object);
        } catch (IOException e) {
            throw new RuntimeExceptionWrapper(e);
        }

        byte[] hdr = SerialOutput.getStreamHeader();
        entry.setData(fo.getBufferBytes(), hdr.length,
                     fo.getBufferLength() - hdr.length);
    }
View Full Code Here

     * @see #setSerialBufferSize
     */
    protected FastOutputStream getSerialOutput(Object object) {
        int byteSize = getSerialBufferSize();
        if (byteSize != 0) {
            return new FastOutputStream(byteSize);
        } else {
            return new FastOutputStream();
        }
    }
View Full Code Here

            throw new IllegalArgumentException(
                        "Data object class (" + object.getClass() +
                        ") not an instance of binding's base class (" +
                        baseClass + ')');
        }
        FastOutputStream fo = getFastOutputStream();
        try {
            SerialOutput jos = new SerialOutput(fo, classCatalog);
            jos.writeObject(object);
        } catch (IOException e) {
            throw new RuntimeExceptionWrapper(e);
        }

        byte[] hdr = SerialOutput.getStreamHeader();
        entry.setData(fo.getBufferBytes(), hdr.length,
                     fo.getBufferLength() - hdr.length);
    }
View Full Code Here

     * creating it if necessary.
     *
     * @return FastOutputStream
     */
    private FastOutputStream getFastOutputStream() {
        FastOutputStream fo = (FastOutputStream) fastOutputStreamHolder.get();
        if (fo == null) {
            fo = new FastOutputStream();
            fastOutputStreamHolder.set(fo);
        }
        fo.reset();
        return fo;
    }
View Full Code Here

        public Object getElement() {
            return value;
        }

        public byte[] asBytes() throws IOException {
            FastOutputStream buffer = new FastOutputStream();
            DataOutputStream out = new DataOutputStream(buffer);
            out.writeLong(unwrapLong(previousKey));
            out.writeLong(unwrapLong(nextKey));
            out.writeUTF((String) value);
            return buffer.toByteArray();
        }
View Full Code Here

        return info;
    }

    public void objectToEntry(final T info, DatabaseEntry entry) {

        FastOutputStream serialOutput = super.getSerialOutput(info);
        OutputStream out = serialOutput;
        if (compress) {
            out = new LZFOutputStream(serialOutput);
        }
        if (DEBUG) {
            out = new TeeOutputStream(out, System.out);
        }
        try {
            xstreamPersister.save(info, out);
            out.flush();
            out.close();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }

        final byte[] bytes = serialOutput.getBufferBytes();
        final int offset = 0;
        final int length = serialOutput.getBufferLength();
        entry.setData(bytes, offset, length);
    }
View Full Code Here

        return info;
    }

    @Override
    public void objectToEntry(T e, DatabaseEntry entry) {
        FastOutputStream serialOutput = super.getSerialOutput(e);
        try {
            ObjectOutputStream out = new ObjectOutputStream(serialOutput);
            out.writeObject(e);
        } catch (Exception ex) {
            throw new RuntimeException(ex);
        }
       
        final byte[] bytes = serialOutput.getBufferBytes();
        final int offset = 0;
        final int length = serialOutput.getBufferLength();
        entry.setData(bytes, offset, length);
    }
View Full Code Here

TOP

Related Classes of com.sleepycat.util.FastOutputStream

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.