blob: a5ea5983e29f449e7e552e5493e999d484437b7c (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespaxmlparser;
import com.yahoo.document.Document;
import com.yahoo.document.DocumentTypeManager;
import com.yahoo.document.serialization.DocumentReader;
import javax.xml.stream.XMLStreamReader;
import java.io.InputStream;
/**
* XML parser that reads Vespa documents from an XML stream.
*
* @author thomasg
*/
public class VespaXMLDocumentReader extends VespaXMLFieldReader implements DocumentReader {
/**
* Creates a reader that reads from the given file.
*/
public VespaXMLDocumentReader(String fileName, DocumentTypeManager docTypeManager) throws Exception {
super(fileName, docTypeManager);
}
/**
* Creates a reader that reads from the given stream.
*/
public VespaXMLDocumentReader(InputStream stream, DocumentTypeManager docTypeManager) throws Exception {
super(stream, docTypeManager);
}
/**
* Creates a reader that reads using the given reader. This is useful if the document is part of a greater
* XML stream.
*/
public VespaXMLDocumentReader(XMLStreamReader reader, DocumentTypeManager docTypeManager) {
super(reader, docTypeManager);
}
/**
* Reads one document from the stream. Function assumes that the current element in the stream is
* the start tag for the document.
*
* @param document the document to be read
*/
public void read(Document document) {
read(null, document);
}
}
|