Here are the examples of the java api class org.apache.activemq.openwire.buffer.DataByteArrayInputStream taken from open source projects.
1. XATransactionId#initFromEncodedBytes()
Project: activemq-openwire
File: XATransactionId.java
File: XATransactionId.java
//+|-,(long)lastAck,(byte)priority,(int)formatid,(short)globalLength.... private void initFromEncodedBytes() throws IOException { DataByteArrayInputStream inputStream = new DataByteArrayInputStream(encodedXidBytes); inputStream.skipBytes(10); formatId = inputStream.readInt(); int globalLength = inputStream.readShort(); globalTransactionId = new byte[globalLength]; try { inputStream.read(globalTransactionId); branchQualifier = new byte[inputStream.available()]; inputStream.read(branchQualifier); } catch (IOException fatal) { throw new RuntimeException(this + ", failed to decode:", fatal); } finally { inputStream.close(); } }
2. OpenWireMarshallingSupportTest#testMarshalBoolean()
Project: activemq-openwire
File: OpenWireMarshallingSupportTest.java
File: OpenWireMarshallingSupportTest.java
@Test public void testMarshalBoolean() throws Exception { DataByteArrayOutputStream dataOut = new DataByteArrayOutputStream(); OpenWireMarshallingSupport.marshalBoolean(dataOut, false); OpenWireMarshallingSupport.marshalBoolean(dataOut, true); DataByteArrayInputStream input = new DataByteArrayInputStream(dataOut.toBuffer()); DataInputStream dataIn = new DataInputStream(input); Boolean result = (Boolean) OpenWireMarshallingSupport.unmarshalPrimitive(dataIn); assertFalse(result); result = (Boolean) OpenWireMarshallingSupport.unmarshalPrimitive(dataIn); assertTrue(result); }
3. XATransactionId#stringFormArj()
Project: activemq-openwire
File: XATransactionId.java
File: XATransactionId.java
private void stringFormArj(StringBuffer s, byte[] uid) { DataByteArrayInputStream byteArrayInputStream = null; try { byteArrayInputStream = new DataByteArrayInputStream(uid); s.append(Long.toString(byteArrayInputStream.readLong(), 16)); s.append(':'); s.append(Long.toString(byteArrayInputStream.readLong(), 16)); s.append(':'); s.append(Integer.toString(byteArrayInputStream.readInt(), 16)); s.append(':'); s.append(Integer.toString(byteArrayInputStream.readInt(), 16)); s.append(':'); s.append(Integer.toString(byteArrayInputStream.readInt(), 16)); } catch (Exception ignored) { stringFormDefault(s, uid); } finally { try { byteArrayInputStream.close(); } catch (IOException e) { } } }
4. OpenWireStreamMessage#readStreamToList()
Project: activemq-openwire
File: OpenWireStreamMessage.java
File: OpenWireStreamMessage.java
/** * Reads the contents of the StreamMessage instances into a single List<Object> instance * and returns it. The read starts from the current position of the message which implies * that the list might not be a complete view of the message if any prior read operations * were invoked. * * @return a List containing the objects store in this message starting from the current position. * * @throws JMSException if an error occurs while reading the message. */ public List<Object> readStreamToList() throws IOException { if (!hasContent()) { return Collections.emptyList(); } Buffer payload = getPayload(); DataByteArrayInputStream dataIn = new DataByteArrayInputStream(payload); List<Object> result = new ArrayList<Object>(); while (true) { try { result.add(readNextElement(dataIn)); } catch (EOFException ex) { break; } catch (Exception e) { throw IOExceptionSupport.create(e); } } return result; }