Changeset 7436 in josm for trunk/src/org/openstreetmap/josm


Ignore:
Timestamp:
2014-08-20T14:36:08+02:00 (10 years ago)
Author:
Don-vip
Message:

global use of Utils.copyArray()

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

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/command/SequenceCommand.java

    r7005 r7436  
    1212import org.openstreetmap.josm.data.osm.OsmPrimitive;
    1313import org.openstreetmap.josm.tools.ImageProvider;
     14import org.openstreetmap.josm.tools.Utils;
    1415
    1516/**
     
    6970        return sequence[sequence.length-1];
    7071    }
    71    
     72
    7273    protected final void undoCommands(int start) {
    7374        // We probably aborted this halfway though the
     
    114115        return prims;
    115116    }
    116    
     117
    117118    protected final void setSequence(Command[] sequence) {
    118         this.sequence = Arrays.copyOf(sequence, sequence.length);
     119        this.sequence = Utils.copyArray(sequence);
    119120    }
    120    
     121
    121122    protected final void setSequenceComplete(boolean sequenceComplete) {
    122123        this.sequenceComplete = sequenceComplete;
  • trunk/src/org/openstreetmap/josm/data/osm/Storage.java

    r7005 r7436  
    33
    44import java.util.AbstractSet;
    5 import java.util.Arrays;
    65import java.util.Collection;
    76import java.util.ConcurrentModificationException;
     
    109import java.util.NoSuchElementException;
    1110import java.util.Set;
     11
     12import org.openstreetmap.josm.tools.Utils;
    1213
    1314/**
     
    148149    private void copyArray() {
    149150        if (arrayCopyNecessary) {
    150             data = Arrays.copyOf(data, data.length);
     151            data = Utils.copyArray(data);
    151152            arrayCopyNecessary = false;
    152153        }
  • trunk/src/org/openstreetmap/josm/data/validation/OsmValidator.java

    r7335 r7436  
    270270     */
    271271    public static Class<Test>[] getAllAvailableTests() {
    272         return Arrays.copyOf(allAvailableTests, allAvailableTests.length);
     272        return Utils.copyArray(allAvailableTests);
    273273    }
    274274
  • trunk/src/org/openstreetmap/josm/gui/mappaint/MapPaintStyles.java

    r7276 r7436  
    342342        if (!canMoveStyles(sel, delta))
    343343            return;
    344         int[] selSorted = Arrays.copyOf(sel, sel.length);
     344        int[] selSorted = Utils.copyArray(sel);
    345345        Arrays.sort(selSorted);
    346346        List<StyleSource> data = new ArrayList<>(styles.getStyleSources());
     
    361361        if (sel.length == 0)
    362362            return false;
    363         int[] selSorted = Arrays.copyOf(sel, sel.length);
     363        int[] selSorted = Utils.copyArray(sel);
    364364        Arrays.sort(selSorted);
    365365
  • trunk/src/org/openstreetmap/josm/gui/preferences/projection/PuwgProjectionChoice.java

    r7025 r7436  
    44import static org.openstreetmap.josm.tools.I18n.tr;
    55
    6 import java.util.Arrays;
    76import java.util.Collection;
    87import java.util.Collections;
     8
     9import org.openstreetmap.josm.tools.Utils;
    910
    1011public class PuwgProjectionChoice extends ListProjectionChoice {
     
    4647    @Override
    4748    public String[] allCodes() {
    48         return Arrays.copyOf(CODES, CODES.length);
     49        return Utils.copyArray(CODES);
    4950    }
    5051
  • trunk/src/org/openstreetmap/josm/tools/Utils.java

    r7423 r7436  
    311311
    312312    /**
     313     * Copies the given array. Unlike {@link Arrays#copyOf}, this method is null-safe.
     314     * @param array The array to copy
     315     * @return A copy of the original array, or {@code null} if {@code array} is null
     316     * @since 7436
     317     */
     318    public static int[] copyArray(int[] array) {
     319        if (array != null) {
     320            return Arrays.copyOf(array, array.length);
     321        }
     322        return null;
     323    }
     324
     325    /**
    313326     * Simple file copy function that will overwrite the target file.<br>
    314327     * @param in The source file
Note: See TracChangeset for help on using the changeset viewer.