|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.openstreetmap.josm.data.osm.AbstractPrimitive
public abstract class AbstractPrimitive
Abstract class to represent common features of the datatypes primitives.
Field Summary | |
---|---|
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 Summary | |
---|---|
AbstractPrimitive()
|
Method Summary | |
---|---|
void |
clearOsmId()
Clears the 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. |
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 |
hasSameTags(OsmPrimitive other)
Replies true if other isn't null and has the same tags (key/value-pairs) as this. |
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 |
isDeleted()
Replies true , if the object has been deleted. |
boolean |
isIncomplete()
|
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)
|
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 |
---|
visit |
Methods inherited from interface org.openstreetmap.josm.data.osm.PrimitiveId |
---|
getType |
Field Detail |
---|
private 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
Constructor Detail |
---|
public AbstractPrimitive()
Method Detail |
---|
static long generateUniqueId()
public void cloneFrom(AbstractPrimitive other)
other
- the primitive to clone data frompublic int getVersion()
getVersion
in interface IPrimitive
PrimitiveData.setVersion(int)
public long getId()
getId
in interface IPrimitive
public long getUniqueId()
getUniqueId
in interface PrimitiveId
public boolean isNew()
PrimitiveId
isNew
in interface PrimitiveId
public boolean isNewOrUndeleted()
isNewOrUndeleted
in interface IPrimitive
isNew()
,
isUndeleted()
public void setOsmId(long id, int version)
setOsmId
in interface IPrimitive
id
- the id. > 0 requiredversion
- the version > 0 required
java.lang.IllegalArgumentException
- thrown if id <= 0
java.lang.IllegalArgumentException
- thrown if version <= 0
DataIntegrityProblemException
- If id is changed and primitive was already added to the datasetpublic void clearOsmId()
public User getUser()
getUser
in interface IPrimitive
public void setUser(User user)
setUser
in interface IPrimitive
user
- the userpublic int getChangesetId()
getChangesetId
in interface IPrimitive
public void setChangesetId(int changesetId) throws java.lang.IllegalStateException, java.lang.IllegalArgumentException
setChangesetId
in interface IPrimitive
changesetId
- 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 IPrimitive
public OsmPrimitiveType getDisplayType()
public void setTimestamp(java.util.Date timestamp)
setTimestamp
in interface IPrimitive
public java.util.Date getTimestamp()
getTimestamp
in interface IPrimitive
public boolean isTimestampEmpty()
isTimestampEmpty
in interface IPrimitive
protected void updateFlags(int flag, boolean value)
public void setModified(boolean modified)
setModified
in interface IPrimitive
modified
- 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 IPrimitive
true
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 IPrimitive
true
, 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 IPrimitive
true
, if the object is visible on server.setVisible(boolean)
public void setVisible(boolean visible) throws java.lang.IllegalStateException
setVisible
in interface IPrimitive
java.lang.IllegalStateException
- thrown if visible is set to false on an primitive with
id==0isVisible()
public void setDeleted(boolean deleted)
setDeleted
in interface IPrimitive
deleted
- true, if this primitive is deleted; false, otherwiseprotected void setIncomplete(boolean incomplete)
public boolean isIncomplete()
isIncomplete
in interface IPrimitive
protected java.lang.String getFlagsAsString()
public java.util.Map<java.lang.String,java.lang.String> getKeys()
getKeys
in interface Tagged
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.
setKeys
in interface Tagged
keys
- the key/value pairs to set. If null, removes all existing key/value pairs.public void put(java.lang.String key, java.lang.String value)
remove(String)
.
put
in interface Tagged
key
- The key, for which the value is to be set. Can be null, 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)
remove
in interface Tagged
key
- the key to be removed. Ignored, if key is null.public void removeAll()
removeAll
in interface Tagged
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.
get
in interface Tagged
key
- the key. Can be null, replies null in this case.
key
.public final java.lang.String getIgnoreCase(java.lang.String key)
public final java.util.Collection<java.lang.String> keySet()
Tagged
keySet
in interface Tagged
public final boolean hasKeys()
hasKeys
in interface Tagged
public boolean hasKey(java.lang.String key)
key
.
key
- the key
key
public boolean hasSameTags(OsmPrimitive other)
other
- the other object primitive
protected abstract void keysChangedImpl(java.util.Map<java.lang.String,java.lang.String> originalKeys)
public java.lang.String getName()
getName
in interface IPrimitive
public java.lang.String getLocalName()
getLocalName
in interface IPrimitive
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
.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |