|
1 | 1 | /*
|
2 |
| - * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved. |
| 2 | + * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved. |
3 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
4 | 4 | *
|
5 | 5 | * This code is free software; you can redistribute it and/or modify it
|
|
33 | 33 | import javax.xml.stream.XMLStreamWriter;
|
34 | 34 |
|
35 | 35 | import com.sun.xml.internal.bind.marshaller.CharacterEscapeHandler;
|
| 36 | +import com.sun.xml.internal.bind.marshaller.NoEscapeHandler; |
36 | 37 | import com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl;
|
37 | 38 | import com.sun.xml.internal.bind.v2.runtime.XMLSerializer;
|
38 | 39 |
|
@@ -71,7 +72,7 @@ public static XmlOutput create(XMLStreamWriter out, JAXBContextImpl context, Cha
|
71 | 72 | }
|
72 | 73 |
|
73 | 74 | CharacterEscapeHandler xmlStreamEscapeHandler = escapeHandler != null ?
|
74 |
| - escapeHandler : NewLineEscapeHandler.theInstance; |
| 75 | + escapeHandler : NoEscapeHandler.theInstance; |
75 | 76 |
|
76 | 77 | // otherwise the normal writer.
|
77 | 78 | return new XMLStreamWriterOutput(out, xmlStreamEscapeHandler);
|
@@ -217,45 +218,6 @@ private static Constructor<? extends XmlOutput> initStAXExOutputClass() {
|
217 | 218 | }
|
218 | 219 | }
|
219 | 220 |
|
220 |
| - |
221 |
| - /** |
222 |
| - * Performs character escaping only for new lines. |
223 |
| - */ |
224 |
| - private static class NewLineEscapeHandler implements CharacterEscapeHandler { |
225 |
| - |
226 |
| - public static final NewLineEscapeHandler theInstance = new NewLineEscapeHandler(); |
227 |
| - |
228 |
| - @Override |
229 |
| - public void escape(char[] ch, int start, int length, boolean isAttVal, Writer out) throws IOException { |
230 |
| - int limit = start+length; |
231 |
| - int lastEscaped = start; |
232 |
| - |
233 |
| - for (int i = start; i < limit; i++) { |
234 |
| - char c = ch[i]; |
235 |
| - if (c == '\r' || c == '\n') { |
236 |
| - if (i != lastEscaped) { |
237 |
| - out.write(ch, lastEscaped, i - lastEscaped); |
238 |
| - } |
239 |
| - lastEscaped = i + 1; |
240 |
| - if (out instanceof XmlStreamOutWriterAdapter) { |
241 |
| - try { |
242 |
| - ((XmlStreamOutWriterAdapter)out).writeEntityRef("#x" + Integer.toHexString(c)); |
243 |
| - } catch (XMLStreamException e) { |
244 |
| - throw new IOException("Error writing xml stream", e); |
245 |
| - } |
246 |
| - } else { |
247 |
| - out.write("&#x"); |
248 |
| - out.write(Integer.toHexString(c)); |
249 |
| - out.write(';'); |
250 |
| - } |
251 |
| - } |
252 |
| - } |
253 |
| - if (lastEscaped != limit) { |
254 |
| - out.write(ch, lastEscaped, length - lastEscaped); |
255 |
| - } |
256 |
| - } |
257 |
| - } |
258 |
| - |
259 | 221 | private static final class XmlStreamOutWriterAdapter extends Writer {
|
260 | 222 |
|
261 | 223 | private final XMLStreamWriter writer;
|
|
0 commit comments