public class AutoCompletionManager extends java.lang.Object implements DataSetListener
Modifier and Type | Field and Description |
---|---|
protected boolean |
dirty
If the dirty flag is set true, a rebuild is necessary.
|
protected DataSet |
ds
The data set that is managed
|
protected static java.util.Set<java.lang.String> |
presetRoleCache
the same as roleCache but for the preset roles
can be accessed directly
|
protected static MultiMap<java.lang.String,java.lang.String> |
presetTagCache
the same as tagCache but for the preset keys and values
can be accessed directly
|
protected java.util.Set<java.lang.String> |
roleCache
the cached list of member roles
only accessed by getRoleCache(), rebuild() and cacheRelationMemberRoles()
use getRoleCache() accessor
|
protected MultiMap<java.lang.String,java.lang.String> |
tagCache
the cached tags given by a tag key and a list of values for this tag
only accessed by getTagCache(), rebuild() and cachePrimitiveTags()
use getTagCache() accessor
|
Constructor and Description |
---|
AutoCompletionManager(DataSet ds) |
Modifier and Type | Method and Description |
---|---|
static void |
cachePresets(java.util.Collection<TaggingPreset> presets)
Initialize the cache for presets.
|
protected void |
cachePrimitives(java.util.Collection<? extends OsmPrimitive> primitives) |
protected void |
cachePrimitiveTags(OsmPrimitive primitive)
make sure, the keys and values of all tags held by primitive are
in the auto completion cache
|
protected void |
cacheRelationMemberRoles(Relation relation)
Caches all member roles of the relation
relation |
void |
dataChanged(DataChangedEvent event)
Called after big changes in dataset.
|
protected java.util.List<java.lang.String> |
getDataKeys()
replies the keys held by the cache
|
protected java.util.List<java.lang.String> |
getDataValues(java.lang.String key)
replies the auto completion values allowed for a specific key.
|
java.util.List<AutoCompletionListItem> |
getKeys()
Returns the currently cached tag keys.
|
java.util.List<java.lang.String> |
getMemberRoles()
Replies the list of member roles
|
protected java.util.List<java.lang.String> |
getPresetKeys() |
protected static java.util.List<java.lang.String> |
getPresetValues(java.lang.String key) |
protected java.util.Set<java.lang.String> |
getRoleCache() |
protected MultiMap<java.lang.String,java.lang.String> |
getTagCache() |
java.util.List<AutoCompletionListItem> |
getValues(java.util.List<java.lang.String> keys)
Returns the currently cached tag values for a given list of tag keys.
|
java.util.List<AutoCompletionListItem> |
getValues(java.lang.String key)
Returns the currently cached tag values for a given tag key.
|
void |
nodeMoved(NodeMovedEvent event)
A node's coordinates were modified.
|
void |
otherDatasetChange(AbstractDatasetChangedEvent event)
Minor dataset change, currently only changeset id changed is supported, but can
be extended in future.
|
void |
populateWithKeys(AutoCompletionList list)
Populates the an
AutoCompletionList with the currently cached tag keys |
void |
populateWithMemberRoles(AutoCompletionList list)
Populates the
AutoCompletionList with the currently cached
member roles. |
void |
populateWithMemberRoles(AutoCompletionList list,
Relation r)
Populates the
AutoCompletionList with the roles used in this relation
plus the ones defined in its applicable presets, if any. |
void |
populateWithTagValues(AutoCompletionList list,
java.util.List<java.lang.String> keys)
Populates the an
AutoCompletionList with the currently cached
values for some given tags |
void |
populateWithTagValues(AutoCompletionList list,
java.lang.String key)
Populates the an
AutoCompletionList with the currently cached
values for a tag |
void |
primitivesAdded(PrimitivesAddedEvent event)
Implementation of the DataSetListener interface
|
void |
primitivesRemoved(PrimitivesRemovedEvent event)
A bunch of primitives were removed from the DataSet, or preexisting
primitives were marked as deleted.
|
protected void |
rebuild()
initializes the cache from the primitives in the dataset
|
void |
relationMembersChanged(RelationMembersChangedEvent event)
A relation's members have changed.
|
void |
tagsChanged(TagsChangedEvent event)
There was some change in the tag set of a primitive.
|
void |
wayNodesChanged(WayNodesChangedEvent event)
A way's node list was changed.
|
protected boolean dirty
protected MultiMap<java.lang.String,java.lang.String> tagCache
protected static final MultiMap<java.lang.String,java.lang.String> presetTagCache
protected java.util.Set<java.lang.String> roleCache
protected static final java.util.Set<java.lang.String> presetRoleCache
public AutoCompletionManager(DataSet ds)
protected MultiMap<java.lang.String,java.lang.String> getTagCache()
protected java.util.Set<java.lang.String> getRoleCache()
protected void rebuild()
protected void cachePrimitives(java.util.Collection<? extends OsmPrimitive> primitives)
protected void cachePrimitiveTags(OsmPrimitive primitive)
primitive
- an OSM primitiveprotected void cacheRelationMemberRoles(Relation relation)
relation
relation
- the relationpublic static void cachePresets(java.util.Collection<TaggingPreset> presets)
protected java.util.List<java.lang.String> getDataKeys()
protected java.util.List<java.lang.String> getPresetKeys()
protected java.util.List<java.lang.String> getDataValues(java.lang.String key)
getKeys()
.key
- protected static java.util.List<java.lang.String> getPresetValues(java.lang.String key)
public java.util.List<java.lang.String> getMemberRoles()
public void populateWithMemberRoles(AutoCompletionList list)
AutoCompletionList
with the currently cached
member roles.list
- the list to populatepublic void populateWithMemberRoles(AutoCompletionList list, Relation r)
AutoCompletionList
with the roles used in this relation
plus the ones defined in its applicable presets, if any. If the relation type is unknown,
then all the roles known globally will be added, as in populateWithMemberRoles(AutoCompletionList)
.list
- the list to populater
- the relation to get roles fromjava.lang.IllegalArgumentException
- if list is nullpublic void populateWithKeys(AutoCompletionList list)
AutoCompletionList
with the currently cached tag keyslist
- the list to populatepublic void populateWithTagValues(AutoCompletionList list, java.lang.String key)
AutoCompletionList
with the currently cached
values for a taglist
- the list to populatekey
- the tag keypublic void populateWithTagValues(AutoCompletionList list, java.util.List<java.lang.String> keys)
AutoCompletionList
with the currently cached
values for some given tagslist
- the list to populatekeys
- the tag keyspublic java.util.List<AutoCompletionListItem> getKeys()
public java.util.List<AutoCompletionListItem> getValues(java.lang.String key)
key
- the tag keypublic java.util.List<AutoCompletionListItem> getValues(java.util.List<java.lang.String> keys)
keys
- the tag keyspublic void primitivesAdded(PrimitivesAddedEvent event)
primitivesAdded
in interface DataSetListener
event
- An event for an collection of newly-visible primitivespublic void primitivesRemoved(PrimitivesRemovedEvent event)
DataSetListener
primitivesRemoved
in interface DataSetListener
event
- An event for an collection of newly-invisible primitivespublic void tagsChanged(TagsChangedEvent event)
DataSetListener
tagsChanged
in interface DataSetListener
event
- the event for the primitive, whose tags were affected.public void nodeMoved(NodeMovedEvent event)
DataSetListener
nodeMoved
in interface DataSetListener
event
- The event for the node that was moved.public void wayNodesChanged(WayNodesChangedEvent event)
DataSetListener
wayNodesChanged
in interface DataSetListener
event
- The event for the way that was modified.public void relationMembersChanged(RelationMembersChangedEvent event)
DataSetListener
relationMembersChanged
in interface DataSetListener
event
- The event for the relation that was modified.public void otherDatasetChange(AbstractDatasetChangedEvent event)
DataSetListener
otherDatasetChange
in interface DataSetListener
event
- the event for data modificationpublic void dataChanged(DataChangedEvent event)
DataSetListener
DataSetListener.dataChanged(DataChangedEvent event)
is called.dataChanged
in interface DataSetListener