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.
|
protected static int |
FLAG_DELETED
An object that was deleted by the user.
|
protected static int |
FLAG_INCOMPLETE
A primitive is incomplete if we know its id and type, but nothing more.
|
protected static int |
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 int |
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 |
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.
|
| Constructor and Description |
|---|
AbstractPrimitive() |
| Modifier and Type | Method and 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.
|
(package private) static long |
generateUniqueId() |
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.
|
OsmPrimitiveType |
getDisplayType() |
protected java.lang.String |
getFlagsAsString() |
long |
getId()
Replies the id of this primitive.
|
java.lang.String |
getIgnoreCase(java.lang.String key) |
java.util.Map<java.lang.String,java.lang.String> |
getKeys()
Replies the map of key/value pairs.
|
java.lang.String |
getLocalName()
Replies the a localized name for this primitive given by the value of the tags (in this order)
name:lang_COUNTRY_Variant of the current locale
name:lang_COUNTRY of the current locale
name:lang of the current locale
name of the current locale
null, if no such tag exists
|
java.lang.String |
getName()
Replies the name of this primitive.
|
int |
getNumKeys() |
PrimitiveId |
getPrimitiveId()
Replies the unique primitive id for this primitive
|
java.util.Date |
getTimestamp()
Time of last modification to this object.
|
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.
|
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.
|
boolean |
hasTag(java.lang.String key,
java.util.Collection<java.lang.String> values)
Tests whether this primitive contains a tag consisting of
key and any of values. |
boolean |
hasTag(java.lang.String key,
java.lang.String... values)
Tests whether this primitive contains a tag consisting of
key and any of values. |
boolean |
hasTag(java.lang.String key,
java.lang.String value)
Tests whether this primitive contains a tag consisting of
key and values. |
boolean |
isDeleted()
Replies
true, if the object has been deleted. |
boolean |
isIncomplete() |
boolean |
isKeyFalse(java.lang.String key)
Returns true if the
key corresponds to an OSM false value. |
boolean |
isKeyTrue(java.lang.String key)
Returns true if the
key corresponds to an OSM true value. |
boolean |
isModified()
Replies
true if the object has been modified since it was loaded from
the server. |
boolean |
isNew()
Replies true if this id represents a new primitive.
|
boolean |
isNewOrUndeleted() |
boolean |
isTimestampEmpty() |
boolean |
isUndeleted()
Replies
true if the object has been deleted on the server and was undeleted by the user. |
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 |
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 |
setTimestamp(java.util.Date timestamp) |
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(int flag,
boolean value) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitacceptgetTypeprivate static final java.util.concurrent.atomic.AtomicLong idCounter
protected static final int FLAG_MODIFIED
protected static final int FLAG_VISIBLE
protected static final int FLAG_DELETED
protected static final int FLAG_INCOMPLETE
protected volatile short flags
protected long id
protected User user
protected int version
protected int changesetId
protected int timestamp
protected java.lang.String[] keys
public AbstractPrimitive()
static long generateUniqueId()
public void cloneFrom(AbstractPrimitive other)
other - the primitive to clone data frompublic int getVersion()
getVersion in interface IPrimitivePrimitiveData.setVersion(int)public long getId()
getId in interface IPrimitivepublic long getUniqueId()
getUniqueId in interface PrimitiveIdpublic boolean isNew()
PrimitiveIdisNew in interface PrimitiveIdpublic boolean isNewOrUndeleted()
isNewOrUndeleted in interface IPrimitiveisNew(),
isUndeleted()public void setOsmId(long id, int version)
setOsmId in interface IPrimitiveid - the id. > 0 requiredversion - the version > 0 requiredjava.lang.IllegalArgumentException - thrown if id <= 0java.lang.IllegalArgumentException - thrown if version <= 0DataIntegrityProblemException - If id is changed and primitive was already added to the datasetpublic void clearOsmMetadata()
public User getUser()
getUser in interface IPrimitivepublic void setUser(User user)
setUser in interface IPrimitiveuser - the userpublic int getChangesetId()
getChangesetId in interface IPrimitivepublic void setChangesetId(int changesetId) throws java.lang.IllegalStateException, java.lang.IllegalArgumentException
setChangesetId in interface IPrimitivechangesetId - the id. >= 0 required.java.lang.IllegalStateException - thrown if this primitive is new.java.lang.IllegalArgumentException - thrown if id < 0public PrimitiveId getPrimitiveId()
getPrimitiveId in interface IPrimitivepublic OsmPrimitiveType getDisplayType()
public void setTimestamp(java.util.Date timestamp)
setTimestamp in interface IPrimitivepublic java.util.Date getTimestamp()
getTimestamp in interface IPrimitivepublic boolean isTimestampEmpty()
isTimestampEmpty in interface IPrimitiveprotected void updateFlags(int flag, boolean value)
public void setModified(boolean modified)
setModified in interface IPrimitivemodified - true, if this primitive is to be modifiedpublic boolean isModified()
true 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()
true, if the object has been deleted.isDeleted in interface IPrimitivetrue, if the object has been deleted.setDeleted(boolean)public boolean isUndeleted()
true if the object has been deleted on the server and was undeleted by the user.true if the object has been undeletedpublic boolean isUsable()
true, if the object is usable
(i.e. complete and not deleted).true, if the object is usable.setDeleted(boolean)public boolean isVisible()
isVisible in interface IPrimitivetrue, if the object is visible on server.setVisible(boolean)public void setVisible(boolean visible) throws java.lang.IllegalStateException
setVisible in interface IPrimitivejava.lang.IllegalStateException - thrown if visible is set to false on an primitive with
id==0isVisible()public void setDeleted(boolean deleted)
setDeleted in interface IPrimitivedeleted - true, if this primitive is deleted; false, otherwiseprotected void setIncomplete(boolean incomplete)
public boolean isIncomplete()
isIncomplete in interface IPrimitiveprotected java.lang.String getFlagsAsString()
public java.util.Map<java.lang.String,java.lang.String> 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.public void put(java.lang.String key, java.lang.String value)
remove(String).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)public void remove(java.lang.String key)
public void removeAll()
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 boolean isKeyTrue(java.lang.String key)
key corresponds to an OSM true value.OsmUtils.isTrue(String)public final boolean isKeyFalse(java.lang.String key)
key corresponds to an OSM false value.OsmUtils.isFalse(String)public final java.lang.String getIgnoreCase(java.lang.String key)
public final int getNumKeys()
public final java.util.Collection<java.lang.String> keySet()
Taggedpublic final boolean hasKeys()
public boolean hasKey(java.lang.String key)
key.key - the keykeyprotected abstract void keysChangedImpl(java.util.Map<java.lang.String,java.lang.String> originalKeys)
public java.lang.String getName()
getName in interface IPrimitivepublic java.lang.String getLocalName()
getLocalName in interface IPrimitivepublic boolean hasTag(java.lang.String key, java.lang.String value)
key and values.key - the key forming the tag.value - value forming the tag.key and value.public boolean hasTag(java.lang.String key, java.lang.String... values)
key and any of values.key - the key forming the tag.values - one or many values forming the tag.key and any of values.public boolean hasTag(java.lang.String key, java.util.Collection<java.lang.String> values)
key and any of values.key - the key forming the tag.values - one or many values forming the tag.key and any of values.