private DataInputStream getStream() { if (dataInput == null) { try { InputStream input = new ActiveMQBufferInputStream(bufferDelegate); dataInput = new DataInputStream(new InflaterReader(input)); } catch (Exception e) { throw new RuntimeException(e.getMessage(), e); } } return dataInput; }
@Override public int read(final byte[] byteArray) throws IOException { if (bb == null) { throw new IOException("read on a closed InputStream"); } return read(byteArray, 0, byteArray.length); }
@Override public int available() throws IOException { if (bb == null) { throw new IOException("available on a closed InputStream"); } return remainingBytes(); }
@Test public void testReadBytesOnStreaming() throws Exception { byte[] byteArray = new byte[1024]; for (int i = 0; i < byteArray.length; i++) { byteArray[i] = getSamplebyte(i); } ActiveMQBuffer splitbuffer = splitBuffer(3, byteArray); ActiveMQBufferInputStream is = new ActiveMQBufferInputStream(splitbuffer); for (int i = 0; i < 100; i++) { assertEquals(getSamplebyte(i), (byte) is.read()); } for (int i = 100; i < byteArray.length; i += 10) { byte[] readBytes = new byte[10]; int size = is.read(readBytes); for (int j = 0; j < size; j++) { assertEquals(getSamplebyte(i + j), readBytes[j]); } } is.close(); }
/** * @param sendBlocking * @param msgI * @param handler * @throws ActiveMQException */ private void largeMessageSendBuffered(final boolean sendBlocking, final ICoreMessage msgI, final ClientProducerCredits credits, SendAcknowledgementHandler handler) throws ActiveMQException { msgI.getBodyBuffer().readerIndex(0); largeMessageSendStreamed(sendBlocking, msgI, new ActiveMQBufferInputStream(msgI.getBodyBuffer()), credits, handler); }
@Override public long skip(final long len) throws IOException { if (bb == null) { throw new IOException("skip on a closed InputStream"); } if (len <= 0L) { return 0L; } int size = Math.min(remainingBytes(), (int) len); bb.skipBytes(size); return size; }
@Override public int read(final byte[] byteArray) throws IOException { if (bb == null) { throw new IOException("read on a closed InputStream"); } return read(byteArray, 0, byteArray.length); }
private DataInputStream getStream() { if (dataInput == null) { try { InputStream input = new ActiveMQBufferInputStream(bufferDelegate); dataInput = new DataInputStream(new InflaterReader(input)); } catch (Exception e) { throw new RuntimeException(e.getMessage(), e); } } return dataInput; }
@Override public int read() throws IOException { if (bb == null) { throw new IOException("read on a closed InputStream"); } if (remainingBytes() == 0) { return -1; } else { return bb.readByte() & 0xFF; } }
@Override public int read(final byte[] byteArray) throws IOException { if (bb == null) { throw new IOException("read on a closed InputStream"); } return read(byteArray, 0, byteArray.length); }
private DataInputStream getStream() { if (dataInput == null) { try { InputStream input = new ActiveMQBufferInputStream(bufferDelegate); dataInput = new DataInputStream(new InflaterReader(input)); } catch (Exception e) { throw new RuntimeException(e.getMessage(), e); } } return dataInput; }
@Override public int read(final byte[] byteArray, final int off, final int len) throws IOException { if (bb == null) { throw new IOException("read on a closed InputStream"); } if (byteArray == null) { throw new NullPointerException(); } if (off < 0 || off > byteArray.length || len < 0 || off + len > byteArray.length || off + len < 0) { throw new IndexOutOfBoundsException(); } if (len == 0) { return 0; } int size = Math.min(remainingBytes(), len); if (size == 0) { return -1; } bb.readBytes(byteArray, off, size); return size; }
@Override public int read(final byte[] byteArray) throws IOException { if (bb == null) { throw new IOException("read on a closed InputStream"); } return read(byteArray, 0, byteArray.length); }
private DataInputStream getStream() { if (dataInput == null) { try { InputStream input = new ActiveMQBufferInputStream(bufferDelegate); dataInput = new DataInputStream(new InflaterReader(input)); } catch (Exception e) { throw new RuntimeException(e.getMessage(), e); } } return dataInput; }
@Override public int available() throws IOException { if (bb == null) { throw new IOException("available on a closed InputStream"); } return remainingBytes(); }
@Override public int read(final byte[] byteArray) throws IOException { if (bb == null) { throw new IOException("read on a closed InputStream"); } return read(byteArray, 0, byteArray.length); }
private DataInputStream getStream() { if (dataInput == null) { try { InputStream input = new ActiveMQBufferInputStream(bufferDelegate); dataInput = new DataInputStream(new InflaterReader(input)); } catch (Exception e) { throw new RuntimeException(e.getMessage(), e); } } return dataInput; }
@Override public int available() throws IOException { if (bb == null) { throw new IOException("available on a closed InputStream"); } return remainingBytes(); }
@Override public int read(final byte[] byteArray) throws IOException { if (bb == null) { throw new IOException("read on a closed InputStream"); } return read(byteArray, 0, byteArray.length); }