diff options
author | Sander Vesik <svesik@openoffice.org> | 2004-04-19 22:07:35 +0000 |
---|---|---|
committer | Sander Vesik <svesik@openoffice.org> | 2004-04-19 22:07:35 +0000 |
commit | b72f29681ffbd22ad8a63d3b50c53ab181636165 (patch) | |
tree | 25058cb175a49eaa413742246c56680d2411311a /scripting/java | |
parent | e4636cf5903ece1efc34ebcfcbc20d63ca154560 (diff) |
INTEGRATION: CWS scriptingf5 (1.1.2); FILE ADDED
2004/02/25 18:30:31 npower 1.1.2.1: #i25272# moved from com/sun/star/script/framework/provider
Diffstat (limited to 'scripting/java')
-rw-r--r-- | scripting/java/com/sun/star/script/framework/io/XInputStreamWrapper.java | 121 |
1 files changed, 121 insertions, 0 deletions
diff --git a/scripting/java/com/sun/star/script/framework/io/XInputStreamWrapper.java b/scripting/java/com/sun/star/script/framework/io/XInputStreamWrapper.java new file mode 100644 index 000000000000..bdd9be4ed002 --- /dev/null +++ b/scripting/java/com/sun/star/script/framework/io/XInputStreamWrapper.java @@ -0,0 +1,121 @@ +/************************************************************************* + * + * $RCSfile: XInputStreamWrapper.java,v $ + * + * $Revision: 1.2 $ + * + * last change: $Author: svesik $ $Date: 2004-04-19 23:07:35 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +package com.sun.star.script.framework.io; + +import java.io.InputStream; +import com.sun.star.io.XInputStream; + +public class XInputStreamWrapper extends InputStream { + private XInputStream m_xInputStream; + + public XInputStreamWrapper(XInputStream xInputStream) { + m_xInputStream = xInputStream; + } + + public int read() throws java.io.IOException + { + byte[][] byteRet = new byte[1][1]; + long numRead; + + try { + numRead = m_xInputStream.readBytes(byteRet, 1); + } + catch (com.sun.star.io.IOException ioe) { + throw new java.io.IOException(ioe.getMessage()); + } + + if (numRead != 1) { + return -1; + } + return byteRet[0][0]; + } + + public long skip(long n) throws java.io.IOException + { + try { + m_xInputStream.skipBytes((int)n); + return n; + } + catch (com.sun.star.io.IOException ioe) { + throw new java.io.IOException(ioe.getMessage()); + } + } + + public int available() throws java.io.IOException + { + try { + return m_xInputStream.available(); + } + catch (com.sun.star.io.IOException ioe) { + throw new java.io.IOException(ioe.getMessage()); + } + } + + public void close() throws java.io.IOException + { + try { + m_xInputStream.closeInput(); + } + catch (com.sun.star.io.IOException ioe) { + throw new java.io.IOException(ioe.getMessage()); + } + } +} |