Changeset 34917 in osm for applications


Ignore:
Timestamp:
2019-03-11T16:00:20+01:00 (6 years ago)
Author:
gerdp
Message:

fix some sonar/javadoc issues, no functional change expected

Location:
applications/editors/josm/plugins/reverter/src/reverter
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/reverter/src/reverter/ChangesetReverter.java

    r33865 r34917  
    2424import org.openstreetmap.josm.data.osm.PrimitiveId;
    2525import org.openstreetmap.josm.data.osm.Relation;
     26import org.openstreetmap.josm.data.osm.RelationMember;
    2627import org.openstreetmap.josm.data.osm.RelationMemberData;
    2728import org.openstreetmap.josm.data.osm.SimplePrimitiveId;
     
    3940import org.openstreetmap.josm.io.OsmTransferException;
    4041import org.openstreetmap.josm.tools.Logging;
     42import org.openstreetmap.josm.tools.Utils;
    4143
    4244import reverter.corehacks.ChangesetDataSet;
     
    110112
    111113    /**
    112      * Checks if {@see ChangesetDataSetEntry} conforms to current RevertType
     114     * Checks if {@link ChangesetDataSetEntry} conforms to current RevertType
    113115     * @param entry entry to be checked
    114      * @return <code>true</code> if {@see ChangesetDataSetEntry} conforms to current RevertType
     116     * @return <code>true</code> if {@link ChangesetDataSetEntry} conforms to current RevertType
    115117     */
    116118    private boolean checkOsmChangeEntry(ChangesetDataSetEntry entry) {
     
    128130     * creates a reverter for specific changeset and fetches initial data
    129131     * @param changesetId changeset id
     132     * @param revertType type of revert
     133     * @param newLayer set to true if a new layer should be created
    130134     * @param monitor progress monitor
    131135     * @throws OsmTransferException if data transfer errors occur
     
    185189    }
    186190
    187     private void readObjectVersion(OsmServerMultiObjectReader rdr, PrimitiveId id, int version, ProgressMonitor progressMonitor)
     191    private static void readObjectVersion(OsmServerMultiObjectReader rdr, PrimitiveId id, int version, ProgressMonitor progressMonitor)
    188192            throws OsmTransferException {
    189193        boolean readOK = false;
     
    214218     * @throws OsmTransferException if data transfer errors occur
    215219     */
    216     @SuppressWarnings("unchecked")
    217220    public void downloadObjectsHistory(ProgressMonitor progressMonitor) throws OsmTransferException {
    218221        final OsmServerMultiObjectReader rdr = new OsmServerMultiObjectReader();
     
    220223        progressMonitor.beginTask(tr("Downloading objects history"), updated.size()+deleted.size()+1);
    221224        try {
    222             for (HashSet<HistoryOsmPrimitive> collection : Arrays.asList(new HashSet[]{updated, deleted})) {
     225            for (HashSet<HistoryOsmPrimitive> collection : Arrays.asList(updated, deleted)) {
    223226                for (HistoryOsmPrimitive entry : collection) {
    224227                    PrimitiveId id = entry.getPrimitiveId();
     
    279282    }
    280283
    281     private static Conflict<? extends OsmPrimitive> CreateConflict(OsmPrimitive p, boolean isMyDeleted) {
     284    private static Conflict<? extends OsmPrimitive> createConflict(OsmPrimitive p, boolean isMyDeleted) {
    282285        switch (p.getType()) {
    283286        case NODE:
     
    337340    /**
    338341     * Builds a list of commands that will revert the changeset
     342     * @return list of commands
    339343     *
    340344     */
     
    390394                    /* Don't create conflict if the object has to be deleted but has already been deleted */
    391395                    && !(toDelete.contains(dp) && dp.isDeleted())) {
    392                 cmds.add(new ConflictAddCommand(layer.data, CreateConflict(dp,
     396                cmds.add(new ConflictAddCommand(layer.data, createConflict(dp,
    393397                        entry.getModificationType() == ChangesetModificationType.CREATED)));
    394398                conflicted.add(dp);
     
    412416                               */
    413417                if (!conflicted.contains(p)) {
    414                     cmds.add(new ConflictAddCommand(layer.data, CreateConflict(p, true)));
     418                    cmds.add(new ConflictAddCommand(layer.data, createConflict(p, true)));
    415419                    conflicted.add(p);
    416420                }
     
    421425
    422426        // Create a Command to delete all marked objects
    423         List<? extends OsmPrimitive> list;
    424         list = OsmPrimitive.getFilteredList(toDelete, Relation.class);
    425         if (!list.isEmpty()) cmds.add(new DeleteCommand(list));
    426         list = OsmPrimitive.getFilteredList(toDelete, Way.class);
    427         if (!list.isEmpty()) cmds.add(new DeleteCommand(list));
    428         list = OsmPrimitive.getFilteredList(toDelete, Node.class);
    429         if (!list.isEmpty()) cmds.add(new DeleteCommand(list));
     427        Collection<? extends OsmPrimitive> collection;
     428        collection = Utils.filteredCollection(toDelete, Relation.class);
     429        if (!collection.isEmpty()) cmds.add(new DeleteCommand(collection));
     430        collection = Utils.filteredCollection(toDelete, Way.class);
     431        if (!collection.isEmpty()) cmds.add(new DeleteCommand(collection));
     432        collection = Utils.filteredCollection(toDelete, Node.class);
     433        if (!collection.isEmpty()) cmds.add(new DeleteCommand(collection));
    430434        return cmds;
    431435    }
  • applications/editors/josm/plugins/reverter/src/reverter/DataSetCommandMerger.java

    r33572 r34917  
    2323
    2424/**
    25  * Modified {@see org.openstreetmap.josm.data.osm.DataSetMerger} that
     25 * Modified {@link org.openstreetmap.josm.data.osm.DataSetMerger} that
    2626 * produces list of commands instead of directly merging layers.
    2727 *
     
    4040    /**
    4141     * constructor
     42     * @param sourceDataSet the source Dataset for the merge
     43     * @param targetDataSet the target Dataset for the merge
    4244     */
    4345    DataSetCommandMerger(DataSet sourceDataSet, DataSet targetDataSet) {
     
    6567    }
    6668
    67     private void mergePrimitive(OsmPrimitive source, OsmPrimitive target, OsmPrimitive newTarget) {
     69    private static void mergePrimitive(OsmPrimitive source, OsmPrimitive target, OsmPrimitive newTarget) {
    6870        newTarget.mergeFrom(source);
    6971        newTarget.setOsmId(target.getId(), target.getVersion());
  • applications/editors/josm/plugins/reverter/src/reverter/MultiOsmReader.java

    r32905 r34917  
    1414
    1515/**
    16  * Subclass of {@see org.openstreetmap.josm.io.OsmReader} that can handle multiple XML streams.
     16 * Subclass of {@link org.openstreetmap.josm.io.OsmReader} that can handle multiple XML streams.
    1717 *
    1818 */
  • applications/editors/josm/plugins/reverter/src/reverter/OsmServerMultiObjectReader.java

    r32905 r34917  
    1414import org.openstreetmap.josm.io.OsmServerReader;
    1515import org.openstreetmap.josm.io.OsmTransferException;
    16 import org.xml.sax.SAXException;
    1716
    1817public class OsmServerMultiObjectReader extends OsmServerReader {
     
    2423
    2524    public void readObject(long id, int version, OsmPrimitiveType type, ProgressMonitor progressMonitor) throws OsmTransferException {
    26         StringBuffer sb = new StringBuffer();
     25        StringBuilder sb = new StringBuilder();
    2726        sb.append(type.getAPIName());
    2827        sb.append("/");
     
    4342     * Method to parse downloaded objects
    4443     * @return the data requested
    45      * @throws SAXException in case of SAX error
    46      * @throws IOException in case of I/O error
     44     * @throws OsmTransferException in case of error
    4745     */
    4846    @Override
  • applications/editors/josm/plugins/reverter/src/reverter/ReverterPlugin.java

    r33572 r34917  
    1111import org.openstreetmap.josm.plugins.PluginInformation;
    1212
     13/**
     14 * The reverter plugin
     15 */
    1316public class ReverterPlugin extends Plugin {
    14     static boolean reverterUsed = false;
     17    static boolean reverterUsed;
     18
     19    /**
     20     * Constructs a new {@code ReverterPlugin}.
     21     * @param info plugin information
     22     */
    1523    public ReverterPlugin(PluginInformation info) {
    1624        super(info);
    1725        JMenu historyMenu = MainApplication.getMenu().dataMenu;
    18         //MainMenu.add(historyMenu, new ObjectsHistoryAction());
    1926        MainMenu.add(historyMenu, new RevertChangesetAction());
    2027        UploadAction.registerUploadHook(new ReverterUploadHook(this));
  • applications/editors/josm/plugins/reverter/src/reverter/corehacks/ChangesetDataSet.java

    r32905 r34917  
    166166
    167167    /**
    168      * Replies the {@see HistoryOsmPrimitive} with id <code>id</code> from this
     168     * Replies the {@link HistoryOsmPrimitive} with id <code>id</code> from this
    169169     * dataset. null, if there is no such primitive in the data set.
    170170     *
    171171     * @param id the id
    172      * @return  the {@see HistoryOsmPrimitive} with id <code>id</code> from this
     172     * @return  the {@link HistoryOsmPrimitive} with id <code>id</code> from this
    173173     * dataset
    174174     */
  • applications/editors/josm/plugins/reverter/src/reverter/corehacks/OsmServerChangesetReader.java

    r34271 r34917  
    5454     * @param query  the query specification. Must not be null.
    5555     * @param monitor a progress monitor. Set to {@link NullProgressMonitor#INSTANCE} if null
    56      * @return the list of changesets read from the server
     56     * @return the list of changesets read from the server or {@code null}
    5757     * @throws IllegalArgumentException thrown if query is null
    5858     * @throws OsmTransferException thrown if something goes wrong w
     
    6565        try {
    6666            monitor.beginTask(tr("Reading changesets..."));
    67             StringBuffer sb = new StringBuffer();
     67            StringBuilder sb = new StringBuilder();
    6868            sb.append("changesets?").append(query.getQueryString());
    6969            InputStream in = getInputStream(sb.toString(), monitor.createSubTaskMonitor(1, true));
     
    9898        try {
    9999            monitor.beginTask(tr("Reading changeset {0} ...", id));
    100             StringBuffer sb = new StringBuffer();
     100            StringBuilder sb = new StringBuilder();
    101101            sb.append("changeset/").append(id);
    102102            InputStream in = getInputStream(sb.toString(), monitor.createSubTaskMonitor(1, true));
     
    120120     * Reads the changeset with id <code>id</code> from the server
    121121     *
    122      * @param ids  the list of ids. Ignored if null. Only load changesets for ids &gt; 0.
     122     * @param ids  the collection of ids. Ignored if null. Only load changesets for ids &gt; 0.
    123123     * @param monitor the progress monitor. Set to {@link NullProgressMonitor#INSTANCE} if null
    124      * @return the changeset read
     124     * @return the list of changesets read or an empty list or null in case of errors
    125125     * @throws OsmTransferException thrown if something goes wrong
    126126     * @throws IllegalArgumentException if id &lt;= 0
     
    143143                }
    144144                i++;
    145                 StringBuffer sb = new StringBuffer();
     145                StringBuilder sb = new StringBuilder();
    146146                sb.append("changeset/").append(id);
    147147                InputStream in = getInputStream(sb.toString(), monitor.createSubTaskMonitor(1, true));
     
    175175     * @throws OsmTransferException thrown if something went wrong
    176176     */
    177     public ChangesetDataSet downloadChangeset(int id, ProgressMonitor monitor) throws IllegalArgumentException, OsmTransferException {
     177    public ChangesetDataSet downloadChangeset(int id, ProgressMonitor monitor) throws OsmTransferException {
    178178        if (id <= 0)
    179179            throw new IllegalArgumentException(
     
    184184        try {
    185185            monitor.beginTask(tr("Downloading changeset content"));
    186             StringBuffer sb = new StringBuffer();
     186            StringBuilder sb = new StringBuilder();
    187187            sb.append("changeset/").append(id).append("/download");
    188188            InputStream in = getInputStream(sb.toString(), monitor.createSubTaskMonitor(1, true));
     
    191191            monitor.setCustomText(tr("Downloading content for changeset {0} ...", id));
    192192            OsmChangesetContentParser parser = new OsmChangesetContentParser(in);
    193             ChangesetDataSet ds = parser.parse(monitor.createSubTaskMonitor(1, true));
    194             return ds;
    195         } catch (UnsupportedEncodingException e) {
    196             throw new OsmTransferException(e);
    197         } catch (XmlParsingException e) {
     193            return parser.parse(monitor.createSubTaskMonitor(1, true));
     194        } catch (UnsupportedEncodingException | XmlParsingException e) {
    198195            throw new OsmTransferException(e);
    199196        } finally {
Note: See TracChangeset for help on using the changeset viewer.