1 38 39 package com.sun.xml.fastinfoset.stax.events ; 40 41 import javax.xml.stream.events.StartDocument; 42 import javax.xml.stream.Location; 43 import javax.xml.stream.XMLStreamConstants; 44 import com.sun.xml.fastinfoset.util.XMLConstants; 45 46 public class StartDocumentEvent extends EventBase implements StartDocument { 47 48 protected String _systemId; 49 protected String _encoding = XMLConstants.ENCODING; protected boolean _standalone = true; 51 protected String _version = XMLConstants.XMLVERSION; 52 private boolean _encodingSet = false; 53 private boolean _standaloneSet = false; 54 55 public void reset() { 56 _encoding = XMLConstants.ENCODING; 57 _standalone = true; 58 _version = XMLConstants.XMLVERSION; 59 _encodingSet = false; 60 _standaloneSet=false; 61 } 62 public StartDocumentEvent() { 63 this(null ,null); 64 } 65 66 public StartDocumentEvent(String encoding){ 67 this(encoding, null); 68 } 69 70 public StartDocumentEvent(String encoding, String version){ 71 if (encoding != null) { 72 _encoding = encoding; 73 _encodingSet = true; 74 } 75 if (version != null) 76 _version = version; 77 setEventType(XMLStreamConstants.START_DOCUMENT); 78 } 79 80 81 86 public String getSystemId() { 87 return super.getSystemId(); 88 } 89 90 94 public String getCharacterEncodingScheme() { 95 return _encoding; 96 } 97 101 public boolean encodingSet() { 102 return _encodingSet; 103 } 104 105 106 110 public boolean isStandalone() { 111 return _standalone; 112 } 113 117 public boolean standaloneSet() { 118 return _standaloneSet; 119 } 120 121 125 public String getVersion() { 126 return _version; 127 } 128 130 public void setStandalone(boolean standalone) { 131 _standaloneSet = true; 132 _standalone = standalone; 133 } 134 135 public void setStandalone(String s) { 136 _standaloneSet = true; 137 if(s == null) { 138 _standalone = true; 139 return; 140 } 141 if(s.equals("yes")) 142 _standalone = true; 143 else 144 _standalone = false; 145 } 146 147 148 public void setEncoding(String encoding) { 149 _encoding = encoding; 150 _encodingSet = true; 151 } 152 153 void setDeclaredEncoding(boolean value){ 154 _encodingSet = value; 155 } 156 157 public void setVersion(String s) { 158 _version = s; 159 } 160 161 void clear() { 162 _encoding = "UTF-8"; 163 _standalone = true; 164 _version = "1.0"; 165 _encodingSet = false; 166 _standaloneSet = false; 167 } 168 169 public String toString() { 170 String s = "<?xml version=\"" + _version + "\""; 171 s = s + " encoding='" + _encoding + "'"; 172 if(_standaloneSet) { 173 if(_standalone) 174 s = s + " standalone='yes'?>"; 175 else 176 s = s + " standalone='no'?>"; 177 } else { 178 s = s + "?>"; 179 } 180 return s; 181 } 182 183 public boolean isStartDocument() { 184 return true; 185 } 186 } 187 | Popular Tags |