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

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

There is a newer version: 0.157
Show newest version
/* Generated SBE (Simple Binary Encoding) message codec. */
package b3.entrypoint.fixp.sbe;

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


/**
 * The SecurityDefinitionRequest message creates a User Defined Spread (UDS) instrument. User-Defined Spreads provide users of the electronic trading platform the ability to create strategies composed by their choice of leg instruments, leg ratio and leg side.
 */
@SuppressWarnings("all")
public final class SecurityDefinitionRequestDecoder implements MessageDecoderFlyweight
{
    public static final int BLOCK_LENGTH = 14;
    public static final int TEMPLATE_ID = 300;
    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 SecurityDefinitionRequestDecoder parentMessage = this;
    private DirectBuffer buffer;
    private int offset;
    private int limit;
    int actingBlockLength;
    int actingVersion;

    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 DirectBuffer buffer()
    {
        return buffer;
    }

    public int offset()
    {
        return offset;
    }

    public SecurityDefinitionRequestDecoder wrap(
        final DirectBuffer buffer,
        final int offset,
        final int actingBlockLength,
        final int actingVersion)
    {
        if (buffer != this.buffer)
        {
            this.buffer = buffer;
        }
        this.offset = offset;
        this.actingBlockLength = actingBlockLength;
        this.actingVersion = actingVersion;
        limit(offset + actingBlockLength);

        return this;
    }

    public SecurityDefinitionRequestDecoder wrapAndApplyHeader(
        final DirectBuffer buffer,
        final int offset,
        final MessageHeaderDecoder headerDecoder)
    {
        headerDecoder.wrap(buffer, offset);

        final int templateId = headerDecoder.templateId();
        if (TEMPLATE_ID != templateId)
        {
            throw new IllegalStateException("Invalid TEMPLATE_ID: " + templateId);
        }

        return wrap(
            buffer,
            offset + MessageHeaderDecoder.ENCODED_LENGTH,
            headerDecoder.blockLength(),
            headerDecoder.version());
    }

    public SecurityDefinitionRequestDecoder sbeRewind()
    {
        return wrap(buffer, offset, actingBlockLength, actingVersion);
    }

    public int sbeDecodedLength()
    {
        final int currentLimit = limit();
        sbeSkip();
        final int decodedLength = encodedLength();
        limit(currentLimit);

        return decodedLength;
    }

    public int actingVersion()
    {
        return actingVersion;
    }

    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 short messageTypeRaw()
    {
        return MessageType.SecurityDefinitionRequest.value();
    }


    public MessageType messageType()
    {
        return MessageType.SecurityDefinitionRequest;
    }


    public static int securityReqIDId()
    {
        return 320;
    }

    public static int securityReqIDSinceVersion()
    {
        return 0;
    }

    public static int securityReqIDEncodingOffset()
    {
        return 0;
    }

    public static int securityReqIDEncodingLength()
    {
        return 8;
    }

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

        return "";
    }

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

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

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

    public long securityReqID()
    {
        return buffer.getLong(offset + 0, BYTE_ORDER);
    }


    public static int enteringTraderId()
    {
        return 35502;
    }

    public static int enteringTraderSinceVersion()
    {
        return 0;
    }

    public static int enteringTraderEncodingOffset()
    {
        return 8;
    }

    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 byte enteringTrader(final int index)
    {
        if (index < 0 || index >= 5)
        {
            throw new IndexOutOfBoundsException("index out of range: index=" + index);
        }

        final int pos = offset + 8 + (index * 1);

        return buffer.getByte(pos);
    }


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

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

        buffer.getBytes(offset + 8, dst, dstOffset, length);

        return length;
    }

    public String enteringTrader()
    {
        final byte[] dst = new byte[5];
        buffer.getBytes(offset + 8, dst, 0, 5);

        int end = 0;
        for (; end < 5 && dst[end] != 0; ++end);

        return new String(dst, 0, end, java.nio.charset.StandardCharsets.US_ASCII);
    }


    public int getEnteringTrader(final Appendable value)
    {
        for (int i = 0; i < 5; ++i)
        {
            final int c = buffer.getByte(offset + 8 + i) & 0xFF;
            if (c == 0)
            {
                return i;
            }

            try
            {
                value.append(c > 127 ? '?' : (char)c);
            }
            catch (final java.io.IOException ex)
            {
                throw new java.io.UncheckedIOException(ex);
            }
        }

        return 5;
    }


    public static int marketSegmentIDId()
    {
        return 1300;
    }

    public static int marketSegmentIDSinceVersion()
    {
        return 0;
    }

    public static int marketSegmentIDEncodingOffset()
    {
        return 13;
    }

    public static int marketSegmentIDEncodingLength()
    {
        return 1;
    }

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

        return "";
    }

    public static short marketSegmentIDNullValue()
    {
        return (short)255;
    }

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

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

    public short marketSegmentID()
    {
        return ((short)(buffer.getByte(offset + 13) & 0xFF));
    }


    private final NoLegsDecoder noLegs = new NoLegsDecoder(this);

    public static long noLegsDecoderId()
    {
        return 555;
    }

    public static int noLegsDecoderSinceVersion()
    {
        return 0;
    }

    public NoLegsDecoder noLegs()
    {
        noLegs.wrap(buffer);
        return noLegs;
    }

    public static final class NoLegsDecoder
        implements Iterable, java.util.Iterator
    {
        public static final int HEADER_SIZE = 3;
        private final SecurityDefinitionRequestDecoder parentMessage;
        private DirectBuffer buffer;
        private int count;
        private int index;
        private int offset;
        private int blockLength;

        NoLegsDecoder(final SecurityDefinitionRequestDecoder parentMessage)
        {
            this.parentMessage = parentMessage;
        }

        public void wrap(final DirectBuffer buffer)
        {
            if (buffer != this.buffer)
            {
                this.buffer = buffer;
            }

            index = 0;
            final int limit = parentMessage.limit();
            parentMessage.limit(limit + HEADER_SIZE);
            blockLength = (buffer.getShort(limit + 0, BYTE_ORDER) & 0xFFFF);
            count = ((short)(buffer.getByte(limit + 2) & 0xFF));
        }

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

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

            return this;
        }

        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 17;
        }

        public int actingBlockLength()
        {
            return blockLength;
        }

        public int actingVersion()
        {
            return parentMessage.actingVersion;
        }

        public int count()
        {
            return count;
        }

        public java.util.Iterator iterator()
        {
            return this;
        }

        public void remove()
        {
            throw new UnsupportedOperationException();
        }

        public boolean hasNext()
        {
            return index < count;
        }

        public static int legSecurityIDId()
        {
            return 602;
        }

        public static int legSecurityIDSinceVersion()
        {
            return 0;
        }

        public static int legSecurityIDEncodingOffset()
        {
            return 0;
        }

        public static int legSecurityIDEncodingLength()
        {
            return 8;
        }

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

            return "";
        }

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

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

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

        public long legSecurityID()
        {
            return buffer.getLong(offset + 0, BYTE_ORDER);
        }


        public static int legSecurityIDSourceId()
        {
            return 603;
        }

        public static int legSecurityIDSourceSinceVersion()
        {
            return 0;
        }

        public static int legSecurityIDSourceEncodingOffset()
        {
            return 8;
        }

        public static int legSecurityIDSourceEncodingLength()
        {
            return 0;
        }

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

            return "";
        }

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

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

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


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

        public static int legSecurityIDSourceLength()
        {
            return 1;
        }


        public byte legSecurityIDSource(final int index)
        {
            return LEGSECURITYIDSOURCE_VALUE[index];
        }

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

            return bytesCopied;
        }

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


        public static int legSecurityExchangeId()
        {
            return 616;
        }

        public static int legSecurityExchangeSinceVersion()
        {
            return 0;
        }

        public static int legSecurityExchangeEncodingOffset()
        {
            return 8;
        }

        public static int legSecurityExchangeEncodingLength()
        {
            return 0;
        }

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

            return "";
        }

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

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

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


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

        public static int legSecurityExchangeLength()
        {
            return 4;
        }


        public byte legSecurityExchange(final int index)
        {
            return LEGSECURITYEXCHANGE_VALUE[index];
        }

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

            return bytesCopied;
        }

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


        public static int legRatioQtyId()
        {
            return 623;
        }

        public static int legRatioQtySinceVersion()
        {
            return 0;
        }

        public static int legRatioQtyEncodingOffset()
        {
            return 8;
        }

        public static int legRatioQtyEncodingLength()
        {
            return 8;
        }

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

            return "";
        }

        private final RatioQtyDecoder legRatioQty = new RatioQtyDecoder();

        /**
         * The ratio of quantity for this individual leg relative to the entire multileg security.
         *
         * @return RatioQtyDecoder : The ratio of quantity for this individual leg relative to the entire multileg security.
         */
        public RatioQtyDecoder legRatioQty()
        {
            legRatioQty.wrap(buffer, offset + 8);
            return legRatioQty;
        }

        public static int legSideId()
        {
            return 624;
        }

        public static int legSideSinceVersion()
        {
            return 0;
        }

        public static int legSideEncodingOffset()
        {
            return 16;
        }

        public static int legSideEncodingLength()
        {
            return 1;
        }

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

            return "";
        }

        public byte legSideRaw()
        {
            return buffer.getByte(offset + 16);
        }

        public Side legSide()
        {
            return Side.get(buffer.getByte(offset + 16));
        }


        public StringBuilder appendTo(final StringBuilder builder)
        {
            if (null == buffer)
            {
                return builder;
            }

            builder.append('(');
            builder.append("legSecurityID=");
            builder.append(this.legSecurityID());
            builder.append('|');
            builder.append("legRatioQty=");
            final RatioQtyDecoder legRatioQty = this.legRatioQty();
            if (null != legRatioQty)
            {
                legRatioQty.appendTo(builder);
            }
            else
            {
                builder.append("null");
            }
            builder.append('|');
            builder.append("legSide=");
            builder.append(this.legSide());
            builder.append(')');

            return builder;
        }
        
        public NoLegsDecoder sbeSkip()
        {

            return this;
        }
    }

    public String toString()
    {
        if (null == buffer)
        {
            return "";
        }

        final SecurityDefinitionRequestDecoder decoder = new SecurityDefinitionRequestDecoder();
        decoder.wrap(buffer, offset, actingBlockLength, actingVersion);

        return decoder.appendTo(new StringBuilder()).toString();
    }

    public StringBuilder appendTo(final StringBuilder builder)
    {
        if (null == buffer)
        {
            return builder;
        }

        final int originalLimit = limit();
        limit(offset + actingBlockLength);
        builder.append("[SecurityDefinitionRequest](sbeTemplateId=");
        builder.append(TEMPLATE_ID);
        builder.append("|sbeSchemaId=");
        builder.append(SCHEMA_ID);
        builder.append("|sbeSchemaVersion=");
        if (parentMessage.actingVersion != SCHEMA_VERSION)
        {
            builder.append(parentMessage.actingVersion);
            builder.append('/');
        }
        builder.append(SCHEMA_VERSION);
        builder.append("|sbeBlockLength=");
        if (actingBlockLength != BLOCK_LENGTH)
        {
            builder.append(actingBlockLength);
            builder.append('/');
        }
        builder.append(BLOCK_LENGTH);
        builder.append("):");
        builder.append("messageType=");
        builder.append(this.messageType());
        builder.append('|');
        builder.append("securityReqID=");
        builder.append(this.securityReqID());
        builder.append('|');
        builder.append("enteringTrader=");
        for (int i = 0; i < enteringTraderLength() && this.enteringTrader(i) > 0; i++)
        {
            builder.append((char)this.enteringTrader(i));
        }
        builder.append('|');
        builder.append("marketSegmentID=");
        builder.append(this.marketSegmentID());
        builder.append('|');
        builder.append("noLegs=[");
        final int noLegsOriginalOffset = noLegs.offset;
        final int noLegsOriginalIndex = noLegs.index;
        final NoLegsDecoder noLegs = this.noLegs();
        if (noLegs.count() > 0)
        {
            while (noLegs.hasNext())
            {
                noLegs.next().appendTo(builder);
                builder.append(',');
            }
            builder.setLength(builder.length() - 1);
        }
        noLegs.offset = noLegsOriginalOffset;
        noLegs.index = noLegsOriginalIndex;
        builder.append(']');

        limit(originalLimit);

        return builder;
    }
    
    public SecurityDefinitionRequestDecoder sbeSkip()
    {
        sbeRewind();
        NoLegsDecoder noLegs = this.noLegs();
        if (noLegs.count() > 0)
        {
            while (noLegs.hasNext())
            {
                noLegs.next();
                noLegs.sbeSkip();
            }
        }

        return this;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy