public static void writeSimpleString(ByteBuf buffer, SimpleString val) { byte[] data = val.getData(); buffer.writeInt(data.length); buffer.writeBytes(data); }
/** * Concatenates 2 SimpleString's * * @param toAdd the SimpleString to concatenate with. * @return the concatenated SimpleString */ public SimpleString concat(final SimpleString toAdd) { byte[] bytes = new byte[data.length + toAdd.getData().length]; System.arraycopy(data, 0, bytes, 0, data.length); System.arraycopy(toAdd.getData(), 0, bytes, data.length, toAdd.getData().length); return new SimpleString(bytes); }
public synchronized void encode(final ByteBuf buffer) { if (properties == null) { buffer.writeByte(DataConstants.NULL); } else { buffer.writeByte(DataConstants.NOT_NULL); buffer.writeInt(properties.size()); //uses internal iteration to allow inlining/loop unrolling properties.forEach((key, value) -> { final byte[] data = key.getData(); buffer.writeInt(data.length); buffer.writeBytes(data); value.write(buffer); }); } }
/** * it will translate a property named HDR_DUPLICATE_DETECTION_ID. * @return */ default byte[] getDuplicateIDBytes() { Object duplicateID = getDuplicateProperty(); if (duplicateID == null) { return null; } else { if (duplicateID instanceof SimpleString) { return ((SimpleString) duplicateID).getData(); } else if (duplicateID instanceof String) { return new SimpleString(duplicateID.toString()).getData(); } else { return (byte[]) duplicateID; } } }
public static void writeSimpleString(ByteBuf buffer, SimpleString val) { byte[] data = val.getData(); buffer.writeInt(data.length); buffer.writeBytes(data); }
public static void writeSimpleString(ByteBuf buffer, SimpleString val) { byte[] data = val.getData(); buffer.writeInt(data.length); buffer.writeBytes(data); }
/** * Concatenates 2 SimpleString's * * @param toAdd the SimpleString to concatenate with. * @return the concatenated SimpleString */ public SimpleString concat(final SimpleString toAdd) { byte[] bytes = new byte[data.length + toAdd.getData().length]; System.arraycopy(data, 0, bytes, 0, data.length); System.arraycopy(toAdd.getData(), 0, bytes, data.length, toAdd.getData().length); return new SimpleString(bytes); }
public static void writeSimpleString(ByteBuf buffer, SimpleString val) { byte[] data = val.getData(); buffer.writeInt(data.length); buffer.writeBytes(data); }
/** * Concatenates 2 SimpleString's * * @param toAdd the SimpleString to concatenate with. * @return the concatenated SimpleString */ public SimpleString concat(final SimpleString toAdd) { byte[] bytes = new byte[data.length + toAdd.getData().length]; System.arraycopy(data, 0, bytes, 0, data.length); System.arraycopy(toAdd.getData(), 0, bytes, data.length, toAdd.getData().length); return new SimpleString(bytes); }
/** * Concatenates 2 SimpleString's * * @param toAdd the SimpleString to concatenate with. * @return the concatenated SimpleString */ public SimpleString concat(final SimpleString toAdd) { byte[] bytes = new byte[data.length + toAdd.getData().length]; System.arraycopy(data, 0, bytes, 0, data.length); System.arraycopy(toAdd.getData(), 0, bytes, data.length, toAdd.getData().length); return new SimpleString(bytes); }
/** * Concatenates 2 SimpleString's * * @param toAdd the SimpleString to concatenate with. * @return the concatenated SimpleString */ public SimpleString concat(final SimpleString toAdd) { byte[] bytes = new byte[data.length + toAdd.getData().length]; System.arraycopy(data, 0, bytes, 0, data.length); System.arraycopy(toAdd.getData(), 0, bytes, data.length, toAdd.getData().length); return new SimpleString(bytes); }
/** * Concatenates 2 SimpleString's * * @param toAdd the SimpleString to concatenate with. * @return the concatenated SimpleString */ public SimpleString concat(final SimpleString toAdd) { byte[] bytes = new byte[data.length + toAdd.getData().length]; System.arraycopy(data, 0, bytes, 0, data.length); System.arraycopy(toAdd.getData(), 0, bytes, data.length, toAdd.getData().length); return new SimpleString(bytes); }
public static void writeSimpleString(ByteBuf buffer, SimpleString val) { byte[] data = val.getData(); buffer.writeInt(data.length); buffer.writeBytes(data); }
@Test public void testEmptySimpleString() throws Exception { SimpleString emptySimpleString = new SimpleString(""); SimpleString result = putAndGetNullableSimpleString(emptySimpleString); Assert.assertNotNull(result); ActiveMQTestBase.assertEqualsByteArrays(emptySimpleString.getData(), result.getData()); }
@Test public void testString() throws Exception { final String str = "hello123ABC__524`16254`6125!%^$!%$!%$!%$!%!$%!$$!\uA324"; SimpleString s = new SimpleString(str); Assert.assertEquals(str, s.toString()); Assert.assertEquals(2 * str.length(), s.getData().length); byte[] data = s.getData(); SimpleString s2 = new SimpleString(data); Assert.assertEquals(str, s2.toString()); }
@Test public void testUnicode() throws Exception { String myString = "abcdef&^*&!^ghijkl\uB5E2\uCAC7\uB2BB\uB7DD\uB7C7\uB3A3\uBCE4\uB5A5"; SimpleString s = new SimpleString(myString); byte[] data = s.getData(); s = new SimpleString(data); Assert.assertEquals(myString, s.toString()); }
@Test public void testUnicodeWithSurrogates() throws Exception { String myString = "abcdef&^*&!^ghijkl\uD900\uDD00"; SimpleString s = new SimpleString(myString); byte[] data = s.getData(); s = new SimpleString(data); Assert.assertEquals(myString, s.toString()); }
@Test public void testSizeofString() throws Exception { Assert.assertEquals(DataConstants.SIZE_INT, SimpleString.sizeofString(new SimpleString(""))); SimpleString str = new SimpleString(RandomUtil.randomString()); Assert.assertEquals(DataConstants.SIZE_INT + str.getData().length, SimpleString.sizeofString(str)); }
@Test public void testSizeofNullableString() throws Exception { Assert.assertEquals(1, SimpleString.sizeofNullableString(null)); Assert.assertEquals(1 + DataConstants.SIZE_INT, SimpleString.sizeofNullableString(new SimpleString(""))); SimpleString str = new SimpleString(RandomUtil.randomString()); Assert.assertEquals(1 + DataConstants.SIZE_INT + str.getData().length, SimpleString.sizeofNullableString(str)); }