All Downloads are FREE. Search and download functionalities are using the official Maven repository.

b3.entrypoint.fixp.sbe.AllocationInstructionEncoder Maven / Gradle / Ivy

/* Generated SBE (Simple Binary Encoding) message codec. */
package b3.entrypoint.fixp.sbe;

import org.agrona.MutableDirectBuffer;
import org.agrona.DirectBuffer;
import org.agrona.sbe.*;


/**
 * AllocationInstruction message submits a blocking position mechanism. The blocking specification functionality has been developed to provide the ability to the system, whenever necessary, to prevent the assignment of an options contract position.
 */
@SuppressWarnings("all")
public final class AllocationInstructionEncoder implements MessageEncoderFlyweight
{
    public static final int BLOCK_LENGTH = 45;
    public static final int TEMPLATE_ID = 601;
    public static final int SCHEMA_ID = 1;
    public static final int SCHEMA_VERSION = 5;
    public static final String SEMANTIC_VERSION = "5.6";
    public static final java.nio.ByteOrder BYTE_ORDER = java.nio.ByteOrder.LITTLE_ENDIAN;

    private final AllocationInstructionEncoder parentMessage = this;
    private MutableDirectBuffer buffer;
    private int offset;
    private 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 offset()
    {
        return offset;
    }

    public AllocationInstructionEncoder wrap(final MutableDirectBuffer buffer, final int offset)
    {
        if (buffer != this.buffer)
        {
            this.buffer = buffer;
        }
        this.offset = offset;
        limit(offset + BLOCK_LENGTH);

        return this;
    }

    public AllocationInstructionEncoder 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 messageTypeId()
    {
        return 35;
    }

    public static int messageTypeSinceVersion()
    {
        return 0;
    }

    public static int messageTypeEncodingOffset()
    {
        return 0;
    }

    public static int messageTypeEncodingLength()
    {
        return 1;
    }

    public static String messageTypeMetaAttribute(final MetaAttribute metaAttribute)
    {
        if (MetaAttribute.PRESENCE == metaAttribute)
        {
            return "constant";
        }

        return "";
    }

    public static int allocIDId()
    {
        return 70;
    }

    public static int allocIDSinceVersion()
    {
        return 0;
    }

    public static int allocIDEncodingOffset()
    {
        return 0;
    }

    public static int allocIDEncodingLength()
    {
        return 8;
    }

    public static String allocIDMetaAttribute(final MetaAttribute metaAttribute)
    {
        if (MetaAttribute.PRESENCE == metaAttribute)
        {
            return "required";
        }

        return "";
    }

    public static long allocIDNullValue()
    {
        return 0xffffffffffffffffL;
    }

    public static long allocIDMinValue()
    {
        return 0x0L;
    }

    public static long allocIDMaxValue()
    {
        return 0xfffffffffffffffeL;
    }

    public AllocationInstructionEncoder allocID(final long value)
    {
        buffer.putLong(offset + 0, value, BYTE_ORDER);
        return this;
    }


    public static int securityIDId()
    {
        return 48;
    }

    public static int securityIDSinceVersion()
    {
        return 0;
    }

    public static int securityIDEncodingOffset()
    {
        return 8;
    }

    public static int securityIDEncodingLength()
    {
        return 8;
    }

    public static String securityIDMetaAttribute(final MetaAttribute metaAttribute)
    {
        if (MetaAttribute.PRESENCE == metaAttribute)
        {
            return "required";
        }

        return "";
    }

    public static long securityIDNullValue()
    {
        return 0xffffffffffffffffL;
    }

    public static long securityIDMinValue()
    {
        return 0x0L;
    }

    public static long securityIDMaxValue()
    {
        return 0xfffffffffffffffeL;
    }

    public AllocationInstructionEncoder securityID(final long value)
    {
        buffer.putLong(offset + 8, value, BYTE_ORDER);
        return this;
    }


    public static int securityIDSourceId()
    {
        return 22;
    }

    public static int securityIDSourceSinceVersion()
    {
        return 0;
    }

    public static int securityIDSourceEncodingOffset()
    {
        return 16;
    }

    public static int securityIDSourceEncodingLength()
    {
        return 0;
    }

    public static String securityIDSourceMetaAttribute(final MetaAttribute metaAttribute)
    {
        if (MetaAttribute.PRESENCE == metaAttribute)
        {
            return "constant";
        }

        return "";
    }

    public static byte securityIDSourceNullValue()
    {
        return (byte)0;
    }

    public static byte securityIDSourceMinValue()
    {
        return (byte)32;
    }

    public static byte securityIDSourceMaxValue()
    {
        return (byte)126;
    }


    private static final byte[] SECURITYIDSOURCE_VALUE = { 56 };

    public static int securityIDSourceLength()
    {
        return 1;
    }


    public byte securityIDSource(final int index)
    {
        return SECURITYIDSOURCE_VALUE[index];
    }

    public int getSecurityIDSource(final byte[] dst, final int offset, final int length)
    {
        final int bytesCopied = Math.min(length, 1);
        System.arraycopy(SECURITYIDSOURCE_VALUE, 0, dst, offset, bytesCopied);

        return bytesCopied;
    }

    public byte securityIDSource()
    {
        return (byte)56;
    }


    public static int securityExchangeId()
    {
        return 207;
    }

    public static int securityExchangeSinceVersion()
    {
        return 0;
    }

    public static int securityExchangeEncodingOffset()
    {
        return 16;
    }

    public static int securityExchangeEncodingLength()
    {
        return 0;
    }

    public static String securityExchangeMetaAttribute(final MetaAttribute metaAttribute)
    {
        if (MetaAttribute.PRESENCE == metaAttribute)
        {
            return "constant";
        }

        return "";
    }

    public static byte securityExchangeNullValue()
    {
        return (byte)0;
    }

    public static byte securityExchangeMinValue()
    {
        return (byte)32;
    }

    public static byte securityExchangeMaxValue()
    {
        return (byte)126;
    }


    private static final byte[] SECURITYEXCHANGE_VALUE = { 66, 86, 77, 70 };

    public static int securityExchangeLength()
    {
        return 4;
    }


    public byte securityExchange(final int index)
    {
        return SECURITYEXCHANGE_VALUE[index];
    }

    public int getSecurityExchange(final byte[] dst, final int offset, final int length)
    {
        final int bytesCopied = Math.min(length, 4);
        System.arraycopy(SECURITYEXCHANGE_VALUE, 0, dst, offset, bytesCopied);

        return bytesCopied;
    }

    public String securityExchange()
    {
        return "BVMF";
    }


    public static int quantityId()
    {
        return 53;
    }

    public static int quantitySinceVersion()
    {
        return 0;
    }

    public static int quantityEncodingOffset()
    {
        return 16;
    }

    public static int quantityEncodingLength()
    {
        return 8;
    }

    public static String quantityMetaAttribute(final MetaAttribute metaAttribute)
    {
        if (MetaAttribute.PRESENCE == metaAttribute)
        {
            return "required";
        }

        return "";
    }

    public static long quantityNullValue()
    {
        return 0xffffffffffffffffL;
    }

    public static long quantityMinValue()
    {
        return 0x0L;
    }

    public static long quantityMaxValue()
    {
        return 0xfffffffffffffffeL;
    }

    public AllocationInstructionEncoder quantity(final long value)
    {
        buffer.putLong(offset + 16, value, BYTE_ORDER);
        return this;
    }


    public static int senderLocationId()
    {
        return 35503;
    }

    public static int senderLocationSinceVersion()
    {
        return 0;
    }

    public static int senderLocationEncodingOffset()
    {
        return 24;
    }

    public static int senderLocationEncodingLength()
    {
        return 10;
    }

    public static String senderLocationMetaAttribute(final MetaAttribute metaAttribute)
    {
        if (MetaAttribute.PRESENCE == metaAttribute)
        {
            return "required";
        }

        return "";
    }

    public static byte senderLocationNullValue()
    {
        return (byte)0;
    }

    public static byte senderLocationMinValue()
    {
        return (byte)32;
    }

    public static byte senderLocationMaxValue()
    {
        return (byte)126;
    }

    public static int senderLocationLength()
    {
        return 10;
    }


    public AllocationInstructionEncoder senderLocation(final int index, final byte value)
    {
        if (index < 0 || index >= 10)
        {
            throw new IndexOutOfBoundsException("index out of range: index=" + index);
        }

        final int pos = offset + 24 + (index * 1);
        buffer.putByte(pos, value);

        return this;
    }

    public static String senderLocationCharacterEncoding()
    {
        return java.nio.charset.StandardCharsets.US_ASCII.name();
    }

    public AllocationInstructionEncoder putSenderLocation(final byte[] src, final int srcOffset)
    {
        final int length = 10;
        if (srcOffset < 0 || srcOffset > (src.length - length))
        {
            throw new IndexOutOfBoundsException("Copy will go out of range: offset=" + srcOffset);
        }

        buffer.putBytes(offset + 24, src, srcOffset, length);

        return this;
    }

    public AllocationInstructionEncoder senderLocation(final String src)
    {
        final int length = 10;
        final int srcLength = null == src ? 0 : src.length();
        if (srcLength > length)
        {
            throw new IndexOutOfBoundsException("String too large for copy: byte length=" + srcLength);
        }

        buffer.putStringWithoutLengthAscii(offset + 24, src);

        for (int start = srcLength; start < length; ++start)
        {
            buffer.putByte(offset + 24 + start, (byte)0);
        }

        return this;
    }

    public AllocationInstructionEncoder senderLocation(final CharSequence src)
    {
        final int length = 10;
        final int srcLength = null == src ? 0 : src.length();
        if (srcLength > length)
        {
            throw new IndexOutOfBoundsException("CharSequence too large for copy: byte length=" + srcLength);
        }

        buffer.putStringWithoutLengthAscii(offset + 24, src);

        for (int start = srcLength; start < length; ++start)
        {
            buffer.putByte(offset + 24 + start, (byte)0);
        }

        return this;
    }

    public static int enteringTraderId()
    {
        return 35502;
    }

    public static int enteringTraderSinceVersion()
    {
        return 0;
    }

    public static int enteringTraderEncodingOffset()
    {
        return 34;
    }

    public static int enteringTraderEncodingLength()
    {
        return 5;
    }

    public static String enteringTraderMetaAttribute(final MetaAttribute metaAttribute)
    {
        if (MetaAttribute.PRESENCE == metaAttribute)
        {
            return "required";
        }

        return "";
    }

    public static byte enteringTraderNullValue()
    {
        return (byte)0;
    }

    public static byte enteringTraderMinValue()
    {
        return (byte)32;
    }

    public static byte enteringTraderMaxValue()
    {
        return (byte)126;
    }

    public static int enteringTraderLength()
    {
        return 5;
    }


    public AllocationInstructionEncoder enteringTrader(final int index, final byte value)
    {
        if (index < 0 || index >= 5)
        {
            throw new IndexOutOfBoundsException("index out of range: index=" + index);
        }

        final int pos = offset + 34 + (index * 1);
        buffer.putByte(pos, value);

        return this;
    }

    public static String enteringTraderCharacterEncoding()
    {
        return java.nio.charset.StandardCharsets.US_ASCII.name();
    }

    public AllocationInstructionEncoder putEnteringTrader(final byte[] src, final int srcOffset)
    {
        final int length = 5;
        if (srcOffset < 0 || srcOffset > (src.length - length))
        {
            throw new IndexOutOfBoundsException("Copy will go out of range: offset=" + srcOffset);
        }

        buffer.putBytes(offset + 34, src, srcOffset, length);

        return this;
    }

    public AllocationInstructionEncoder enteringTrader(final String src)
    {
        final int length = 5;
        final int srcLength = null == src ? 0 : src.length();
        if (srcLength > length)
        {
            throw new IndexOutOfBoundsException("String too large for copy: byte length=" + srcLength);
        }

        buffer.putStringWithoutLengthAscii(offset + 34, src);

        for (int start = srcLength; start < length; ++start)
        {
            buffer.putByte(offset + 34 + start, (byte)0);
        }

        return this;
    }

    public AllocationInstructionEncoder enteringTrader(final CharSequence src)
    {
        final int length = 5;
        final int srcLength = null == src ? 0 : src.length();
        if (srcLength > length)
        {
            throw new IndexOutOfBoundsException("CharSequence too large for copy: byte length=" + srcLength);
        }

        buffer.putStringWithoutLengthAscii(offset + 34, src);

        for (int start = srcLength; start < length; ++start)
        {
            buffer.putByte(offset + 34 + start, (byte)0);
        }

        return this;
    }

    public static int tradeDateId()
    {
        return 75;
    }

    public static int tradeDateSinceVersion()
    {
        return 0;
    }

    public static int tradeDateEncodingOffset()
    {
        return 39;
    }

    public static int tradeDateEncodingLength()
    {
        return 2;
    }

    public static String tradeDateMetaAttribute(final MetaAttribute metaAttribute)
    {
        if (MetaAttribute.PRESENCE == metaAttribute)
        {
            return "optional";
        }

        return "";
    }

    public static int tradeDateNullValue()
    {
        return 0;
    }

    public static int tradeDateMinValue()
    {
        return 0;
    }

    public static int tradeDateMaxValue()
    {
        return 65534;
    }

    public AllocationInstructionEncoder tradeDate(final int value)
    {
        buffer.putShort(offset + 39, (short)value, BYTE_ORDER);
        return this;
    }


    public static int allocTransTypeId()
    {
        return 71;
    }

    public static int allocTransTypeSinceVersion()
    {
        return 0;
    }

    public static int allocTransTypeEncodingOffset()
    {
        return 41;
    }

    public static int allocTransTypeEncodingLength()
    {
        return 1;
    }

    public static String allocTransTypeMetaAttribute(final MetaAttribute metaAttribute)
    {
        if (MetaAttribute.PRESENCE == metaAttribute)
        {
            return "required";
        }

        return "";
    }

    public AllocationInstructionEncoder allocTransType(final AllocTransType value)
    {
        buffer.putByte(offset + 41, value.value());
        return this;
    }

    public static int allocTypeId()
    {
        return 626;
    }

    public static int allocTypeSinceVersion()
    {
        return 0;
    }

    public static int allocTypeEncodingOffset()
    {
        return 42;
    }

    public static int allocTypeEncodingLength()
    {
        return 1;
    }

    public static String allocTypeMetaAttribute(final MetaAttribute metaAttribute)
    {
        if (MetaAttribute.PRESENCE == metaAttribute)
        {
            return "required";
        }

        return "";
    }

    public AllocationInstructionEncoder allocType(final AllocType value)
    {
        buffer.putByte(offset + 42, value.value());
        return this;
    }

    public static int allocNoOrdersTypeId()
    {
        return 857;
    }

    public static int allocNoOrdersTypeSinceVersion()
    {
        return 0;
    }

    public static int allocNoOrdersTypeEncodingOffset()
    {
        return 43;
    }

    public static int allocNoOrdersTypeEncodingLength()
    {
        return 1;
    }

    public static String allocNoOrdersTypeMetaAttribute(final MetaAttribute metaAttribute)
    {
        if (MetaAttribute.PRESENCE == metaAttribute)
        {
            return "required";
        }

        return "";
    }

    public AllocationInstructionEncoder allocNoOrdersType(final AllocNoOrdersType value)
    {
        buffer.putByte(offset + 43, value.value());
        return this;
    }

    public static int sideId()
    {
        return 54;
    }

    public static int sideSinceVersion()
    {
        return 0;
    }

    public static int sideEncodingOffset()
    {
        return 44;
    }

    public static int sideEncodingLength()
    {
        return 1;
    }

    public static String sideMetaAttribute(final MetaAttribute metaAttribute)
    {
        if (MetaAttribute.PRESENCE == metaAttribute)
        {
            return "required";
        }

        return "";
    }

    public AllocationInstructionEncoder side(final Side value)
    {
        buffer.putByte(offset + 44, value.value());
        return this;
    }

    private final NoExecsEncoder noExecs = new NoExecsEncoder(this);

    public static long noExecsId()
    {
        return 124;
    }

    public NoExecsEncoder noExecsCount(final int count)
    {
        noExecs.wrap(buffer, count);
        return noExecs;
    }

    public static final class NoExecsEncoder
    {
        public static final int HEADER_SIZE = 3;
        private final AllocationInstructionEncoder parentMessage;
        private MutableDirectBuffer buffer;
        private int count;
        private int index;
        private int offset;
        private int initialLimit;

        NoExecsEncoder(final AllocationInstructionEncoder parentMessage)
        {
            this.parentMessage = parentMessage;
        }

        public void wrap(final MutableDirectBuffer buffer, final int count)
        {
            if (count < 0 || count > 254)
            {
                throw new IllegalArgumentException("count outside allowed range: count=" + count);
            }

            if (buffer != this.buffer)
            {
                this.buffer = buffer;
            }

            index = 0;
            this.count = count;
            final int limit = parentMessage.limit();
            initialLimit = limit;
            parentMessage.limit(limit + HEADER_SIZE);
            buffer.putShort(limit + 0, (short)4, BYTE_ORDER);
            buffer.putByte(limit + 2, (byte)count);
        }

        public NoExecsEncoder next()
        {
            if (index >= count)
            {
                throw new java.util.NoSuchElementException();
            }

            offset = parentMessage.limit();
            parentMessage.limit(offset + sbeBlockLength());
            ++index;

            return this;
        }

        public int resetCountToIndex()
        {
            count = index;
            buffer.putByte(initialLimit + 2, (byte)count);

            return count;
        }

        public static short countMinValue()
        {
            return (short)0;
        }

        public static short countMaxValue()
        {
            return (short)254;
        }

        public static int sbeHeaderSize()
        {
            return HEADER_SIZE;
        }

        public static int sbeBlockLength()
        {
            return 4;
        }

        public static int tradeIDId()
        {
            return 1003;
        }

        public static int tradeIDSinceVersion()
        {
            return 0;
        }

        public static int tradeIDEncodingOffset()
        {
            return 0;
        }

        public static int tradeIDEncodingLength()
        {
            return 4;
        }

        public static String tradeIDMetaAttribute(final MetaAttribute metaAttribute)
        {
            if (MetaAttribute.PRESENCE == metaAttribute)
            {
                return "optional";
            }

            return "";
        }

        public static long tradeIDNullValue()
        {
            return 0L;
        }

        public static long tradeIDMinValue()
        {
            return 0L;
        }

        public static long tradeIDMaxValue()
        {
            return 4294967294L;
        }

        public NoExecsEncoder tradeID(final long value)
        {
            buffer.putInt(offset + 0, (int)value, BYTE_ORDER);
            return this;
        }

    }

    private final NoAllocsEncoder noAllocs = new NoAllocsEncoder(this);

    public static long noAllocsId()
    {
        return 78;
    }

    public NoAllocsEncoder noAllocsCount(final int count)
    {
        noAllocs.wrap(buffer, count);
        return noAllocs;
    }

    public static final class NoAllocsEncoder
    {
        public static final int HEADER_SIZE = 3;
        private final AllocationInstructionEncoder parentMessage;
        private MutableDirectBuffer buffer;
        private int count;
        private int index;
        private int offset;
        private int initialLimit;

        NoAllocsEncoder(final AllocationInstructionEncoder parentMessage)
        {
            this.parentMessage = parentMessage;
        }

        public void wrap(final MutableDirectBuffer buffer, final int count)
        {
            if (count < 0 || count > 254)
            {
                throw new IllegalArgumentException("count outside allowed range: count=" + count);
            }

            if (buffer != this.buffer)
            {
                this.buffer = buffer;
            }

            index = 0;
            this.count = count;
            final int limit = parentMessage.limit();
            initialLimit = limit;
            parentMessage.limit(limit + HEADER_SIZE);
            buffer.putShort(limit + 0, (short)20, BYTE_ORDER);
            buffer.putByte(limit + 2, (byte)count);
        }

        public NoAllocsEncoder next()
        {
            if (index >= count)
            {
                throw new java.util.NoSuchElementException();
            }

            offset = parentMessage.limit();
            parentMessage.limit(offset + sbeBlockLength());
            ++index;

            return this;
        }

        public int resetCountToIndex()
        {
            count = index;
            buffer.putByte(initialLimit + 2, (byte)count);

            return count;
        }

        public static short countMinValue()
        {
            return (short)0;
        }

        public static short countMaxValue()
        {
            return (short)254;
        }

        public static int sbeHeaderSize()
        {
            return HEADER_SIZE;
        }

        public static int sbeBlockLength()
        {
            return 20;
        }

        public static int individualAllocIDId()
        {
            return 467;
        }

        public static int individualAllocIDSinceVersion()
        {
            return 0;
        }

        public static int individualAllocIDEncodingOffset()
        {
            return 0;
        }

        public static int individualAllocIDEncodingLength()
        {
            return 8;
        }

        public static String individualAllocIDMetaAttribute(final MetaAttribute metaAttribute)
        {
            if (MetaAttribute.PRESENCE == metaAttribute)
            {
                return "required";
            }

            return "";
        }

        public static long individualAllocIDNullValue()
        {
            return 0xffffffffffffffffL;
        }

        public static long individualAllocIDMinValue()
        {
            return 0x0L;
        }

        public static long individualAllocIDMaxValue()
        {
            return 0xfffffffffffffffeL;
        }

        public NoAllocsEncoder individualAllocID(final long value)
        {
            buffer.putLong(offset + 0, value, BYTE_ORDER);
            return this;
        }


        public static int allocAccountId()
        {
            return 79;
        }

        public static int allocAccountSinceVersion()
        {
            return 0;
        }

        public static int allocAccountEncodingOffset()
        {
            return 8;
        }

        public static int allocAccountEncodingLength()
        {
            return 4;
        }

        public static String allocAccountMetaAttribute(final MetaAttribute metaAttribute)
        {
            if (MetaAttribute.PRESENCE == metaAttribute)
            {
                return "optional";
            }

            return "";
        }

        public static long allocAccountNullValue()
        {
            return 0L;
        }

        public static long allocAccountMinValue()
        {
            return 0L;
        }

        public static long allocAccountMaxValue()
        {
            return 4294967294L;
        }

        public NoAllocsEncoder allocAccount(final long value)
        {
            buffer.putInt(offset + 8, (int)value, BYTE_ORDER);
            return this;
        }


        public static int allocQtyId()
        {
            return 80;
        }

        public static int allocQtySinceVersion()
        {
            return 0;
        }

        public static int allocQtyEncodingOffset()
        {
            return 12;
        }

        public static int allocQtyEncodingLength()
        {
            return 8;
        }

        public static String allocQtyMetaAttribute(final MetaAttribute metaAttribute)
        {
            if (MetaAttribute.PRESENCE == metaAttribute)
            {
                return "required";
            }

            return "";
        }

        public static long allocQtyNullValue()
        {
            return 0xffffffffffffffffL;
        }

        public static long allocQtyMinValue()
        {
            return 0x0L;
        }

        public static long allocQtyMaxValue()
        {
            return 0xfffffffffffffffeL;
        }

        public NoAllocsEncoder allocQty(final long value)
        {
            buffer.putLong(offset + 12, value, BYTE_ORDER);
            return this;
        }

    }

    public static int deskIDId()
    {
        return 35510;
    }

    public static String deskIDCharacterEncoding()
    {
        return java.nio.charset.StandardCharsets.US_ASCII.name();
    }

    public static String deskIDMetaAttribute(final MetaAttribute metaAttribute)
    {
        if (MetaAttribute.PRESENCE == metaAttribute)
        {
            return "required";
        }
        if (MetaAttribute.SEMANTIC_TYPE == metaAttribute)
        {
            return "String";
        }

        return "";
    }

    public static int deskIDHeaderLength()
    {
        return 1;
    }

    public AllocationInstructionEncoder putDeskID(final DirectBuffer src, final int srcOffset, final int length)
    {
        if (length > 20)
        {
            throw new IllegalStateException("length > maxValue for type: " + length);
        }

        final int headerLength = 1;
        final int limit = parentMessage.limit();
        parentMessage.limit(limit + headerLength + length);
        buffer.putByte(limit, (byte)length);
        buffer.putBytes(limit + headerLength, src, srcOffset, length);

        return this;
    }

    public AllocationInstructionEncoder putDeskID(final byte[] src, final int srcOffset, final int length)
    {
        if (length > 20)
        {
            throw new IllegalStateException("length > maxValue for type: " + length);
        }

        final int headerLength = 1;
        final int limit = parentMessage.limit();
        parentMessage.limit(limit + headerLength + length);
        buffer.putByte(limit, (byte)length);
        buffer.putBytes(limit + headerLength, src, srcOffset, length);

        return this;
    }

    public AllocationInstructionEncoder deskID(final String value)
    {
        final int length = null == value ? 0 : value.length();
        if (length > 20)
        {
            throw new IllegalStateException("length > maxValue for type: " + length);
        }

        final int headerLength = 1;
        final int limit = parentMessage.limit();
        parentMessage.limit(limit + headerLength + length);
        buffer.putByte(limit, (byte)length);
        buffer.putStringWithoutLengthAscii(limit + headerLength, value);

        return this;
    }

    public AllocationInstructionEncoder deskID(final CharSequence value)
    {
        final int length = null == value ? 0 : value.length();
        if (length > 20)
        {
            throw new IllegalStateException("length > maxValue for type: " + length);
        }

        final int headerLength = 1;
        final int limit = parentMessage.limit();
        parentMessage.limit(limit + headerLength + length);
        buffer.putByte(limit, (byte)length);
        buffer.putStringWithoutLengthAscii(limit + headerLength, value);

        return this;
    }

    public static int memoId()
    {
        return 5149;
    }

    public static String memoCharacterEncoding()
    {
        return java.nio.charset.StandardCharsets.UTF_8.name();
    }

    public static String memoMetaAttribute(final MetaAttribute metaAttribute)
    {
        if (MetaAttribute.PRESENCE == metaAttribute)
        {
            return "required";
        }
        if (MetaAttribute.SEMANTIC_TYPE == metaAttribute)
        {
            return "String";
        }

        return "";
    }

    public static int memoHeaderLength()
    {
        return 1;
    }

    public AllocationInstructionEncoder putMemo(final DirectBuffer src, final int srcOffset, final int length)
    {
        if (length > 40)
        {
            throw new IllegalStateException("length > maxValue for type: " + length);
        }

        final int headerLength = 1;
        final int limit = parentMessage.limit();
        parentMessage.limit(limit + headerLength + length);
        buffer.putByte(limit, (byte)length);
        buffer.putBytes(limit + headerLength, src, srcOffset, length);

        return this;
    }

    public AllocationInstructionEncoder putMemo(final byte[] src, final int srcOffset, final int length)
    {
        if (length > 40)
        {
            throw new IllegalStateException("length > maxValue for type: " + length);
        }

        final int headerLength = 1;
        final int limit = parentMessage.limit();
        parentMessage.limit(limit + headerLength + length);
        buffer.putByte(limit, (byte)length);
        buffer.putBytes(limit + headerLength, src, srcOffset, length);

        return this;
    }

    public AllocationInstructionEncoder memo(final String value)
    {
        final byte[] bytes = (null == value || value.isEmpty()) ? org.agrona.collections.ArrayUtil.EMPTY_BYTE_ARRAY : value.getBytes(java.nio.charset.StandardCharsets.UTF_8);

        final int length = bytes.length;
        if (length > 40)
        {
            throw new IllegalStateException("length > maxValue for type: " + length);
        }

        final int headerLength = 1;
        final int limit = parentMessage.limit();
        parentMessage.limit(limit + headerLength + length);
        buffer.putByte(limit, (byte)length);
        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 AllocationInstructionDecoder decoder = new AllocationInstructionDecoder();
        decoder.wrap(buffer, offset, BLOCK_LENGTH, SCHEMA_VERSION);

        return decoder.appendTo(builder);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy