|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.openstreetmap.josm.data.osm.TagCollection
public class TagCollection
TagCollection is a collection of tags which can be used to manipulate
tags managed by OsmPrimitive
s.
A TagCollection can be created:
OsmPrimitive
with #from(OsmPrimitive)
OsmPrimitive
s with unionOfAllPrimitives(Collection)
DataSet
with unionOfAllPrimitives(DataSet)
commonToAllPrimitives(Collection)
size()
, hasTagsFor(String)
, etc.
Basic set operations allow to create the union, the intersection and the difference
of tag collections, see union(TagCollection)
, intersect(TagCollection)
,
and minus(TagCollection)
.
Field Summary | |
---|---|
private java.util.HashSet<Tag> |
tags
|
Constructor Summary | |
---|---|
TagCollection()
Creates an empty tag collection |
|
TagCollection(TagCollection other)
Creates a clone of the tag collection other . |
Method Summary | |
---|---|
void |
add(java.util.Collection<Tag> tags)
Adds a collection of tags to the tag collection. |
void |
add(Tag tag)
Adds a tag to the tag collection. |
void |
add(TagCollection tags)
Adds the tags of another tag collection to this collection. |
void |
applyTo(java.util.Collection<? extends Tagged> primitives)
Applies this tag collection to a collection of OsmPrimitive s. |
void |
applyTo(Tagged primitive)
Applies this tag collection to an OsmPrimitive . |
java.util.List<Tag> |
asList()
Replies the tags of this tag collection as list. |
java.util.Set<Tag> |
asSet()
Replies the tags of this tag collection as set |
static TagCollection |
commonToAllPrimitives(java.util.Collection<? extends Tagged> primitives)
Replies a tag collection with the tags which are common to all primitives in in primitives . |
boolean |
contains(Tag tag)
Replies true if the this tag collection contains tag . |
boolean |
containsAll(java.util.Collection<Tag> tags)
Replies true if this tag collection contains all tags in tags . |
boolean |
containsAllKeys(java.util.Collection<java.lang.String> keys)
Replies true if this tag collection at least one tag for every key in keys . |
boolean |
containsKey(java.lang.String key)
Replies true if this tag collection contains at least one tag with key key . |
TagCollection |
emptyTagsForKeysMissingIn(TagCollection other)
|
static TagCollection |
from(java.util.Map<java.lang.String,java.lang.String> tags)
Creates a tag collection from a map of key/value-pairs. |
static TagCollection |
from(Tagged primitive)
Creates a tag collection from the tags managed by a specific OsmPrimitive . |
java.lang.String |
getJoinedValues(java.lang.String key)
Replies the concatenation of all tag values (concatenated by a semicolon) |
java.util.Set<java.lang.String> |
getKeys()
Replies the set of keys of this tag collection. |
java.util.Set<java.lang.String> |
getKeysWithMultipleValues()
Replies the set of keys which have at least 2 matching tags. |
int |
getNumTagsFor(java.lang.String key)
Replies the number of tags with key key |
TagCollection |
getTagsFor(java.util.Collection<java.lang.String> keys)
Replies a tag collection with all tags whose key is equal to one of the keys in keys . |
TagCollection |
getTagsFor(java.lang.String key)
Replies a tag collection with the tags for a given key. |
java.util.Set<java.lang.String> |
getValues()
Replies the set of values in this tag collection |
java.util.Set<java.lang.String> |
getValues(java.lang.String key)
Replies the set of values for a given key. |
boolean |
hasEmptyValue(java.lang.String key)
Replies true if there is a tag with an empty value for key . |
boolean |
hasTagsFor(java.lang.String key)
Replies true if there is at least one tag for the given key. |
boolean |
hasUniqueEmptyValue(java.lang.String key)
Replies true if there is exactly one tag for key and if
the value for this tag is empty. |
boolean |
hasUniqueNonEmptyValue(java.lang.String key)
Replies true if there is exactly one tag for key and
if the value of this tag is not empty. |
boolean |
hasValuesFor(java.lang.String key)
Replies true it there is at least one tag with a non empty value for key. |
TagCollection |
intersect(TagCollection other)
Builds the intersection of this tag collection and another tag collection |
boolean |
isApplicableToPrimitive()
Replies true if for every key there is one tag only, i.e. |
boolean |
isEmpty()
Replies true if this tag collection is empty |
java.util.Iterator<Tag> |
iterator()
Replies an iterator to iterate over the tags in this collection |
TagCollection |
minus(TagCollection other)
Replies the difference of this tag collection and another tag collection |
void |
remove(java.util.Collection<Tag> tags)
Removes a collection of tags from the tag collection. |
void |
remove(Tag tag)
Removes a specific tag from the tag collection. |
void |
remove(TagCollection tags)
Removes all tags in the tag collection tags from the current tag collection. |
void |
removeByKey(java.util.Collection<java.lang.String> keys)
Removes all tags whose key is in the collection keys . |
void |
removeByKey(java.lang.String key)
Removes all tags whose keys are equal to key . |
void |
replaceTagsOf(java.util.Collection<? extends Tagged> primitives)
Replaces the tags of a collection of OsmPrimitive s by the tags in this collection. |
void |
replaceTagsOf(Tagged primitive)
Replaces the tags of an OsmPrimitive by the tags in this collection . |
void |
setUniqueForKey(java.lang.String key,
java.lang.String value)
Sets a unique tag for the key of this tag. |
void |
setUniqueForKey(Tag tag)
Sets a unique tag for the key of this tag. |
int |
size()
Replies the number of tags in this tag collection |
java.lang.String |
toString()
|
TagCollection |
union(TagCollection other)
Replies the union of this tag collection and another tag collection |
static TagCollection |
unionOfAllPrimitives(java.util.Collection<? extends Tagged> primitives)
Creates a tag collection from the union of the tags managed by a collection of primitives. |
static TagCollection |
unionOfAllPrimitives(DataSet ds)
Replies a tag collection with the union of the tags which are common to all primitives in the dataset ds . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private final java.util.HashSet<Tag> tags
Constructor Detail |
---|
public TagCollection()
public TagCollection(TagCollection other)
other
. Creats an empty
tag collection if other
is null.
other
- the other collectionMethod Detail |
---|
public static TagCollection from(Tagged primitive)
OsmPrimitive
. If primitive
is null, replies
an empty tag collection.
primitive
- the primitive
OsmPrimitive
public static TagCollection from(java.util.Map<java.lang.String,java.lang.String> tags)
tags
is null.
tags
- the key/value-pairs
public static TagCollection unionOfAllPrimitives(java.util.Collection<? extends Tagged> primitives)
primitives
is null.
primitives
- the primitives
public static TagCollection commonToAllPrimitives(java.util.Collection<? extends Tagged> primitives)
primitives
. Replies an empty tag collection of primitives
is null.
primitives
- the primitives
public static TagCollection unionOfAllPrimitives(DataSet ds)
ds
. Returns an empty tag collection of ds
is null.
ds
- the dataset
ds
public int size()
public boolean isEmpty()
public void add(Tag tag)
tag
is null, nothing is added.
tag
- the tag to addpublic void add(java.util.Collection<Tag> tags)
tags
is null, nothing
is added. null values in the collection are ignored.
tags
- the collection of tagspublic void add(TagCollection tags)
tags
is null.
tags
- the other tag collectionpublic void remove(Tag tag)
tag
is
null.
tag
- the tag to be removedpublic void remove(java.util.Collection<Tag> tags)
tags
is
null.
tags
- the tags to be removedpublic void remove(TagCollection tags)
tags
from the current tag collection.
Does nothing if tags
is null.
tags
- the tag collection to be removed.public void removeByKey(java.lang.String key)
key
. Does nothing if key
is null.
key
- the key to be removedpublic void removeByKey(java.util.Collection<java.lang.String> keys)
keys
. Does nothing if
keys
is null.
keys
- the collection of keys to be removedpublic boolean contains(Tag tag)
tag
.
tag
- the tag to look up
tag
; false, otherwisepublic boolean containsKey(java.lang.String key)
key
.
key
- the key to look up
key
; false, otherwisepublic boolean containsAll(java.util.Collection<Tag> tags)
tags
. Replies
false, if tags is null.
tags
- the tags to look up
tags
. Replies
false, if tags is null.public boolean containsAllKeys(java.util.Collection<java.lang.String> keys)
keys
.
Replies false, if keys
is null. null values in keys
are ignored.
keys
- the keys to lookup
keys
.public int getNumTagsFor(java.lang.String key)
key
key
- the key to look up
key
. 0, if key is null.public boolean hasTagsFor(java.lang.String key)
key
- the key to look up
public boolean hasValuesFor(java.lang.String key)
key
- the key
public boolean hasUniqueNonEmptyValue(java.lang.String key)
key
and
if the value of this tag is not empty. Replies false if key is
null.
key
- the key
key
and
if the value of this tag is not emptypublic boolean hasEmptyValue(java.lang.String key)
key
.
Replies false, if key is null.
key
- the key
key
public boolean hasUniqueEmptyValue(java.lang.String key)
key
and if
the value for this tag is empty. Replies false if key is null.
key
- the key
key
and if
the value for this tag is emptypublic TagCollection getTagsFor(java.lang.String key)
key
- the key to look up
public TagCollection getTagsFor(java.util.Collection<java.lang.String> keys)
keys
. Replies an empty collection if keys is null.
keys
- the keys to look up
keys
public java.util.Set<Tag> asSet()
public java.util.List<Tag> asList()
public java.util.Iterator<Tag> iterator()
iterator
in interface java.lang.Iterable<Tag>
public java.util.Set<java.lang.String> getKeys()
public java.util.Set<java.lang.String> getKeysWithMultipleValues()
public void setUniqueForKey(Tag tag)
tag
- the tag to setpublic void setUniqueForKey(java.lang.String key, java.lang.String value)
key
- the keyvalue
- the valuepublic java.util.Set<java.lang.String> getValues()
public java.util.Set<java.lang.String> getValues(java.lang.String key)
key
- the key to look up
public boolean isApplicableToPrimitive()
public void applyTo(Tagged primitive) throws java.lang.IllegalStateException
OsmPrimitive
. Does nothing if
primitive is null
primitive
- the primitive
java.lang.IllegalStateException
- thrown if this tag collection can't be applied
because there are keys with multiple valuespublic void applyTo(java.util.Collection<? extends Tagged> primitives) throws java.lang.IllegalStateException
OsmPrimitive
s. Does nothing if
primitives is null
primitives
- the collection of primitives
java.lang.IllegalStateException
- thrown if this tag collection can't be applied
because there are keys with multiple valuespublic void replaceTagsOf(Tagged primitive) throws java.lang.IllegalStateException
OsmPrimitive
by the tags in this collection . Does nothing if
primitive is null
primitive
- the primitive
java.lang.IllegalStateException
- thrown if this tag collection can't be applied
because there are keys with multiple valuespublic void replaceTagsOf(java.util.Collection<? extends Tagged> primitives) throws java.lang.IllegalStateException
OsmPrimitive
s by the tags in this collection.
Does nothing if primitives is null
primitive
- the collection of primitives
java.lang.IllegalStateException
- thrown if this tag collection can't be applied
because there are keys with multiple valuespublic TagCollection intersect(TagCollection other)
other
- the other tag collection. If null, replies an empty tag collection.
public TagCollection minus(TagCollection other)
other
- the other tag collection. May be null.
public TagCollection union(TagCollection other)
other
- the other tag collection. May be null.
public TagCollection emptyTagsForKeysMissingIn(TagCollection other)
public java.lang.String getJoinedValues(java.lang.String key)
public java.lang.String toString()
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |