Changeset 5724 in josm for trunk/src/org/openstreetmap/josm/data/osm/TagCollection.java
- Timestamp:
- 2013-02-17T15:01:13+01:00 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/TagCollection.java
r5266 r5724 24 24 * A TagCollection can be created: 25 25 * <ul> 26 * <li>from the tags managed by a specific {@link OsmPrimitive} with {@link #from( OsmPrimitive)}</li>26 * <li>from the tags managed by a specific {@link OsmPrimitive} with {@link #from(Tagged)}</li> 27 27 * <li>from the union of all tags managed by a collection of {@link OsmPrimitive}s with {@link #unionOfAllPrimitives(Collection)}</li> 28 28 * <li>from the union of all tags managed by a {@link DataSet} with {@link #unionOfAllPrimitives(DataSet)}</li> … … 51 51 public static TagCollection from(Tagged primitive) { 52 52 TagCollection tags = new TagCollection(); 53 for (String key: primitive.keySet()) { 54 tags.add(new Tag(key, primitive.get(key))); 53 if (primitive != null) { 54 for (String key: primitive.keySet()) { 55 tags.add(new Tag(key, primitive.get(key))); 56 } 55 57 } 56 58 return tags; … … 158 160 159 161 /** 162 * Creates a tag collection from <code>tags</code>. 163 * @param tags the collection of tags 164 * @since 5724 165 */ 166 public TagCollection(Collection<Tag> tags) { 167 add(tags); 168 } 169 170 /** 160 171 * Replies the number of tags in this tag collection 161 172 * … … 637 648 * Does nothing if primitives is null 638 649 * 639 * @param primitive 650 * @param primitives the collection of primitives 640 651 * @throws IllegalStateException thrown if this tag collection can't be applied 641 652 * because there are keys with multiple values … … 657 668 */ 658 669 public TagCollection intersect(TagCollection other) { 659 if (other == null) { 660 other = new TagCollection(); 661 } 662 TagCollection ret = new TagCollection(this); 663 for (Tag tag: tags) { 664 if (other.contains(tag)) { 665 ret.add(tag); 670 TagCollection ret = new TagCollection(); 671 if (other != null) { 672 for (Tag tag: tags) { 673 if (other.contains(tag)) { 674 ret.add(tag); 675 } 666 676 } 667 677 }
Note:
See TracChangeset
for help on using the changeset viewer.