Class AbstractPrimitive
- java.lang.Object
-
- org.openstreetmap.josm.data.osm.AbstractPrimitive
-
- All Implemented Interfaces:
java.lang.Comparable<IPrimitive>
,IQuadBucketType
,IFilterablePrimitive
,IPrimitive
,PrimitiveId
,Stylable
,Tagged
- Direct Known Subclasses:
OsmPrimitive
,PrimitiveData
,VectorPrimitive
public abstract class AbstractPrimitive extends java.lang.Object implements IPrimitive, IFilterablePrimitive
Abstract class to represent common features of the datatypes primitives.- Since:
- 4099
-
-
Field Summary
Fields Modifier and Type Field Description protected int
changesetId
The id of the changeset this primitive was last uploaded to.private static java.util.Collection<java.lang.String>
discardable
protected static short
FLAG_ALL_REFERRERS_DOWNLOADED
Determines if the primitive has all of its referrersprotected static short
FLAG_ANNOTATED
If the primitive is annotated with a tag such as note, fixme, etc.protected static short
FLAG_DELETED
An object that was deleted by the user.protected static short
FLAG_DIRECTION_REVERSED
This flag is only relevant if FLAG_HAS_DIRECTIONS is set.protected static short
FLAG_DISABLED
An object can be disabled by the filter mechanism.protected static short
FLAG_DISABLED_TYPE
Flag used internally by the filter mechanism.protected static short
FLAG_HAS_DIRECTIONS
This flag is set if the primitive is a way and according to the tags, the direction of the way is important.protected static short
FLAG_HIDDEN_TYPE
Flag used internally by the filter mechanism.protected static short
FLAG_HIDE_IF_DISABLED
This flag is only relevant if an object is disabled by the filter mechanism (i.e. FLAG_DISABLED is set).protected static short
FLAG_HIGHLIGHTED
When hovering over ways and nodes in add mode, the "target" objects are visually highlighted.protected static short
FLAG_INCOMPLETE
A primitive is incomplete if we know its id and type, but nothing more.protected static short
FLAG_MODIFIED
This flag shows, that the properties have been changed by the user and on upload the object will be send to the server.protected static short
FLAG_PRESERVED
Determines if the primitive is preserved from the filter mechanism.protected static short
FLAG_TAGGED
If the primitive is tagged.protected static short
FLAG_VISIBLE
This flag is false, if the object is marked as deleted on the server.protected short
flags
Put several boolean flags to one short int field to save memory.protected long
id
Unique identifier in OSM.protected java.lang.String[]
keys
The key/value list for this primitive.protected short
mappaintCacheIdx
The mappaint cache index for this primitive.protected int
timestamp
A time value, measured in seconds from the epoch, or in other words, a number of seconds that have passed since 1970-01-01T00:00:00Zprivate static java.util.Collection<java.lang.String>
uninteresting
protected User
user
User that last modified this primitive, as specified by the server.protected int
version
Contains the version number as returned by the API.private static java.util.Collection<java.lang.String>
workinprogress
-
Fields inherited from interface org.openstreetmap.josm.data.osm.Tagged
MAX_TAG_LENGTH
-
-
Constructor Summary
Constructors Constructor Description AbstractPrimitive()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
clearOsmMetadata()
Clears the metadata, including id and version known to the OSM API.void
cloneFrom(AbstractPrimitive other)
Get and write all attributes from the parameter.protected java.lang.String
doGet(java.lang.String key, java.util.function.BiPredicate<java.lang.String,java.lang.String> predicate)
java.lang.String
get(java.lang.String key)
Replies the value for keykey
.int
getChangesetId()
Replies the id of the changeset this primitive was last uploaded to.boolean
getDisabledType()
Get binary property used internally by the filter mechanism.static java.util.Collection<java.lang.String>
getDiscardableKeys()
Returns a list of keys which have been deemed uninteresting to the point that they can be silently removed from data which is being edited.protected java.lang.String
getFlagsAsString()
boolean
getHiddenType()
Get binary property used internally by the filter mechanism.long
getId()
Replies the id of this primitive.abstract UniqueIdGenerator
getIdGenerator()
Returns the unique identifier generator.java.lang.String
getIgnoreCase(java.lang.String key)
Gets a key ignoring the case of the keyjava.time.Instant
getInstant()
Time of last modification to this object.java.util.Map<java.lang.String,java.lang.String>
getInterestingTags()
ReturnsTagged.getKeys()
for whichkey
does not fulfill uninteresting criteria.TagMap
getKeys()
Replies the map of key/value pairs.int
getNumKeys()
Gets the number of keysint
getRawTimestamp()
Time of last modification to this object.java.util.Date
getTimestamp()
Deprecated.static java.util.Collection<java.lang.String>
getUninterestingKeys()
Returns a list of "uninteresting" keys that do not make an object "tagged".long
getUniqueId()
Gets a unique id representing this object.User
getUser()
Replies the user who has last touched this object.int
getVersion()
Replies the version number as returned by the API.static java.util.Collection<java.lang.String>
getWorkInProgressKeys()
Returns a list of "work in progress" keys that do not make an object "tagged" but "annotated".boolean
hasDirectionKeys()
true if this object has direction dependent tags (e.g.boolean
hasKey(java.lang.String key)
Replies true if this primitive has a tag with keykey
.boolean
hasKey(java.lang.String... keys)
Replies true if this primitive has a tag any of thekeys
.boolean
hasKeys()
Replies true, if the map of key/value pairs of this primitive is not empty.private static int
indexOfKey(java.lang.String[] keys, java.lang.String key)
Scans a key/value array for a given key.boolean
isAnnotated()
Determines if this object is considered "annotated".boolean
isDeleted()
Repliestrue
, if the object has been deleted.boolean
isDisabled()
Replies true, if this primitive is disabled.boolean
isDisabledAndHidden()
Replies true, if this primitive is disabled and marked as completely hidden on the map.boolean
isDrawable()
Determines if this object is drawable.boolean
isHighlighted()
Checks if the highlight flag for this primitive was setboolean
isIncomplete()
Determines if this primitive is incomplete.boolean
isModified()
Repliestrue
if the object has been modified since it was loaded from the server.boolean
isNew()
Determines if this primitive is new.boolean
isNewOrUndeleted()
Determines if this primitive is new or undeleted.boolean
isPreserved()
Replies true, if this primitive is preserved from filtering.boolean
isReferrersDownloaded()
Determines if this primitive is fully downloadedboolean
isTagged()
Determines if this object is considered "tagged".boolean
isTimestampEmpty()
Determines if this primitive has no timestamp information.boolean
isUndeleted()
Repliestrue
if the object has been deleted on the server and was undeleted by the user.static boolean
isUninterestingKey(java.lang.String key)
Determines if key is considered "uninteresting".boolean
isUsable()
Repliestrue
, if the object is usable (i.e.boolean
isVisible()
Checks if object is known to the server.java.util.stream.Stream<java.lang.String>
keys()
Replies the keys as streamprotected abstract void
keysChangedImpl(java.util.Map<java.lang.String,java.lang.String> originalKeys)
What to do, when the tags have changed by one of the tag-changing methods.java.util.Collection<java.lang.String>
keySet()
Replies the set of keysvoid
put(java.lang.String key, java.lang.String value)
Set the given value to the given key.void
putAll(java.util.Map<java.lang.String,java.lang.String> tags)
Add all key/value pairs.void
remove(java.lang.String key)
Remove the given key from the listvoid
removeAll()
Removes all keys from this primitive.boolean
reversedDirection()
true if this object has the "reversed direction" flag enabledvoid
setChangesetId(int changesetId)
Sets the changeset id of this primitive.void
setDeleted(boolean deleted)
Sets whether this primitive is deleted or not.boolean
setDisabledState(boolean hidden)
Make the primitive disabled (e.g. if a filter applies).void
setDisabledType(boolean isExplicit)
Set binary property used internally by the filter mechanism.void
setHiddenType(boolean isExplicit)
Set binary property used internally by the filter mechanism.protected void
setIncomplete(boolean incomplete)
If set to true, this object is incomplete, which means only the id and type is known (type is the objects instance class)void
setInstant(java.time.Instant timestamp)
Sets time of last modification to this objectvoid
setKeys(java.util.Map<java.lang.String,java.lang.String> keys)
Sets the keys of this primitives to the key/value pairs inkeys
.void
setKeys(TagMap keys)
Copy the keys from a TagMap.void
setModified(boolean modified)
Marks this primitive as being modified.void
setOsmId(long id, int version)
Sets the id and the version of this primitive if it is known to the OSM API.void
setRawTimestamp(int timestamp)
Sets time of last modification to this objectvoid
setReferrersDownloaded(boolean referrersDownloaded)
Set the status of the referrersvoid
setTimestamp(java.util.Date timestamp)
Deprecated.void
setUser(User user)
Sets the user who has last touched this object.void
setVisible(boolean visible)
Sets whether this primitive is visible, i.e.boolean
unsetDisabledState()
Remove the disabled flag from the primitive.protected void
updateFlags(short flag, boolean value)
protected boolean
updateFlagsChanged(short flag, boolean value)
Update flagsvoid
visitKeys(KeyValueVisitor visitor)
Calls the visitor for every key/value pair.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.openstreetmap.josm.data.osm.IPrimitive
accept, getBBox, getChildren, getDataSet, getDisplayName, getDisplayType, getLocalName, getName, getOsmId, getOsmPrimitiveId, getPrimitiveId, getReferrers, getReferrers, getStyleCacheSyncObject, hasSameInterestingTags, isMemberOfSelected, isMultipolygon, isOuterMemberOfSelected, isSelectable, isSelected, setHighlighted, visitReferrers
-
Methods inherited from interface org.openstreetmap.josm.data.osm.PrimitiveId
getType
-
Methods inherited from interface org.openstreetmap.josm.data.osm.Stylable
clearCachedStyle, declareCachedStyleUpToDate, getCachedStyle, isCachedStyleUpToDate, setCachedStyle
-
Methods inherited from interface org.openstreetmap.josm.data.osm.Tagged
hasTag, hasTag, hasTag, hasTag, hasTagDifferent, hasTagDifferent, hasTagDifferent, isKeyFalse, isKeyTrue, put
-
-
-
-
Field Detail
-
FLAG_MODIFIED
protected static final short FLAG_MODIFIED
This flag shows, that the properties have been changed by the user and on upload the object will be send to the server.- See Also:
- Constant Field Values
-
FLAG_VISIBLE
protected static final short FLAG_VISIBLE
This flag is false, if the object is marked as deleted on the server.- See Also:
- Constant Field Values
-
FLAG_DELETED
protected static final short FLAG_DELETED
An object that was deleted by the user. Deleted objects are usually hidden on the map and a request for deletion will be send to the server on upload. An object usually cannot be deleted if it has non-deleted objects still referring to it.- See Also:
- Constant Field Values
-
FLAG_INCOMPLETE
protected static final short FLAG_INCOMPLETE
A primitive is incomplete if we know its id and type, but nothing more. Typically some members of a relation are incomplete until they are fetched from the server.- See Also:
- Constant Field Values
-
FLAG_DISABLED
protected static final short FLAG_DISABLED
An object can be disabled by the filter mechanism. Then it will show in a shade of gray on the map or it is completely hidden from the view. Disabled objects usually cannot be selected or modified while the filter is active.- See Also:
- Constant Field Values
-
FLAG_HIDE_IF_DISABLED
protected static final short FLAG_HIDE_IF_DISABLED
This flag is only relevant if an object is disabled by the filter mechanism (i.e. FLAG_DISABLED is set). Then it indicates, whether it is completely hidden or just shown in gray color.When the primitive is not disabled, this flag should be unset as well (for efficient access).
- See Also:
- Constant Field Values
-
FLAG_DISABLED_TYPE
protected static final short FLAG_DISABLED_TYPE
Flag used internally by the filter mechanism.- See Also:
- Constant Field Values
-
FLAG_HIDDEN_TYPE
protected static final short FLAG_HIDDEN_TYPE
Flag used internally by the filter mechanism.- See Also:
- Constant Field Values
-
FLAG_HAS_DIRECTIONS
protected static final short FLAG_HAS_DIRECTIONS
This flag is set if the primitive is a way and according to the tags, the direction of the way is important. (e.g. one way street.)- See Also:
- Constant Field Values
-
FLAG_TAGGED
protected static final short FLAG_TAGGED
If the primitive is tagged. Some trivial tags like source=* are ignored here.- See Also:
- Constant Field Values
-
FLAG_DIRECTION_REVERSED
protected static final short FLAG_DIRECTION_REVERSED
This flag is only relevant if FLAG_HAS_DIRECTIONS is set. It shows, that direction of the arrows should be reversed. (E.g. oneway=-1.)- See Also:
- Constant Field Values
-
FLAG_HIGHLIGHTED
protected static final short FLAG_HIGHLIGHTED
When hovering over ways and nodes in add mode, the "target" objects are visually highlighted. This flag indicates that the primitive is currently highlighted.- See Also:
- Constant Field Values
-
FLAG_ANNOTATED
protected static final short FLAG_ANNOTATED
If the primitive is annotated with a tag such as note, fixme, etc. Match the "work in progress" tags in default map style.- See Also:
- Constant Field Values
-
FLAG_PRESERVED
protected static final short FLAG_PRESERVED
Determines if the primitive is preserved from the filter mechanism.- See Also:
- Constant Field Values
-
FLAG_ALL_REFERRERS_DOWNLOADED
protected static final short FLAG_ALL_REFERRERS_DOWNLOADED
Determines if the primitive has all of its referrers- See Also:
- Constant Field Values
-
flags
protected volatile short flags
Put several boolean flags to one short int field to save memory. Other bits of this field are used in subclasses.
-
mappaintCacheIdx
protected short mappaintCacheIdx
The mappaint cache index for this primitive. This field belongs toOsmPrimitive
, but due to Java's memory layout alignment, see #20830.
-
id
protected long id
Unique identifier in OSM. This is used to identify objects on the server. An id of 0 means an unknown id. The object has not been uploaded yet to know what id it will get.
-
user
protected User user
User that last modified this primitive, as specified by the server. Never changed by JOSM.
-
version
protected int version
Contains the version number as returned by the API. Needed to ensure update consistency
-
changesetId
protected int changesetId
The id of the changeset this primitive was last uploaded to. 0 if it wasn't uploaded to a changeset yet of if the changeset id isn't known.
-
timestamp
protected int timestamp
A time value, measured in seconds from the epoch, or in other words, a number of seconds that have passed since 1970-01-01T00:00:00Z
-
keys
protected volatile java.lang.String[] keys
The key/value list for this primitive.Note that the keys field is synchronized using RCU. Writes to it are not synchronized by this object, the writers have to synchronize writes themselves.
In short this means that you should not rely on this variable being the same value when read again and your should always copy it on writes.
Further reading:
CopyOnWriteArrayList
- http://stackoverflow.com/questions/2950871/how-can-copyonwritearraylist-be-thread-safe
-
https://en.wikipedia.org/wiki/Read-copy-update (mind that we have a Garbage collector,
rcu_assign_pointer
andrcu_dereference
are ensured by thevolatile
keyword)
-
workinprogress
private static volatile java.util.Collection<java.lang.String> workinprogress
-
uninteresting
private static volatile java.util.Collection<java.lang.String> uninteresting
-
discardable
private static volatile java.util.Collection<java.lang.String> discardable
-
-
Constructor Detail
-
AbstractPrimitive
public AbstractPrimitive()
-
-
Method Detail
-
cloneFrom
public void cloneFrom(AbstractPrimitive other)
Get and write all attributes from the parameter. Does not fire any listener, so use this only in the data initializing phase- Parameters:
other
- the primitive to clone data from
-
getVersion
public int getVersion()
Description copied from interface:IPrimitive
Replies the version number as returned by the API. The version is 0 if the id is 0 or if this primitive is incomplete.- Specified by:
getVersion
in interfaceIPrimitive
- Returns:
- the version number as returned by the API
- See Also:
PrimitiveData.setVersion(int)
-
getId
public long getId()
Description copied from interface:IPrimitive
Replies the id of this primitive.- Specified by:
getId
in interfaceIPrimitive
- Returns:
- the id of this primitive.
-
getUniqueId
public long getUniqueId()
Gets a unique id representing this object.- Specified by:
getUniqueId
in interfacePrimitiveId
- Returns:
- Osm id if primitive already exists on the server. Unique negative value if primitive is new
-
isNew
public boolean isNew()
Determines if this primitive is new.- Specified by:
isNew
in interfacePrimitiveId
- Returns:
true
if this primitive is new (not yet uploaded the server, id <= 0)
-
isNewOrUndeleted
public boolean isNewOrUndeleted()
Description copied from interface:IPrimitive
Determines if this primitive is new or undeleted.- Specified by:
isNewOrUndeleted
in interfaceIPrimitive
- Returns:
- True if primitive is new or undeleted
- See Also:
PrimitiveId.isNew()
,IPrimitive.isUndeleted()
-
setOsmId
public void setOsmId(long id, int version)
Description copied from interface:IPrimitive
Sets the id and the version of this primitive if it is known to the OSM API.Since we know the id and its version it can't be incomplete anymore. incomplete is set to false.
- Specified by:
setOsmId
in interfaceIPrimitive
- Parameters:
id
- the id. > 0 requiredversion
- the version > 0 required
-
clearOsmMetadata
public void clearOsmMetadata()
Clears the metadata, including id and version known to the OSM API. The id is a new unique id. The version, changeset and timestamp are set to 0. incomplete and deleted are set to false. It's preferred to use copy constructor with clearMetadata set to true instead of calling this method.- Since:
- 6140
-
getIdGenerator
public abstract UniqueIdGenerator getIdGenerator()
Returns the unique identifier generator.- Returns:
- the unique identifier generator
- Since:
- 15820
-
getUser
public User getUser()
Description copied from interface:IPrimitive
Replies the user who has last touched this object. May be null.- Specified by:
getUser
in interfaceIPrimitive
- Returns:
- the user who has last touched this object. May be null.
-
setUser
public void setUser(User user)
Description copied from interface:IPrimitive
Sets the user who has last touched this object.- Specified by:
setUser
in interfaceIPrimitive
- Parameters:
user
- the user
-
getChangesetId
public int getChangesetId()
Description copied from interface:IPrimitive
Replies the id of the changeset this primitive was last uploaded to. 0 if this primitive wasn't uploaded to a changeset yet or if the changeset isn't known.- Specified by:
getChangesetId
in interfaceIPrimitive
- Returns:
- the id of the changeset this primitive was last uploaded to.
-
setChangesetId
public void setChangesetId(int changesetId)
Description copied from interface:IPrimitive
Sets the changeset id of this primitive. Can't be set on a new primitive.- Specified by:
setChangesetId
in interfaceIPrimitive
- Parameters:
changesetId
- the id. >= 0 required.
-
setTimestamp
@Deprecated(since="17749") public void setTimestamp(java.util.Date timestamp)
Deprecated.Description copied from interface:IPrimitive
Sets time of last modification to this object- Specified by:
setTimestamp
in interfaceIPrimitive
- Parameters:
timestamp
- date of last modification- See Also:
IPrimitive.getTimestamp()
-
setInstant
public void setInstant(java.time.Instant timestamp)
Description copied from interface:IPrimitive
Sets time of last modification to this object- Specified by:
setInstant
in interfaceIPrimitive
- Parameters:
timestamp
- date of last modification- See Also:
IPrimitive.getInstant()
-
setRawTimestamp
public void setRawTimestamp(int timestamp)
Description copied from interface:IPrimitive
Sets time of last modification to this object- Specified by:
setRawTimestamp
in interfaceIPrimitive
- Parameters:
timestamp
- date of last modification- See Also:
IPrimitive.getRawTimestamp()
-
getTimestamp
@Deprecated(since="17749") public java.util.Date getTimestamp()
Deprecated.Description copied from interface:IPrimitive
Time of last modification to this object. This is not set by JOSM but read from the server and delivered back to the server unmodified. It is used to check against edit conflicts.- Specified by:
getTimestamp
in interfaceIPrimitive
- Returns:
- date of last modification
- See Also:
IPrimitive.setTimestamp(java.util.Date)
-
getInstant
public java.time.Instant getInstant()
Description copied from interface:IPrimitive
Time of last modification to this object. This is not set by JOSM but read from the server and delivered back to the server unmodified. It is used to check against edit conflicts.- Specified by:
getInstant
in interfaceIPrimitive
- Returns:
- date of last modification
- See Also:
IPrimitive.setInstant(java.time.Instant)
-
getRawTimestamp
public int getRawTimestamp()
Description copied from interface:IPrimitive
Time of last modification to this object. This is not set by JOSM but read from the server and delivered back to the server unmodified. It is used to check against edit conflicts.- Specified by:
getRawTimestamp
in interfaceIPrimitive
- Returns:
- last modification as timestamp
- See Also:
IPrimitive.setRawTimestamp(int)
-
isTimestampEmpty
public boolean isTimestampEmpty()
Description copied from interface:IPrimitive
Determines if this primitive has no timestamp information.- Specified by:
isTimestampEmpty
in interfaceIPrimitive
- Returns:
true
if this primitive has no timestamp information- See Also:
IPrimitive.getTimestamp()
,IPrimitive.getRawTimestamp()
-
updateFlags
protected void updateFlags(short flag, boolean value)
-
updateFlagsChanged
protected boolean updateFlagsChanged(short flag, boolean value)
Update flags- Parameters:
flag
- The flag to updatevalue
- The value to set- Returns:
true
if the flags have changed
-
setModified
public void setModified(boolean modified)
Description copied from interface:IPrimitive
Marks this primitive as being modified.- Specified by:
setModified
in interfaceIPrimitive
- Parameters:
modified
- true, if this primitive is to be modified
-
isModified
public boolean isModified()
Description copied from interface:IPrimitive
Repliestrue
if the object has been modified since it was loaded from the server. In this case, on next upload, this object will be updated.Deleted objects are deleted from the server. If the objects are added (id=0), the modified is ignored and the object is added to the server.
- Specified by:
isModified
in interfaceIPrimitive
- Returns:
true
if the object has been modified since it was loaded from the server
-
isDeleted
public boolean isDeleted()
Description copied from interface:IPrimitive
Repliestrue
, if the object has been deleted.- Specified by:
isDeleted
in interfaceIPrimitive
- Returns:
true
, if the object has been deleted.- See Also:
IPrimitive.setDeleted(boolean)
-
setReferrersDownloaded
public void setReferrersDownloaded(boolean referrersDownloaded)
Description copied from interface:IPrimitive
Set the status of the referrers- Specified by:
setReferrersDownloaded
in interfaceIPrimitive
- Parameters:
referrersDownloaded
-true
if all referrers for this object have been downloaded
-
isUndeleted
public boolean isUndeleted()
Description copied from interface:IPrimitive
Repliestrue
if the object has been deleted on the server and was undeleted by the user.- Specified by:
isUndeleted
in interfaceIPrimitive
- Returns:
true
if the object has been undeleted
-
isUsable
public boolean isUsable()
Description copied from interface:IPrimitive
Repliestrue
, if the object is usable (i.e. complete and not deleted).- Specified by:
isUsable
in interfaceIPrimitive
- Returns:
true
, if the object is usable.- See Also:
IPrimitive.setDeleted(boolean)
-
isVisible
public boolean isVisible()
Description copied from interface:IPrimitive
Checks if object is known to the server. Replies true if this primitive is either unknown to the server (i.e. its id is 0) or it is known to the server and it hasn't be deleted on the server. Replies false, if this primitive is known on the server and has been deleted on the server.- Specified by:
isVisible
in interfaceIPrimitive
- Returns:
true
, if the object is visible on server.- See Also:
IPrimitive.setVisible(boolean)
-
setVisible
public void setVisible(boolean visible)
Description copied from interface:IPrimitive
Sets whether this primitive is visible, i.e. whether it is known on the server and not deleted on the server.- Specified by:
setVisible
in interfaceIPrimitive
- Parameters:
visible
-true
if this primitive is visible- See Also:
IPrimitive.isVisible()
-
setDeleted
public void setDeleted(boolean deleted)
Description copied from interface:IPrimitive
Sets whether this primitive is deleted or not.Also marks this primitive as modified if deleted is true.
- Specified by:
setDeleted
in interfaceIPrimitive
- Parameters:
deleted
- true, if this primitive is deleted; false, otherwise
-
hasDirectionKeys
public boolean hasDirectionKeys()
Description copied from interface:IPrimitive
true if this object has direction dependent tags (e.g. oneway)- Specified by:
hasDirectionKeys
in interfaceIPrimitive
- Returns:
true
if this object has direction dependent tags
-
reversedDirection
public boolean reversedDirection()
Description copied from interface:IPrimitive
true if this object has the "reversed direction" flag enabled- Specified by:
reversedDirection
in interfaceIPrimitive
- Returns:
true
if this object has the "reversed direction" flag enabled
-
isTagged
public boolean isTagged()
Description copied from interface:IPrimitive
Determines if this object is considered "tagged". To be "tagged", an object must have one or more "interesting" tags. "created_by" and "source" are typically considered "uninteresting" and do not make an object "tagged".- Specified by:
isTagged
in interfaceIPrimitive
- Returns:
- true if this object is considered "tagged"
-
isAnnotated
public boolean isAnnotated()
Description copied from interface:IPrimitive
Determines if this object is considered "annotated". To be "annotated", an object must have one or more "work in progress" tags, such as "note" or "fixme".- Specified by:
isAnnotated
in interfaceIPrimitive
- Returns:
- true if this object is considered "annotated"
-
isHighlighted
public boolean isHighlighted()
Description copied from interface:IPrimitive
Checks if the highlight flag for this primitive was set- Specified by:
isHighlighted
in interfaceIPrimitive
- Returns:
- The highlight flag.
-
isDisabled
public boolean isDisabled()
Description copied from interface:IPrimitive
Replies true, if this primitive is disabled. (E.g. a filter applies)- Specified by:
isDisabled
in interfaceIPrimitive
- Returns:
true
if this object has the "disabled" flag enabled
-
isDisabledAndHidden
public boolean isDisabledAndHidden()
Description copied from interface:IPrimitive
Replies true, if this primitive is disabled and marked as completely hidden on the map.- Specified by:
isDisabledAndHidden
in interfaceIPrimitive
- Returns:
true
if this object has both the "disabled" and "hide if disabled" flags enabled
-
isPreserved
public boolean isPreserved()
Description copied from interface:IPrimitive
Replies true, if this primitive is preserved from filtering.- Specified by:
isPreserved
in interfaceIPrimitive
- Returns:
true
if this object has the "preserved" flag enabled
-
isReferrersDownloaded
public boolean isReferrersDownloaded()
Description copied from interface:IPrimitive
Determines if this primitive is fully downloaded- Specified by:
isReferrersDownloaded
in interfaceIPrimitive
- Returns:
true
if the primitive is fully downloaded and all parents and children should be available.false
otherwise.
-
setIncomplete
protected void setIncomplete(boolean incomplete)
If set to true, this object is incomplete, which means only the id and type is known (type is the objects instance class)- Parameters:
incomplete
- incomplete flag value
-
isIncomplete
public boolean isIncomplete()
Description copied from interface:IPrimitive
Determines if this primitive is incomplete.- Specified by:
isIncomplete
in interfaceIPrimitive
- Returns:
true
if this primitive is incomplete,false
otherwise
-
getHiddenType
public boolean getHiddenType()
Description copied from interface:IFilterablePrimitive
Get binary property used internally by the filter mechanism.- Specified by:
getHiddenType
in interfaceIFilterablePrimitive
- Returns:
true
if this object has the "hidden type" flag enabled
-
getDisabledType
public boolean getDisabledType()
Description copied from interface:IFilterablePrimitive
Get binary property used internally by the filter mechanism.- Specified by:
getDisabledType
in interfaceIFilterablePrimitive
- Returns:
true
if this object has the "disabled type" flag enabled
-
setDisabledState
public boolean setDisabledState(boolean hidden)
Description copied from interface:IFilterablePrimitive
Make the primitive disabled (e.g. if a filter applies). To enable the primitive again, use unsetDisabledState.- Specified by:
setDisabledState
in interfaceIFilterablePrimitive
- Parameters:
hidden
- if the primitive should be completely hidden from view or just shown in gray color.- Returns:
- true, any flag has changed; false if you try to set the disabled state to the value that is already preset
-
unsetDisabledState
public boolean unsetDisabledState()
Description copied from interface:IFilterablePrimitive
Remove the disabled flag from the primitive. Afterwards, the primitive is displayed normally and can be selected again.- Specified by:
unsetDisabledState
in interfaceIFilterablePrimitive
- Returns:
true
if a change occurred
-
setDisabledType
public void setDisabledType(boolean isExplicit)
Description copied from interface:IFilterablePrimitive
Set binary property used internally by the filter mechanism.- Specified by:
setDisabledType
in interfaceIFilterablePrimitive
- Parameters:
isExplicit
- new "disabled type" flag value
-
setHiddenType
public void setHiddenType(boolean isExplicit)
Description copied from interface:IFilterablePrimitive
Set binary property used internally by the filter mechanism.- Specified by:
setHiddenType
in interfaceIFilterablePrimitive
- Parameters:
isExplicit
- new "hidden type" flag value
-
isDrawable
public boolean isDrawable()
Description copied from interface:IPrimitive
Determines if this object is drawable.A primitive is drawable if all conditions are met:
- type and id is known
- tags are known
- it is not deleted
- it is not hidden by a filter
- for nodes: lat/lon are known
- for ways: all nodes are known and complete
- for relations: all members are known and complete
- Specified by:
isDrawable
in interfaceIPrimitive
- Returns:
true
if this object is drawable
-
getFlagsAsString
protected java.lang.String getFlagsAsString()
-
getKeys
public TagMap getKeys()
Replies the map of key/value pairs. Never replies null. The map can be empty, though.- Specified by:
getKeys
in interfaceTagged
- Returns:
- tags of this primitive. Changes made in returned map are not mapped back to the primitive, use setKeys() to modify the keys
- See Also:
visitKeys(KeyValueVisitor)
-
visitKeys
public void visitKeys(KeyValueVisitor visitor)
Description copied from interface:Tagged
Calls the visitor for every key/value pair.- Specified by:
visitKeys
in interfaceTagged
- Parameters:
visitor
- The visitor to call.- See Also:
Tagged.getKeys()
-
setKeys
public void setKeys(java.util.Map<java.lang.String,java.lang.String> keys)
Sets the keys of this primitives to the key/value pairs inkeys
. Old key/value pairs are removed. Ifkeys
is null, clears existing key/value pairs.Note that this method, like all methods that modify keys, is not synchronized and may lead to data corruption when being used from multiple threads.
-
setKeys
public void setKeys(TagMap keys)
Copy the keys from a TagMap.- Parameters:
keys
- The new key map.
-
put
public void put(java.lang.String key, java.lang.String value)
Set the given value to the given key. If key is null, does nothing. If value is null, removes the key and behaves likeremove(String)
.Note that this method, like all methods that modify keys, is not synchronized and may lead to data corruption when being used from multiple threads.
- Specified by:
put
in interfaceTagged
- Parameters:
key
- The key, for which the value is to be set. Can be null or empty, does nothing in this case.value
- The value for the key. If null, removes the respective key/value pair.- See Also:
remove(String)
-
putAll
public void putAll(java.util.Map<java.lang.String,java.lang.String> tags)
Description copied from interface:Tagged
Add all key/value pairs. This may be more performant thanTagged.put(java.lang.String, java.lang.String)
, depending upon the implementation. By default, this callsTagged.put(java.lang.String, java.lang.String)
for each map entry.
-
indexOfKey
private static int indexOfKey(java.lang.String[] keys, java.lang.String key)
Scans a key/value array for a given key.- Parameters:
keys
- The key array. It is not modified. It may be null to indicate an empty array.key
- The key to search for.- Returns:
- The position of that key in the keys array - which is always a multiple of 2 - or -1 if it was not found.
-
remove
public void remove(java.lang.String key)
Remove the given key from the listNote that this method, like all methods that modify keys, is not synchronized and may lead to data corruption when being used from multiple threads.
-
removeAll
public void removeAll()
Removes all keys from this primitive.Note that this method, like all methods that modify keys, is not synchronized and may lead to data corruption when being used from multiple threads.
-
doGet
protected final java.lang.String doGet(java.lang.String key, java.util.function.BiPredicate<java.lang.String,java.lang.String> predicate)
-
get
public final java.lang.String get(java.lang.String key)
Replies the value for keykey
. Replies null, ifkey
is null. Replies null, if there is no value for the given key.
-
getIgnoreCase
public final java.lang.String getIgnoreCase(java.lang.String key)
Gets a key ignoring the case of the key- Parameters:
key
- The key to get- Returns:
- The value for a key that matches the given key ignoring case.
-
getNumKeys
public final int getNumKeys()
Description copied from interface:Tagged
Gets the number of keys- Specified by:
getNumKeys
in interfaceTagged
- Returns:
- The number of keys set for this tagged object.
-
keySet
public final java.util.Collection<java.lang.String> keySet()
Description copied from interface:Tagged
Replies the set of keys- Specified by:
keySet
in interfaceTagged
- Returns:
- the set of keys
- See Also:
Tagged.keys()
-
keys
public java.util.stream.Stream<java.lang.String> keys()
Description copied from interface:Tagged
Replies the keys as stream- Specified by:
keys
in interfaceTagged
- Returns:
- the keys as stream
- See Also:
Tagged.keySet()
-
hasKeys
public final boolean hasKeys()
Replies true, if the map of key/value pairs of this primitive is not empty.
-
hasKey
public boolean hasKey(java.lang.String key)
Replies true if this primitive has a tag with keykey
.- Specified by:
hasKey
in interfaceTagged
- Parameters:
key
- the key- Returns:
- true, if this primitive has a tag with key
key
- See Also:
Tagged.hasTag(String)
-
hasKey
public boolean hasKey(java.lang.String... keys)
Replies true if this primitive has a tag any of thekeys
.- Parameters:
keys
- the keys- Returns:
- true, if this primitive has a tag with any of the
keys
- Since:
- 11587
-
keysChangedImpl
protected abstract void keysChangedImpl(java.util.Map<java.lang.String,java.lang.String> originalKeys)
What to do, when the tags have changed by one of the tag-changing methods.- Parameters:
originalKeys
- original tags
-
getUninterestingKeys
public static java.util.Collection<java.lang.String> getUninterestingKeys()
Returns a list of "uninteresting" keys that do not make an object "tagged". Entries that end with ':' are causing a whole namespace to be considered "uninteresting". Only the first level namespace is considered. Initialized by isUninterestingKey()- Returns:
- The list of uninteresting keys.
-
getDiscardableKeys
public static java.util.Collection<java.lang.String> getDiscardableKeys()
Returns a list of keys which have been deemed uninteresting to the point that they can be silently removed from data which is being edited.- Returns:
- The list of discardable keys.
-
getWorkInProgressKeys
public static java.util.Collection<java.lang.String> getWorkInProgressKeys()
Returns a list of "work in progress" keys that do not make an object "tagged" but "annotated".- Returns:
- The list of work in progress keys.
- Since:
- 5754
-
isUninterestingKey
public static boolean isUninterestingKey(java.lang.String key)
Determines if key is considered "uninteresting".- Parameters:
key
- The key to check- Returns:
- true if key is considered "uninteresting".
-
getInterestingTags
public java.util.Map<java.lang.String,java.lang.String> getInterestingTags()
Description copied from interface:IPrimitive
ReturnsTagged.getKeys()
for whichkey
does not fulfill uninteresting criteria.- Specified by:
getInterestingTags
in interfaceIPrimitive
- Returns:
- A map of interesting tags
-
-