public int size()

in proton-j/src/main/java/org/apache/qpid/proton/codec/impl/ArrayElement.java [82:146]


    public int size()
    {
        ConstructorType oldConstructorType;
        int bodySize;
        int count = 0;
        do
        {
            bodySize = 1; // data type constructor
            oldConstructorType = _constructorType;
            Element element = _first;
            while(element != null)
            {
                count++;
                bodySize += element.size();
                element = element.next();
            }
        }
        while (oldConstructorType != constructorType());

        if(isDescribed())
        {
            bodySize++; // 00 instruction
            if(count != 0)
            {
                count--;
            }
        }

        if(isElementOfArray())
        {
            ArrayElement parent = (ArrayElement)parent();
            if(parent.constructorType()==SMALL)
            {
                if(count<=255 && bodySize<=254)
                {
                    bodySize+=2;
                }
                else
                {
                    parent.setConstructorType(LARGE);
                    bodySize+=8;
                }
            }
            else
            {
                bodySize+=8;
            }
        }
        else
        {

            if(count<=255 && bodySize<=254)
            {
                bodySize+=3;
            }
            else
            {
                bodySize+=9;
            }

        }


        return bodySize;
    }