org.openstreetmap.josm.gui.conflict.tags
Class MultiValueResolutionDecision

java.lang.Object
  extended by org.openstreetmap.josm.gui.conflict.tags.MultiValueResolutionDecision

public class MultiValueResolutionDecision
extends java.lang.Object

Represents a decision for a conflict due to multiple possible value for a tag.


Field Summary
private  TagCollection tags
          the collection of tags for which a decision is needed
private  MultiValueDecisionType type
          the type of decision
private  java.lang.String value
          the selected value if type is MultiValueDecisionType.KEEP_ONE
 
Constructor Summary
MultiValueResolutionDecision()
          constuctor
MultiValueResolutionDecision(TagCollection tags)
          Creates a new decision for the tag collection tags.
 
Method Summary
 void applyTo(java.util.Collection<? extends OsmPrimitive> primitives)
          Applies this resolution to a collection of primitives
 void applyTo(OsmPrimitive primitive)
          Applies the resolution to an OsmPrimitive
protected  void autoDecide()
          Tries to find the best decision based on the current values.
 Command buildChangeCommand(java.util.Collection<? extends OsmPrimitive> primitives)
          Builds a change command for applying this resolution to a collection of primitives
 Command buildChangeCommand(OsmPrimitive primitive)
          Builds a change command for applying this resolution to a primitive
 boolean canKeepAll()
          Replies true, if this resolution has more than 1 possible non-empty values
 boolean canKeepNone()
          Replies true if the empty value is a possible value in this resolution
 java.lang.String getChosenValue()
          Replies the chosen value
 MultiValueDecisionType getDecisionType()
          Replies the type of the resolution
 java.lang.String getKey()
          Replies the key of the tag to be resolved by this resolution
 Tag getResolution()
          Replies a tag representing the current resolution.
 java.util.List<java.lang.String> getValues()
          Replies the list of possible, non empty values
 boolean isDecided()
          Replies true if this resolution is decided
 void keepAll()
          Apply the decision to keep all values
 void keepNone()
          Apply the decision to keep no value
 void keepOne(java.lang.String value)
          Apply the decision to keep exactly one value
 void setNew(java.lang.String value)
          sets a new value for this
 void undecide()
          marks this as undecided
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

type

private MultiValueDecisionType type
the type of decision


tags

private TagCollection tags
the collection of tags for which a decision is needed


value

private java.lang.String value
the selected value if type is MultiValueDecisionType.KEEP_ONE

Constructor Detail

MultiValueResolutionDecision

public MultiValueResolutionDecision()
constuctor


MultiValueResolutionDecision

public MultiValueResolutionDecision(TagCollection tags)
                             throws java.lang.IllegalArgumentException
Creates a new decision for the tag collection tags. All tags must have the same key.

Parameters:
tags - the tags. Must not be null.
Throws:
java.lang.IllegalArgumentException - thrown if tags is null
java.lang.IllegalArgumentException - thrown if there are more than one keys
java.lang.IllegalArgumentException - thrown if tags is empty
Method Detail

autoDecide

protected void autoDecide()
Tries to find the best decision based on the current values.


keepNone

public void keepNone()
Apply the decision to keep no value


keepAll

public void keepAll()
Apply the decision to keep all values


keepOne

public void keepOne(java.lang.String value)
             throws java.lang.IllegalArgumentException,
                    java.lang.IllegalStateException
Apply the decision to keep exactly one value

Parameters:
value - the value to keep
Throws:
java.lang.IllegalArgumentException - thrown if value is null
java.lang.IllegalStateException - thrown if value is not in the list of known values for this tag

setNew

public void setNew(java.lang.String value)
sets a new value for this

Parameters:
value - the new vlaue

undecide

public void undecide()
marks this as undecided


getChosenValue

public java.lang.String getChosenValue()
                                throws java.lang.IllegalStateException
Replies the chosen value

Returns:
the chosen value
Throws:
java.lang.IllegalStateException - thrown if this resolution is not yet decided

getValues

public java.util.List<java.lang.String> getValues()
Replies the list of possible, non empty values

Returns:
the list of possible, non empty values

getKey

public java.lang.String getKey()
Replies the key of the tag to be resolved by this resolution

Returns:
the key of the tag to be resolved by this resolution

canKeepNone

public boolean canKeepNone()
Replies true if the empty value is a possible value in this resolution

Returns:
true if the empty value is a possible value in this resolution

canKeepAll

public boolean canKeepAll()
Replies true, if this resolution has more than 1 possible non-empty values

Returns:
true, if this resolution has more than 1 possible non-empty values

isDecided

public boolean isDecided()
Replies true if this resolution is decided

Returns:
true if this resolution is decided

getDecisionType

public MultiValueDecisionType getDecisionType()
Replies the type of the resolution

Returns:
the type of the resolution

applyTo

public void applyTo(OsmPrimitive primitive)
             throws java.lang.IllegalStateException
Applies the resolution to an OsmPrimitive

Parameters:
primitive - the primitive
Throws:
java.lang.IllegalStateException - thrown if this resolution is not resolved yet

applyTo

public void applyTo(java.util.Collection<? extends OsmPrimitive> primitives)
             throws java.lang.IllegalStateException
Applies this resolution to a collection of primitives

Parameters:
primitives - the collection of primitives
Throws:
java.lang.IllegalStateException - thrown if this resolution is not resolved yet

buildChangeCommand

public Command buildChangeCommand(OsmPrimitive primitive)
                           throws java.lang.IllegalArgumentException,
                                  java.lang.IllegalStateException
Builds a change command for applying this resolution to a primitive

Parameters:
primitive - the primitive
Returns:
the change command
Throws:
java.lang.IllegalArgumentException - thrown if primitive is null
java.lang.IllegalStateException - thrown if this resolution is not resolved yet

buildChangeCommand

public Command buildChangeCommand(java.util.Collection<? extends OsmPrimitive> primitives)
Builds a change command for applying this resolution to a collection of primitives

Parameters:
primitives - the collection of primitives
Returns:
the change command
Throws:
java.lang.IllegalArgumentException - thrown if primitives is null
java.lang.IllegalStateException - thrown if this resolution is not resolved yet

getResolution

public Tag getResolution()
Replies a tag representing the current resolution. Null, if this resolution is not resolved yet.

Returns:
a tag representing the current resolution. Null, if this resolution is not resolved yet


JOSM