Package org.hsqldb.lib

Examples of org.hsqldb.lib.CountdownInputStream


        String       encoding = (ver < 4) ? "UTF16"
                : "UTF8";
        StringWriter writer   = new StringWriter();

        try {
            CountdownInputStream cis    = new CountdownInputStream(x);
            InputStreamReader    reader = new InputStreamReader(cis, encoding);
            char[]               buff   = new char[1024];
            int                  charsRead;

            cis.setCount(length);

            while (-1 != (charsRead = reader.read(buff))) {
                writer.write(buff, 0, charsRead);
            }
        } catch (IOException ex) {
View Full Code Here


     */
    public void allocateLobForResult(ResultLob result,
                                     InputStream inputStream) {

        long                 resultLobId = result.getLobID();
        CountdownInputStream countStream;

        switch (result.getSubType()) {

            case ResultLob.LobResultTypes.REQUEST_CREATE_BYTES : {
                long blobId;
                long blobLength = result.getBlockLength();

                if (inputStream == null) {
                    blobId      = resultLobId;
                    inputStream = result.getInputStream();
                } else {
                    BlobData blob = session.createBlob(blobLength);

                    blobId = blob.getId();

                    resultLobs.put(resultLobId, blobId);
                }

                countStream = new CountdownInputStream(inputStream);

                countStream.setCount(blobLength);
                database.lobManager.setBytesForNewBlob(
                    blobId, countStream, result.getBlockLength());

                break;
            }
            case ResultLob.LobResultTypes.REQUEST_CREATE_CHARS : {
                long clobId;
                long clobLength = result.getBlockLength();

                if (inputStream == null) {
                    clobId = resultLobId;

                    if (result.getReader() != null) {
                        inputStream =
                            new ReaderInputStream(result.getReader());
                    } else {
                        inputStream = result.getInputStream();
                    }
                } else {
                    ClobData clob = session.createClob(clobLength);

                    clobId = clob.getId();

                    resultLobs.put(resultLobId, clobId);
                }

                countStream = new CountdownInputStream(inputStream);

                countStream.setCount(clobLength * 2);
                database.lobManager.setCharsForNewClob(
                    clobId, countStream, result.getBlockLength());

                break;
            }
View Full Code Here

            if (pos > 0) {
                final long actualPos = fis.skip(pos);
            }

            final BufferedInputStream  bis = new BufferedInputStream(fis);
            final CountdownInputStream cis = new CountdownInputStream(bis);

            cis.setCount(length);

            m_countdownInputStream = cis;
        }
View Full Code Here

        String       encoding = (ver < 4) ? "UTF16"
                : "UTF8";
        StringWriter writer   = new StringWriter();

        try {
            CountdownInputStream cis    = new CountdownInputStream(x);
            InputStreamReader    reader = new InputStreamReader(cis, encoding);
            char[]               buff   = new char[1024];
            int                  charsRead;

            cis.setCount(length);

            while (-1 != (charsRead = reader.read(buff))) {
                writer.write(buff, 0, charsRead);
            }
        } catch (IOException ex) {
View Full Code Here

        String       encoding = (ver < 4) ? "UTF16"
                : "UTF8";
        StringWriter writer   = new StringWriter();

        try {
            CountdownInputStream cis    = new CountdownInputStream(x);
            InputStreamReader    reader = new InputStreamReader(cis, encoding);
            char[]               buff   = new char[1024];
            int                  charsRead;

            cis.setCount(length);

            while (-1 != (charsRead = reader.read(buff))) {
                writer.write(buff, 0, charsRead);
            }
        } catch (IOException ex) {
View Full Code Here

            if (pos > 0) {
                final long actualPos = fis.skip(pos);
            }

            final BufferedInputStream  bis = new BufferedInputStream(fis);
            final CountdownInputStream cis = new CountdownInputStream(bis);

            cis.setCount(length);

            m_countdownInputStream = cis;
        }
View Full Code Here

     */
    public void allocateLobForResult(ResultLob result,
                                     InputStream inputStream) {

        try {
            CountdownInputStream countStream;

            switch (result.getSubType()) {

                case ResultLob.LobResultTypes.REQUEST_CREATE_BYTES : {
                    long blobId;
                    long blobLength = result.getBlockLength();

                    if (blobLength < 0) {

                        // embedded session + unknown lob length
                        allocateBlobSegments(result, result.getInputStream());

                        break;
                    }

                    if (inputStream == null) {

                        // embedded session + known lob length
                        blobId      = result.getLobID();
                        inputStream = result.getInputStream();
                    } else {

                        // server session + known or unknown lob length
                        BlobData blob = session.createBlob(blobLength);

                        blobId = blob.getId();

                        resultLobs.put(result.getLobID(), blobId);
                    }

                    countStream = new CountdownInputStream(inputStream);

                    countStream.setCount(blobLength);
                    database.lobManager.setBytesForNewBlob(
                        blobId, countStream, result.getBlockLength());

                    break;
                }
                case ResultLob.LobResultTypes.REQUEST_CREATE_CHARS : {
                    long clobId;
                    long clobLength = result.getBlockLength();

                    if (clobLength < 0) {

                        // embedded session + unknown lob length
                        allocateClobSegments(result, result.getReader());

                        break;
                    }

                    if (inputStream == null) {
                        clobId = result.getLobID();

                        // embedded session + known lob length
                        if (result.getReader() != null) {
                            inputStream =
                                new ReaderInputStream(result.getReader());
                        } else {
                            inputStream = result.getInputStream();
                        }
                    } else {

                        // server session + known or unknown lob length
                        ClobData clob = session.createClob(clobLength);

                        clobId = clob.getId();

                        resultLobs.put(result.getLobID(), clobId);
                    }

                    countStream = new CountdownInputStream(inputStream);

                    countStream.setCount(clobLength * 2);
                    database.lobManager.setCharsForNewClob(
                        clobId, countStream, result.getBlockLength(), false);

                    break;
                }
View Full Code Here

     */
    public void allocateLobForResult(ResultLob result,
                                     InputStream inputStream) {

        try {
            CountdownInputStream countStream;

            switch (result.getSubType()) {

                case ResultLob.LobResultTypes.REQUEST_CREATE_BYTES : {
                    long blobId;
                    long blobLength = result.getBlockLength();

                    if (blobLength < 0) {

                        // embedded session + unknown lob length
                        allocateBlobSegments(result, result.getInputStream());

                        break;
                    }

                    if (inputStream == null) {

                        // embedded session + known lob length
                        blobId      = result.getLobID();
                        inputStream = result.getInputStream();
                    } else {

                        // server session + known or unknown lob length
                        BlobData blob = session.createBlob(blobLength);

                        blobId = blob.getId();

                        resultLobs.put(result.getLobID(), blobId);
                    }

                    countStream = new CountdownInputStream(inputStream);

                    countStream.setCount(blobLength);
                    database.lobManager.setBytesForNewBlob(
                        blobId, countStream, result.getBlockLength());

                    break;
                }
                case ResultLob.LobResultTypes.REQUEST_CREATE_CHARS : {
                    long clobId;
                    long clobLength = result.getBlockLength();

                    if (clobLength < 0) {

                        // embedded session + unknown lob length
                        allocateClobSegments(result, result.getReader());

                        break;
                    }

                    if (inputStream == null) {
                        clobId = result.getLobID();

                        // embedded session + known lob length
                        if (result.getReader() != null) {
                            inputStream =
                                new ReaderInputStream(result.getReader());
                        } else {
                            inputStream = result.getInputStream();
                        }
                    } else {

                        // server session + known or unknown lob length
                        ClobData clob = session.createClob(clobLength);

                        clobId = clob.getId();

                        resultLobs.put(result.getLobID(), clobId);
                    }

                    countStream = new CountdownInputStream(inputStream);

                    countStream.setCount(clobLength * 2);
                    database.lobManager.setCharsForNewClob(
                        clobId, countStream, result.getBlockLength());

                    break;
                }
View Full Code Here

        String       encoding = (ver < 4) ? "UTF16"
                : "UTF8";
        StringWriter writer   = new StringWriter();

        try {
            CountdownInputStream cis    = new CountdownInputStream(x);
            InputStreamReader    reader = new InputStreamReader(cis, encoding);
            char[]               buff   = new char[1024];
            int                  charsRead;

            cis.setCount(length);

            while (-1 != (charsRead = reader.read(buff))) {
                writer.write(buff, 0, charsRead);
            }
        } catch (IOException ex) {
View Full Code Here

     */
    public void allocateLobForResult(ResultLob result,
                                     InputStream inputStream) {

        long                 resultLobId = result.getLobID();
        CountdownInputStream countStream;

        switch (result.getSubType()) {

            case ResultLob.LobResultTypes.REQUEST_CREATE_BYTES : {
                long blobId;
                long blobLength = result.getBlockLength();

                if (inputStream == null) {
                    blobId      = resultLobId;
                    inputStream = result.getInputStream();
                } else {
                    BlobData blob = session.createBlob(blobLength);

                    blobId = blob.getId();

                    resultLobs.put(resultLobId, blobId);
                }

                countStream = new CountdownInputStream(inputStream);

                countStream.setCount(blobLength);
                database.lobManager.setBytesForNewBlob(
                    blobId, countStream, result.getBlockLength());

                break;
            }
            case ResultLob.LobResultTypes.REQUEST_CREATE_CHARS : {
                long clobId;
                long clobLength = result.getBlockLength();

                if (inputStream == null) {
                    clobId = resultLobId;

                    if (result.getReader() != null) {
                        inputStream =
                            new ReaderInputStream(result.getReader());
                    } else {
                        inputStream = result.getInputStream();
                    }
                } else {
                    ClobData clob = session.createClob(clobLength);

                    clobId = clob.getId();

                    resultLobs.put(resultLobId, clobId);
                }

                countStream = new CountdownInputStream(inputStream);

                countStream.setCount(clobLength * 2);
                database.lobManager.setCharsForNewClob(
                    clobId, countStream, result.getBlockLength());

                break;
            }
View Full Code Here

TOP

Related Classes of org.hsqldb.lib.CountdownInputStream

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.