- Timestamp:
- 2021-05-01T21:50:00+02:00 (4 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/gpx/GpxExtensionCollection.java
r16913 r17846 23 23 private static final long serialVersionUID = 1L; 24 24 25 private final Stack<GpxExtension> childStack = new Stack<>();25 private Stack<GpxExtension> childStack; 26 26 private IWithAttributes parent; 27 27 … … 47 47 */ 48 48 public void openChild(String namespaceURI, String qName, Attributes atts) { 49 if (childStack == null) { 50 childStack = new Stack<>(); 51 } 49 52 GpxExtension child = new GpxExtension(namespaceURI, qName, atts); 50 53 if (!childStack.isEmpty()) { … … 63 66 */ 64 67 public void closeChild(String qName, String value) { 65 if (childStack .isEmpty())68 if (childStack == null || childStack.isEmpty()) 66 69 throw new InvalidArgumentException("Can't close child " + qName + ", no element in stack."); 67 70 … … 259 262 @Override 260 263 public void clear() { 261 childStack.clear(); 264 if (childStack != null) { 265 childStack.clear(); 266 childStack = null; 267 } 262 268 super.clear(); 263 269 } -
trunk/src/org/openstreetmap/josm/data/gpx/GpxTrack.java
r16436 r17846 105 105 106 106 private Color getColorFromExtension() { 107 if (!hasExtensions()) { 108 return null; 109 } 107 110 GpxExtension gpxd = getExtensions().find("gpxd", "color"); 108 111 if (gpxd != null) { -
trunk/src/org/openstreetmap/josm/data/gpx/IWithAttributes.java
r15496 r17846 58 58 59 59 /** 60 * Returns whether the {@link GpxExtensionCollection} instance has been created yet, should be overridden. 61 * The instance will usually be created on first call of {@link #getExtensions()}. 62 * @return whether the {@link GpxExtensionCollection} instance has been created yet 63 */ 64 default boolean hasExtensions() { 65 return getExtensions() != null; 66 } 67 68 /** 60 69 * Returns the extensions 61 70 * @return the extensions -
trunk/src/org/openstreetmap/josm/data/gpx/WithAttributes.java
r15496 r17846 25 25 * The "exts" collection contains all extensions. 26 26 */ 27 private final GpxExtensionCollection exts = new GpxExtensionCollection(this);27 private GpxExtensionCollection exts; 28 28 29 29 /** … … 87 87 88 88 @Override 89 public boolean hasExtensions() { 90 return exts != null; 91 } 92 93 @Override 89 94 public GpxExtensionCollection getExtensions() { 95 if (exts == null) { 96 exts = new GpxExtensionCollection(this); 97 } 90 98 return exts; 91 99 } -
trunk/src/org/openstreetmap/josm/io/GpxReader.java
r17748 r17846 507 507 if (!currentTrackSeg.isEmpty()) { 508 508 GpxTrackSegment seg = new GpxTrackSegment(currentTrackSeg); 509 seg.getExtensions().addAll(currentExtensionCollection); 509 if (!currentExtensionCollection.isEmpty()) { 510 seg.getExtensions().addAll(currentExtensionCollection); 511 } 510 512 currentTrack.add(seg); 511 513 } … … 519 521 convertUrlToLink(currentTrackAttr); 520 522 GpxTrack trk = new GpxTrack(new ArrayList<>(currentTrack), currentTrackAttr); 521 trk.getExtensions().addAll(currentTrackExtensionCollection); 523 if (!currentTrackExtensionCollection.isEmpty()) { 524 trk.getExtensions().addAll(currentTrackExtensionCollection); 525 } 522 526 data.addTrack(trk); 523 527 currentTrackExtensionCollection.clear();
Note:
See TracChangeset
for help on using the changeset viewer.