public CodedInputStream(byte[] data) { this(new BufferInputStream(data)); limit = data.length; }
public int read(byte[] b) throws IOException { return read(b, 0, b.length); }
Buffer rc = bis.readBuffer(size); if( rc==null || rc.getLength() < size ) { throw new EOFException();
public CodedInputStream(Buffer data) { this(new BufferInputStream(data)); limit = data.length; }
public int read(byte[] b) throws IOException { return read(b, 0, b.length); }
final public BufferInputStream in() { return new BufferInputStream(this); }
public int read(byte[] b) throws IOException { return read(b, 0, b.length); }
final public BufferInputStream in() { return new BufferInputStream(this); }
final public BufferInputStream in() { return new BufferInputStream(this); }
public static Object readObjectFromBuffer(Buffer buffer) throws JMSException { try { BufferInputStream bufferIn = new BufferInputStream(buffer); ClassLoadingAwareObjectInputStream is = new ClassLoadingAwareObjectInputStream(bufferIn); return is.readObject(); } catch (Exception e) { throw new JMSException("Could not decode: "+e); } }
public static Object readObjectFromBuffer(Buffer buffer) throws JMSException { try { BufferInputStream bufferIn = new BufferInputStream(buffer); ClassLoadingAwareObjectInputStream is = new ClassLoadingAwareObjectInputStream(bufferIn); return is.readObject(); } catch (Exception e) { throw new JMSException("Could not decode: "+e); } }
/** * Inflate a compressed buffer * * @param buffer * @return inflated buffer * @throws IOException */ public static Buffer inflate(Buffer buffer) throws IOException { Buffer result = buffer; if (isCompressed(buffer)) { InputStream bytesIn = new BufferInputStream(buffer); GZIPInputStream gzipIn = new GZIPInputStream(bytesIn); BufferOutputStream bytesOut = new BufferOutputStream(buffer.length); byte[] data = new byte[4096]; int bytesRead = 0; while ((bytesRead = gzipIn.read(data, 0, data.length)) > 0) { bytesOut.write(data, 0, bytesRead); } gzipIn.close(); bytesIn.close(); result = bytesOut.toBuffer(); bytesOut.close(); } return result; }
/** * Inflate a compressed buffer * * @param buffer * @return inflated buffer * @throws IOException */ public static Buffer inflate(Buffer buffer) throws IOException { Buffer result = buffer; if (isCompressed(buffer)) { InputStream bytesIn = new BufferInputStream(buffer); GZIPInputStream gzipIn = new GZIPInputStream(bytesIn); BufferOutputStream bytesOut = new BufferOutputStream(buffer.length); byte[] data = new byte[4096]; int bytesRead = 0; while ((bytesRead = gzipIn.read(data, 0, data.length)) > 0) { bytesOut.write(data, 0, bytesRead); } gzipIn.close(); bytesIn.close(); result = bytesOut.toBuffer(); bytesOut.close(); } return result; }