bump product version to 5.0.4.1
[LibreOffice.git] / jurt / com / sun / star / lib / uno / bridges / java_remote / XConnectionOutputStream_Adapter.java
blobfe970749233533e8e7fa579b51be9e4eac22cfb1
1 /*
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;
40 @Override
41 public void write(int b) throws IOException {
42 _bytes[0] = (byte)b;
44 try {
45 _xConnection.write(_bytes);
46 } catch(com.sun.star.io.IOException ioException) {
47 IOException ex = new IOException(ioException.getMessage());
48 ex.initCause(ioException);
49 throw ex;
52 if(DEBUG) System.err.println("#### " + this.getClass() + " - one byte written:" + _bytes[0]);
55 @Override
56 public void write(byte[] b, int off, int len) throws IOException {
57 byte bytes[] ;
59 if(off == 0 && len == b.length) {
60 bytes = b;
61 } else {
62 bytes = new byte[len];
64 System.arraycopy(b, off, bytes, 0, len);
67 try {
68 _xConnection.write(bytes);
69 } catch(com.sun.star.io.IOException ioException) {
70 IOException ex = new IOException(ioException.getMessage());
71 ex.initCause(ioException);
72 throw ex;
76 @Override
77 public void flush() throws IOException {
78 try {
79 _xConnection.flush();
80 } catch(com.sun.star.io.IOException ioException) {
81 IOException ex = new IOException(ioException.getMessage());
82 ex.initCause(ioException);
83 throw ex;