Class Changeset

java.lang.Object
org.openstreetmap.josm.data.osm.Changeset
All Implemented Interfaces:
Comparable<Changeset>, Tagged

public final class Changeset extends Object implements Tagged, Comparable<Changeset>
Represents a single changeset in JOSM. For now its only used during upload but in the future we may do more.
Since:
625
  • Field Details

    • MAX_CHANGESET_TAG_LENGTH

      public static final int MAX_CHANGESET_TAG_LENGTH
      The maximum changeset tag length allowed by API 0.6
      See Also:
    • id

      private int id
      the changeset id
    • user

      private User user
      the user who owns the changeset
    • createdAt

      private Instant createdAt
      date this changeset was created at
    • closedAt

      private Instant closedAt
      the date this changeset was closed at
    • open

      private boolean open
      indicates whether this changeset is still open or not
    • min

      private LatLon min
      the min. coordinates of the bounding box of this changeset
    • max

      private LatLon max
      the max. coordinates of the bounding box of this changeset
    • commentsCount

      private int commentsCount
      the number of comments for this changeset
    • changesCount

      private int changesCount
      the number of changes for this changeset
    • tags

      private Map<String,String> tags
      the map of tags
    • incomplete

      private boolean incomplete
      indicates whether this changeset is incomplete. For an incomplete changeset we only know its id
    • content

      the changeset content
    • discussion

      the changeset discussion
  • Constructor Details

    • Changeset

      public Changeset()
      Creates a new changeset with id 0.
    • Changeset

      public Changeset(int id)
      Creates a changeset with id id. If id > 0, sets incomplete to true.
      Parameters:
      id - the id
    • Changeset

      public Changeset(Changeset other)
      Creates a clone of other
      Parameters:
      other - the other changeset. If null, creates a new changeset with id 0.
  • Method Details

    • fromPrimitive

      public static Changeset fromPrimitive(OsmPrimitive primitive)
      Creates a changeset with the data obtained from the given preset, i.e., the changeset id, user, and timestamp.
      Parameters:
      primitive - the primitive to use
      Returns:
      the created changeset
    • compareTo

      public int compareTo(Changeset other)
      Compares this changeset to another, based on their identifier.
      Specified by:
      compareTo in interface Comparable<Changeset>
      Parameters:
      other - other changeset
      Returns:
      the value 0 if getId() == other.getId(); a value less than 0 if getId() < other.getId(); and a value greater than 0 if getId() > other.getId()
    • getName

      public String getName()
      Returns the changeset name.
      Returns:
      the changeset name (untranslated: "changeset <identifier>")
    • getDisplayName

      public String getDisplayName(NameFormatter formatter)
      Returns the changeset display name, as per given name formatter.
      Parameters:
      formatter - name formatter
      Returns:
      the changeset display name, as per given name formatter
    • getId

      public int getId()
      Returns the changeset identifier.
      Returns:
      the changeset identifier
    • setId

      public void setId(int id)
      Sets the changeset identifier.
      Parameters:
      id - changeset identifier
    • getUser

      public User getUser()
      Returns the changeset user.
      Returns:
      the changeset user
    • setUser

      public void setUser(User user)
      Sets the changeset user.
      Parameters:
      user - changeset user
    • getCreatedAt

      Returns the changeset creation date.
      Returns:
      the changeset creation date
    • setCreatedAt

      public void setCreatedAt(Instant createdAt)
      Sets the changeset creation date.
      Parameters:
      createdAt - changeset creation date
    • getClosedAt

      public Instant getClosedAt()
      Returns the changeset closure date.
      Returns:
      the changeset closure date
    • setClosedAt

      public void setClosedAt(Instant closedAt)
      Sets the changeset closure date.
      Parameters:
      closedAt - changeset closure date
    • isOpen

      public boolean isOpen()
      Determines if this changeset is open.
      Returns:
      true if this changeset is open
    • setOpen

      public void setOpen(boolean open)
      Sets whether this changeset is open.
      Parameters:
      open - true if this changeset is open
    • getMin

      public LatLon getMin()
      Returns the min lat/lon of the changeset bounding box.
      Returns:
      the min lat/lon of the changeset bounding box
    • setMin

      public void setMin(LatLon min)
      Sets the min lat/lon of the changeset bounding box.
      Parameters:
      min - min lat/lon of the changeset bounding box
    • getMax

      public LatLon getMax()
      Returns the max lat/lon of the changeset bounding box.
      Returns:
      the max lat/lon of the changeset bounding box
    • setMax

      public void setMax(LatLon max)
      Sets the max lat/lon of the changeset bounding box.
      Parameters:
      max - min lat/lon of the changeset bounding box
    • getBounds

      public Bounds getBounds()
      Returns the changeset bounding box.
      Returns:
      the changeset bounding box
    • getComment

      public String getComment()
      Replies this changeset comment.
      Returns:
      this changeset comment (empty string if missing)
      Since:
      12494
    • getCommentsCount

      public int getCommentsCount()
      Replies the number of comments for this changeset discussion.
      Returns:
      the number of comments for this changeset discussion
      Since:
      7700
    • setCommentsCount

      public void setCommentsCount(int commentsCount)
      Sets the number of comments for this changeset discussion.
      Parameters:
      commentsCount - the number of comments for this changeset discussion
      Since:
      7700
    • getChangesCount

      public int getChangesCount()
      Replies the number of changes for this changeset.
      Returns:
      the number of changes for this changeset
      Since:
      14231
    • setChangesCount

      public void setChangesCount(int changesCount)
      Sets the number of changes for this changeset.
      Parameters:
      changesCount - the number of changes for this changeset
      Since:
      14231
    • getKeys

      public Map<String,String> getKeys()
      Description copied from interface: Tagged
      Replies the map of key/value pairs. Never null, but may be the empty map.
      Specified by:
      getKeys in interface Tagged
      Returns:
      the map of key/value pairs
    • setKeys

      public void setKeys(Map<String,String> keys)
      Description copied from interface: Tagged
      Sets the map of key/value pairs
      Specified by:
      setKeys in interface Tagged
      Parameters:
      keys - the map of key value pairs. If null, reset to the empty map.
    • isIncomplete

      public boolean isIncomplete()
      Determines if this changeset is incomplete.
      Returns:
      true if this changeset is incomplete
    • setIncomplete

      public void setIncomplete(boolean incomplete)
      Sets whether this changeset is incomplete
      Parameters:
      incomplete - true if this changeset is incomplete
    • put

      public void put(String key, String value)
      Description copied from interface: Tagged
      Sets a key/value pairs
      Specified by:
      put in interface Tagged
      Parameters:
      key - the key
      value - the value. If null, removes the key/value pair.
    • get

      public String get(String key)
      Description copied from interface: Tagged
      Replies the value of the given key; null, if there is no value for this key
      Specified by:
      get in interface Tagged
      Parameters:
      key - the key
      Returns:
      the value
    • remove

      public void remove(String key)
      Description copied from interface: Tagged
      Removes a given key/value pair
      Specified by:
      remove in interface Tagged
      Parameters:
      key - the key
    • removeAll

      public void removeAll()
      Description copied from interface: Tagged
      Removes all tags
      Specified by:
      removeAll in interface Tagged
    • hasEqualSemanticAttributes

      public boolean hasEqualSemanticAttributes(Changeset other)
      Determines if this changeset has equals semantic attributes with another one.
      Parameters:
      other - other changeset
      Returns:
      true if this changeset has equals semantic attributes with other changeset
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hasKeys

      public boolean hasKeys()
      Description copied from interface: Tagged
      Replies true, if there is at least one key/value pair; false, otherwise
      Specified by:
      hasKeys in interface Tagged
      Returns:
      true, if there is at least one key/value pair; false, otherwise
    • keySet

      Description copied from interface: Tagged
      Replies the set of keys
      Specified by:
      keySet in interface Tagged
      Returns:
      the set of keys
      See Also:
    • getNumKeys

      public int getNumKeys()
      Description copied from interface: Tagged
      Gets the number of keys
      Specified by:
      getNumKeys in interface Tagged
      Returns:
      The number of keys set for this tagged object.
    • isNew

      public boolean isNew()
      Determines if this changeset is new.
      Returns:
      true if this changeset is new (id <= 0)
    • mergeFrom

      public void mergeFrom(Changeset other)
      Merges changeset metadata from another changeset.
      Parameters:
      other - other changeset
    • hasContent

      public boolean hasContent()
      Determines if this changeset has contents.
      Returns:
      true if this changeset has contents
    • getContent

      Returns the changeset contents.
      Returns:
      the changeset contents, can be null
    • setContent

      public void setContent(ChangesetDataSet content)
      Sets the changeset contents.
      Parameters:
      content - changeset contents, can be null
    • getDiscussion

      Replies the list of comments in the changeset discussion, if any.
      Returns:
      the list of comments in the changeset discussion. May be empty but never null
      Since:
      7704
    • addDiscussionComment

      Adds a comment to the changeset discussion.
      Parameters:
      comment - the comment to add. Ignored if null
      Since:
      7704
    • toString

      public String toString()
      Overrides:
      toString in class Object