@Override
        public void writeTo(Output output, Object message) throws IOException
        {
            final Object[] array = (Object[])message;
            final int len = array.length;

            output.writeInt32(ID_ARRAY_LEN, len, false);

            int nullCount = 0;
            for (int i = 0; i < len; i++)
            {
                Object v = array[i];
                if (v != null)
                {
                    if (nullCount != 0)
                    {
                        output.writeUInt32(ID_ARRAY_NULLCOUNT, nullCount, false);
                        nullCount = 0;
                    }

                    output.writeObject(ID_ARRAY_DATA, v, hs.getSchema(), true);
                }
                else if (allowNullArrayElement)
                {
                    nullCount++;
                }
            }

            // if last element is null
            if (nullCount != 0)
                output.writeUInt32(ID_ARRAY_NULLCOUNT, nullCount, false);
        }
Built-in array schemas.

@author David Yu
@created Dec 4, 2012
protostuff-runtime/src/main/java/io/protostuff/runtime/ArraySchemas.java