4040 * @author Kristian Rosenvold
4141 */
4242public class Xpp3DomBuilder {
43- private static final boolean DEFAULT_TRIM = true ;
4443
4544 /**
4645 * @param reader {@link Reader}
4746 * @return the built DOM
4847 * @throws XmlPullParserException in case of an error
4948 */
5049 public static Xpp3Dom build (@ WillClose @ Nonnull Reader reader ) throws XmlPullParserException {
51- return build (reader , DEFAULT_TRIM );
50+ return build (reader , false );
5251 }
5352
5453 /**
@@ -58,45 +57,49 @@ public static Xpp3Dom build(@WillClose @Nonnull Reader reader) throws XmlPullPar
5857 * @throws XmlPullParserException in case of an error
5958 */
6059 public static Xpp3Dom build (@ WillClose InputStream is , @ Nonnull String encoding ) throws XmlPullParserException {
61- return build (is , encoding , DEFAULT_TRIM );
60+ return build (is , encoding , false );
6261 }
6362
6463 /**
6564 * @param is {@link InputStream}
6665 * @param encoding the encoding
67- * @param trim true/false
66+ * @param noop vestigial argument with no effect
6867 * @return the built DOM
6968 * @throws XmlPullParserException in case of an error
69+ * @deprecated use the two-arg variant
7070 */
71- public static Xpp3Dom build (@ WillClose InputStream is , @ Nonnull String encoding , boolean trim )
71+ @ Deprecated
72+ public static Xpp3Dom build (@ WillClose InputStream is , @ Nonnull String encoding , boolean noop )
7273 throws XmlPullParserException {
7374 try {
7475 Reader reader = new InputStreamReader (is , encoding );
75- return build (reader , trim );
76+ return build (reader );
7677 } catch (UnsupportedEncodingException e ) {
7778 throw new XmlPullParserException (e );
7879 }
7980 }
8081
8182 /**
8283 * @param in {@link Reader}
83- * @param trim true/false
84+ * @param noop vestigial argument with no effect
8485 * @return the built DOM
8586 * @throws XmlPullParserException in case of an error
87+ * @deprecated use {#build(java.io.Reader)}
8688 */
87- public static Xpp3Dom build (@ WillClose Reader in , boolean trim ) throws XmlPullParserException {
89+ @ Deprecated
90+ public static Xpp3Dom build (@ WillClose Reader in , boolean noop ) throws XmlPullParserException {
8891 try (Reader reader = in ) {
89- DocHandler docHandler = parseSax (new InputSource (reader ), trim );
92+ DocHandler docHandler = parseSax (new InputSource (reader ));
9093 reader .close ();
9194 return docHandler .result ;
9295 } catch (final IOException e ) {
9396 throw new XmlPullParserException (e );
9497 }
9598 }
9699
97- private static DocHandler parseSax (@ Nonnull InputSource inputSource , boolean trim ) throws XmlPullParserException {
100+ private static DocHandler parseSax (@ Nonnull InputSource inputSource ) throws XmlPullParserException {
98101 try {
99- DocHandler ch = new DocHandler (trim );
102+ DocHandler ch = new DocHandler ();
100103 XMLReader parser = createXmlReader ();
101104 parser .setContentHandler (ch );
102105 parser .parse (inputSource );
@@ -147,14 +150,8 @@ private static class DocHandler extends DefaultHandler {
147150
148151 Xpp3Dom result = null ;
149152
150- private final boolean trim ;
151-
152153 private boolean spacePreserve = false ;
153154
154- DocHandler (boolean trim ) {
155- this .trim = trim ;
156- }
157-
158155 @ Override
159156 public void startElement (String uri , String localName , String qName , Attributes attributes )
160157 throws SAXException {
@@ -216,7 +213,7 @@ public void endElement(String uri, String localName, String qName) throws SAXExc
216213 @ Override
217214 public void characters (char [] ch , int start , int length ) throws SAXException {
218215 String text = new String (ch , start , length );
219- appendToTopValue (( trim && ! spacePreserve ) ? text . trim () : text );
216+ appendToTopValue (text );
220217 }
221218
222219 private void appendToTopValue (String toAppend ) {
0 commit comments