Ignore:
Timestamp:
2014-05-09T05:32:37+02:00 (6 years ago)
Author:
Don-vip
Message:

see #8465 - replace Utils.UTF_8 by StandardCharsets.UTF_8, new in Java 7

Location:
trunk/src/org/openstreetmap/josm/io
Files:
18 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/io/CacheCustomContent.java

    r7033 r7082  
    88import java.io.FileOutputStream;
    99import java.io.IOException;
     10import java.nio.charset.StandardCharsets;
    1011
    1112import org.openstreetmap.josm.Main;
    12 import org.openstreetmap.josm.tools.Utils;
    1313
    1414/**
     
    119119    public String updateForceString() throws T {
    120120        updateForce();
    121         return new String(data, Utils.UTF_8);
     121        return new String(data, StandardCharsets.UTF_8);
    122122    }
    123123
     
    138138     */
    139139    public String getDataString() throws T {
    140         return new String(getData(), Utils.UTF_8);
     140        return new String(getData(), StandardCharsets.UTF_8);
    141141    }
    142142
  • trunk/src/org/openstreetmap/josm/io/CacheFiles.java

    r7033 r7082  
    66import java.io.RandomAccessFile;
    77import java.math.BigInteger;
     8import java.nio.charset.StandardCharsets;
    89import java.security.MessageDigest;
    910import java.util.Iterator;
     
    1415
    1516import org.openstreetmap.josm.Main;
    16 import org.openstreetmap.josm.tools.Utils;
    1717
    1818/**
     
    321321        try {
    322322            MessageDigest md = MessageDigest.getInstance("MD5");
    323             BigInteger number = new BigInteger(1, md.digest(ident.getBytes(Utils.UTF_8)));
     323            BigInteger number = new BigInteger(1, md.digest(ident.getBytes(StandardCharsets.UTF_8)));
    324324            return number.toString(16);
    325325        } catch(Exception e) {
  • trunk/src/org/openstreetmap/josm/io/GeoJSONExporter.java

    r7033 r7082  
    1010import java.io.OutputStreamWriter;
    1111import java.io.Writer;
     12import java.nio.charset.StandardCharsets;
    1213
    1314import org.openstreetmap.josm.actions.ExtensionFileFilter;
    1415import org.openstreetmap.josm.gui.layer.Layer;
    1516import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    16 import org.openstreetmap.josm.tools.Utils;
    1717
    1818public class GeoJSONExporter extends FileExporter {
     
    3232        if (layer instanceof OsmDataLayer) {
    3333            String json = new GeoJSONWriter((OsmDataLayer) layer).write();
    34             try (Writer out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), Utils.UTF_8))) {
     34            try (Writer out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), StandardCharsets.UTF_8))) {
    3535                out.write(json);
    3636            }
  • trunk/src/org/openstreetmap/josm/io/GpxWriter.java

    r7033 r7082  
    88import java.io.OutputStreamWriter;
    99import java.io.PrintWriter;
     10import java.nio.charset.StandardCharsets;
    1011import java.util.Collection;
    1112import java.util.Map;
     
    2526import org.openstreetmap.josm.data.gpx.IWithAttributes;
    2627import org.openstreetmap.josm.data.gpx.WayPoint;
    27 import org.openstreetmap.josm.tools.Utils;
    2828
    2929/**
     
    3737
    3838    public GpxWriter(OutputStream out) {
    39         super(new PrintWriter(new BufferedWriter(new OutputStreamWriter(out, Utils.UTF_8))));
     39        super(new PrintWriter(new BufferedWriter(new OutputStreamWriter(out, StandardCharsets.UTF_8))));
    4040    }
    4141
  • trunk/src/org/openstreetmap/josm/io/NmeaReader.java

    r7049 r7082  
    55import java.io.InputStream;
    66import java.io.InputStreamReader;
     7import java.nio.charset.StandardCharsets;
    78import java.text.ParsePosition;
    89import java.text.SimpleDateFormat;
     
    1819import org.openstreetmap.josm.data.gpx.WayPoint;
    1920import org.openstreetmap.josm.tools.DateUtils;
    20 import org.openstreetmap.josm.tools.Utils;
    2121
    2222/**
     
    170170        Collection<Collection<WayPoint>> currentTrack = new ArrayList<>();
    171171
    172         try (BufferedReader rd = new BufferedReader(new InputStreamReader(source, Utils.UTF_8))) {
     172        try (BufferedReader rd = new BufferedReader(new InputStreamReader(source, StandardCharsets.UTF_8))) {
    173173            StringBuilder sb = new StringBuilder(1024);
    174174            int loopstart_char = rd.read();
     
    235235            if(chkstrings.length > 1)
    236236            {
    237                 byte[] chb = chkstrings[0].getBytes(Utils.UTF_8);
     237                byte[] chb = chkstrings[0].getBytes(StandardCharsets.UTF_8);
    238238                int chk=0;
    239239                for (int i = 1; i < chb.length; i++) {
  • trunk/src/org/openstreetmap/josm/io/OsmApi.java

    r7081 r7082  
    2020import java.net.SocketTimeoutException;
    2121import java.net.URL;
     22import java.nio.charset.StandardCharsets;
    2223import java.util.Collection;
    2324import java.util.Collections;
     
    190191        @Override
    191192        protected byte[] updateData() throws OsmTransferException {
    192             return sendRequest("GET", "capabilities", null, monitor, false, fastFail).getBytes(Utils.UTF_8);
     193            return sendRequest("GET", "capabilities", null, monitor, false, fastFail).getBytes(StandardCharsets.UTF_8);
    193194        }
    194195    }
     
    638639                        // even if there is no payload.
    639640                        if (requestBody != null) {
    640                             try (BufferedWriter bwr = new BufferedWriter(new OutputStreamWriter(out, Utils.UTF_8))) {
     641                            try (BufferedWriter bwr = new BufferedWriter(new OutputStreamWriter(out, StandardCharsets.UTF_8))) {
    641642                                bwr.write(requestBody);
    642643                                bwr.flush();
     
    670671                    //
    671672                    String s;
    672                     try (BufferedReader in = new BufferedReader(new InputStreamReader(i, Utils.UTF_8))) {
     673                    try (BufferedReader in = new BufferedReader(new InputStreamReader(i, StandardCharsets.UTF_8))) {
    673674                        while((s = in.readLine()) != null) {
    674675                            responseBody.append(s);
  • trunk/src/org/openstreetmap/josm/io/OsmChangesetContentParser.java

    r7033 r7082  
    88import java.io.InputStreamReader;
    99import java.io.StringReader;
     10import java.nio.charset.StandardCharsets;
    1011
    1112import javax.xml.parsers.ParserConfigurationException;
     
    1819import org.openstreetmap.josm.gui.progress.ProgressMonitor;
    1920import org.openstreetmap.josm.tools.CheckParameterUtil;
    20 import org.openstreetmap.josm.tools.Utils;
    2121import org.openstreetmap.josm.tools.XmlParsingException;
    2222import org.xml.sax.Attributes;
     
    3939        private ChangesetDataSet.ChangesetModificationType currentModificationType;
    4040
     41        @Override
    4142        protected void throwException(String message) throws XmlParsingException {
    4243            throw new XmlParsingException(message).rememberLocation(locator);
     
    5354                return;
    5455            }
    55             switch (qName) { 
     56            switch (qName) {
    5657            case "osmChange":
    5758                // do nothing
     
    6768                break;
    6869            default:
    69                 Main.warn(tr("Unsupported start element ''{0}'' in changeset content at position ({1},{2}). Skipping.", 
     70                Main.warn(tr("Unsupported start element ''{0}'' in changeset content at position ({1},{2}). Skipping.",
    7071                        qName, locator.getLineNumber(), locator.getColumnNumber()));
    7172            }
     
    101102                break;
    102103            default:
    103                 Main.warn(tr("Unsupported end element ''{0}'' in changeset content at position ({1},{2}). Skipping.", 
     104                Main.warn(tr("Unsupported end element ''{0}'' in changeset content at position ({1},{2}). Skipping.",
    104105                        qName, locator.getLineNumber(), locator.getColumnNumber()));
    105106            }
     
    126127    public OsmChangesetContentParser(InputStream source) {
    127128        CheckParameterUtil.ensureParameterNotNull(source, "source");
    128         this.source = new InputSource(new InputStreamReader(source, Utils.UTF_8));
     129        this.source = new InputSource(new InputStreamReader(source, StandardCharsets.UTF_8));
    129130    }
    130131
  • trunk/src/org/openstreetmap/josm/io/OsmChangesetParser.java

    r7033 r7082  
    66import java.io.InputStream;
    77import java.io.InputStreamReader;
     8import java.nio.charset.StandardCharsets;
    89import java.text.MessageFormat;
    910import java.util.LinkedList;
     
    1819import org.openstreetmap.josm.gui.progress.ProgressMonitor;
    1920import org.openstreetmap.josm.tools.DateUtils;
    20 import org.openstreetmap.josm.tools.Utils;
    2121import org.openstreetmap.josm.tools.XmlParsingException;
    2222import org.xml.sax.Attributes;
     
    225225            progressMonitor.beginTask("");
    226226            progressMonitor.indeterminateSubTask(tr("Parsing list of changesets..."));
    227             InputSource inputSource = new InputSource(new InvalidXmlCharacterFilter(new InputStreamReader(source, Utils.UTF_8)));
     227            InputSource inputSource = new InputSource(new InvalidXmlCharacterFilter(new InputStreamReader(source, StandardCharsets.UTF_8)));
    228228            SAXParserFactory.newInstance().newSAXParser().parse(inputSource, parser.new Parser());
    229229            return parser.getChangesets();
  • trunk/src/org/openstreetmap/josm/io/OsmConnection.java

    r7012 r7082  
    1010import java.nio.charset.CharacterCodingException;
    1111import java.nio.charset.CharsetEncoder;
     12import java.nio.charset.StandardCharsets;
    1213
    1314import oauth.signpost.OAuthConsumer;
     
    2122import org.openstreetmap.josm.io.auth.CredentialsManager;
    2223import org.openstreetmap.josm.tools.Base64;
    23 import org.openstreetmap.josm.tools.Utils;
    2424
    2525/**
     
    7676     */
    7777    protected void addBasicAuthorizationHeader(HttpURLConnection con) throws OsmTransferException {
    78         CharsetEncoder encoder = Utils.UTF_8.newEncoder();
     78        CharsetEncoder encoder = StandardCharsets.UTF_8.newEncoder();
    7979        CredentialsAgentResponse response;
    8080        String token;
  • trunk/src/org/openstreetmap/josm/io/OsmExporter.java

    r7033 r7082  
    1111import java.io.PrintWriter;
    1212import java.io.Writer;
     13import java.nio.charset.StandardCharsets;
    1314import java.text.MessageFormat;
    1415
     
    7273            try (
    7374                OutputStream out = getOutputStream(file);
    74                 Writer writer = new OutputStreamWriter(out, Utils.UTF_8);
     75                Writer writer = new OutputStreamWriter(out, StandardCharsets.UTF_8);
    7576                OsmWriter w = OsmWriterFactory.createOsmWriter(new PrintWriter(writer), false, layer.data.getVersion());
    7677            ) {
  • trunk/src/org/openstreetmap/josm/io/OsmHistoryReader.java

    r7012 r7082  
    77import java.io.InputStream;
    88import java.io.InputStreamReader;
     9import java.nio.charset.StandardCharsets;
    910
    1011import javax.xml.parsers.ParserConfigurationException;
     
    1718import org.openstreetmap.josm.gui.progress.ProgressMonitor;
    1819import org.openstreetmap.josm.tools.CheckParameterUtil;
    19 import org.openstreetmap.josm.tools.Utils;
    2020import org.xml.sax.Attributes;
    2121import org.xml.sax.InputSource;
     
    8383     */
    8484    public HistoryDataSet parse(ProgressMonitor progressMonitor) throws SAXException, IOException {
    85         InputSource inputSource = new InputSource(new InputStreamReader(in, Utils.UTF_8));
     85        InputSource inputSource = new InputSource(new InputStreamReader(in, StandardCharsets.UTF_8));
    8686        progressMonitor.beginTask(tr("Parsing OSM history data ..."));
    8787        try {
  • trunk/src/org/openstreetmap/josm/io/OsmServerReader.java

    r7033 r7082  
    1111import java.net.MalformedURLException;
    1212import java.net.URL;
     13import java.nio.charset.StandardCharsets;
    1314import java.util.List;
    1415import java.util.Map;
     
    175176                        InputStream i = fixEncoding(activeConnection.getErrorStream(), encoding);
    176177                        if (i != null) {
    177                             BufferedReader in = new BufferedReader(new InputStreamReader(i, Utils.UTF_8));
     178                            BufferedReader in = new BufferedReader(new InputStreamReader(i, StandardCharsets.UTF_8));
    178179                            String s;
    179180                            while((s = in.readLine()) != null) {
  • trunk/src/org/openstreetmap/josm/io/imagery/WMSGrabber.java

    r7033 r7082  
    1313import java.net.URL;
    1414import java.net.URLConnection;
     15import java.nio.charset.StandardCharsets;
    1516import java.text.DecimalFormat;
    1617import java.text.DecimalFormatSymbols;
     
    187188        StringBuilder exception = new StringBuilder();
    188189        InputStream in = conn.getInputStream();
    189         try (BufferedReader br = new BufferedReader(new InputStreamReader(in, Utils.UTF_8))) {
     190        try (BufferedReader br = new BufferedReader(new InputStreamReader(in, StandardCharsets.UTF_8))) {
    190191            String line = null;
    191192            while( (line = br.readLine()) != null) {
  • trunk/src/org/openstreetmap/josm/io/remotecontrol/RequestProcessor.java

    r7030 r7082  
    1212import java.io.Writer;
    1313import java.net.Socket;
     14import java.nio.charset.StandardCharsets;
    1415import java.util.Arrays;
    1516import java.util.Date;
     
    143144        try {
    144145            OutputStream raw = new BufferedOutputStream(request.getOutputStream());
    145             out = new OutputStreamWriter(raw, Utils.UTF_8);
     146            out = new OutputStreamWriter(raw, StandardCharsets.UTF_8);
    146147            BufferedReader in = new BufferedReader(new InputStreamReader(request.getInputStream(), "ASCII"));
    147148
     
    394395                return null;
    395396            }
    396    
     397
    397398            printJsonInfo(cmd, r, handler);
    398399            return w.toString();
  • trunk/src/org/openstreetmap/josm/io/session/GpxTracksSessionExporter.java

    r7071 r7082  
    2121import java.net.URI;
    2222import java.net.URL;
     23import java.nio.charset.StandardCharsets;
    2324import java.util.Collection;
    2425import java.util.Collections;
     
    3839import org.openstreetmap.josm.io.session.SessionWriter.ExportSupport;
    3940import org.openstreetmap.josm.tools.GBC;
    40 import org.openstreetmap.josm.tools.Utils;
    4141import org.w3c.dom.Element;
    4242
     
    181181    @SuppressWarnings("resource")
    182182    protected void addDataFile(OutputStream out) {
    183         Writer writer = new OutputStreamWriter(out, Utils.UTF_8);
     183        Writer writer = new OutputStreamWriter(out, StandardCharsets.UTF_8);
    184184        GpxWriter w = new GpxWriter(new PrintWriter(writer));
    185185        w.write(layer.data);
  • trunk/src/org/openstreetmap/josm/io/session/MarkerSessionExporter.java

    r7071 r7082  
    99import java.io.PrintWriter;
    1010import java.io.Writer;
     11import java.nio.charset.StandardCharsets;
    1112import java.util.Collection;
    1213import java.util.Collections;
     
    2526import org.openstreetmap.josm.io.session.SessionWriter.ExportSupport;
    2627import org.openstreetmap.josm.tools.GBC;
    27 import org.openstreetmap.josm.tools.Utils;
    2828import org.w3c.dom.Element;
    2929
     
    8686    @SuppressWarnings("resource")
    8787    protected void addDataFile(OutputStream out) {
    88         Writer writer = new OutputStreamWriter(out, Utils.UTF_8);
     88        Writer writer = new OutputStreamWriter(out, StandardCharsets.UTF_8);
    8989        MarkerWriter w = new MarkerWriter(new PrintWriter(writer));
    9090        w.write(layer);
  • trunk/src/org/openstreetmap/josm/io/session/OsmDataSessionExporter.java

    r7071 r7082  
    2121import java.net.URI;
    2222import java.net.URL;
     23import java.nio.charset.StandardCharsets;
    2324import java.util.Collection;
    2425import java.util.Collections;
     
    4344import org.openstreetmap.josm.tools.GBC;
    4445import org.openstreetmap.josm.tools.ImageProvider;
    45 import org.openstreetmap.josm.tools.Utils;
    4646import org.w3c.dom.Element;
    4747
     
    210210
    211211    protected void addDataFile(OutputStream out) {
    212         Writer writer = new OutputStreamWriter(out, Utils.UTF_8);
     212        Writer writer = new OutputStreamWriter(out, StandardCharsets.UTF_8);
    213213        OsmWriter w = OsmWriterFactory.createOsmWriter(new PrintWriter(writer), false, layer.data.getVersion());
    214214        layer.data.getReadLock().lock();
  • trunk/src/org/openstreetmap/josm/io/session/SessionWriter.java

    r7070 r7082  
    1010import java.io.OutputStreamWriter;
    1111import java.lang.reflect.Constructor;
     12import java.nio.charset.StandardCharsets;
    1213import java.util.ArrayList;
    1314import java.util.HashMap;
     
    223224    public void writeJos(Document doc, OutputStream out) throws IOException {
    224225        try {
    225             OutputStreamWriter writer = new OutputStreamWriter(out, Utils.UTF_8);
     226            OutputStreamWriter writer = new OutputStreamWriter(out, StandardCharsets.UTF_8);
    226227            writer.write("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n");
    227228            TransformerFactory transfac = TransformerFactory.newInstance();
Note: See TracChangeset for help on using the changeset viewer.