Ejemplo n.º 1
0
        /**
         * Writes the ptgs to the data buffer, starting at the specified offset.
         *
         * <br/>
         * The 2 byte encode Length field is <b>not</b> written by this method.
         * @return number of bytes written
         */
        public static int SerializePtgs(Ptg[] ptgs, byte[] array, int offset)
        {
            int size = ptgs.Length;

            LittleEndianByteArrayOutputStream out1 = new LittleEndianByteArrayOutputStream(array, offset);

            ArrayList arrayPtgs = null;

            for (int k = 0; k < size; k++)
            {
                Ptg ptg = ptgs[k];

                ptg.Write(out1);
                if (ptg is ArrayPtg)
                {
                    if (arrayPtgs == null)
                    {
                        arrayPtgs = new ArrayList(5);
                    }
                    arrayPtgs.Add(ptg);
                }
            }
            if (arrayPtgs != null)
            {
                for (int i = 0; i < arrayPtgs.Count; i++)
                {
                    ArrayPtg p = (ArrayPtg)arrayPtgs[i];
                    p.WriteTokenValueBytes(out1);
                }
            }
            return(out1.WriteIndex - offset);;
        }
Ejemplo n.º 2
0
        public override Object Clone()
        {
            ArrayPtg ptg = (ArrayPtg)base.Clone();

            ptg.field_1_reserved    = (byte[])field_1_reserved.Clone();
            ptg.token_3_arrayValues = (Object[])token_3_arrayValues.Clone();
            return(ptg);
        }
Ejemplo n.º 3
0
        /**
         * Reads <tt>size</tt> bytes of the input stream, to Create an array of <tt>Ptg</tt>s.
         * Extra data (beyond <tt>size</tt>) may be Read if and <tt>ArrayPtg</tt>s are present.
         */
        public static Ptg[] ReadTokens(int size, LittleEndianInput in1)
        {
            ArrayList temp      = new ArrayList(4 + size / 2);
            int       pos       = 0;
            ArrayList arrayPtgs = null;

            while (pos < size)
            {
                Ptg ptg = Ptg.CreatePtg(in1);
                if (ptg is ArrayPtg)
                {
                    if (arrayPtgs == null)
                    {
                        arrayPtgs = new ArrayList(5);
                    }
                    arrayPtgs.Add(ptg);
                    pos += ArrayPtg.PLAIN_TOKEN_SIZE;
                }
                else
                {
                    pos += ptg.Size;
                }
                temp.Add(ptg);
            }
            if (pos != size)
            {
                throw new Exception("Ptg array size mismatch");
            }
            if (arrayPtgs != null)
            {
                for (int i = 0; i < arrayPtgs.Count; i++)
                {
                    ArrayPtg p = (ArrayPtg)arrayPtgs[i];
                    p.ReadTokenValues(in1);
                }
            }
            return(ToPtgArray(temp));
        }