Changeset 7033 in josm for trunk/src/org/openstreetmap/josm/data/validation
- Timestamp:
- 2014-05-01T02:34:43+02:00 (10 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/data/validation
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/validation/OsmValidator.java
r7005 r7033 171 171 File file = new File(getValidatorDir() + "ignorederrors"); 172 172 if (file.exists()) { 173 BufferedReader in = null; 174 try { 175 in = new BufferedReader(new InputStreamReader(new FileInputStream(file), Utils.UTF_8)); 173 try (BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(file), Utils.UTF_8))) { 176 174 for (String line = in.readLine(); line != null; line = in.readLine()) { 177 175 ignoredErrors.add(line); … … 181 179 } catch (final IOException e) { 182 180 Main.error(e); 183 } finally {184 Utils.close(in);185 181 } 186 182 } … … 197 193 198 194 public static void saveIgnoredErrors() { 199 PrintWriter out = null; 200 try { 201 out = new PrintWriter(new OutputStreamWriter(new FileOutputStream(getValidatorDir() + "ignorederrors"), Utils.UTF_8), false); 195 try (PrintWriter out = new PrintWriter(new OutputStreamWriter( 196 new FileOutputStream(getValidatorDir() + "ignorederrors"), Utils.UTF_8), false)) { 202 197 for (String e : ignoredErrors) { 203 198 out.println(e); … … 205 200 } catch (IOException e) { 206 201 Main.error(e); 207 } finally {208 Utils.close(out);209 202 } 210 203 } -
trunk/src/org/openstreetmap/josm/data/validation/tests/MapCSSTagChecker.java
r7027 r7033 453 453 Main.info(tr("Adding {0} to tag checker", i)); 454 454 } 455 MirroredInputStream s = new MirroredInputStream(i); 456 try { 455 try (MirroredInputStream s = new MirroredInputStream(i)) { 457 456 addMapCSS(new BufferedReader(UTFInputStreamReader.create(s))); 458 } finally {459 Utils.close(s);460 457 } 461 458 } catch (IOException ex) { -
trunk/src/org/openstreetmap/josm/data/validation/tests/OpeningHourTest.java
r7005 r7033 5 5 6 6 import java.io.InputStreamReader; 7 import java.io.Reader; 7 8 import java.util.ArrayList; 8 9 import java.util.Arrays; … … 51 52 super.initialize(); 52 53 if (ENGINE != null) { 53 ENGINE.eval(new InputStreamReader(new MirroredInputStream("resource://data/validator/opening_hours.js"), Utils.UTF_8)); 54 // fake country/state to not get errors on holidays 55 ENGINE.eval("var nominatimJSON = {address: {state: 'Bayern', country_code: 'de'}};"); 56 ENGINE.eval( 57 "var oh = function (value, mode) {" + 58 " try {" + 59 " var r= new opening_hours(value, nominatimJSON, mode);" + 60 " r.getErrors = function() {return [];};" + 61 " return r;" + 62 " } catch(err) {" + 63 " return {" + 64 " getWarnings: function() {return [];}," + 65 " getErrors: function() {return [err.toString()]}" + 66 " };" + 67 " }" + 68 "};"); 54 try (Reader reader = new InputStreamReader( 55 new MirroredInputStream("resource://data/validator/opening_hours.js"), Utils.UTF_8)) { 56 ENGINE.eval(reader); 57 // fake country/state to not get errors on holidays 58 ENGINE.eval("var nominatimJSON = {address: {state: 'Bayern', country_code: 'de'}};"); 59 ENGINE.eval( 60 "var oh = function (value, mode) {" + 61 " try {" + 62 " var r= new opening_hours(value, nominatimJSON, mode);" + 63 " r.getErrors = function() {return [];};" + 64 " return r;" + 65 " } catch(err) {" + 66 " return {" + 67 " getWarnings: function() {return [];}," + 68 " getErrors: function() {return [err.toString()]}" + 69 " };" + 70 " }" + 71 "};"); 72 } 69 73 } else { 70 74 Main.warn("Unable to initialize OpeningHourTest because no JavaScript engine has been found"); -
trunk/src/org/openstreetmap/josm/data/validation/tests/TagChecker.java
r7025 r7033 54 54 import org.openstreetmap.josm.tools.GBC; 55 55 import org.openstreetmap.josm.tools.MultiMap; 56 import org.openstreetmap.josm.tools.Utils;57 56 58 57 /** … … 165 164 String errorSources = ""; 166 165 for (String source : Main.pref.getCollection(PREF_SOURCES, DEFAULT_SOURCES)) { 167 BufferedReader reader = null; 168 try { 166 try ( 169 167 MirroredInputStream s = new MirroredInputStream(source); 170 reader = new BufferedReader(UTFInputStreamReader.create(s));171 168 BufferedReader reader = new BufferedReader(UTFInputStreamReader.create(s)); 169 ) { 172 170 String okValue = null; 173 171 boolean tagcheckerfile = false; … … 242 240 } catch (IOException e) { 243 241 errorSources += source + "\n"; 244 } finally {245 Utils.close(reader);246 242 } 247 243 }
Note:
See TracChangeset
for help on using the changeset viewer.