|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.openstreetmap.josm.data.osm.AbstractPrimitive
org.openstreetmap.josm.data.osm.OsmPrimitive
public abstract class OsmPrimitive
An OSM primitive can be associated with a key/value pair. It can be created, deleted
and updated within the OSM-Server.
Although OsmPrimitive is designed as a base class, it is not to be meant to subclass
it by any other than from the package org.openstreetmap.josm.data.osm. The available primitives are a fixed set that are given
by the server environment and not an extendible data stuff.
| Field Summary | |
|---|---|
static Predicate<OsmPrimitive> |
allPredicate
|
private DataSet |
dataSet
the parent dataset |
private static SearchCompiler.Match |
directionKeys
|
private static java.util.Collection<java.lang.String> |
discardable
|
protected static int |
FLAG_DIRECTION_REVERSED
This flag is only relevant if FLAG_HAS_DIRECTIONS is set. |
protected static int |
FLAG_DISABLED
An object can be disabled by the filter mechanism. |
protected static int |
FLAG_DISABLED_TYPE
Flag used internally by the filter mechanism. |
protected static int |
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 int |
FLAG_HIDDEN_TYPE
Flag used internally by the filter mechanism. |
protected static int |
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 int |
FLAG_HIGHLIGHTED
When hovering over ways and nodes in add mode, the "target" objects are visually highlighted. |
protected static int |
FLAG_TAGGED
If the primitive is tagged. |
static Predicate<OsmPrimitive> |
isSelectablePredicate
|
static Predicate<OsmPrimitive> |
isUsablePredicate
Some predicates, that describe conditions on primitives. |
int |
mappaintCacheIdx
|
StyleCache |
mappaintStyle
|
static Predicate<OsmPrimitive> |
modifiedPredicate
|
static Predicate<OsmPrimitive> |
multipolygonPredicate
|
static Predicate<OsmPrimitive> |
nodePredicate
|
static Predicate<OsmPrimitive> |
nonDeletedCompletePredicate
|
static Predicate<OsmPrimitive> |
nonDeletedPhysicalPredicate
|
static Predicate<OsmPrimitive> |
nonDeletedPredicate
|
private java.lang.Object |
referrers
|
static Predicate<OsmPrimitive> |
relationPredicate
|
private static SearchCompiler.Match |
reversedDirectionKeys
|
private static java.lang.String |
SPECIAL_VALUE_ID
|
private static java.lang.String |
SPECIAL_VALUE_LOCAL_NAME
|
private static java.util.Collection<java.lang.String> |
uninteresting
|
static Predicate<OsmPrimitive> |
wayPredicate
|
| Fields inherited from class org.openstreetmap.josm.data.osm.AbstractPrimitive |
|---|
changesetId, FLAG_DELETED, FLAG_INCOMPLETE, FLAG_MODIFIED, FLAG_VISIBLE, flags, id, keys, timestamp, user, version |
| Constructor Summary | |
|---|---|
protected |
OsmPrimitive(long id,
boolean allowNegativeId)
Creates a new primitive for the given id. |
protected |
OsmPrimitive(long id,
int version,
boolean allowNegativeId)
Creates a new primitive for the given id and version. |
| Method Summary | ||
|---|---|---|
protected void |
addReferrer(OsmPrimitive referrer)
Add new referrer. |
|
void |
checkDataset()
Throws exception if primitive is not part of the dataset |
|
void |
clearCachedStyle()
|
|
void |
clearOsmId()
Clears the id and version known to the OSM API. |
|
void |
cloneFrom(OsmPrimitive other)
Get and write all attributes from the parameter. |
|
boolean |
equals(java.lang.Object obj)
Equal, if the id (and class) is equal. |
|
boolean |
evaluateCondition(SearchCompiler.Match condition)
|
|
abstract BBox |
getBBox()
|
|
DataSet |
getDataSet()
|
|
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. |
|
abstract java.lang.String |
getDisplayName(NameFormatter formatter)
Replies the display name of a primitive formatted by formatter |
|
static
|
getFilteredList(java.util.Collection<OsmPrimitive> list,
java.lang.Class<T> type)
Replies the sub-collection of OsmPrimitives of type type present in
another collection of OsmPrimitives. |
|
static
|
getFilteredSet(java.util.Collection<OsmPrimitive> set,
java.lang.Class<T> type)
Replies the sub-collection of OsmPrimitives of type type present in
another collection of OsmPrimitives. |
|
protected java.lang.String |
getFlagsAsString()
|
|
boolean |
getHiddenType()
Get binary property used internally by the filter mechanism. |
|
static java.util.Set<Relation> |
getParentRelations(java.util.Collection<? extends OsmPrimitive> primitives)
Replies the set of referring relations |
|
static java.util.Set<OsmPrimitive> |
getReferrer(java.util.Collection<? extends OsmPrimitive> primitives)
Replies the collection of referring primitives for the primitives in primitives. |
|
java.util.List<OsmPrimitive> |
getReferrers()
|
|
java.util.List<OsmPrimitive> |
getReferrers(boolean allowWithoutDataset)
Find primitives that reference this primitive. |
|
java.util.Collection<java.lang.String> |
getTemplateKeys()
|
|
java.lang.Object |
getTemplateValue(java.lang.String name,
boolean special)
|
|
static java.util.Collection<java.lang.String> |
getUninterestingKeys()
Contains a list of "uninteresting" keys that do not make an object "tagged". |
|
boolean |
hasDirectionKeys()
true if this object has direction dependent tags (e.g. |
|
boolean |
hasEqualSemanticAttributes(OsmPrimitive other)
Replies true if this primitive and other are equal with respect to their semantic attributes. |
|
boolean |
hasEqualTechnicalAttributes(OsmPrimitive other)
Replies true if this primitive and other are equal with respect to their technical attributes. |
|
int |
hashCode()
Return the id plus the class type encoded as hashcode or super's hashcode if id is 0. |
|
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()
|
|
boolean |
isHighlighted()
|
|
boolean |
isMemberOfSelected()
|
|
boolean |
isReferredByWays(int n)
Return true, if this primitive is referred by at least n ways |
|
boolean |
isSelectable()
|
|
boolean |
isSelected()
|
|
boolean |
isTagged()
true if this object is considered "tagged". |
|
static boolean |
isUninterestingKey(java.lang.String key)
Returns true if key is considered "uninteresting". |
|
protected 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. |
|
void |
load(PrimitiveData data)
Loads (clone) this primitive from provided PrimitiveData |
|
void |
mergeFrom(OsmPrimitive other)
Merges the technical and semantical attributes from other onto this. |
|
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. |
|
protected void |
removeReferrer(OsmPrimitive referrer)
Remove referrer. |
|
boolean |
reversedDirection()
|
|
abstract PrimitiveData |
save()
Save parameters of this primitive to the transport object |
|
protected void |
saveCommonAttributes(PrimitiveData data)
|
|
void |
setChangesetId(int changesetId)
Sets the changeset id of this primitive. |
|
(package private) void |
setDataset(DataSet dataSet)
This method should never ever by called from somewhere else than Dataset.addPrimitive or removePrimitive methods |
|
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. |
|
void |
setHighlighted(boolean highlighted)
|
|
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 |
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. |
|
boolean |
unsetDisabledState()
Remove the disabled flag from the primitive. |
|
private void |
updateDirectionFlags()
|
|
protected void |
updateFlags(int flag,
boolean value)
|
|
private void |
updateFlagsNoLock(int flag,
boolean value)
|
|
abstract void |
updatePosition()
Called by Dataset to update cached position information of primitive (bbox, cached EarthNorth, ...) |
|
private void |
updateTagged()
|
|
abstract void |
visit(Visitor visitor)
|
|
void |
visitReferrers(Visitor visitor)
Visits visitor for all referrers. |
|
protected boolean |
writeLock()
|
|
protected void |
writeUnlock(boolean locked)
|
|
| Methods inherited from class org.openstreetmap.josm.data.osm.AbstractPrimitive |
|---|
cloneFrom, generateUniqueId, get, getChangesetId, getDisplayType, getId, getIgnoreCase, getKeys, getLocalName, getName, getPrimitiveId, getTimestamp, getUniqueId, getUser, getVersion, hasKey, hasKeys, hasSameTags, hasTag, hasTag, isDeleted, isIncomplete, isModified, isNew, isNewOrUndeleted, isTimestampEmpty, isUndeleted, isUsable, isVisible, keySet, setModified |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface java.lang.Comparable |
|---|
compareTo |
| 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.lang.String SPECIAL_VALUE_ID
private static final java.lang.String SPECIAL_VALUE_LOCAL_NAME
protected static final int FLAG_DISABLED
protected static final int FLAG_HIDE_IF_DISABLED
protected static final int FLAG_DISABLED_TYPE
protected static final int FLAG_HIDDEN_TYPE
protected static final int FLAG_HAS_DIRECTIONS
protected static final int FLAG_TAGGED
protected static final int FLAG_DIRECTION_REVERSED
protected static final int FLAG_HIGHLIGHTED
public static final Predicate<OsmPrimitive> isUsablePredicate
public static final Predicate<OsmPrimitive> isSelectablePredicate
public static final Predicate<OsmPrimitive> nonDeletedPredicate
public static final Predicate<OsmPrimitive> nonDeletedCompletePredicate
public static final Predicate<OsmPrimitive> nonDeletedPhysicalPredicate
public static final Predicate<OsmPrimitive> modifiedPredicate
public static final Predicate<OsmPrimitive> nodePredicate
public static final Predicate<OsmPrimitive> wayPredicate
public static final Predicate<OsmPrimitive> relationPredicate
public static final Predicate<OsmPrimitive> multipolygonPredicate
public static final Predicate<OsmPrimitive> allPredicate
public StyleCache mappaintStyle
public int mappaintCacheIdx
private DataSet dataSet
private static volatile java.util.Collection<java.lang.String> uninteresting
private static volatile java.util.Collection<java.lang.String> discardable
private static volatile SearchCompiler.Match directionKeys
private static volatile SearchCompiler.Match reversedDirectionKeys
private java.lang.Object referrers
| Constructor Detail |
|---|
protected OsmPrimitive(long id,
boolean allowNegativeId)
throws java.lang.IllegalArgumentException
id - the idallowNegativeId -
java.lang.IllegalArgumentException - thrown if id < 0 and allowNegativeId is false
protected OsmPrimitive(long id,
int version,
boolean allowNegativeId)
throws java.lang.IllegalArgumentException
id - version - allowNegativeId -
java.lang.IllegalArgumentException - thrown if id < 0 and allowNegativeId is false| Method Detail |
|---|
public static <T extends OsmPrimitive> java.util.List<T> getFilteredList(java.util.Collection<OsmPrimitive> list,
java.lang.Class<T> type)
OsmPrimitives of type type present in
another collection of OsmPrimitives. The result collection is a list.
If list is null, replies an empty list.
T - list - the original listtype - the type to filter for
type
public static <T extends OsmPrimitive> java.util.LinkedHashSet<T> getFilteredSet(java.util.Collection<OsmPrimitive> set,
java.lang.Class<T> type)
OsmPrimitives of type type present in
another collection of OsmPrimitives. The result collection is a set.
If list is null, replies an empty set.
T - list - the original collectiontype - the type to filter for
typepublic static java.util.Set<OsmPrimitive> getReferrer(java.util.Collection<? extends OsmPrimitive> primitives)
primitives.
primitives - the collection of primitives.
primitives;
empty set if primitives is null or if there are no referring primitivespublic void clearCachedStyle()
void setDataset(DataSet dataSet)
dataSet - public DataSet getDataSet()
public void checkDataset()
protected boolean writeLock()
protected void writeUnlock(boolean locked)
public void setOsmId(long id,
int version)
setOsmId in interface IPrimitivesetOsmId in class AbstractPrimitiveid - 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()
DataSet.
clearOsmId in class AbstractPrimitiveDataIntegrityProblemException - If primitive was already added to the datasetpublic void setUser(User user)
AbstractPrimitive
setUser in interface IPrimitivesetUser in class AbstractPrimitiveuser - the user
public void setChangesetId(int changesetId)
throws java.lang.IllegalStateException,
java.lang.IllegalArgumentException
AbstractPrimitive
setChangesetId in interface IPrimitivesetChangesetId in class AbstractPrimitivechangesetId - the id. >= 0 required.
java.lang.IllegalStateException - thrown if this primitive is new.
java.lang.IllegalArgumentException - thrown if id < 0public void setTimestamp(java.util.Date timestamp)
setTimestamp in interface IPrimitivesetTimestamp in class AbstractPrimitive
private void updateFlagsNoLock(int flag,
boolean value)
protected final void updateFlags(int flag,
boolean value)
updateFlags in class AbstractPrimitivepublic boolean setDisabledState(boolean hidden)
hidden - if the primitive should be completely hidden from view or
just shown in gray color.
public boolean unsetDisabledState()
public void setDisabledType(boolean isExplicit)
public void setHiddenType(boolean isExplicit)
public boolean isDisabled()
public boolean isDisabledAndHidden()
public boolean getHiddenType()
public boolean getDisabledType()
public boolean isSelectable()
public boolean isDrawable()
public void setVisible(boolean visible)
throws java.lang.IllegalStateException
AbstractPrimitive
setVisible in interface IPrimitivesetVisible in class AbstractPrimitivejava.lang.IllegalStateException - thrown if visible is set to false on an primitive with
id==0AbstractPrimitive.isVisible()public void setDeleted(boolean deleted)
AbstractPrimitive
setDeleted in interface IPrimitivesetDeleted in class AbstractPrimitivedeleted - true, if this primitive is deleted; false, otherwiseprotected void setIncomplete(boolean incomplete)
AbstractPrimitive
setIncomplete in class AbstractPrimitivepublic boolean isSelected()
public boolean isMemberOfSelected()
public void setHighlighted(boolean highlighted)
public boolean isHighlighted()
public static java.util.Collection<java.lang.String> getUninterestingKeys()
public static java.util.Collection<java.lang.String> getDiscardableKeys()
public static boolean isUninterestingKey(java.lang.String key)
private void updateTagged()
public boolean isTagged()
private void updateDirectionFlags()
public boolean hasDirectionKeys()
public boolean reversedDirection()
public final void setKeys(java.util.Map<java.lang.String,java.lang.String> keys)
AbstractPrimitivekeys.
Old key/value pairs are removed.
If keys is null, clears existing key/value pairs.
setKeys in interface TaggedsetKeys in class AbstractPrimitivekeys - the key/value pairs to set. If null, removes all existing key/value pairs.
public final void put(java.lang.String key,
java.lang.String value)
AbstractPrimitiveAbstractPrimitive.remove(String).
put in interface Taggedput in class AbstractPrimitivekey - 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.AbstractPrimitive.remove(String)public final void remove(java.lang.String key)
AbstractPrimitive
remove in interface Taggedremove in class AbstractPrimitivekey - the key to be removed. Ignored, if key is null.public final void removeAll()
AbstractPrimitive
removeAll in interface TaggedremoveAll in class AbstractPrimitiveprotected final void keysChangedImpl(java.util.Map<java.lang.String,java.lang.String> originalKeys)
AbstractPrimitive
keysChangedImpl in class AbstractPrimitiveprotected void addReferrer(OsmPrimitive referrer)
referrer - protected void removeReferrer(OsmPrimitive referrer)
referrer - public final java.util.List<OsmPrimitive> getReferrers(boolean allowWithoutDataset)
Way wnew = new Way(existingWay)
allowWithoutDataset - If true, method will return empty list if primitive is not part of the dataset. If false,
exception will be thrown in this case
public final java.util.List<OsmPrimitive> getReferrers()
public void visitReferrers(Visitor visitor)
Visits visitor for all referrers.
visitor - the visitor. Ignored, if null.public final boolean isReferredByWays(int n)
n - Minimal number of ways to return true. Must be positivepublic abstract void visit(Visitor visitor)
public void cloneFrom(OsmPrimitive other)
public void mergeFrom(OsmPrimitive other)
other onto this.
Both this and other must be new, or both must be assigned an OSM ID. If both this and other
have an assigend OSM id, the IDs have to be the same.
other - the other primitive. Must not be null.
java.lang.IllegalArgumentException - thrown if other is null.
DataIntegrityProblemException - thrown if either this is new and other is not, or other is new and this is not
DataIntegrityProblemException - thrown if other isn't new and other.getId() != this.getId()public boolean hasEqualSemanticAttributes(OsmPrimitive other)
other -
public boolean hasEqualTechnicalAttributes(OsmPrimitive other)
other - the other primitive
public void load(PrimitiveData data)
data - public abstract PrimitiveData save()
protected void saveCommonAttributes(PrimitiveData data)
public abstract BBox getBBox()
public abstract void updatePosition()
protected java.lang.String getFlagsAsString()
getFlagsAsString in class AbstractPrimitivepublic boolean equals(java.lang.Object obj)
equals in class java.lang.Objectpublic final int hashCode()
hashCode in class java.lang.Objectpublic abstract java.lang.String getDisplayName(NameFormatter formatter)
formatter
public java.util.Collection<java.lang.String> getTemplateKeys()
getTemplateKeys in interface TemplateEngineDataProvider
public java.lang.Object getTemplateValue(java.lang.String name,
boolean special)
getTemplateValue in interface TemplateEngineDataProviderpublic boolean evaluateCondition(SearchCompiler.Match condition)
evaluateCondition in interface TemplateEngineDataProviderpublic static java.util.Set<Relation> getParentRelations(java.util.Collection<? extends OsmPrimitive> primitives)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||