2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 package com
.sun
.star
.lib
.uno
.bridges
.java_remote
;
22 import java
.io
.IOException
;
23 import java
.io
.OutputStream
;
25 import com
.sun
.star
.connection
.XConnection
;
28 class XConnectionOutputStream_Adapter
extends OutputStream
{
29 static private final boolean DEBUG
= false;
31 protected XConnection _xConnection
;
32 protected byte _bytes
[] = new byte[1];
34 XConnectionOutputStream_Adapter(XConnection xConnection
) {
35 if(DEBUG
) System
.err
.println("#### " + this.getClass() + " - instantiated ");
37 _xConnection
= xConnection
;
41 public void write(int b
) throws IOException
{
45 _xConnection
.write(_bytes
);
46 } catch(com
.sun
.star
.io
.IOException ioException
) {
47 IOException ex
= new IOException(ioException
.getMessage());
48 ex
.initCause(ioException
);
52 if(DEBUG
) System
.err
.println("#### " + this.getClass() + " - one byte written:" + _bytes
[0]);
56 public void write(byte[] b
, int off
, int len
) throws IOException
{
59 if(off
== 0 && len
== b
.length
) {
62 bytes
= new byte[len
];
64 System
.arraycopy(b
, off
, bytes
, 0, len
);
68 _xConnection
.write(bytes
);
69 } catch(com
.sun
.star
.io
.IOException ioException
) {
70 IOException ex
= new IOException(ioException
.getMessage());
71 ex
.initCause(ioException
);
77 public void flush() throws IOException
{
80 } catch(com
.sun
.star
.io
.IOException ioException
) {
81 IOException ex
= new IOException(ioException
.getMessage());
82 ex
.initCause(ioException
);