|
1 | 1 | /* |
2 | 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
3 | 3 | * |
4 | | - * Copyright (c) 1997-2017 Oracle and/or its affiliates. All rights reserved. |
| 4 | + * Copyright (c) 1997-2018 Oracle and/or its affiliates. All rights reserved. |
5 | 5 | * |
6 | 6 | * The contents of this file are subject to the terms of either the GNU |
7 | 7 | * General Public License Version 2 only ("GPL") or the Common Development |
|
48 | 48 | import javax.xml.stream.XMLStreamWriter; |
49 | 49 |
|
50 | 50 | import com.sun.xml.bind.marshaller.CharacterEscapeHandler; |
| 51 | +import com.sun.xml.bind.marshaller.NoEscapeHandler; |
51 | 52 | import com.sun.xml.bind.v2.runtime.JAXBContextImpl; |
52 | 53 | import com.sun.xml.bind.v2.runtime.XMLSerializer; |
53 | 54 |
|
@@ -86,7 +87,7 @@ public static XmlOutput create(XMLStreamWriter out, JAXBContextImpl context, Cha |
86 | 87 | } |
87 | 88 |
|
88 | 89 | CharacterEscapeHandler xmlStreamEscapeHandler = escapeHandler != null ? |
89 | | - escapeHandler : NewLineEscapeHandler.theInstance; |
| 90 | + escapeHandler : NoEscapeHandler.theInstance; |
90 | 91 |
|
91 | 92 | // otherwise the normal writer. |
92 | 93 | return new XMLStreamWriterOutput(out, xmlStreamEscapeHandler); |
@@ -232,44 +233,6 @@ private static Constructor<? extends XmlOutput> initStAXExOutputClass() { |
232 | 233 | } |
233 | 234 | } |
234 | 235 |
|
235 | | - /** |
236 | | - * Performs character escaping only for new lines. |
237 | | - */ |
238 | | - private static class NewLineEscapeHandler implements CharacterEscapeHandler { |
239 | | - |
240 | | - public static final NewLineEscapeHandler theInstance = new NewLineEscapeHandler(); |
241 | | - |
242 | | - @Override |
243 | | - public void escape(char[] ch, int start, int length, boolean isAttVal, Writer out) throws IOException { |
244 | | - int limit = start+length; |
245 | | - int lastEscaped = start; |
246 | | - for (int i = start; i < limit; i++) { |
247 | | - char c = ch[i]; |
248 | | - if (c == '\r' || c == '\n') { |
249 | | - if (i != lastEscaped) { |
250 | | - out.write(ch, lastEscaped, i - lastEscaped); |
251 | | - } |
252 | | - lastEscaped = i + 1; |
253 | | - if (out instanceof XmlStreamOutWriterAdapter) { |
254 | | - try { |
255 | | - ((XmlStreamOutWriterAdapter)out).writeEntityRef("#x" + Integer.toHexString(c)); |
256 | | - } catch (XMLStreamException e) { |
257 | | - throw new IOException("Error writing xml stream", e); |
258 | | - } |
259 | | - } else { |
260 | | - out.write("&#x"); |
261 | | - out.write(Integer.toHexString(c)); |
262 | | - out.write(';'); |
263 | | - } |
264 | | - } |
265 | | - } |
266 | | - |
267 | | - if (lastEscaped != limit) { |
268 | | - out.write(ch, lastEscaped, length - lastEscaped); |
269 | | - } |
270 | | - } |
271 | | - } |
272 | | - |
273 | 236 | private static final class XmlStreamOutWriterAdapter extends Writer { |
274 | 237 |
|
275 | 238 | private final XMLStreamWriter writer; |
|
0 commit comments