1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: XConnectionOutputStream_Adapter.java,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 package com
.sun
.star
.lib
.uno
.bridges
.java_remote
;
34 import java
.io
.IOException
;
35 import java
.io
.OutputStream
;
37 import com
.sun
.star
.connection
.XConnection
;
40 class XConnectionOutputStream_Adapter
extends OutputStream
{
41 static private final boolean DEBUG
= false;
43 protected XConnection _xConnection
;
44 protected byte _bytes
[] = new byte[1];
46 XConnectionOutputStream_Adapter(XConnection xConnection
) {
47 if(DEBUG
) System
.err
.println("#### " + this.getClass() + " - instantiated ");
49 _xConnection
= xConnection
;
52 public void write(int b
) throws IOException
{
56 _xConnection
.write(_bytes
);
58 catch(com
.sun
.star
.io
.IOException ioException
) {
59 throw new IOException(ioException
.toString());
62 if(DEBUG
) System
.err
.println("#### " + this.getClass() + " - one byte written:" + _bytes
[0]);
65 public void write(byte[] b
, int off
, int len
) throws IOException
{
68 if(off
== 0 && len
== b
.length
)
72 bytes
= new byte[len
];
74 System
.arraycopy(b
, off
, bytes
, 0, len
);
78 _xConnection
.write(bytes
);
80 catch(com
.sun
.star
.io
.IOException ioException
) {
81 throw new IOException(ioException
.toString());
85 public void flush() throws IOException
{
89 catch(com
.sun
.star
.io
.IOException ioException
) {
90 throw new IOException(ioException
.toString());