Examples of XInputStream


Examples of com.sun.star.io.XInputStream

    {
        try {

            log.println("Checking SPARQL queries...");

            XInputStream xIn = new StreamSimulator(
                util.utils.getFullTestDocName("example.rdf"), true, param);
            xRep.importGraph(FileFormat.RDF_XML, xIn, manifest, base);

            String query;
            query = "SELECT ?p WHERE { ?p rdf:type pkg:Package . }";
View Full Code Here

Examples of com.sun.star.io.XInputStream

                XSeekable xSeek = (XSeekable) UnoRuntime.queryInterface(XSeekable.class, m_RootStream);
                int oleLength = (int) xSeek.getLength();
                xSeek.seek(0);
                xSeek = null;
                //read all bytes
                XInputStream xInput = m_RootStream.getInputStream();
                byte oledata[][] = new byte[1][oleLength];
                xInput.readBytes(oledata, oleLength);
                //return the base64 encoded string
                return Base64.encodeBytes(oledata[0]);
            } catch (Exception ex) {
                ex.printStackTrace();
            }
View Full Code Here

Examples of com.sun.star.io.XInputStream

            }
            Object oSubStream = m_Storage.getByName(aName);
            if (oSubStream == null) {
                return "Not Found:" + aName;
            }
            XInputStream xSubStream = (XInputStream) UnoRuntime.queryInterface(XInputStream.class,
                    oSubStream);
            if (xSubStream == null) {
                return "Not Found:" + aName;
            }
            //The first four byte are the length of the uncompressed data
            byte pLength[][] = new byte[1][4];
            XSeekable xSeek = (XSeekable) UnoRuntime.queryInterface(XSeekable.class, xSubStream);
            xSeek.seek(0);
            xSeek = null;
            //Get the uncompressed length
            int readbytes = xSubStream.readBytes(pLength, 4);
            if (4 != readbytes) {
                System.out.println("readbytes:" + readbytes);
                return "Can not read the length.";
            }
            int oleLength = (pLength[0][0] << 0) + (pLength[0][1] << 8) + (pLength[0][2] << 16) + (pLength[0][3] << 24);
            byte pContents[][] = new byte[1][oleLength];
            //Read all bytes. The compressed length should less then the uncompressed length
            readbytes = xSubStream.readBytes(pContents, oleLength);
            if (oleLength < readbytes) {
                return "oleLength :" + oleLength + " readbytes: " + readbytes;
            }

            // Decompress the bytes
View Full Code Here

Examples of com.sun.star.io.XInputStream

            m_RootStream = CreateTempFileStream(m_xMSF);
            XOutputStream xOutput = m_RootStream.getOutputStream();
            xOutput.writeBytes(oledata);
            xOutput.flush();
            //Get the input stream and seek to begin
            XInputStream xInput = m_RootStream.getInputStream();
            XSeekable xSeek = (XSeekable) UnoRuntime.queryInterface(XSeekable.class, xInput);
            xSeek.seek(0);
            oledata = null;
            xSeek = null;
View Full Code Here

Examples of com.sun.star.io.XInputStream

        try {
            //decode the base64 string
            byte[] oledata = Base64.decode(aBase64);
            //create a temp stream to write data to
            XStream subStream = CreateTempFileStream(m_xMSF);
            XInputStream xInput = subStream.getInputStream();
            XOutputStream xOutput = subStream.getOutputStream();
            //write the length to the temp stream
            byte oleHead[] = new byte[4];
            oleHead[0] = (byte) ((oledata.length >>> 0) & 0xFF);
            oleHead[1] = (byte) ((oledata.length >>> 8) & 0xFF);
View Full Code Here

Examples of com.sun.star.io.XInputStream

    private InputStream getFileStreamFromUCB(String path)
        throws IOException
    {
        InputStream result = null;
        XInputStream xInputStream = null;

        try {
            LogUtils.DEBUG("Trying to read from " + path );
            xInputStream = m_xSimpleFileAccess.openFileRead(path);
            LogUtils.DEBUG("sfa appeared to read file " );
            byte[][] inputBytes = new byte[1][];

            int ln = 0;
            int sz = m_xSimpleFileAccess.getSize(path);
            // TODO don't depend on result of available() or size()
            // just read stream 'till complete
            if ( sz == 0 )
            {
                if ( xInputStream.available() > 0 )
                {
                    sz = xInputStream.available();
                }
            }
            LogUtils.DEBUG("size of file " + path  + " is " + sz );
            LogUtils.DEBUG("available = " + xInputStream.available() );
            inputBytes[0] = new byte[sz];

            ln = xInputStream.readBytes(inputBytes, sz);

            if (ln != sz) {
                throw new IOException(
                    "Failed to read " + sz + " bytes from XInputStream");
            }

            result = new ByteArrayInputStream(inputBytes[0]);
        }
        catch (com.sun.star.io.IOException ioe) {
            LogUtils.DEBUG("caught exception " + ioe );
            throw new IOException(ioe.getMessage());
        }
        catch (com.sun.star.uno.Exception e) {
            LogUtils.DEBUG("caught exception " + e );
            throw new IOException(e.getMessage());
        }
        finally
        {
            if (xInputStream != null) {
                try {
                    xInputStream.closeInput();
                }
                catch (Exception e2) {
                    LogUtils.DEBUG(
                        "Error closing XInputStream:" + e2.getMessage());
                }
View Full Code Here

Examples of com.sun.star.io.XInputStream

        }

        try {
            Object oStream = ((XMultiServiceFactory)tParam.getMSF()).
                createInstance("com.sun.star.io.DataInputStream") ;
            XInputStream newVal = (XInputStream) UnoRuntime.queryInterface
                (XInputStream.class, oStream);

            oObj.updateBinaryStream(idx, newVal, 0) ;
            XInputStream getVal = row.getBinaryStream(idx) ;
            result = UnoRuntime.areSame(newVal, getVal) ;
        } catch (SQLException e) {
            e.printStackTrace(log) ;
            result = false ;
        } catch (com.sun.star.uno.Exception e) {
View Full Code Here

Examples of com.sun.star.io.XInputStream

        }

        try {
            Object oStream = ((XMultiServiceFactory)tParam.getMSF()).
                createInstance("com.sun.star.io.TextInputStream") ;
            XInputStream newVal = (XInputStream) UnoRuntime.queryInterface
                (XInputStream.class, oStream);

            oObj.updateCharacterStream(idx, newVal, 0) ;
            XInputStream getVal = row.getCharacterStream(idx) ;
            result = UnoRuntime.areSame(newVal, getVal) ;
        } catch (SQLException e) {
            e.printStackTrace(log) ;
            result = false ;
        } catch (com.sun.star.uno.Exception e) {
View Full Code Here

Examples of com.sun.star.io.XInputStream

 
   
    {
      byte bytes[][] = new byte[1][];

      XInputStream rIn = (XInputStream)UnoRuntime.queryInterface(XInputStream.class, rOut);
      if(rIn.available() != 10)
        System.err.println("wrong bytes available\n");

      if(rIn.readBytes(bytes, 10) != 10)
        System.err.println("wrong bytes read\n");

      if(42 != bytes[0][0])
        System.err.println("wrong element in sequence\n");
    }
View Full Code Here

Examples of com.sun.star.io.XInputStream

        boolean result = true ;
        int col = findColumnOfType(XDataInputStream.class) ;
        if (col < 0) log.println("Type not found in relation: not tested");
        else {
            try {
                XInputStream getVal = oObj.getBinaryStream(col) ;
            } catch (SQLException e) {
                log.println("Unexpected SQL exception:") ;
                log.println(e) ;
                result = false ;
            }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.