public abstract class AbstractPrimitive extends java.lang.Object implements IPrimitive
| Modifier and Type | Field and 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_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.
|
private static java.util.concurrent.atomic.AtomicLong |
idCounter |
protected java.lang.String[] |
keys
The key/value list 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:00Z
|
private 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 |
MAX_TAG_LENGTH| Constructor and Description |
|---|
AbstractPrimitive() |
| Modifier and Type | Method and Description |
|---|---|
static void |
advanceUniqueId(long newId)
Advances the current primitive unique id to skip a range of values.
|
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.
|
static long |
currentUniqueId()
Returns the current primitive unique id.
|
protected java.lang.String |
doGet(java.lang.String key,
java.util.function.BiPredicate<java.lang.String,java.lang.String> predicate) |
(package private) static long |
generateUniqueId()
Generates a new primitive unique id.
|
java.lang.String |
get(java.lang.String key)
Replies the value for key
key. |
int |
getChangesetId()
Replies the id of the changeset this primitive was last uploaded to.
|
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() |
long |
getId()
Replies the id of this primitive.
|
java.lang.String |
getIgnoreCase(java.lang.String key)
Gets a key ignoring the case of the key
|
java.util.Map<java.lang.String,java.lang.String> |
getInterestingTags()
Returns
Tagged.getKeys() for which key does not fulfill uninteresting criteria. |
TagMap |
getKeys()
Replies the map of key/value pairs.
|
int |
getNumKeys()
Gets the number of keys
|
int |
getRawTimestamp()
Time of last modification to this object.
|
java.util.Date |
getTimestamp()
Time of last modification to this object.
|
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 |
hasKey(java.lang.String... keys)
Replies true if this primitive has a tag any of the
keys. |
boolean |
hasKey(java.lang.String key)
Replies true if this primitive has a tag with key
key. |
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 |
isDeleted()
Replies
true, if the object has been deleted. |
boolean |
isIncomplete()
Determines if this primitive is incomplete.
|
boolean |
isModified()
Replies
true 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 |
isTimestampEmpty()
Determines if this primitive has no timestamp information.
|
boolean |
isUndeleted()
Replies
true 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()
Replies
true, if the object is usable
(i.e. |
boolean |
isVisible()
Checks if object is known to the server.
|
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.
|
java.util.Collection<java.lang.String> |
keySet()
Replies the set of keys
|
void |
put(java.lang.String key,
java.lang.String value)
Set the given value to the given key.
|
void |
remove(java.lang.String key)
Remove the given key from the list
|
void |
removeAll()
Removes all keys from this primitive.
|
void |
setChangesetId(int changesetId)
Sets the changeset id of this primitive.
|
void |
setDeleted(boolean deleted)
Sets whether this primitive is deleted or not.
|
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 |
setKeys(java.util.Map<java.lang.String,java.lang.String> keys)
Sets the keys of this primitives to the key/value pairs in
keys. |
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 object
|
void |
setTimestamp(java.util.Date timestamp)
Sets time of last modification to this object
|
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.
|
protected void |
updateFlags(short flag,
boolean value) |
void |
visitKeys(KeyValueVisitor visitor)
Calls the visitor for every key/value pair.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitaccept, getBBox, getDataSet, getDisplayName, getDisplayType, getLocalName, getName, getOsmId, getOsmPrimitiveId, getPrimitiveId, getReferrers, getReferrers, hasDirectionKeys, hasSameInterestingTags, isAnnotated, isDisabled, isDisabledAndHidden, isDrawable, isHighlighted, isMemberOfSelected, isMultipolygon, isOuterMemberOfSelected, isPreserved, isSelectable, isSelected, isTagged, reversedDirection, setHighlighted, visitReferrershasTag, hasTag, hasTag, hasTag, hasTagDifferent, hasTagDifferent, hasTagDifferent, isKeyFalse, isKeyTrue, putgetTypeclearCachedStyle, declareCachedStyleUpToDate, getCachedStyle, isCachedStyleUpToDate, setCachedStyleprivate static final java.util.concurrent.atomic.AtomicLong idCounter
protected static final short FLAG_MODIFIED
protected static final short FLAG_VISIBLE
protected static final short FLAG_DELETED
protected static final short FLAG_INCOMPLETE
protected static final short FLAG_DISABLED
protected static final short FLAG_HIDE_IF_DISABLED
protected static final short FLAG_DISABLED_TYPE
protected static final short FLAG_HIDDEN_TYPE
protected static final short FLAG_HAS_DIRECTIONS
protected static final short FLAG_TAGGED
protected static final short FLAG_DIRECTION_REVERSED
protected static final short FLAG_HIGHLIGHTED
protected static final short FLAG_ANNOTATED
protected static final short FLAG_PRESERVED
protected volatile short flags
protected long id
protected User user
protected int version
protected int changesetId
protected int timestamp
protected volatile java.lang.String[] keys
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:
CopyOnWriteArrayListrcu_assign_pointer and rcu_dereference are ensured by the volatile keyword)private static volatile java.util.Collection<java.lang.String> workinprogress
private static volatile java.util.Collection<java.lang.String> uninteresting
private static volatile java.util.Collection<java.lang.String> discardable
public AbstractPrimitive()
static long generateUniqueId()
public static long currentUniqueId()
public static void advanceUniqueId(long newId)
newId - new unique idjava.lang.IllegalArgumentException - if newId is greater than current unique idpublic void cloneFrom(AbstractPrimitive other)
other - the primitive to clone data frompublic int getVersion()
IPrimitivegetVersion in interface IPrimitivePrimitiveData.setVersion(int)public long getId()
IPrimitivegetId in interface IPrimitivepublic long getUniqueId()
getUniqueId in interface PrimitiveIdpublic boolean isNew()
isNew in interface PrimitiveIdtrue if this primitive is new (not yet uploaded the server, id <= 0)public boolean isNewOrUndeleted()
IPrimitiveisNewOrUndeleted in interface IPrimitivePrimitiveId.isNew(),
IPrimitive.isUndeleted()public void setOsmId(long id, int version)
IPrimitivesetOsmId in interface IPrimitiveid - the id. > 0 requiredversion - the version > 0 requiredpublic void clearOsmMetadata()
public User getUser()
IPrimitivegetUser in interface IPrimitivepublic void setUser(User user)
IPrimitivesetUser in interface IPrimitiveuser - the userpublic int getChangesetId()
IPrimitivegetChangesetId in interface IPrimitivepublic void setChangesetId(int changesetId)
IPrimitivesetChangesetId in interface IPrimitivechangesetId - the id. >= 0 required.public void setTimestamp(java.util.Date timestamp)
IPrimitivesetTimestamp in interface IPrimitivetimestamp - date of last modificationIPrimitive.getTimestamp()public void setRawTimestamp(int timestamp)
IPrimitivesetRawTimestamp in interface IPrimitivetimestamp - date of last modificationIPrimitive.getRawTimestamp()public java.util.Date getTimestamp()
IPrimitivegetTimestamp in interface IPrimitiveIPrimitive.setTimestamp(java.util.Date)public int getRawTimestamp()
IPrimitivegetRawTimestamp in interface IPrimitiveIPrimitive.setRawTimestamp(int)public boolean isTimestampEmpty()
IPrimitiveisTimestampEmpty in interface IPrimitivetrue if this primitive has no timestamp informationIPrimitive.getTimestamp(),
IPrimitive.getRawTimestamp()protected void updateFlags(short flag, boolean value)
public void setModified(boolean modified)
IPrimitivesetModified in interface IPrimitivemodified - true, if this primitive is to be modifiedpublic boolean isModified()
IPrimitivetrue 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.isModified in interface IPrimitivetrue if the object has been modified since it was loaded from
the serverpublic boolean isDeleted()
IPrimitivetrue, if the object has been deleted.isDeleted in interface IPrimitivetrue, if the object has been deleted.IPrimitive.setDeleted(boolean)public boolean isUndeleted()
IPrimitivetrue if the object has been deleted on the server and was undeleted by the user.isUndeleted in interface IPrimitivetrue if the object has been undeletedpublic boolean isUsable()
IPrimitivetrue, if the object is usable
(i.e. complete and not deleted).isUsable in interface IPrimitivetrue, if the object is usable.IPrimitive.setDeleted(boolean)public boolean isVisible()
IPrimitiveisVisible in interface IPrimitivetrue, if the object is visible on server.IPrimitive.setVisible(boolean)public void setVisible(boolean visible)
IPrimitivesetVisible in interface IPrimitivevisible - true if this primitive is visibleIPrimitive.isVisible()public void setDeleted(boolean deleted)
IPrimitivesetDeleted in interface IPrimitivedeleted - true, if this primitive is deleted; false, otherwiseprotected void setIncomplete(boolean incomplete)
incomplete - incomplete flag valuepublic boolean isIncomplete()
IPrimitiveisIncomplete in interface IPrimitivetrue if this primitive is incomplete, false otherwiseprotected java.lang.String getFlagsAsString()
public TagMap getKeys()
getKeys in interface TaggedvisitKeys(KeyValueVisitor)public void visitKeys(KeyValueVisitor visitor)
TaggedvisitKeys in interface Taggedvisitor - The visitor to call.Tagged.getKeys()public void setKeys(java.util.Map<java.lang.String,java.lang.String> keys)
keys.
Old key/value pairs are removed.
If keys 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.
public void setKeys(TagMap keys)
keys - The new key map.public void put(java.lang.String key, java.lang.String value)
remove(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.
put in interface Taggedkey - 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.remove(String)private static int indexOfKey(java.lang.String[] keys, java.lang.String key)
keys - The key array. It is not modified. It may be null to indicate an emtpy array.key - The key to search for.public void remove(java.lang.String key)
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.
public void removeAll()
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.
protected final java.lang.String doGet(java.lang.String key, java.util.function.BiPredicate<java.lang.String,java.lang.String> predicate)
public final java.lang.String get(java.lang.String key)
key. Replies null, if key is null.
Replies null, if there is no value for the given key.public final java.lang.String getIgnoreCase(java.lang.String key)
key - The key to getpublic final int getNumKeys()
TaggedgetNumKeys in interface Taggedpublic final java.util.Collection<java.lang.String> keySet()
Taggedpublic final boolean hasKeys()
public boolean hasKey(java.lang.String key)
key.hasKey in interface Taggedkey - the keykeyTagged.hasTag(String)public boolean hasKey(java.lang.String... keys)
keys.keys - the keyskeysprotected abstract void keysChangedImpl(java.util.Map<java.lang.String,java.lang.String> originalKeys)
originalKeys - original tagspublic static java.util.Collection<java.lang.String> getUninterestingKeys()
public static java.util.Collection<java.lang.String> getDiscardableKeys()
public static java.util.Collection<java.lang.String> getWorkInProgressKeys()
public static boolean isUninterestingKey(java.lang.String key)
key - The key to checkpublic java.util.Map<java.lang.String,java.lang.String> getInterestingTags()
IPrimitiveTagged.getKeys() for which key does not fulfill uninteresting criteria.getInterestingTags in interface IPrimitive