1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.internal.xml;
20
21 import javax.xml.stream.XMLInputFactory;
22 import javax.xml.stream.XMLStreamException;
23 import javax.xml.stream.XMLStreamReader;
24
25 import java.io.InputStream;
26 import java.io.Reader;
27
28 import org.apache.maven.api.xml.XmlNode;
29 import org.apache.maven.api.xml.XmlService;
30
31
32
33
34
35
36
37 @Deprecated
38 public class XmlNodeStaxBuilder {
39 private static final boolean DEFAULT_TRIM = true;
40
41 public static XmlNode build(InputStream stream, InputLocationBuilderStax locationBuilder)
42 throws XMLStreamException {
43 XMLStreamReader parser = XMLInputFactory.newFactory().createXMLStreamReader(stream);
44 return build(parser, DEFAULT_TRIM, locationBuilder);
45 }
46
47 public static XmlNode build(Reader reader, InputLocationBuilderStax locationBuilder) throws XMLStreamException {
48 XMLStreamReader parser = XMLInputFactory.newFactory().createXMLStreamReader(reader);
49 return build(parser, DEFAULT_TRIM, locationBuilder);
50 }
51
52 public static XmlNode build(XMLStreamReader parser) throws XMLStreamException {
53 return build(parser, DEFAULT_TRIM, null);
54 }
55
56 public static XmlNode build(XMLStreamReader parser, InputLocationBuilderStax locationBuilder)
57 throws XMLStreamException {
58 return build(parser, DEFAULT_TRIM, locationBuilder);
59 }
60
61 public static XmlNode build(XMLStreamReader parser, boolean trim, InputLocationBuilderStax locationBuilder)
62 throws XMLStreamException {
63 return XmlService.read(parser, locationBuilder != null ? locationBuilder::toInputLocation : null);
64 }
65
66 @Deprecated
67 public interface InputLocationBuilderStax {
68 Object toInputLocation(XMLStreamReader parser);
69 }
70 }