1:
37:
38: package ;
39:
40: import ;
41: import ;
42: import ;
43: import ;
44: import ;
45:
46:
51: public class StartDocumentImpl
52: extends XMLEventImpl
53: implements StartDocument
54: {
55:
56: protected final String systemId;
57: protected final String encoding;
58: protected final String xmlVersion;
59: protected final boolean xmlStandalone;
60: protected final boolean standaloneDeclared;
61: protected final boolean encodingDeclared;
62:
63: protected StartDocumentImpl(Location location,
64: String systemId, String encoding,
65: String xmlVersion, boolean xmlStandalone,
66: boolean standaloneDeclared,
67: boolean encodingDeclared)
68: {
69: super(location);
70: this.systemId = systemId;
71: this.encoding = encoding;
72: this.xmlVersion = xmlVersion;
73: this.xmlStandalone = xmlStandalone;
74: this.standaloneDeclared = standaloneDeclared;
75: this.encodingDeclared = encodingDeclared;
76: }
77:
78: public int getEventType()
79: {
80: return START_DOCUMENT;
81: }
82:
83: public String getSystemId()
84: {
85: return systemId;
86: }
87:
88: public String getCharacterEncodingScheme()
89: {
90: return encoding;
91: }
92:
93: public boolean encodingSet()
94: {
95: return encodingDeclared;
96: }
97:
98: public boolean isStandalone()
99: {
100: return xmlStandalone;
101: }
102:
103: public boolean standaloneSet()
104: {
105: return standaloneDeclared;
106: }
107:
108: public String getVersion()
109: {
110: return xmlVersion;
111: }
112:
113: public void writeAsEncodedUnicode(Writer writer)
114: throws XMLStreamException
115: {
116: try
117: {
118: writer.write("<?xml version='");
119: writer.write(xmlVersion);
120: writer.write('\'');
121: if (standaloneDeclared)
122: {
123: writer.write(" standalone='");
124: writer.write(xmlStandalone ? "yes" : "no");
125: writer.write('\'');
126: }
127: if (encodingDeclared)
128: {
129: writer.write(" encoding='");
130: writer.write(encoding);
131: writer.write('\'');
132: }
133: writer.write("?>");
134: }
135: catch (IOException e)
136: {
137: XMLStreamException e2 = new XMLStreamException(e.getMessage());
138: e2.initCause(e);
139: throw e2;
140: }
141: }
142:
143: }