Class VespaXMLFeedReader

  • All Implemented Interfaces:
    FeedReader

    public class VespaXMLFeedReader
    extends VespaXMLReader
    implements FeedReader
    XML parser for Vespa document XML. Parses an entire document "feed", which consists of a vespafeed element containing zero or more instances of documents, updates or removes. Standard usage is to create an Operation object and call read(Operation) until operation.getType() returns OperationType.INVALID. If you are looking to parse only a single document or update, use VespaXMLDocumentReader or VespaXMLUpdateReader respectively.
    • Constructor Detail

      • VespaXMLFeedReader

        public VespaXMLFeedReader​(java.lang.String fileName,
                                  DocumentTypeManager docTypeManager)
                           throws java.lang.Exception
        Creates a reader that reads from the given file.
        Throws:
        java.lang.Exception
      • VespaXMLFeedReader

        public VespaXMLFeedReader​(java.io.InputStream stream,
                                  DocumentTypeManager docTypeManager)
                           throws java.lang.Exception
        Creates a reader that reads from the given stream.
        Throws:
        java.lang.Exception
      • VespaXMLFeedReader

        public VespaXMLFeedReader​(javax.xml.stream.XMLStreamReader reader,
                                  DocumentTypeManager manager)
                           throws java.lang.Exception
        Creates a reader that uses the given reader to read - this can be used if the vespa feed is part of a larger XML document.
        Throws:
        java.lang.Exception
    • Method Detail

      • readAll

        public java.util.List<FeedOperation> readAll()
                                              throws java.lang.Exception

        Reads all operations from the XML stream and puts into a list. Note that if the XML stream is large, this may cause out of memory errors, so make sure to use this only with small streams.

        Returns:
        The list of all read operations.
        Throws:
        java.lang.Exception
      • read

        public FeedOperation read()
                           throws java.lang.Exception
        Description copied from interface: FeedReader
        Reads the next operation from the stream.
        Specified by:
        read in interface FeedReader
        Returns:
        operation, possibly invalid if none was found.
        Throws:
        java.lang.Exception