static protected void writeUTF(DataByteArrayOutputStream os, Buffer buffer) throws IOException { os.writeShort(buffer.length); os.write(buffer); }
@Override protected void encode(Object value) throws IOException { MQTTFrame frame = (MQTTFrame) value; nextWriteBuffer.write(frame.header()); int remaining = 0; for(Buffer buffer : frame.buffers) { remaining += buffer.length; } do { byte digit = (byte) (remaining & 0x7F); remaining >>>= 7; if (remaining > 0) { digit |= 0x80; } nextWriteBuffer.write(digit); } while (remaining > 0); for(Buffer buffer : frame.buffers) { nextWriteBuffer.write(buffer.data, buffer.offset, buffer.length); } }
protected void looseMarshalString(UTF8Buffer value, DataByteArrayOutputStream dataOut) throws IOException { dataOut.writeBoolean(value != null); if (value != null) { dataOut.writeShort(value.length); dataOut.write(value); } }
protected void looseMarshalByteArray(OpenWireFormat wireFormat, byte[] data, DataByteArrayOutputStream dataOut) throws IOException { dataOut.writeBoolean(data != null); if (data != null) { dataOut.writeInt(data.length); dataOut.write(data); } }
protected void tightMarshalByteArray2(byte[] data, DataByteArrayOutputStream dataOut, BooleanStream bs) throws IOException { if (bs.readBoolean()) { dataOut.writeInt(data.length); dataOut.write(data); } }
private void writePageFileHeader(int freePageExtent) throws IOException { DataByteArrayOutputStream os = new DataByteArrayOutputStream(); os.write(HAWT_DB_PAGE_FILE_MAGIC); os.writeInt(freePageExtent); os.writeInt(headerSize); os.writeShort(pageSize); os.close(); mappedFileFactory.getMemoryMappedFile().write(0, os.toBuffer()); }
protected void looseMarshalByteArray(OpenWireFormat wireFormat, byte[] data, DataByteArrayOutputStream dataOut) throws IOException { dataOut.writeBoolean(data != null); if (data != null) { dataOut.writeInt(data.length); dataOut.write(data); } }
public MQTTFrame encode() { try { DataByteArrayOutputStream os = new DataByteArrayOutputStream(2+grantedQos.length); os.writeShort(messageId); os.write(grantedQos); MQTTFrame frame = new MQTTFrame(); frame.commandType(TYPE); return frame.buffer(os.toBuffer()); } catch (IOException e) { throw new RuntimeException("The impossible happened"); } }
public int hashNode(N node, int i) { try { DataByteArrayOutputStream os = new DataByteArrayOutputStream(); nodeCodec.encode(node, os); os.write(':'); os.writeInt(i); return hash(os.toBuffer()); } catch (IOException e) { throw new RuntimeException(e); } }
protected void tightMarshalConstByteArray2(byte[] data, DataByteArrayOutputStream dataOut, BooleanStream bs, int i) throws IOException { dataOut.write(data, 0, i); }
protected void looseMarshalBuffer(OpenWireFormat wireFormat, Buffer data, DataByteArrayOutputStream dataOut) throws IOException { dataOut.writeBoolean(data != null); if (data != null) { dataOut.writeInt(data.getLength()); dataOut.write(data.getData(), data.getOffset(), data.getLength()); } }
public MQTTFrame encode() { try { DataByteArrayOutputStream os = new DataByteArrayOutputStream(); MessageSupport.writeUTF(os, topicName); QoS qos = qos(); if(qos != QoS.AT_MOST_ONCE) { os.writeShort(messageId); } MQTTFrame frame = new MQTTFrame(); frame.header(header()); frame.commandType(TYPE); if(payload!=null && payload.length!=0) { os.write(payload); } frame.buffer(os.toBuffer()); return frame; } catch (IOException e) { throw new RuntimeException("The impossible happened"); } }
protected void tightMarshalBuffer2(Buffer data, DataByteArrayOutputStream dataOut, BooleanStream bs) throws IOException { if (bs.readBoolean()) { dataOut.writeInt(data.getLength()); dataOut.write(data.getData(), data.getOffset(), data.getLength()); } }
protected void tightMarshalString2(UTF8Buffer value, DataByteArrayOutputStream dataOut, BooleanStream bs) throws IOException { if (bs.readBoolean()) { // If we verified it only holds ascii values bs.readBoolean(); dataOut.writeShort(value.length); dataOut.write(value); } }
public MQTTFrame encode() { try { DataByteArrayOutputStream os = new DataByteArrayOutputStream(2+grantedQos.length); os.writeShort(messageId); os.write(grantedQos); MQTTFrame frame = new MQTTFrame(); frame.commandType(TYPE); return frame.buffer(os.toBuffer()); } catch (IOException e) { throw new RuntimeException("The impossible happened"); } }
public void writeBytes(String s) throws IOException { int length = s.length(); for (int i = 0; i < length; i++) { write((byte)s.charAt(i)); } }
public void writeBytes(String s) throws IOException { int length = s.length(); for (int i = 0; i < length; i++) { write((byte)s.charAt(i)); } }