1 package org.codehaus.plexus.util.xml;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 import java.io.IOException;
20 import java.io.InputStream;
21 import java.io.Reader;
22
23 import org.codehaus.plexus.util.xml.pull.XmlPullParser;
24 import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
25
26
27
28
29 public class Xpp3DomBuilder {
30 private static final boolean DEFAULT_TRIM = true;
31
32 public static Xpp3Dom build(Reader reader) throws XmlPullParserException, IOException {
33 return build(reader, null);
34 }
35
36
37
38
39 public static Xpp3Dom build(Reader reader, InputLocationBuilder locationBuilder)
40 throws XmlPullParserException, IOException {
41 return build(reader, DEFAULT_TRIM, locationBuilder);
42 }
43
44 public static Xpp3Dom build(InputStream is, String encoding) throws XmlPullParserException, IOException {
45 return build(is, encoding, DEFAULT_TRIM);
46 }
47
48 public static Xpp3Dom build(InputStream is, String encoding, boolean trim)
49 throws XmlPullParserException, IOException {
50 try (InputStream closeMe = is) {
51 return new Xpp3Dom(XmlNodePullBuilder.build(is, encoding, trim));
52 }
53 }
54
55 public static Xpp3Dom build(Reader reader, boolean trim) throws XmlPullParserException, IOException {
56 return build(reader, trim, null);
57 }
58
59
60
61
62 public static Xpp3Dom build(Reader reader, boolean trim, InputLocationBuilder locationBuilder)
63 throws XmlPullParserException, IOException {
64 try (Reader closeMe = reader) {
65 return new Xpp3Dom(XmlNodePullBuilder.build(reader, trim, locationBuilder));
66 }
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(XmlNodePullBuilder.build(parser, trim, locationBuilder));
83 }
84
85
86
87
88
89
90 public interface InputLocationBuilder {
91 Object toInputLocation(XmlPullParser parser);
92 }
93 }