Package org.openstreetmap.josm.command
Class ChangePropertyCommand
java.lang.Object
org.openstreetmap.josm.command.Command
org.openstreetmap.josm.command.ChangePropertyCommand
- All Implemented Interfaces:
PseudoCommand
Command that manipulate the key/value structure of several objects. Manages deletion,
adding and modify of values and keys.
- Since:
- 24
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static final classNested classes/interfaces inherited from class org.openstreetmap.josm.command.Command
Command.OldNodeState -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final List<OsmPrimitive>All primitives that are affected with this command.Key and value pairs.Fields inherited from class org.openstreetmap.josm.command.Command
IS_INCOMPLETE, IS_OK, IS_OUTSIDE -
Constructor Summary
ConstructorsConstructorDescriptionChangePropertyCommand(Collection<? extends OsmPrimitive> objects, String key, String value) Creates a command to change one tag of multiple objectsChangePropertyCommand(Collection<? extends OsmPrimitive> objects, Map<String, String> tags) Creates a command to change multiple tags of multiple objectsChangePropertyCommand(DataSet ds, Collection<? extends OsmPrimitive> objects, Map<String, String> tags) Creates a command to change multiple tags of multiple objectsChangePropertyCommand(OsmPrimitive object, String key, String value) Creates a command to change one tag of one object -
Method Summary
Modifier and TypeMethodDescriptionstatic Commandbuild(OsmPrimitive source, Tagged target) Calculate theChangePropertyCommandthat is needed to change the tags in source to be equal to those in target.booleanbooleanExecutes the command on the dataset.voidfillModifiedData(Collection<OsmPrimitive> modified, Collection<OsmPrimitive> deleted, Collection<OsmPrimitive> added) Fill in the changed data this command operates on.Returns the subcommands of this command.Provides a descriptive icon of this command.Provides a description text representing this command.final intReturns the number of objects that will effectively be modified, before the command is executed.getTags()Returns the tags to set (key/value pairs).inthashCode()private voidinit(Collection<? extends OsmPrimitive> objects) Initialize the instance by finding what objects will be modifiedMethods inherited from class org.openstreetmap.josm.command.Command
checkOutlyingOrIncompleteOperation, ensurePrimitivesAreInDataset, getAffectedDataSet, getOrig, getParticipatingPrimitives, undoCommand
-
Field Details
-
objects
All primitives that are affected with this command. -
tags
Key and value pairs. If value isnull, delete all key references with the given key. Otherwise, change the tags of all objects to the given value or create keys of those objects that do not have the key yet.
-
-
Constructor Details
-
ChangePropertyCommand
public ChangePropertyCommand(DataSet ds, Collection<? extends OsmPrimitive> objects, Map<String, String> tags) Creates a command to change multiple tags of multiple objects- Parameters:
ds- The target data set. Must not benullobjects- the objects to modify. Must not be emptytags- the tags to set. Caller must make sure that the tas are not changed once the command was executed.- Since:
- 12726
-
ChangePropertyCommand
Creates a command to change multiple tags of multiple objects- Parameters:
objects- the objects to modify. Must not be empty, and objects must belong to a data settags- the tags to set. Caller must make sure that the tas are not changed once the command was executed.- Throws:
NullPointerException- if objects is null or contain null itemNoSuchElementException- if objects is empty
-
ChangePropertyCommand
Creates a command to change one tag of multiple objects- Parameters:
objects- the objects to modify. Must not be empty, and objects must belong to a data setkey- the key of the tag to setvalue- the value of the key to set- Throws:
NullPointerException- if objects is null or contain null itemNoSuchElementException- if objects is empty
-
ChangePropertyCommand
Creates a command to change one tag of one object- Parameters:
object- the object to modify. Must belong to a data setkey- the key of the tag to setvalue- the value of the key to set- Throws:
NullPointerException- if object is null
-
-
Method Details
-
init
Initialize the instance by finding what objects will be modified- Parameters:
objects- the objects to (possibly) modify
-
executeCommand
Description copied from class:CommandExecutes the command on the dataset. This implementation will remember all primitives returned by fillModifiedData for restoring them on undo.The layer should be invalidated after execution so that it can be re-painted.
- Overrides:
executeCommandin classCommand- Returns:
- true
-
fillModifiedData
public void fillModifiedData(Collection<OsmPrimitive> modified, Collection<OsmPrimitive> deleted, Collection<OsmPrimitive> added) Description copied from class:CommandFill in the changed data this command operates on. Add to the lists, don't clear them.- Specified by:
fillModifiedDatain classCommand- Parameters:
modified- The modified primitivesdeleted- The deleted primitivesadded- The added primitives
-
getDescriptionText
Description copied from interface:PseudoCommandProvides a description text representing this command.- Returns:
- description text representing this command
-
getDescriptionIcon
Description copied from interface:PseudoCommandProvides a descriptive icon of this command.- Returns:
- descriptive icon of this command
-
getChildren
Description copied from interface:PseudoCommandReturns the subcommands of this command. Override for subclasses that have child commands.- Returns:
- the subcommands, null if there are no child commands
-
getObjectsNumber
Returns the number of objects that will effectively be modified, before the command is executed.- Returns:
- the number of objects that will effectively be modified (can be 0)
- Since:
- 8945
- See Also:
-
getTags
Returns the tags to set (key/value pairs).- Returns:
- the tags to set (key/value pairs)
-
hashCode
-
equals
-
build
Calculate theChangePropertyCommandthat is needed to change the tags in source to be equal to those in target.- Parameters:
source- the source primitivetarget- the target primitive- Returns:
- null if no changes are needed, else a
ChangePropertyCommand - Since:
- 17357
-