/** * @see org.apache.activemq.store.jdbc.adapter.DefaultJDBCAdapter#setBinaryData(java.sql.PreparedStatement, * int, byte[]) */ @Override protected void setBinaryData(PreparedStatement s, int index, byte[] data) throws SQLException { s.setBinaryStream(index, new ByteArrayInputStream(data), data.length); }
private boolean evaluate(byte[] data) { try { InputSource inputSource = new InputSource(new ByteArrayInputStream(data)); Document inputDocument = builder.parse(inputSource); return ((Boolean) xpath.evaluate(xpathExpression, inputDocument, XPathConstants.BOOLEAN)).booleanValue(); } catch (Exception e) { return false; } }
private boolean evaluate(byte[] data) { try { InputSource inputSource = new InputSource(new ByteArrayInputStream(data)); Document inputDocument = builder.parse(inputSource); return ((Boolean)xpath.evaluate(xpathExpression, inputDocument, XPathConstants.BOOLEAN)).booleanValue(); } catch (Exception e) { return false; } }
private Map<String, Object> unmarsallProperties(ByteSequence marshalledProperties) throws IOException { return MarshallingSupport.unmarshalPrimitiveMap(new DataInputStream(new ByteArrayInputStream(marshalledProperties)), MAX_PROPERTY_SIZE); }
private Map<String, Object> unmarsallProperties(ByteSequence marshalledProperties) throws IOException { return MarshallingSupport.unmarshalPrimitiveMap(new DataInputStream(new ByteArrayInputStream(marshalledProperties))); }
public Object unmarshal(ByteSequence packet) throws IOException { return unmarshal(new DataInputStream(new ByteArrayInputStream(packet))); }
public Command read() throws IOException { Command answer = null; Endpoint from = null; synchronized (readLock) { while (true) { DatagramPacket datagram = createDatagramPacket(); channel.receive(datagram); // TODO could use a DataInput implementation that talks direct // to the byte[] to avoid object allocation receiveCounter++; DataInputStream dataIn = new DataInputStream(new ByteArrayInputStream(datagram.getData(), 0, datagram.getLength())); from = headerMarshaller.createEndpoint(datagram, dataIn); answer = (Command)wireFormat.unmarshal(dataIn); break; } } if (answer != null) { answer.setFrom(from); if (LOG.isDebugEnabled()) { LOG.debug("Channel: " + name + " about to process: " + answer); } } return answer; }
DataInputStream dataIn = new DataInputStream(new ByteArrayInputStream(data)); answer = (Command)wireFormat.unmarshal(dataIn); break;
private void initializeReading() throws MessageNotReadableException { checkWriteOnlyBody(); if (this.dataIn == null) { ByteSequence data = getContent(); if (data == null) { data = new ByteSequence(new byte[] {}, 0, 0); } InputStream is = new ByteArrayInputStream(data); if (isCompressed()) { is = new InflaterInputStream(is); is = new BufferedInputStream(is); } this.dataIn = new DataInputStream(is); } }
private String decodeContent(ByteSequence bodyAsBytes) throws JMSException { String text = null; if (bodyAsBytes != null) { InputStream is = null; try { is = new ByteArrayInputStream(bodyAsBytes); if (isCompressed()) { is = new InflaterInputStream(is); } DataInputStream dataIn = new DataInputStream(is); text = MarshallingSupport.readUTF8(dataIn); dataIn.close(); } catch (IOException ioe) { throw JMSExceptionSupport.create(ioe); } finally { if (is != null) { try { is.close(); } catch (IOException e) { // ignore } } } } return text; }
/** * Builds the message body from data * * @throws JMSException * @throws IOException */ private void loadContent() throws JMSException { try { if (getContent() != null && map.isEmpty()) { ByteSequence content = getContent(); InputStream is = new ByteArrayInputStream(content); if (isCompressed()) { is = new InflaterInputStream(is); } DataInputStream dataIn = new DataInputStream(is); map = MarshallingSupport.unmarshalPrimitiveMap(dataIn); dataIn.close(); } } catch (IOException e) { throw JMSExceptionSupport.create(e); } }
private void initializeReading() throws JMSException { checkWriteOnlyBody(); if (dataIn == null) { try { ByteSequence data = getContent(); if (data == null) { data = new ByteSequence(new byte[] {}, 0, 0); } InputStream is = new ByteArrayInputStream(data); if (isCompressed()) { if (data.length != 0) { is = new ByteArrayInputStream(decompress(data)); } } else { length = data.getLength(); } dataIn = new DataInputStream(is); } catch (IOException ioe) { throw JMSExceptionSupport.create(ioe); } } }
public void onCommand(Object o) { Command command = (Command)o; byte type = command.getDataStructureType(); if (type == PartialCommand.DATA_STRUCTURE_TYPE || type == LastPartialCommand.DATA_STRUCTURE_TYPE) { PartialCommand header = (PartialCommand)command; byte[] partialData = header.getData(); try { out.write(partialData); } catch (IOException e) { getTransportListener().onException(e); } if (type == LastPartialCommand.DATA_STRUCTURE_TYPE) { try { byte[] fullData = out.toByteArray(); out.reset(); DataInputStream dataIn = new DataInputStream(new ByteArrayInputStream(fullData)); Command completeCommand = (Command)wireFormat.unmarshal(dataIn); LastPartialCommand lastCommand = (LastPartialCommand)command; lastCommand.configure(completeCommand); getTransportListener().onCommand(completeCommand); } catch (IOException e) { LOG.warn("Failed to unmarshal partial command: " + command); getTransportListener().onException(e); } } } else { getTransportListener().onCommand(command); } }
try { ByteSequence content = getContent(); InputStream is = new ByteArrayInputStream(content); if (isCompressed()) { is = new InflaterInputStream(is);
try { if (compressed) { ByteArrayInputStream input = new ByteArrayInputStream(this.content.getData(), this.content.getOffset(), this.content.getLength()); InflaterInputStream inflater = new InflaterInputStream(input); try {
/** * @see org.apache.activemq.store.jdbc.adapter.DefaultJDBCAdapter#setBinaryData(java.sql.PreparedStatement, * int, byte[]) */ @Override protected void setBinaryData(PreparedStatement s, int index, byte[] data) throws SQLException { s.setBinaryStream(index, new ByteArrayInputStream(data), data.length); }
private boolean evaluate(byte[] data) { try { InputSource inputSource = new InputSource(new ByteArrayInputStream(data)); return ((Boolean)expression.evaluate(inputSource, XPathConstants.BOOLEAN)).booleanValue(); } catch (XPathExpressionException e) { return false; } }
private boolean evaluate(byte[] data) { try { InputSource inputSource = new InputSource(new ByteArrayInputStream(data)); Document inputDocument = builder.parse(inputSource); return ((Boolean) xpath.evaluate(xpathExpression, inputDocument, XPathConstants.BOOLEAN)).booleanValue(); } catch (Exception e) { return false; } }
@Override public Object unmarshal(ByteSequence packet) throws IOException { ByteArrayInputStream stream = new ByteArrayInputStream(packet); DataInputStream dis = new DataInputStream(stream); return unmarshal(dis); }
@Override public Object unmarshal(ByteSequence packet) throws IOException { ByteArrayInputStream stream = new ByteArrayInputStream(packet); DataInputStream dis = new DataInputStream(stream); return unmarshal(dis); }