src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/output/XMLStreamWriterOutput.java

changeset 1667
e716ed4b0efb
parent 1609
09b083e0759c
child 1620
6df7b161ae4a
     1.1 --- a/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/output/XMLStreamWriterOutput.java	Tue Apr 03 17:09:13 2018 -0700
     1.2 +++ b/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/output/XMLStreamWriterOutput.java	Mon Apr 23 13:24:44 2018 +0100
     1.3 @@ -1,5 +1,5 @@
     1.4  /*
     1.5 - * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
     1.6 + * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
     1.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.8   *
     1.9   * This code is free software; you can redistribute it and/or modify it
    1.10 @@ -33,6 +33,7 @@
    1.11  import javax.xml.stream.XMLStreamWriter;
    1.12  
    1.13  import com.sun.xml.internal.bind.marshaller.CharacterEscapeHandler;
    1.14 +import com.sun.xml.internal.bind.marshaller.NoEscapeHandler;
    1.15  import com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl;
    1.16  import com.sun.xml.internal.bind.v2.runtime.XMLSerializer;
    1.17  
    1.18 @@ -71,7 +72,7 @@
    1.19          }
    1.20  
    1.21          CharacterEscapeHandler xmlStreamEscapeHandler = escapeHandler != null ?
    1.22 -                escapeHandler : NewLineEscapeHandler.theInstance;
    1.23 +                escapeHandler : NoEscapeHandler.theInstance;
    1.24  
    1.25          // otherwise the normal writer.
    1.26          return new XMLStreamWriterOutput(out, xmlStreamEscapeHandler);
    1.27 @@ -217,45 +218,6 @@
    1.28          }
    1.29      }
    1.30  
    1.31 -
    1.32 -    /**
    1.33 -     * Performs character escaping only for new lines.
    1.34 -     */
    1.35 -    private static class NewLineEscapeHandler implements CharacterEscapeHandler {
    1.36 -
    1.37 -        public static final NewLineEscapeHandler theInstance = new NewLineEscapeHandler();
    1.38 -
    1.39 -        @Override
    1.40 -        public void escape(char[] ch, int start, int length, boolean isAttVal, Writer out) throws IOException {
    1.41 -            int limit = start+length;
    1.42 -            int lastEscaped = start;
    1.43 -
    1.44 -            for (int i = start; i < limit; i++) {
    1.45 -                char c = ch[i];
    1.46 -                if (c == '\r' || c == '\n') {
    1.47 -                    if (i != lastEscaped) {
    1.48 -                        out.write(ch, lastEscaped, i - lastEscaped);
    1.49 -                    }
    1.50 -                    lastEscaped = i + 1;
    1.51 -                    if (out instanceof XmlStreamOutWriterAdapter) {
    1.52 -                        try {
    1.53 -                            ((XmlStreamOutWriterAdapter)out).writeEntityRef("#x" + Integer.toHexString(c));
    1.54 -                        } catch (XMLStreamException e) {
    1.55 -                            throw new IOException("Error writing xml stream", e);
    1.56 -                        }
    1.57 -                    } else {
    1.58 -                        out.write("&#x");
    1.59 -                        out.write(Integer.toHexString(c));
    1.60 -                        out.write(';');
    1.61 -                    }
    1.62 -                }
    1.63 -            }
    1.64 -            if (lastEscaped != limit) {
    1.65 -                out.write(ch, lastEscaped, length - lastEscaped);
    1.66 -            }
    1.67 -        }
    1.68 -    }
    1.69 -
    1.70      private static final class XmlStreamOutWriterAdapter extends Writer {
    1.71  
    1.72          private final XMLStreamWriter writer;

mercurial