public static <T> List<T> parseListFrom(XMLStreamReader parser, Schema<T> schema)
            throws IOException, XMLStreamException
    {
        if (parser.nextTag() != START_ELEMENT || !"list".equals(parser.getLocalName()))
            throw new XmlInputException("Expected token START_ELEMENT: list");

        // final String simpleName = schema.messageName();
        final ArrayList<T> list = new ArrayList<T>();
        final XmlInput input = new XmlInput(parser);

        for (int tag = parser.nextTag(); tag != END_ELEMENT; tag = parser.nextTag())
        {
            if (tag != START_ELEMENT || !schema.messageName().equals(parser.getLocalName()))
                throw new XmlInputException("Expected token START_ELEMENT: " + schema.messageName());

            final T message = schema.newMessage();

            if (parser.nextTag() == END_ELEMENT)
            {
                // if(!simpleName.equals(parser.getLocalName()))
                // throw new XmlInputException("Expecting token END_ELEMENT: " + simpleName);

                // empty message
                list.add(message);
                continue;
            }

            schema.mergeFrom(input, message);

            // if(!simpleName.equals(parser.getLocalName()))
            // throw new XmlInputException("Expecting token END_ELEMENT: " + simpleName);

            list.add(message);
        }

        return list;
    }
public static < T > List < T > parseListFrom ( XMLStreamReader parser , Schema < T > schema ) throws IOException , XMLStreamException { if ( parser . nextTag ( ) != START_ELEMENT || ! "list" . equals ( parser . getLocalName ( ) ) ) throw new XmlInputException ( "Expected token START_ELEMENT: list" ) ; final ArrayList < T > list = new ArrayList < T > ( ) ; final XmlInput input = new XmlInput ( parser ) ; for ( int tag = parser . nextTag ( ) ; tag != END_ELEMENT ; tag = parser . nextTag ( ) ) { if ( tag != START_ELEMENT || ! schema . messageName ( ) . equals ( parser . getLocalName ( ) ) ) throw new XmlInputException ( "Expected token START_ELEMENT: " + schema . messageName ( ) ) ; final T message = schema . newMessage ( ) ; if ( parser . nextTag ( ) == END_ELEMENT ) { list . add ( message ) ; continue ; } schema . mergeFrom ( input , message ) ; list . add ( message ) ; } return list ; }
Parses the {@code messages} from the {@link XMLStreamReader} using the given {@code schema}.