Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openjdk-multiarch-jdk8u
Path: blob/aarch64-shenandoah-jdk8u272-b10/jaxp/src/com/sun/xml/internal/stream/events/StartDocumentEvent.java
86414 views
1
/*
2
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
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
7
* published by the Free Software Foundation. Oracle designates this
8
* particular file as subject to the "Classpath" exception as provided
9
* by Oracle in the LICENSE file that accompanied this code.
10
*
11
* This code is distributed in the hope that it will be useful, but WITHOUT
12
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14
* version 2 for more details (a copy is included in the LICENSE file that
15
* accompanied this code).
16
*
17
* You should have received a copy of the GNU General Public License version
18
* 2 along with this work; if not, write to the Free Software Foundation,
19
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20
*
21
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22
* or visit www.oracle.com if you need additional information or have any
23
* questions.
24
*/
25
26
package com.sun.xml.internal.stream.events ;
27
28
import javax.xml.stream.events.StartDocument;
29
import javax.xml.stream.Location;
30
import javax.xml.stream.XMLStreamConstants;
31
32
/** Implementation of StartDocumentEvent.
33
*
34
* @author Neeraj Bajaj Sun Microsystems,Inc.
35
* @author K.Venugopal Sun Microsystems,Inc.
36
*
37
*/
38
39
public class StartDocumentEvent extends DummyEvent
40
implements StartDocument {
41
42
protected String fSystemId;
43
protected String fEncodingScheam;
44
protected boolean fStandalone;
45
protected String fVersion;
46
private boolean fEncodingSchemeSet = false;
47
private boolean fStandaloneSet = false;
48
private boolean nestedCall = false;
49
50
public StartDocumentEvent() {
51
init("UTF-8","1.0",true,null);
52
}
53
54
public StartDocumentEvent(String encoding){
55
init(encoding,"1.0",true,null);
56
}
57
58
public StartDocumentEvent(String encoding, String version){
59
init(encoding,version,true,null);
60
}
61
62
public StartDocumentEvent(String encoding, String version, boolean standalone){
63
this.fStandaloneSet = true;
64
init(encoding,version,standalone,null);
65
}
66
67
public StartDocumentEvent(String encoding, String version, boolean standalone,Location loc){
68
this.fStandaloneSet = true;
69
init(encoding, version, standalone, loc);
70
}
71
protected void init(String encoding, String version, boolean standalone,Location loc) {
72
setEventType(XMLStreamConstants.START_DOCUMENT);
73
this.fEncodingScheam = encoding;
74
this.fVersion = version;
75
this.fStandalone = standalone;
76
if (encoding != null && !encoding.equals(""))
77
this.fEncodingSchemeSet = true;
78
else {
79
this.fEncodingSchemeSet = false;
80
this.fEncodingScheam = "UTF-8";
81
}
82
this.fLocation = loc;
83
}
84
85
public String getSystemId() {
86
if(fLocation == null )
87
return "";
88
else
89
return fLocation.getSystemId();
90
}
91
92
93
public String getCharacterEncodingScheme() {
94
return fEncodingScheam;
95
}
96
97
public boolean isStandalone() {
98
return fStandalone;
99
}
100
101
public String getVersion() {
102
return fVersion;
103
}
104
105
public void setStandalone(boolean flag) {
106
fStandaloneSet = true;
107
fStandalone = flag;
108
}
109
110
public void setStandalone(String s) {
111
fStandaloneSet = true;
112
if(s == null) {
113
fStandalone = true;
114
return;
115
}
116
if(s.equals("yes"))
117
fStandalone = true;
118
else
119
fStandalone = false;
120
}
121
122
public boolean encodingSet() {
123
return fEncodingSchemeSet;
124
}
125
126
public boolean standaloneSet() {
127
return fStandaloneSet;
128
}
129
130
public void setEncoding(String encoding) {
131
fEncodingScheam = encoding;
132
}
133
134
void setDeclaredEncoding(boolean value){
135
fEncodingSchemeSet = value;
136
}
137
138
public void setVersion(String s) {
139
fVersion = s;
140
}
141
142
void clear() {
143
fEncodingScheam = "UTF-8";
144
fStandalone = true;
145
fVersion = "1.0";
146
fEncodingSchemeSet = false;
147
fStandaloneSet = false;
148
}
149
150
public String toString() {
151
String s = "<?xml version=\"" + fVersion + "\"";
152
s = s + " encoding='" + fEncodingScheam + "'";
153
if(fStandaloneSet) {
154
if(fStandalone)
155
s = s + " standalone='yes'?>";
156
else
157
s = s + " standalone='no'?>";
158
} else {
159
s = s + "?>";
160
}
161
return s;
162
}
163
164
public boolean isStartDocument() {
165
return true;
166
}
167
168
protected void writeAsEncodedUnicodeEx(java.io.Writer writer)
169
throws java.io.IOException
170
{
171
writer.write(toString());
172
}
173
}
174
175