/** * Set channel field in ASCII * * @param channel field value * @return flyweight */ public DestinationMessageFlyweight channel(final String channel) { lengthOfChannel = buffer.putStringAscii(offset + CHANNEL_OFFSET, channel); return this; }
/** * Set channel field in ASCII * * @param channel field value * @return flyweight */ public SubscriptionMessageFlyweight channel(final String channel) { lengthOfChannel = buffer.putStringAscii(offset + CHANNEL_OFFSET, channel); return this; }
/** * Set the log filename in ASCII * * @param logFileName for the image * @return flyweight */ public ImageBuffersReadyFlyweight logFileName(final String logFileName) { buffer.putStringAscii(offset + LOG_FILE_NAME_OFFSET, logFileName); return this; }
/** * Set the log file name in ASCII. * * @param logFileName for the publication buffers. * @return the log file name in ASCII. */ public PublicationBuffersReadyFlyweight logFileName(final String logFileName) { buffer.putStringAscii(offset + LOGFILE_FIELD_OFFSET, logFileName); return this; }
/** * Set the channel field as ASCII * * @param channel field value * @return flyweight */ public ImageMessageFlyweight channel(final String channel) { lengthOfChannel = buffer.putStringAscii(offset + CHANNEL_OFFSET, channel); return this; }
/** * Set the channel field in ASCII * * @param channel field value * @return flyweight */ public PublicationMessageFlyweight channel(final String channel) { lengthOfChannel = buffer.putStringAscii(offset + CHANNEL_OFFSET, channel); return this; }
/** * Fill the label. * * @param label for the counter * @return flyweight */ public CounterMessageFlyweight label(final String label) { buffer.putStringAscii(labelOffset(), label); return this; }
/** * Set the source identity string in ASCII * * @param value for the source identity * @return flyweight */ public ImageBuffersReadyFlyweight sourceIdentity(final String value) { buffer.putStringAscii(offset + sourceIdentityOffset(), value); return this; }
@Theory public void shouldRoundTripAsciiStringNativeLength(final MutableDirectBuffer buffer) { final String value = "Hello World"; buffer.putStringAscii(INDEX, value); assertThat(buffer.getStringAscii(INDEX), is(value)); }
@Theory public void shouldInsertNonAsciiAsQuestionMark(final MutableDirectBuffer buffer) { final String value = "Hello World £"; buffer.putStringAscii(INDEX, value); assertThat(buffer.getStringAscii(INDEX), is("Hello World ?")); }
@Theory public void shouldRoundTripAsciiStringBigEndianLength(final MutableDirectBuffer buffer) { final String value = "Hello World"; buffer.putStringAscii(INDEX, value, ByteOrder.BIG_ENDIAN); assertThat(buffer.getStringAscii(INDEX, ByteOrder.BIG_ENDIAN), is(value)); }
private void testAlignedWriteMethods(final MutableDirectBuffer buffer, final int offset) { buffer.putLong(offset + SIZE_OF_LONG, Long.MAX_VALUE); buffer.putLong(offset + SIZE_OF_LONG, Long.MAX_VALUE, BIG_ENDIAN); buffer.putDouble(offset + SIZE_OF_DOUBLE, Double.MAX_VALUE); buffer.putDouble(offset + SIZE_OF_DOUBLE, Double.MAX_VALUE, BIG_ENDIAN); buffer.putInt(offset + SIZE_OF_INT, Integer.MAX_VALUE); buffer.putInt(offset + SIZE_OF_INT, Integer.MAX_VALUE, BIG_ENDIAN); buffer.putFloat(offset + SIZE_OF_FLOAT, Float.MAX_VALUE); buffer.putFloat(offset + SIZE_OF_FLOAT, Float.MAX_VALUE, BIG_ENDIAN); buffer.putShort(offset + SIZE_OF_SHORT, Short.MAX_VALUE); buffer.putShort(offset + SIZE_OF_SHORT, Short.MAX_VALUE, BIG_ENDIAN); buffer.putChar(offset + SIZE_OF_CHAR, Character.MAX_VALUE); buffer.putChar(offset + SIZE_OF_CHAR, Character.MAX_VALUE, BIG_ENDIAN); buffer.putByte(offset + SIZE_OF_BYTE, Byte.MAX_VALUE); buffer.putByte(offset + SIZE_OF_BYTE, Byte.MAX_VALUE); buffer.putStringUtf8(offset + SIZE_OF_INT, TEST_STRING); buffer.putStringUtf8(offset + SIZE_OF_INT, TEST_STRING, BIG_ENDIAN); buffer.putStringUtf8(offset + SIZE_OF_INT, TEST_STRING, Integer.MAX_VALUE); buffer.putStringUtf8(offset + SIZE_OF_INT, TEST_STRING, BIG_ENDIAN, Integer.MAX_VALUE); buffer.putStringAscii(offset + SIZE_OF_INT, TEST_STRING); buffer.putStringAscii(offset + SIZE_OF_INT, TEST_STRING, BIG_ENDIAN); // string size is not read for these method => no need for 4-bytes // alignment buffer.putStringWithoutLengthUtf8(offset + SIZE_OF_BYTE, TEST_STRING); buffer.putStringWithoutLengthAscii(offset + SIZE_OF_BYTE, TEST_STRING); }
private void testUnAlignedWriteMethods(final MutableDirectBuffer buffer, final int offset) { buffer.putLong(offset, Long.MAX_VALUE); // assert that buffer[offset] is // 8-bytes aligned assertUnaligned(offset + SIZE_OF_INT, (i) -> buffer.putLong(i, Long.MAX_VALUE)); assertUnaligned(offset + SIZE_OF_INT, (i) -> buffer.putLong(i, Long.MAX_VALUE, BIG_ENDIAN)); assertUnaligned(offset + SIZE_OF_FLOAT, (i) -> buffer.putDouble(i, Double.MAX_VALUE)); assertUnaligned(offset + SIZE_OF_FLOAT, (i) -> buffer.putDouble(i, Double.MAX_VALUE, BIG_ENDIAN)); assertUnaligned(offset + SIZE_OF_SHORT, (i) -> buffer.putInt(i, Integer.MAX_VALUE)); assertUnaligned(offset + SIZE_OF_SHORT, (i) -> buffer.putInt(i, Integer.MAX_VALUE, BIG_ENDIAN)); assertUnaligned(offset + SIZE_OF_SHORT, (i) -> buffer.putFloat(i, Float.MAX_VALUE)); assertUnaligned(offset + SIZE_OF_SHORT, (i) -> buffer.putFloat(i, Float.MAX_VALUE, BIG_ENDIAN)); assertUnaligned(offset + SIZE_OF_BYTE, (i) -> buffer.putShort(i, Short.MAX_VALUE)); assertUnaligned(offset + SIZE_OF_BYTE, (i) -> buffer.putShort(i, Short.MAX_VALUE, BIG_ENDIAN)); assertUnaligned(offset + SIZE_OF_BYTE, (i) -> buffer.putChar(i, Character.MAX_VALUE)); assertUnaligned(offset + SIZE_OF_BYTE, (i) -> buffer.putChar(i, Character.MAX_VALUE, BIG_ENDIAN)); assertUnaligned(offset + SIZE_OF_SHORT, (i) -> buffer.putStringAscii(i, TEST_STRING)); assertUnaligned(offset + SIZE_OF_SHORT, (i) -> buffer.putStringAscii(i, TEST_STRING, BIG_ENDIAN)); assertUnaligned(offset + SIZE_OF_SHORT, (i) -> buffer.putStringUtf8(i, TEST_STRING)); assertUnaligned(offset + SIZE_OF_SHORT, (i) -> buffer.putStringUtf8(i, TEST_STRING, BIG_ENDIAN)); assertUnaligned(offset + SIZE_OF_SHORT, (i) -> buffer.putStringUtf8(i, TEST_STRING, Integer.MAX_VALUE)); assertUnaligned(offset + SIZE_OF_SHORT, (i) -> buffer.putStringUtf8(i, TEST_STRING, BIG_ENDIAN, Integer.MAX_VALUE)); }
/** * Set channel field in ASCII * * @param channel field value * @return flyweight */ public DestinationMessageFlyweight channel(final String channel) { lengthOfChannel = buffer.putStringAscii(offset + CHANNEL_OFFSET, channel); return this; }
/** * Set channel field in ASCII * * @param channel field value * @return flyweight */ public SubscriptionMessageFlyweight channel(final String channel) { lengthOfChannel = buffer.putStringAscii(offset + CHANNEL_OFFSET, channel); return this; }
/** * Set the log file name in ASCII. * * @param logFileName for the publication buffers. * @return the log file name in ASCII. */ public PublicationBuffersReadyFlyweight logFileName(final String logFileName) { buffer.putStringAscii(offset + LOGFILE_FIELD_OFFSET, logFileName); return this; }
/** * Set the channel field in ASCII * * @param channel field value * @return flyweight */ public PublicationMessageFlyweight channel(final String channel) { lengthOfChannel = buffer.putStringAscii(offset + CHANNEL_OFFSET, channel); return this; }
/** * Set the channel field as ASCII * * @param channel field value * @return flyweight */ public ImageMessageFlyweight channel(final String channel) { lengthOfChannel = buffer.putStringAscii(offset + CHANNEL_OFFSET, channel); return this; }
/** * Fill the label. * * @param label for the counter * @return flyweight */ public CounterMessageFlyweight label(final String label) { buffer.putStringAscii(labelOffset(), label); return this; }
/** * Set the source identity string in ASCII * * @param value for the source identity * @return flyweight */ public ImageBuffersReadyFlyweight sourceIdentity(final String value) { buffer.putStringAscii(offset + sourceIdentityOffset(), value); return this; }