1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.codehaus.plexus.util.xml;
20
21 import java.io.IOException;
22 import java.io.InputStream;
23 import java.io.Reader;
24
25 import org.apache.maven.internal.xml.XmlNodeBuilder;
26 import org.codehaus.plexus.util.xml.pull.XmlPullParser;
27 import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
28
29
30
31
32 public class Xpp3DomBuilder {
33 private static final boolean DEFAULT_TRIM = true;
34
35 public static Xpp3Dom build(Reader reader) throws XmlPullParserException, IOException {
36 return build(reader, null);
37 }
38
39
40
41
42 public static Xpp3Dom build(Reader reader, InputLocationBuilder locationBuilder)
43 throws XmlPullParserException, IOException {
44 return build(reader, DEFAULT_TRIM, locationBuilder);
45 }
46
47 public static Xpp3Dom build(InputStream is, String encoding) throws XmlPullParserException, IOException {
48 return build(is, encoding, DEFAULT_TRIM);
49 }
50
51 public static Xpp3Dom build(InputStream is, String encoding, boolean trim)
52 throws XmlPullParserException, IOException {
53 return new Xpp3Dom(XmlNodeBuilder.build(is, encoding, trim));
54 }
55
56 public static Xpp3Dom build(Reader reader, boolean trim) throws XmlPullParserException, IOException {
57 return build(reader, trim, null);
58 }
59
60
61
62
63 public static Xpp3Dom build(Reader reader, boolean trim, InputLocationBuilder locationBuilder)
64 throws XmlPullParserException, IOException {
65 return new Xpp3Dom(
66 XmlNodeBuilder.build(reader, trim, locationBuilder != null ? locationBuilder::toInputLocation : null));
67 }
68
69 public static Xpp3Dom build(XmlPullParser parser) throws XmlPullParserException, IOException {
70 return build(parser, DEFAULT_TRIM);
71 }
72
73 public static Xpp3Dom build(XmlPullParser parser, boolean trim) throws XmlPullParserException, IOException {
74 return build(parser, trim, null);
75 }
76
77
78
79
80 public static Xpp3Dom build(XmlPullParser parser, boolean trim, InputLocationBuilder locationBuilder)
81 throws XmlPullParserException, IOException {
82 return new Xpp3Dom(
83 XmlNodeBuilder.build(parser, trim, locationBuilder != null ? locationBuilder::toInputLocation : null));
84 }
85
86
87
88
89
90
91 public interface InputLocationBuilder {
92 Object toInputLocation(XmlPullParser parser);
93 }
94 }