src/java.xml/share/classes/com/sun/xml/internal/stream/writers/XMLEventWriterImpl.java
equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
49 * |
49 * |
50 */ |
50 */ |
51 public class XMLEventWriterImpl implements XMLEventWriter { |
51 public class XMLEventWriterImpl implements XMLEventWriter { |
52 |
52 |
53 //delegate everything to XMLStreamWriter.. |
53 //delegate everything to XMLStreamWriter.. |
54 private final XMLStreamWriterBase fStreamWriter; |
54 private final XMLStreamWriter fStreamWriter; |
55 private static final boolean DEBUG = false; |
55 private static final boolean DEBUG = false; |
56 |
56 |
57 /** |
57 /** |
58 * |
58 * Constructs an XMLEventWriterImpl that implements the standard XMLStreamWriter |
|
59 * interface. |
59 * @param streamWriter |
60 * @param streamWriter |
60 */ |
61 */ |
61 public XMLEventWriterImpl(XMLStreamWriter streamWriter) { |
62 public XMLEventWriterImpl(XMLStreamWriter streamWriter) { |
62 fStreamWriter = (XMLStreamWriterBase) streamWriter; |
63 fStreamWriter = streamWriter; |
63 } |
64 } |
64 |
65 |
65 /** |
66 /** |
66 * |
67 * |
67 * @param xMLEventReader |
68 * @param xMLEventReader |
96 StartDocument startDocument = (StartDocument) xMLEvent; |
97 StartDocument startDocument = (StartDocument) xMLEvent; |
97 if (DEBUG) { |
98 if (DEBUG) { |
98 System.out.println("Adding StartDocument = " + startDocument.toString()); |
99 System.out.println("Adding StartDocument = " + startDocument.toString()); |
99 } |
100 } |
100 try { |
101 try { |
101 fStreamWriter.writeStartDocument(startDocument.getCharacterEncodingScheme(), |
102 if (XMLStreamWriterBase.class.isAssignableFrom(fStreamWriter.getClass())) { |
102 startDocument.getVersion(), |
103 // internal impl uses the extended interface |
103 startDocument.isStandalone(), startDocument.standaloneSet()); |
104 ((XMLStreamWriterBase)fStreamWriter).writeStartDocument( |
|
105 startDocument.getCharacterEncodingScheme(), |
|
106 startDocument.getVersion(), |
|
107 startDocument.isStandalone(), |
|
108 startDocument.standaloneSet()); |
|
109 } else { |
|
110 fStreamWriter.writeStartDocument( |
|
111 startDocument.getCharacterEncodingScheme(), |
|
112 startDocument.getVersion()); |
|
113 } |
104 } catch (XMLStreamException e) { |
114 } catch (XMLStreamException e) { |
105 fStreamWriter.writeStartDocument(startDocument.getVersion()); |
115 fStreamWriter.writeStartDocument(startDocument.getVersion()); |
106 } |
116 } |
107 break; |
117 break; |
108 } |
118 } |