Ignore:
Timestamp:
2013-12-28T00:30:15+01:00 (11 years ago)
Author:
simon04
Message:

Refactoring: introduce Utils.UTF_8 charset to avoid handling of UnsupportedEncodingException

According to the Javadoc of Charset, every implementation of the Java
platform is required to support UTF-8.

Location:
trunk/src/org/openstreetmap/josm/data
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/CustomConfigurator.java

    r6362 r6552  
    232232        try {
    233233            String toXML = Main.pref.toXML(true);
    234             InputStream is = new ByteArrayInputStream(toXML.getBytes("UTF-8"));
     234            InputStream is = new ByteArrayInputStream(toXML.getBytes(Utils.UTF_8));
    235235            DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
    236236            builderFactory.setValidating(false);
  • trunk/src/org/openstreetmap/josm/data/Preferences.java

    r6380 r6552  
    596596
    597597        final PrintWriter out = new PrintWriter(new OutputStreamWriter(
    598                 new FileOutputStream(prefFile + "_tmp"), "utf-8"), false);
     598                new FileOutputStream(prefFile + "_tmp"), Utils.UTF_8), false);
    599599        out.print(toXML(false));
    600600        Utils.close(out);
     
    621621        if (!Main.applet) {
    622622            File pref = getPreferenceFile();
    623             BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(pref), "utf-8"));
     623            BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(pref), Utils.UTF_8));
    624624            try {
    625625                validateXML(in);
    626626                Utils.close(in);
    627                 in = new BufferedReader(new InputStreamReader(new FileInputStream(pref), "utf-8"));
     627                in = new BufferedReader(new InputStreamReader(new FileInputStream(pref), Utils.UTF_8));
    628628                fromXML(in);
    629629            } finally {
  • trunk/src/org/openstreetmap/josm/data/validation/tests/MapCSSTagChecker.java

    r6551 r6552  
    66import java.io.InputStreamReader;
    77import java.io.Reader;
    8 import java.io.UnsupportedEncodingException;
    98import java.util.ArrayList;
    109import java.util.Collection;
     
    368367     * @param internalConfigFile the filename in data/validator
    369368     * @throws ParseException if the config file does not match MapCSS syntax
    370      * @throws UnsupportedEncodingException if UTF-8 charset is not supported on the platform
    371369     */
    372     private void addMapCSS(String internalConfigFile) throws ParseException, UnsupportedEncodingException {
    373         addMapCSS(new InputStreamReader(getClass().getResourceAsStream("/data/validator/" + internalConfigFile + ".mapcss"), "UTF-8"));
     370    private void addMapCSS(String internalConfigFile) throws ParseException {
     371        addMapCSS(new InputStreamReader(getClass().getResourceAsStream("/data/validator/" + internalConfigFile + ".mapcss"), Utils.UTF_8));
    374372    }
    375373
  • trunk/src/org/openstreetmap/josm/data/validation/tests/OpeningHourTest.java

    r6533 r6552  
    2626import org.openstreetmap.josm.data.validation.TestError;
    2727import org.openstreetmap.josm.io.MirroredInputStream;
     28import org.openstreetmap.josm.tools.Utils;
    2829
    2930/**
     
    5354        super.initialize();
    5455        if (ENGINE != null) {
    55             ENGINE.eval(new InputStreamReader(new MirroredInputStream("resource://data/validator/opening_hours.js"), "UTF-8"));
     56            ENGINE.eval(new InputStreamReader(new MirroredInputStream("resource://data/validator/opening_hours.js"), Utils.UTF_8));
    5657            // fake country/state to not get errors on holidays
    5758            ENGINE.eval("var nominatimJSON = {address: {state: 'Bayern', country_code: 'de'}};");
  • trunk/src/org/openstreetmap/josm/data/validation/tests/TagChecker.java

    r6529 r6552  
    1414import java.io.IOException;
    1515import java.io.InputStreamReader;
    16 import java.io.UnsupportedEncodingException;
    1716import java.text.MessageFormat;
    1817import java.util.ArrayList;
     
    211210            try {
    212211                MirroredInputStream s = new MirroredInputStream(source);
    213                 InputStreamReader r;
    214                 try {
    215                     r = new InputStreamReader(s, "UTF-8");
    216                 } catch (UnsupportedEncodingException e) {
    217                     r = new InputStreamReader(s);
    218                 }
    219                 reader = new BufferedReader(r);
     212                reader = new BufferedReader(new InputStreamReader(s, Utils.UTF_8));
    220213
    221214                String okValue = null;
  • trunk/src/org/openstreetmap/josm/data/validation/tests/UnconnectedWays.java

    r6529 r6552  
    128128                    }
    129129                    if (en.hasTag("highway", "turning_circle", "bus_stop")
     130                            || en.hasTag("amenity", "parking_entrance")
    130131                            || en.hasTag("railway", "buffer_stop")
    131132                            || OsmUtils.isTrue(en.get("noexit"))
     133                            || en.hasKey("entrance")
    132134                            || en.hasKey("barrier")) {
    133135                        continue;
Note: See TracChangeset for help on using the changeset viewer.