/** * returns the size of a SimpleString * * @param str the SimpleString to check * @return the size */ public static int sizeofString(final SimpleString str) { return str.sizeof(); }
@Override public int getEncodeSize() { return addressMatch.sizeof() + SimpleString.sizeofNullableString(sendRoles) + SimpleString.sizeofNullableString(consumeRoles) + SimpleString.sizeofNullableString(createDurableQueueRoles) + SimpleString.sizeofNullableString(deleteDurableQueueRoles) + SimpleString.sizeofNullableString(createNonDurableQueueRoles) + SimpleString.sizeofNullableString(deleteNonDurableQueueRoles) + SimpleString.sizeofNullableString(manageRoles) + SimpleString.sizeofNullableString(browseRoles) + SimpleString.sizeofNullableString(createAddressRoles) + SimpleString.sizeofNullableString(deleteAddressRoles); }
/** * returns the size of a SimpleString which could be null * * @param str the SimpleString to check * @return the size */ public static int sizeofNullableString(final SimpleString str) { if (str == null) { return 1; } else { return 1 + str.sizeof(); } }
/** * returns the size of a SimpleString * * @param str the SimpleString to check * @return the size */ public static int sizeofString(final SimpleString str) { return str.sizeof(); }
/** * returns the size of a SimpleString * * @param str the SimpleString to check * @return the size */ public static int sizeofString(final SimpleString str) { return str.sizeof(); }
/** * returns the size of a SimpleString * * @param str the SimpleString to check * @return the size */ public static int sizeofString(final SimpleString str) { return str.sizeof(); }
/** * returns the size of a SimpleString which could be null * * @param str the SimpleString to check * @return the size */ public static int sizeofNullableString(final SimpleString str) { if (str == null) { return 1; } else { return 1 + str.sizeof(); } }
/** * returns the size of a SimpleString which could be null * * @param str the SimpleString to check * @return the size */ public static int sizeofNullableString(final SimpleString str) { if (str == null) { return 1; } else { return 1 + str.sizeof(); } }
/** * returns the size of a SimpleString * * @param str the SimpleString to check * @return the size */ public static int sizeofString(final SimpleString str) { return str.sizeof(); }
/** * returns the size of a SimpleString * * @param str the SimpleString to check * @return the size */ public static int sizeofString(final SimpleString str) { return str.sizeof(); }
/** * returns the size of a SimpleString which could be null * * @param str the SimpleString to check * @return the size */ public static int sizeofNullableString(final SimpleString str) { if (str == null) { return 1; } else { return 1 + str.sizeof(); } }
/** * returns the size of a SimpleString * * @param str the SimpleString to check * @return the size */ public static int sizeofString(final SimpleString str) { return str.sizeof(); }
/** * returns the size of a SimpleString which could be null * * @param str the SimpleString to check * @return the size */ public static int sizeofNullableString(final SimpleString str) { if (str == null) { return 1; } else { return 1 + str.sizeof(); } }
/** * returns the size of a SimpleString which could be null * * @param str the SimpleString to check * @return the size */ public static int sizeofNullableString(final SimpleString str) { if (str == null) { return 1; } else { return 1 + str.sizeof(); } }
/** * returns the size of a SimpleString which could be null * * @param str the SimpleString to check * @return the size */ public static int sizeofNullableString(final SimpleString str) { if (str == null) { return 1; } else { return 1 + str.sizeof(); } }
@Override public int getEncodeSize() { return addressMatch.sizeof() + setting.getEncodeSize(); }
@Test public void testByteBufSimpleStringPoolTooLong() { final SimpleString tooLong = new SimpleString("aa"); final ByteBuf bb = Unpooled.buffer(tooLong.sizeof(), tooLong.sizeof()); SimpleString.writeSimpleString(bb, tooLong); final SimpleString.ByteBufSimpleStringPool pool = new SimpleString.ByteBufSimpleStringPool(1, tooLong.length() - 1); Assert.assertNotSame(pool.getOrCreate(bb), pool.getOrCreate(bb.resetReaderIndex())); }
@Test public void testByteBufStringValuePoolTooLong() { final SimpleString tooLong = new SimpleString("aa"); final ByteBuf bb = Unpooled.buffer(tooLong.sizeof(), tooLong.sizeof()); SimpleString.writeSimpleString(bb, tooLong); final TypedProperties.StringValue.ByteBufStringValuePool pool = new TypedProperties.StringValue.ByteBufStringValuePool(1, tooLong.length() - 1); Assert.assertNotSame(pool.getOrCreate(bb), pool.getOrCreate(bb.resetReaderIndex())); }
@Test public void testByteBufStringValuePool() { final int capacity = 8; final int chars = Integer.toString(capacity).length(); final TypedProperties.StringValue.ByteBufStringValuePool pool = new TypedProperties.StringValue.ByteBufStringValuePool(capacity, chars); final int bytes = new SimpleString(Integer.toString(capacity)).sizeof(); final ByteBuf bb = Unpooled.buffer(bytes, bytes); for (int i = 0; i < capacity; i++) { final SimpleString s = new SimpleString(Integer.toString(i)); bb.resetWriterIndex(); SimpleString.writeSimpleString(bb, s); bb.resetReaderIndex(); final TypedProperties.StringValue expectedPooled = pool.getOrCreate(bb); bb.resetReaderIndex(); Assert.assertSame(expectedPooled, pool.getOrCreate(bb)); bb.resetReaderIndex(); } }
@Test public void testByteBufSimpleStringPool() { final int capacity = 8; final int chars = Integer.toString(capacity).length(); final SimpleString.ByteBufSimpleStringPool pool = new SimpleString.ByteBufSimpleStringPool(capacity, chars); final int bytes = new SimpleString(Integer.toString(capacity)).sizeof(); final ByteBuf bb = Unpooled.buffer(bytes, bytes); for (int i = 0; i < capacity; i++) { final SimpleString s = new SimpleString(Integer.toString(i)); bb.resetWriterIndex(); SimpleString.writeSimpleString(bb, s); bb.resetReaderIndex(); final SimpleString expectedPooled = pool.getOrCreate(bb); bb.resetReaderIndex(); Assert.assertSame(expectedPooled, pool.getOrCreate(bb)); bb.resetReaderIndex(); } }