Changeset 2852 in josm


Ignore:
Timestamp:
2010-01-13T20:20:51+01:00 (11 years ago)
Author:
mjulius
Message:

fix messages for io

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

Legend:

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

    r2822 r2852  
    55
    66import java.text.DateFormat;
     7import java.text.MessageFormat;
    78import java.text.ParseException;
    89import java.text.SimpleDateFormat;
     
    5657    public ChangesetQuery forUser(int uid) throws IllegalArgumentException{
    5758        if (uid <= 0)
    58             throw new IllegalArgumentException(tr("Parameter ''{0}'' > 0 expected. Got ''{1}''.", "uid", uid));
     59            throw new IllegalArgumentException(MessageFormat.format("Parameter ''{0}'' > 0 expected. Got ''{1}''.", "uid", uid));
    5960        this.uid = uid;
    6061        this.userName = null;
     
    359360                if (k.equals("uid")) {
    360361                    if (queryParams.containsKey("display_name"))
    361                         throw new ChangesetQueryUrlException(tr("Can't create a changeset query including both the query parameters 'uid' and 'display_name'"));
     362                        throw new ChangesetQueryUrlException(tr("Cannot create a changeset query including both the query parameters ''uid'' and ''display_name''"));
    362363                    csQuery.forUser(parseUid(queryParams.get("uid")));
    363364                } else if (k.equals("display_name")) {
    364365                    if (queryParams.containsKey("uid"))
    365                         throw new ChangesetQueryUrlException(tr("Can't create a changeset query including both the query parameters 'uid' and 'display_name'"));
     366                        throw new ChangesetQueryUrlException(tr("Cannot create a changeset query including both the query parameters ''uid'' and ''display_name''"));
    366367                    csQuery.forUser(queryParams.get("display_name"));
    367368                } else if (k.equals("open")) {
  • trunk/src/org/openstreetmap/josm/io/DefaultProxySelector.java

    r2822 r2852  
    150150        case USE_SYSTEM_SETTINGS:
    151151            if (!JVM_WILL_USE_SYSTEM_PROXIES) {
    152                 System.err.println(tr("Warning: the JVM is not configured to lookup proxies from the system settings. The property 'java.net.useSystemProxies' was missing at startup time. Won't use a proxy."));
     152                System.err.println(tr("Warning: the JVM is not configured to lookup proxies from the system settings. The property ''java.net.useSystemProxies'' was missing at startup time.  Will not use a proxy."));
    153153                return Collections.singletonList(Proxy.NO_PROXY);
    154154            }
  • trunk/src/org/openstreetmap/josm/io/DiffResultProcessor.java

    r2711 r2852  
    2323import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
    2424import org.openstreetmap.josm.gui.progress.ProgressMonitor;
     25import org.openstreetmap.josm.tools.CheckParameterUtil;
    2526import org.xml.sax.Attributes;
    2627import org.xml.sax.InputSource;
     
    7879            progressMonitor = NullProgressMonitor.INSTANCE;
    7980        }
    80         if (diffUploadResponse == null)
    81             throw new IllegalArgumentException(tr("Parameter ''{0}'' must not be null", "source"));
     81        CheckParameterUtil.ensureParameterNotNull(diffUploadResponse, "diffUploadResponse");
    8282        try {
    8383            progressMonitor.beginTask(tr("Parsing response from server..."));
  • trunk/src/org/openstreetmap/josm/io/GpxExporter.java

    r2181 r2852  
    1212import java.io.FileOutputStream;
    1313import java.io.IOException;
     14import java.text.MessageFormat;
    1415import java.util.Calendar;
    1516
     
    3334import org.openstreetmap.josm.gui.layer.Layer;
    3435import org.openstreetmap.josm.gui.layer.OsmDataLayer;
     36import org.openstreetmap.josm.tools.CheckParameterUtil;
    3537import org.openstreetmap.josm.tools.GBC;
    3638
     
    5254    @Override
    5355    public void exportData(File file, Layer layer) throws IOException {
    54         if (layer == null)
    55             throw new IllegalArgumentException(tr("Parameter ''{0}'' must not be null.", "layer"));
     56        CheckParameterUtil.ensureParameterNotNull(layer, "layer");
    5657        if (!(layer instanceof OsmDataLayer) && !(layer instanceof GpxLayer))
    57             throw new IllegalArgumentException(tr("Expected instance of OsmDataLayer or GpxLayer. Got ''{0}''.", layer
     58            throw new IllegalArgumentException(MessageFormat.format("Expected instance of OsmDataLayer or GpxLayer. Got ''{0}''.", layer
    5859                    .getClass().getName()));
    59         if (file == null)
    60             throw new IllegalArgumentException(tr("Parameter ''{0}'' must not be null.", "file"));
     60        CheckParameterUtil.ensureParameterNotNull(file, "file");
    6161
    6262        String fn = file.getPath();
  • trunk/src/org/openstreetmap/josm/io/MultiFetchServerObjectReader.java

    r2771 r2852  
    2525import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
    2626import org.openstreetmap.josm.gui.progress.ProgressMonitor;
     27import org.openstreetmap.josm.tools.CheckParameterUtil;
    2728
    2829/**
     
    107108     */
    108109    protected void remember(DataSet ds, long id, OsmPrimitiveType type) throws IllegalArgumentException, NoSuchElementException{
    109         if (ds == null)
    110             throw new IllegalArgumentException(tr("Parameter ''{0}'' must not be null.", "ds"));
     110        CheckParameterUtil.ensureParameterNotNull(ds, "ds");
    111111        if (id <= 0) return;
    112112        OsmPrimitive primitive = ds.getPrimitiveById(id, type);
  • trunk/src/org/openstreetmap/josm/io/OsmApi.java

    r2825 r2852  
    33
    44import static org.openstreetmap.josm.tools.I18n.tr;
     5import static org.openstreetmap.josm.tools.I18n.trn;
    56
    67import java.io.BufferedReader;
     
    3334import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
    3435import org.openstreetmap.josm.gui.progress.ProgressMonitor;
     36import org.openstreetmap.josm.tools.CheckParameterUtil;
    3537import org.xml.sax.Attributes;
    3638import org.xml.sax.InputSource;
     
    132134     */
    133135    protected OsmApi(String serverUrl)  {
    134         if (serverUrl == null)
    135             throw new IllegalArgumentException(tr("Parameter ''{0}'' must not be null.", "serverUrl"));
     136        CheckParameterUtil.ensureParameterNotNull(serverUrl, "serverUrl");
    136137        this.serverUrl = serverUrl;
    137138    }
     
    306307     */
    307308    public void openChangeset(Changeset changeset, ProgressMonitor progressMonitor) throws OsmTransferException {
    308         if (changeset == null)
    309             throw new IllegalArgumentException(tr("Parameter ''{0}'' must not be null.", "changeset"));
     309        CheckParameterUtil.ensureParameterNotNull(changeset, "changeset");
    310310        try {
    311311            progressMonitor.beginTask((tr("Creating changeset...")));
     
    338338     */
    339339    public void updateChangeset(Changeset changeset, ProgressMonitor monitor) throws OsmTransferException {
    340         if (changeset == null)
    341             throw new IllegalArgumentException(tr("Parameter ''{0}'' must not be null.", "changeset"));
     340        CheckParameterUtil.ensureParameterNotNull(changeset, "changeset");
    342341        if (monitor == null) {
    343342            monitor = NullProgressMonitor.INSTANCE;
     
    379378     */
    380379    public void closeChangeset(Changeset changeset, ProgressMonitor monitor) throws OsmTransferException {
    381         if (changeset == null)
    382             throw new IllegalArgumentException(tr("Parameter ''{0}'' must not be null.", "changeset"));
     380        CheckParameterUtil.ensureParameterNotNull(changeset, "changeset");
    383381        if (monitor == null) {
    384382            monitor = NullProgressMonitor.INSTANCE;
     
    423421            // Upload to the server
    424422            //
    425             monitor.indeterminateSubTask(tr("Uploading {0} objects...", list.size()));
     423            monitor.indeterminateSubTask(
     424                    trn("Uploading {0} object...", "Uploading {0} objects...", list.size(), list.size()));
    426425            String diffUploadResponse = sendRequest("POST", "changeset/" + changeset.getId() + "/upload", diffUploadRequest,monitor);
    427426
  • trunk/src/org/openstreetmap/josm/io/OsmChangesetContentParser.java

    r2828 r2852  
    239239                    || qName.equals("relation")) {
    240240                if (currentModificationType == null) {
    241                     throwException(tr("Illegal document structure. Found node, way, or relation outside of 'create', 'modify', or 'delete'."));
     241                    throwException(tr("Illegal document structure. Found node, way, or relation outside of ''create'', ''modify'', or ''delete''."));
    242242                }
    243243                data.put(currentPrimitive, currentModificationType);
  • trunk/src/org/openstreetmap/josm/io/OsmChangesetParser.java

    r2828 r2852  
    55import java.io.InputStream;
    66import java.io.InputStreamReader;
     7import java.text.MessageFormat;
    78import java.util.LinkedList;
    89import java.util.List;
     
    195196                return User.createOsmUser(id, name);
    196197            } catch(NumberFormatException e) {
    197                 throwException(tr("Illegal value for attribute ''uid''. Got ''{0}''.", uid));
     198                throwException(MessageFormat.format("Illegal value for attribute ''uid''. Got ''{0}''.", uid));
    198199            }
    199200            return null;
  • trunk/src/org/openstreetmap/josm/io/OsmExporter.java

    r2396 r2852  
    1313import java.io.PrintWriter;
    1414import java.io.Writer;
     15import java.text.MessageFormat;
    1516
    1617import javax.swing.JOptionPane;
     
    4344            save(file, (OsmDataLayer) layer);
    4445        } else
    45             throw new IllegalArgumentException(tr("Expected instance of OsmDataLayer. Got ''{0}''.", layer
     46            throw new IllegalArgumentException(MessageFormat.format("Expected instance of OsmDataLayer. Got ''{0}''.", layer
    4647                    .getClass().getName()));
    4748    }
  • trunk/src/org/openstreetmap/josm/io/OsmReader.java

    r2751 r2852  
    55import java.io.InputStream;
    66import java.io.InputStreamReader;
     7import java.text.MessageFormat;
    78import java.util.ArrayList;
    89import java.util.Collection;
     
    3334import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
    3435import org.openstreetmap.josm.gui.progress.ProgressMonitor;
     36import org.openstreetmap.josm.tools.CheckParameterUtil;
    3537import org.openstreetmap.josm.tools.DateUtils;
    3638import org.xml.sax.Attributes;
     
    325327                return User.createOsmUser(id, name);
    326328            } catch(NumberFormatException e) {
    327                 throwException(tr("Illegal value for attribute ''uid''. Got ''{0}''.", uid));
     329                throwException(MessageFormat.format("Illegal value for attribute ''uid''. Got ''{0}''.", uid));
    328330            }
    329331            return null;
     
    586588            progressMonitor = NullProgressMonitor.INSTANCE;
    587589        }
    588         if (source == null)
    589             throw new IllegalArgumentException(tr("Parameter ''{0}'' must not be null", "source"));
     590        CheckParameterUtil.ensureParameterNotNull(source, "source");
    590591        OsmReader reader = new OsmReader();
    591592        try {
  • trunk/src/org/openstreetmap/josm/io/OsmServerBackreferenceReader.java

    r2578 r2852  
    55
    66import java.io.InputStream;
     7import java.text.MessageFormat;
    78import java.util.ArrayList;
    89import java.util.Collection;
     
    1617import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
    1718import org.openstreetmap.josm.gui.progress.ProgressMonitor;
     19import org.openstreetmap.josm.tools.CheckParameterUtil;
    1820
    1921/**
     
    5052     */
    5153    public OsmServerBackreferenceReader(OsmPrimitive primitive) throws IllegalArgumentException {
    52         if (primitive == null)
    53             throw new IllegalArgumentException(tr("Parameter ''{0}'' must not be null.", "primitive"));
    54         if (primitive.isNew())
    55             throw new IllegalArgumentException(tr("ID parameter ''{0}'' > 0 expected. Got ''{1}''.", "primitive", primitive.getId()));
     54        CheckParameterUtil.ensureValidPrimitiveId(primitive, "primitive");
    5655        this.id = primitive.getId();
    5756        this.primitiveType = OsmPrimitiveType.from(primitive);
     
    7170    public OsmServerBackreferenceReader(long id, OsmPrimitiveType type) throws IllegalArgumentException   {
    7271        if (id <= 0)
    73             throw new IllegalArgumentException(tr("Parameter ''{0}'' > 0 expected. Got ''{1}''.", "id", id));
    74         if (type == null)
    75             throw new IllegalArgumentException(tr("Parameter ''{0}'' must not be null.", "type"));
     72            throw new IllegalArgumentException(MessageFormat.format("Parameter ''{0}'' > 0 expected. Got ''{1}''.", "id", id));
     73        CheckParameterUtil.ensureParameterNotNull(type, "type");
    7674        this.id = id;
    7775        this.primitiveType = type;
  • trunk/src/org/openstreetmap/josm/io/OsmServerChangesetReader.java

    r2781 r2852  
    77import java.io.InputStream;
    88import java.io.UnsupportedEncodingException;
     9import java.text.MessageFormat;
    910import java.util.ArrayList;
    1011import java.util.Collection;
     
    1819import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
    1920import org.openstreetmap.josm.gui.progress.ProgressMonitor;
     21import org.openstreetmap.josm.tools.CheckParameterUtil;
    2022
    2123/**
     
    5153     */
    5254    public List<Changeset> queryChangesets(ChangesetQuery query, ProgressMonitor monitor) throws OsmTransferException {
    53         if (query == null)
    54             throw new IllegalArgumentException(tr("Parameter ''{0}'' must not be null.", "query"));
     55        CheckParameterUtil.ensureParameterNotNull(query, "query");
    5556        if (monitor == null) {
    5657            monitor = NullProgressMonitor.INSTANCE;
     
    8687    public Changeset readChangeset(long id, ProgressMonitor monitor) throws OsmTransferException {
    8788        if (id <= 0)
    88             throw new IllegalArgumentException(tr("Parameter ''{0}'' > 0 expected. Got ''{1}''.", "id", id));
     89            throw new IllegalArgumentException(MessageFormat.format("Parameter ''{0}'' > 0 expected. Got ''{1}''.", "id", id));
    8990        if (monitor == null) {
    9091            monitor = NullProgressMonitor.INSTANCE;
     
    171172    public ChangesetDataSet downloadChangeset(int id, ProgressMonitor monitor) throws IllegalArgumentException, OsmTransferException {
    172173        if (id <= 0)
    173             throw new IllegalArgumentException(tr("Expected value of type integer > 0 for parameter ''{0}'', got {1}", "id", id));
     174            throw new IllegalArgumentException(MessageFormat.format("Expected value of type integer > 0 for parameter ''{0}'', got {1}", "id", id));
    174175        if (monitor == null) {
    175176            monitor = NullProgressMonitor.INSTANCE;
  • trunk/src/org/openstreetmap/josm/io/OsmServerHistoryReader.java

    r2512 r2852  
    55
    66import java.io.InputStream;
     7import java.text.MessageFormat;
    78
    89import org.openstreetmap.josm.data.osm.DataSet;
     
    1011import org.openstreetmap.josm.data.osm.history.HistoryDataSet;
    1112import org.openstreetmap.josm.gui.progress.ProgressMonitor;
     13import org.openstreetmap.josm.tools.CheckParameterUtil;
    1214
    1315/**
     
    3032     */
    3133    public OsmServerHistoryReader(OsmPrimitiveType type, long id) throws IllegalArgumentException {
    32         if (type == null)
    33             throw new IllegalArgumentException(tr("Parameter ''{0}'' must not be null.", "type"));
     34        CheckParameterUtil.ensureParameterNotNull(type, "type");
    3435        if (id < 0)
    35             throw new IllegalArgumentException(tr("Parameter ''{0}'' >= 0 expected. Got ''{1}''.", "id", id));
     36            throw new IllegalArgumentException(MessageFormat.format("Parameter ''{0}'' >= 0 expected. Got ''{1}''.", "id", id));
    3637        this.primitiveType = type;
    3738        this.id = id;
  • trunk/src/org/openstreetmap/josm/io/OsmServerObjectReader.java

    r2711 r2852  
    66import java.io.IOException;
    77import java.io.InputStream;
     8import java.text.MessageFormat;
    89
    910import org.openstreetmap.josm.data.osm.DataSet;
     
    1314import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
    1415import org.openstreetmap.josm.gui.progress.ProgressMonitor;
     16import org.openstreetmap.josm.tools.CheckParameterUtil;
    1517import org.xml.sax.SAXException;
    1618
     
    4042    public OsmServerObjectReader(long id, OsmPrimitiveType type, boolean full) throws IllegalArgumentException {
    4143        if (id <= 0)
    42             throw new IllegalArgumentException(tr("Expected value > 0 for parameter ''{0}'', got {1}", "id", id));
    43         if (type == null)
    44             throw new IllegalArgumentException(tr("Parameter ''{0}'' must not be null", "type"));
     44            throw new IllegalArgumentException(MessageFormat.format("Expected value > 0 for parameter ''{0}'', got {1}", "id", id));
     45        CheckParameterUtil.ensureParameterNotNull(type, "type");
    4546        this.id = new SimplePrimitiveId(id, type);
    4647        this.full = full;
     
    5758     */
    5859    public OsmServerObjectReader(PrimitiveId id, boolean full) {
    59         if (id == null)
    60             throw new IllegalArgumentException(tr("Parameter ''{0}'' must not be null", "id"));
    61         if (id.getUniqueId() <= 0)
    62             throw new IllegalArgumentException(tr("Expected value > 0 for parameter ''{0}'', got {1}", "id.getUniqueId()", id.getUniqueId()));
     60        CheckParameterUtil.ensureValidPrimitiveId(id, "id");
    6361        this.id = id;
    6462        this.full = full;
  • trunk/src/org/openstreetmap/josm/io/OsmServerReader.java

    r2641 r2852  
    8484            } catch (Exception e) {
    8585                e.printStackTrace();
    86                 throw new OsmTransferException(tr("Couldn't connect to the OSM server. Please check your internet connection."), e);
     86                throw new OsmTransferException(tr("Could not connect to the OSM server. Please check your internet connection."), e);
    8787            }
    8888            try {
  • trunk/src/org/openstreetmap/josm/io/OsmServerWriter.java

    r2825 r2852  
    44import static org.openstreetmap.josm.tools.I18n.marktr;
    55import static org.openstreetmap.josm.tools.I18n.tr;
     6import static org.openstreetmap.josm.tools.I18n.trn;
    67
    78import java.util.ArrayList;
     
    1819import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
    1920import org.openstreetmap.josm.gui.progress.ProgressMonitor;
     21import org.openstreetmap.josm.tools.CheckParameterUtil;
    2022
    2123/**
     
    154156                    chunk.add(it.next());
    155157                }
    156                 progressMonitor.setCustomText(tr("({0}/{1}) Uploading {2} objects...", i,numChunks,chunk.size()));
     158                progressMonitor.setCustomText(
     159                        trn("({0}/{1}) Uploading {2} object...",
     160                                "({0}/{1}) Uploading {2} objects...",
     161                                chunk.size(), i, numChunks, chunk.size()));
    157162                processed.addAll(api.uploadDiff(chunk, progressMonitor.createSubTaskMonitor(ProgressMonitor.ALL_TICKS, false)));
    158163            }
     
    176181     */
    177182    public void uploadOsm(UploadStrategySpecification strategy, Collection<OsmPrimitive> primitives, Changeset changeset, ProgressMonitor monitor) throws OsmTransferException {
    178         if (changeset == null)
    179             throw new IllegalArgumentException(tr("Parameter ''{0}'' must not be null", "changeset"));
     183        CheckParameterUtil.ensureParameterNotNull(changeset, "changeset");
    180184        processed = new LinkedList<OsmPrimitive>();
    181185        monitor = monitor == null ? NullProgressMonitor.INSTANCE : monitor;
Note: See TracChangeset for help on using the changeset viewer.