Changeset 34100
- Timestamp:
- 2020-04-09T11:39:25+12:00 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/XMLConverter.java
r33897 r34100 72 72 static Logger logger = Logger.getLogger(org.greenstone.gsdl3.util.XMLConverter.class.getName()); 73 73 74 75 public static final String XML_FILE_ENCODING="UTF-8"; 76 77 static { 78 String fileEncodingProperty = System.getProperty("file.encoding"); 79 80 // log a warning if the file.encoding Java property departs from XML_FILE_ENCODING, 81 // but always use the latter for reading in XML files in getDOM(File, ...) methods 82 if(fileEncodingProperty == null) { 83 logger.warn("file.encoding Java property was not set."); 84 System.err.println("Using XMLConverter.XML_FILE_ENCODING="+XML_FILE+ENCODING+"in XMLConverter.getDOM() calls."); 85 } 86 else if(!fileEncodingProperty.equals(XML_FILE_ENCODING)) { 87 logger.warn("file.encoding property passed in with JAVA_TOOLS_OPTIONS: " 88 + fileEncodingProperty); 89 logger.warn("does not match XMLConverter.XML_FILE_ENCODING: " + XML_FILE_ENCODING); 90 logger.warn("Using XMLConverter.XML_FILE_ENCODING in XMLConverter.getDOM() calls."); 91 } 92 }; 93 94 74 95 /** the no-args constructor */ 75 96 public XMLConverter() … … 78 99 } 79 100 80 /** returns a DOM Document */ 101 /** returns a DOM Document 102 * Question: why is this not simply calling the getDOM(String in, String encoding) version? 103 * Answer: Because the string, being a Java String, is already fully formed in unicode, 104 * so it doesn't need to call that other version. 105 */ 81 106 public static Document getDOM(String in) 82 107 { … … 123 148 /** returns a DOM Document */ 124 149 public static Document getDOM(File in) { 150 151 // now we're always going to explicitly use XML_FILE_ENCODING (UTF-8) 152 // as the encoding to read in a file unless otherwise specified. 153 return getDOM(in, XML_FILE_ENCODING, null); 154 155 /* 125 156 try 126 157 { … … 140 171 } 141 172 return null; 173 */ 142 174 } 143 175 … … 169 201 170 202 public static Document getDOM(File in, EntityResolver er) { 171 203 // now we're always going to explicitly use XML_FILE_ENCODING (UTF-8) 204 // as the encoding to read in a file unless otherwise specified. 205 return getDOM(in, XML_FILE_ENCODING, er); 206 /* 172 207 try { 173 208 InputSource xml_source = new InputSource(new FileInputStream(in)); … … 182 217 } 183 218 return null; 219 */ 184 220 } 185 221
Note:
See TracChangeset
for help on using the changeset viewer.