/* Generated SBE (Simple Binary Encoding) message codec. */ package uk.co.real_logic.sbe.ir.generated; import org.agrona.MutableDirectBuffer; import org.agrona.DirectBuffer; /** * Codec for an IR Token */ @SuppressWarnings("all") public class TokenCodecEncoder { public static final int BLOCK_LENGTH = 28; public static final int TEMPLATE_ID = 2; public static final int SCHEMA_ID = 1; public static final int SCHEMA_VERSION = 0; public static final java.nio.ByteOrder BYTE_ORDER = java.nio.ByteOrder.LITTLE_ENDIAN; private final TokenCodecEncoder parentMessage = this; private MutableDirectBuffer buffer; protected int initialOffset; protected int offset; protected int limit; public int sbeBlockLength() { return BLOCK_LENGTH; } public int sbeTemplateId() { return TEMPLATE_ID; } public int sbeSchemaId() { return SCHEMA_ID; } public int sbeSchemaVersion() { return SCHEMA_VERSION; } public String sbeSemanticType() { return ""; } public MutableDirectBuffer buffer() { return buffer; } public int initialOffset() { return initialOffset; } public int offset() { return offset; } public TokenCodecEncoder wrap(final MutableDirectBuffer buffer, final int offset) { if (buffer != this.buffer) { this.buffer = buffer; } this.initialOffset = offset; this.offset = offset; limit(offset + BLOCK_LENGTH); return this; } public TokenCodecEncoder wrapAndApplyHeader( final MutableDirectBuffer buffer, final int offset, final MessageHeaderEncoder headerEncoder) { headerEncoder .wrap(buffer, offset) .blockLength(BLOCK_LENGTH) .templateId(TEMPLATE_ID) .schemaId(SCHEMA_ID) .version(SCHEMA_VERSION); return wrap(buffer, offset + MessageHeaderEncoder.ENCODED_LENGTH); } public int encodedLength() { return limit - offset; } public int limit() { return limit; } public void limit(final int limit) { this.limit = limit; } public static int tokenOffsetId() { return 1; } public static int tokenOffsetSinceVersion() { return 0; } public static int tokenOffsetEncodingOffset() { return 0; } public static int tokenOffsetEncodingLength() { return 4; } public static String tokenOffsetMetaAttribute(final MetaAttribute metaAttribute) { if (MetaAttribute.PRESENCE == metaAttribute) { return "required"; } return ""; } public static int tokenOffsetNullValue() { return -2147483648; } public static int tokenOffsetMinValue() { return -2147483647; } public static int tokenOffsetMaxValue() { return 2147483647; } public TokenCodecEncoder tokenOffset(final int value) { buffer.putInt(offset + 0, value, java.nio.ByteOrder.LITTLE_ENDIAN); return this; } public static int tokenSizeId() { return 2; } public static int tokenSizeSinceVersion() { return 0; } public static int tokenSizeEncodingOffset() { return 4; } public static int tokenSizeEncodingLength() { return 4; } public static String tokenSizeMetaAttribute(final MetaAttribute metaAttribute) { if (MetaAttribute.PRESENCE == metaAttribute) { return "required"; } return ""; } public static int tokenSizeNullValue() { return -2147483648; } public static int tokenSizeMinValue() { return -2147483647; } public static int tokenSizeMaxValue() { return 2147483647; } public TokenCodecEncoder tokenSize(final int value) { buffer.putInt(offset + 4, value, java.nio.ByteOrder.LITTLE_ENDIAN); return this; } public static int fieldIdId() { return 3; } public static int fieldIdSinceVersion() { return 0; } public static int fieldIdEncodingOffset() { return 8; } public static int fieldIdEncodingLength() { return 4; } public static String fieldIdMetaAttribute(final MetaAttribute metaAttribute) { if (MetaAttribute.PRESENCE == metaAttribute) { return "required"; } return ""; } public static int fieldIdNullValue() { return -2147483648; } public static int fieldIdMinValue() { return -2147483647; } public static int fieldIdMaxValue() { return 2147483647; } public TokenCodecEncoder fieldId(final int value) { buffer.putInt(offset + 8, value, java.nio.ByteOrder.LITTLE_ENDIAN); return this; } public static int tokenVersionId() { return 4; } public static int tokenVersionSinceVersion() { return 0; } public static int tokenVersionEncodingOffset() { return 12; } public static int tokenVersionEncodingLength() { return 4; } public static String tokenVersionMetaAttribute(final MetaAttribute metaAttribute) { if (MetaAttribute.PRESENCE == metaAttribute) { return "required"; } return ""; } public static int tokenVersionNullValue() { return -2147483648; } public static int tokenVersionMinValue() { return -2147483647; } public static int tokenVersionMaxValue() { return 2147483647; } public TokenCodecEncoder tokenVersion(final int value) { buffer.putInt(offset + 12, value, java.nio.ByteOrder.LITTLE_ENDIAN); return this; } public static int componentTokenCountId() { return 5; } public static int componentTokenCountSinceVersion() { return 0; } public static int componentTokenCountEncodingOffset() { return 16; } public static int componentTokenCountEncodingLength() { return 4; } public static String componentTokenCountMetaAttribute(final MetaAttribute metaAttribute) { if (MetaAttribute.PRESENCE == metaAttribute) { return "required"; } return ""; } public static int componentTokenCountNullValue() { return -2147483648; } public static int componentTokenCountMinValue() { return -2147483647; } public static int componentTokenCountMaxValue() { return 2147483647; } public TokenCodecEncoder componentTokenCount(final int value) { buffer.putInt(offset + 16, value, java.nio.ByteOrder.LITTLE_ENDIAN); return this; } public static int signalId() { return 6; } public static int signalSinceVersion() { return 0; } public static int signalEncodingOffset() { return 20; } public static int signalEncodingLength() { return 1; } public static String signalMetaAttribute(final MetaAttribute metaAttribute) { if (MetaAttribute.PRESENCE == metaAttribute) { return "required"; } return ""; } public TokenCodecEncoder signal(final SignalCodec value) { buffer.putByte(offset + 20, (byte)value.value()); return this; } public static int primitiveTypeId() { return 7; } public static int primitiveTypeSinceVersion() { return 0; } public static int primitiveTypeEncodingOffset() { return 21; } public static int primitiveTypeEncodingLength() { return 1; } public static String primitiveTypeMetaAttribute(final MetaAttribute metaAttribute) { if (MetaAttribute.PRESENCE == metaAttribute) { return "required"; } return ""; } public TokenCodecEncoder primitiveType(final PrimitiveTypeCodec value) { buffer.putByte(offset + 21, (byte)value.value()); return this; } public static int byteOrderId() { return 8; } public static int byteOrderSinceVersion() { return 0; } public static int byteOrderEncodingOffset() { return 22; } public static int byteOrderEncodingLength() { return 1; } public static String byteOrderMetaAttribute(final MetaAttribute metaAttribute) { if (MetaAttribute.PRESENCE == metaAttribute) { return "required"; } return ""; } public TokenCodecEncoder byteOrder(final ByteOrderCodec value) { buffer.putByte(offset + 22, (byte)value.value()); return this; } public static int presenceId() { return 9; } public static int presenceSinceVersion() { return 0; } public static int presenceEncodingOffset() { return 23; } public static int presenceEncodingLength() { return 1; } public static String presenceMetaAttribute(final MetaAttribute metaAttribute) { if (MetaAttribute.PRESENCE == metaAttribute) { return "required"; } return ""; } public TokenCodecEncoder presence(final PresenceCodec value) { buffer.putByte(offset + 23, (byte)value.value()); return this; } public static int deprecatedId() { return 10; } public static int deprecatedSinceVersion() { return 0; } public static int deprecatedEncodingOffset() { return 24; } public static int deprecatedEncodingLength() { return 4; } public static String deprecatedMetaAttribute(final MetaAttribute metaAttribute) { if (MetaAttribute.PRESENCE == metaAttribute) { return "optional"; } return ""; } public static int deprecatedNullValue() { return 0; } public static int deprecatedMinValue() { return -2147483647; } public static int deprecatedMaxValue() { return 2147483647; } public TokenCodecEncoder deprecated(final int value) { buffer.putInt(offset + 24, value, java.nio.ByteOrder.LITTLE_ENDIAN); return this; } public static int nameId() { return 11; } public static String nameCharacterEncoding() { return "UTF-8"; } public static String nameMetaAttribute(final MetaAttribute metaAttribute) { if (MetaAttribute.PRESENCE == metaAttribute) { return "required"; } return ""; } public static int nameHeaderLength() { return 2; } public TokenCodecEncoder putName(final DirectBuffer src, final int srcOffset, final int length) { if (length > 65534) { throw new IllegalStateException("length > maxValue for type: " + length); } final int headerLength = 2; final int limit = parentMessage.limit(); parentMessage.limit(limit + headerLength + length); buffer.putShort(limit, (short)length, java.nio.ByteOrder.LITTLE_ENDIAN); buffer.putBytes(limit + headerLength, src, srcOffset, length); return this; } public TokenCodecEncoder putName(final byte[] src, final int srcOffset, final int length) { if (length > 65534) { throw new IllegalStateException("length > maxValue for type: " + length); } final int headerLength = 2; final int limit = parentMessage.limit(); parentMessage.limit(limit + headerLength + length); buffer.putShort(limit, (short)length, java.nio.ByteOrder.LITTLE_ENDIAN); buffer.putBytes(limit + headerLength, src, srcOffset, length); return this; } public TokenCodecEncoder name(final String value) { final byte[] bytes; try { bytes = null == value || value.isEmpty() ? org.agrona.collections.ArrayUtil.EMPTY_BYTE_ARRAY : value.getBytes("UTF-8"); } catch (final java.io.UnsupportedEncodingException ex) { throw new RuntimeException(ex); } final int length = bytes.length; if (length > 65534) { throw new IllegalStateException("length > maxValue for type: " + length); } final int headerLength = 2; final int limit = parentMessage.limit(); parentMessage.limit(limit + headerLength + length); buffer.putShort(limit, (short)length, java.nio.ByteOrder.LITTLE_ENDIAN); buffer.putBytes(limit + headerLength, bytes, 0, length); return this; } public static int constValueId() { return 12; } public static String constValueCharacterEncoding() { return "UTF-8"; } public static String constValueMetaAttribute(final MetaAttribute metaAttribute) { if (MetaAttribute.PRESENCE == metaAttribute) { return "required"; } return ""; } public static int constValueHeaderLength() { return 2; } public TokenCodecEncoder putConstValue(final DirectBuffer src, final int srcOffset, final int length) { if (length > 65534) { throw new IllegalStateException("length > maxValue for type: " + length); } final int headerLength = 2; final int limit = parentMessage.limit(); parentMessage.limit(limit + headerLength + length); buffer.putShort(limit, (short)length, java.nio.ByteOrder.LITTLE_ENDIAN); buffer.putBytes(limit + headerLength, src, srcOffset, length); return this; } public TokenCodecEncoder putConstValue(final byte[] src, final int srcOffset, final int length) { if (length > 65534) { throw new IllegalStateException("length > maxValue for type: " + length); } final int headerLength = 2; final int limit = parentMessage.limit(); parentMessage.limit(limit + headerLength + length); buffer.putShort(limit, (short)length, java.nio.ByteOrder.LITTLE_ENDIAN); buffer.putBytes(limit + headerLength, src, srcOffset, length); return this; } public TokenCodecEncoder constValue(final String value) { final byte[] bytes; try { bytes = null == value || value.isEmpty() ? org.agrona.collections.ArrayUtil.EMPTY_BYTE_ARRAY : value.getBytes("UTF-8"); } catch (final java.io.UnsupportedEncodingException ex) { throw new RuntimeException(ex); } final int length = bytes.length; if (length > 65534) { throw new IllegalStateException("length > maxValue for type: " + length); } final int headerLength = 2; final int limit = parentMessage.limit(); parentMessage.limit(limit + headerLength + length); buffer.putShort(limit, (short)length, java.nio.ByteOrder.LITTLE_ENDIAN); buffer.putBytes(limit + headerLength, bytes, 0, length); return this; } public static int minValueId() { return 13; } public static String minValueCharacterEncoding() { return "UTF-8"; } public static String minValueMetaAttribute(final MetaAttribute metaAttribute) { if (MetaAttribute.PRESENCE == metaAttribute) { return "required"; } return ""; } public static int minValueHeaderLength() { return 2; } public TokenCodecEncoder putMinValue(final DirectBuffer src, final int srcOffset, final int length) { if (length > 65534) { throw new IllegalStateException("length > maxValue for type: " + length); } final int headerLength = 2; final int limit = parentMessage.limit(); parentMessage.limit(limit + headerLength + length); buffer.putShort(limit, (short)length, java.nio.ByteOrder.LITTLE_ENDIAN); buffer.putBytes(limit + headerLength, src, srcOffset, length); return this; } public TokenCodecEncoder putMinValue(final byte[] src, final int srcOffset, final int length) { if (length > 65534) { throw new IllegalStateException("length > maxValue for type: " + length); } final int headerLength = 2; final int limit = parentMessage.limit(); parentMessage.limit(limit + headerLength + length); buffer.putShort(limit, (short)length, java.nio.ByteOrder.LITTLE_ENDIAN); buffer.putBytes(limit + headerLength, src, srcOffset, length); return this; } public TokenCodecEncoder minValue(final String value) { final byte[] bytes; try { bytes = null == value || value.isEmpty() ? org.agrona.collections.ArrayUtil.EMPTY_BYTE_ARRAY : value.getBytes("UTF-8"); } catch (final java.io.UnsupportedEncodingException ex) { throw new RuntimeException(ex); } final int length = bytes.length; if (length > 65534) { throw new IllegalStateException("length > maxValue for type: " + length); } final int headerLength = 2; final int limit = parentMessage.limit(); parentMessage.limit(limit + headerLength + length); buffer.putShort(limit, (short)length, java.nio.ByteOrder.LITTLE_ENDIAN); buffer.putBytes(limit + headerLength, bytes, 0, length); return this; } public static int maxValueId() { return 14; } public static String maxValueCharacterEncoding() { return "UTF-8"; } public static String maxValueMetaAttribute(final MetaAttribute metaAttribute) { if (MetaAttribute.PRESENCE == metaAttribute) { return "required"; } return ""; } public static int maxValueHeaderLength() { return 2; } public TokenCodecEncoder putMaxValue(final DirectBuffer src, final int srcOffset, final int length) { if (length > 65534) { throw new IllegalStateException("length > maxValue for type: " + length); } final int headerLength = 2; final int limit = parentMessage.limit(); parentMessage.limit(limit + headerLength + length); buffer.putShort(limit, (short)length, java.nio.ByteOrder.LITTLE_ENDIAN); buffer.putBytes(limit + headerLength, src, srcOffset, length); return this; } public TokenCodecEncoder putMaxValue(final byte[] src, final int srcOffset, final int length) { if (length > 65534) { throw new IllegalStateException("length > maxValue for type: " + length); } final int headerLength = 2; final int limit = parentMessage.limit(); parentMessage.limit(limit + headerLength + length); buffer.putShort(limit, (short)length, java.nio.ByteOrder.LITTLE_ENDIAN); buffer.putBytes(limit + headerLength, src, srcOffset, length); return this; } public TokenCodecEncoder maxValue(final String value) { final byte[] bytes; try { bytes = null == value || value.isEmpty() ? org.agrona.collections.ArrayUtil.EMPTY_BYTE_ARRAY : value.getBytes("UTF-8"); } catch (final java.io.UnsupportedEncodingException ex) { throw new RuntimeException(ex); } final int length = bytes.length; if (length > 65534) { throw new IllegalStateException("length > maxValue for type: " + length); } final int headerLength = 2; final int limit = parentMessage.limit(); parentMessage.limit(limit + headerLength + length); buffer.putShort(limit, (short)length, java.nio.ByteOrder.LITTLE_ENDIAN); buffer.putBytes(limit + headerLength, bytes, 0, length); return this; } public static int nullValueId() { return 15; } public static String nullValueCharacterEncoding() { return "UTF-8"; } public static String nullValueMetaAttribute(final MetaAttribute metaAttribute) { if (MetaAttribute.PRESENCE == metaAttribute) { return "required"; } return ""; } public static int nullValueHeaderLength() { return 2; } public TokenCodecEncoder putNullValue(final DirectBuffer src, final int srcOffset, final int length) { if (length > 65534) { throw new IllegalStateException("length > maxValue for type: " + length); } final int headerLength = 2; final int limit = parentMessage.limit(); parentMessage.limit(limit + headerLength + length); buffer.putShort(limit, (short)length, java.nio.ByteOrder.LITTLE_ENDIAN); buffer.putBytes(limit + headerLength, src, srcOffset, length); return this; } public TokenCodecEncoder putNullValue(final byte[] src, final int srcOffset, final int length) { if (length > 65534) { throw new IllegalStateException("length > maxValue for type: " + length); } final int headerLength = 2; final int limit = parentMessage.limit(); parentMessage.limit(limit + headerLength + length); buffer.putShort(limit, (short)length, java.nio.ByteOrder.LITTLE_ENDIAN); buffer.putBytes(limit + headerLength, src, srcOffset, length); return this; } public TokenCodecEncoder nullValue(final String value) { final byte[] bytes; try { bytes = null == value || value.isEmpty() ? org.agrona.collections.ArrayUtil.EMPTY_BYTE_ARRAY : value.getBytes("UTF-8"); } catch (final java.io.UnsupportedEncodingException ex) { throw new RuntimeException(ex); } final int length = bytes.length; if (length > 65534) { throw new IllegalStateException("length > maxValue for type: " + length); } final int headerLength = 2; final int limit = parentMessage.limit(); parentMessage.limit(limit + headerLength + length); buffer.putShort(limit, (short)length, java.nio.ByteOrder.LITTLE_ENDIAN); buffer.putBytes(limit + headerLength, bytes, 0, length); return this; } public static int characterEncodingId() { return 16; } public static String characterEncodingCharacterEncoding() { return "UTF-8"; } public static String characterEncodingMetaAttribute(final MetaAttribute metaAttribute) { if (MetaAttribute.PRESENCE == metaAttribute) { return "required"; } return ""; } public static int characterEncodingHeaderLength() { return 2; } public TokenCodecEncoder putCharacterEncoding(final DirectBuffer src, final int srcOffset, final int length) { if (length > 65534) { throw new IllegalStateException("length > maxValue for type: " + length); } final int headerLength = 2; final int limit = parentMessage.limit(); parentMessage.limit(limit + headerLength + length); buffer.putShort(limit, (short)length, java.nio.ByteOrder.LITTLE_ENDIAN); buffer.putBytes(limit + headerLength, src, srcOffset, length); return this; } public TokenCodecEncoder putCharacterEncoding(final byte[] src, final int srcOffset, final int length) { if (length > 65534) { throw new IllegalStateException("length > maxValue for type: " + length); } final int headerLength = 2; final int limit = parentMessage.limit(); parentMessage.limit(limit + headerLength + length); buffer.putShort(limit, (short)length, java.nio.ByteOrder.LITTLE_ENDIAN); buffer.putBytes(limit + headerLength, src, srcOffset, length); return this; } public TokenCodecEncoder characterEncoding(final String value) { final byte[] bytes; try { bytes = null == value || value.isEmpty() ? org.agrona.collections.ArrayUtil.EMPTY_BYTE_ARRAY : value.getBytes("UTF-8"); } catch (final java.io.UnsupportedEncodingException ex) { throw new RuntimeException(ex); } final int length = bytes.length; if (length > 65534) { throw new IllegalStateException("length > maxValue for type: " + length); } final int headerLength = 2; final int limit = parentMessage.limit(); parentMessage.limit(limit + headerLength + length); buffer.putShort(limit, (short)length, java.nio.ByteOrder.LITTLE_ENDIAN); buffer.putBytes(limit + headerLength, bytes, 0, length); return this; } public static int epochId() { return 17; } public static String epochCharacterEncoding() { return "UTF-8"; } public static String epochMetaAttribute(final MetaAttribute metaAttribute) { if (MetaAttribute.PRESENCE == metaAttribute) { return "required"; } return ""; } public static int epochHeaderLength() { return 2; } public TokenCodecEncoder putEpoch(final DirectBuffer src, final int srcOffset, final int length) { if (length > 65534) { throw new IllegalStateException("length > maxValue for type: " + length); } final int headerLength = 2; final int limit = parentMessage.limit(); parentMessage.limit(limit + headerLength + length); buffer.putShort(limit, (short)length, java.nio.ByteOrder.LITTLE_ENDIAN); buffer.putBytes(limit + headerLength, src, srcOffset, length); return this; } public TokenCodecEncoder putEpoch(final byte[] src, final int srcOffset, final int length) { if (length > 65534) { throw new IllegalStateException("length > maxValue for type: " + length); } final int headerLength = 2; final int limit = parentMessage.limit(); parentMessage.limit(limit + headerLength + length); buffer.putShort(limit, (short)length, java.nio.ByteOrder.LITTLE_ENDIAN); buffer.putBytes(limit + headerLength, src, srcOffset, length); return this; } public TokenCodecEncoder epoch(final String value) { final byte[] bytes; try { bytes = null == value || value.isEmpty() ? org.agrona.collections.ArrayUtil.EMPTY_BYTE_ARRAY : value.getBytes("UTF-8"); } catch (final java.io.UnsupportedEncodingException ex) { throw new RuntimeException(ex); } final int length = bytes.length; if (length > 65534) { throw new IllegalStateException("length > maxValue for type: " + length); } final int headerLength = 2; final int limit = parentMessage.limit(); parentMessage.limit(limit + headerLength + length); buffer.putShort(limit, (short)length, java.nio.ByteOrder.LITTLE_ENDIAN); buffer.putBytes(limit + headerLength, bytes, 0, length); return this; } public static int timeUnitId() { return 18; } public static String timeUnitCharacterEncoding() { return "UTF-8"; } public static String timeUnitMetaAttribute(final MetaAttribute metaAttribute) { if (MetaAttribute.PRESENCE == metaAttribute) { return "required"; } return ""; } public static int timeUnitHeaderLength() { return 2; } public TokenCodecEncoder putTimeUnit(final DirectBuffer src, final int srcOffset, final int length) { if (length > 65534) { throw new IllegalStateException("length > maxValue for type: " + length); } final int headerLength = 2; final int limit = parentMessage.limit(); parentMessage.limit(limit + headerLength + length); buffer.putShort(limit, (short)length, java.nio.ByteOrder.LITTLE_ENDIAN); buffer.putBytes(limit + headerLength, src, srcOffset, length); return this; } public TokenCodecEncoder putTimeUnit(final byte[] src, final int srcOffset, final int length) { if (length > 65534) { throw new IllegalStateException("length > maxValue for type: " + length); } final int headerLength = 2; final int limit = parentMessage.limit(); parentMessage.limit(limit + headerLength + length); buffer.putShort(limit, (short)length, java.nio.ByteOrder.LITTLE_ENDIAN); buffer.putBytes(limit + headerLength, src, srcOffset, length); return this; } public TokenCodecEncoder timeUnit(final String value) { final byte[] bytes; try { bytes = null == value || value.isEmpty() ? org.agrona.collections.ArrayUtil.EMPTY_BYTE_ARRAY : value.getBytes("UTF-8"); } catch (final java.io.UnsupportedEncodingException ex) { throw new RuntimeException(ex); } final int length = bytes.length; if (length > 65534) { throw new IllegalStateException("length > maxValue for type: " + length); } final int headerLength = 2; final int limit = parentMessage.limit(); parentMessage.limit(limit + headerLength + length); buffer.putShort(limit, (short)length, java.nio.ByteOrder.LITTLE_ENDIAN); buffer.putBytes(limit + headerLength, bytes, 0, length); return this; } public static int semanticTypeId() { return 19; } public static String semanticTypeCharacterEncoding() { return "UTF-8"; } public static String semanticTypeMetaAttribute(final MetaAttribute metaAttribute) { if (MetaAttribute.PRESENCE == metaAttribute) { return "required"; } return ""; } public static int semanticTypeHeaderLength() { return 2; } public TokenCodecEncoder putSemanticType(final DirectBuffer src, final int srcOffset, final int length) { if (length > 65534) { throw new IllegalStateException("length > maxValue for type: " + length); } final int headerLength = 2; final int limit = parentMessage.limit(); parentMessage.limit(limit + headerLength + length); buffer.putShort(limit, (short)length, java.nio.ByteOrder.LITTLE_ENDIAN); buffer.putBytes(limit + headerLength, src, srcOffset, length); return this; } public TokenCodecEncoder putSemanticType(final byte[] src, final int srcOffset, final int length) { if (length > 65534) { throw new IllegalStateException("length > maxValue for type: " + length); } final int headerLength = 2; final int limit = parentMessage.limit(); parentMessage.limit(limit + headerLength + length); buffer.putShort(limit, (short)length, java.nio.ByteOrder.LITTLE_ENDIAN); buffer.putBytes(limit + headerLength, src, srcOffset, length); return this; } public TokenCodecEncoder semanticType(final String value) { final byte[] bytes; try { bytes = null == value || value.isEmpty() ? org.agrona.collections.ArrayUtil.EMPTY_BYTE_ARRAY : value.getBytes("UTF-8"); } catch (final java.io.UnsupportedEncodingException ex) { throw new RuntimeException(ex); } final int length = bytes.length; if (length > 65534) { throw new IllegalStateException("length > maxValue for type: " + length); } final int headerLength = 2; final int limit = parentMessage.limit(); parentMessage.limit(limit + headerLength + length); buffer.putShort(limit, (short)length, java.nio.ByteOrder.LITTLE_ENDIAN); buffer.putBytes(limit + headerLength, bytes, 0, length); return this; } public static int descriptionId() { return 20; } public static String descriptionCharacterEncoding() { return "UTF-8"; } public static String descriptionMetaAttribute(final MetaAttribute metaAttribute) { if (MetaAttribute.PRESENCE == metaAttribute) { return "required"; } return ""; } public static int descriptionHeaderLength() { return 2; } public TokenCodecEncoder putDescription(final DirectBuffer src, final int srcOffset, final int length) { if (length > 65534) { throw new IllegalStateException("length > maxValue for type: " + length); } final int headerLength = 2; final int limit = parentMessage.limit(); parentMessage.limit(limit + headerLength + length); buffer.putShort(limit, (short)length, java.nio.ByteOrder.LITTLE_ENDIAN); buffer.putBytes(limit + headerLength, src, srcOffset, length); return this; } public TokenCodecEncoder putDescription(final byte[] src, final int srcOffset, final int length) { if (length > 65534) { throw new IllegalStateException("length > maxValue for type: " + length); } final int headerLength = 2; final int limit = parentMessage.limit(); parentMessage.limit(limit + headerLength + length); buffer.putShort(limit, (short)length, java.nio.ByteOrder.LITTLE_ENDIAN); buffer.putBytes(limit + headerLength, src, srcOffset, length); return this; } public TokenCodecEncoder description(final String value) { final byte[] bytes; try { bytes = null == value || value.isEmpty() ? org.agrona.collections.ArrayUtil.EMPTY_BYTE_ARRAY : value.getBytes("UTF-8"); } catch (final java.io.UnsupportedEncodingException ex) { throw new RuntimeException(ex); } final int length = bytes.length; if (length > 65534) { throw new IllegalStateException("length > maxValue for type: " + length); } final int headerLength = 2; final int limit = parentMessage.limit(); parentMessage.limit(limit + headerLength + length); buffer.putShort(limit, (short)length, java.nio.ByteOrder.LITTLE_ENDIAN); buffer.putBytes(limit + headerLength, bytes, 0, length); return this; } public static int referencedNameId() { return 21; } public static String referencedNameCharacterEncoding() { return "UTF-8"; } public static String referencedNameMetaAttribute(final MetaAttribute metaAttribute) { if (MetaAttribute.PRESENCE == metaAttribute) { return "required"; } return ""; } public static int referencedNameHeaderLength() { return 2; } public TokenCodecEncoder putReferencedName(final DirectBuffer src, final int srcOffset, final int length) { if (length > 65534) { throw new IllegalStateException("length > maxValue for type: " + length); } final int headerLength = 2; final int limit = parentMessage.limit(); parentMessage.limit(limit + headerLength + length); buffer.putShort(limit, (short)length, java.nio.ByteOrder.LITTLE_ENDIAN); buffer.putBytes(limit + headerLength, src, srcOffset, length); return this; } public TokenCodecEncoder putReferencedName(final byte[] src, final int srcOffset, final int length) { if (length > 65534) { throw new IllegalStateException("length > maxValue for type: " + length); } final int headerLength = 2; final int limit = parentMessage.limit(); parentMessage.limit(limit + headerLength + length); buffer.putShort(limit, (short)length, java.nio.ByteOrder.LITTLE_ENDIAN); buffer.putBytes(limit + headerLength, src, srcOffset, length); return this; } public TokenCodecEncoder referencedName(final String value) { final byte[] bytes; try { bytes = null == value || value.isEmpty() ? org.agrona.collections.ArrayUtil.EMPTY_BYTE_ARRAY : value.getBytes("UTF-8"); } catch (final java.io.UnsupportedEncodingException ex) { throw new RuntimeException(ex); } final int length = bytes.length; if (length > 65534) { throw new IllegalStateException("length > maxValue for type: " + length); } final int headerLength = 2; final int limit = parentMessage.limit(); parentMessage.limit(limit + headerLength + length); buffer.putShort(limit, (short)length, java.nio.ByteOrder.LITTLE_ENDIAN); buffer.putBytes(limit + headerLength, bytes, 0, length); return this; } public String toString() { if (null == buffer) { return ""; } return appendTo(new StringBuilder()).toString(); } public StringBuilder appendTo(final StringBuilder builder) { if (null == buffer) { return builder; } final TokenCodecDecoder decoder = new TokenCodecDecoder(); decoder.wrap(buffer, initialOffset, BLOCK_LENGTH, SCHEMA_VERSION); return decoder.appendTo(builder); } }