Class ChangesetQuery

java.lang.Object
org.openstreetmap.josm.io.ChangesetQuery

public class ChangesetQuery extends Object
Data class to collect restrictions (parameters) for downloading changesets from the OSM API.
See Also:
  • Field Details

    • ERROR_UNEXPECTED_VALUE_CHANGESET_QUERY_URL

    • DISPLAY_NAME

      private static final String DISPLAY_NAME
      See Also:
    • MAX_CHANGESETS_NUMBER

      public static final int MAX_CHANGESETS_NUMBER
      Maximum number of changesets returned by the OSM API call "/changesets?"
      See Also:
    • uid

      private Integer uid
      the user id this query is restricted to. null, if no restriction to a user id applies
    • userName

      private String userName
      the user name this query is restricted to. null, if no restriction to a user name applies
    • bounds

      private Bounds bounds
      the bounding box this query is restricted to. null, if no restriction to a bounding box applies
    • closedAfter

      the date after which changesets have been closed this query is restricted to. null, if no restriction to closure date applies
    • createdBefore

      the date before which changesets have been created this query is restricted to. null, if no restriction to creation date applies
    • open

      private Boolean open
      indicates whether only open changesets are queried. null, if no restrictions regarding open changesets apply
    • closed

      private Boolean closed
      indicates whether only closed changesets are queried. null, if no restrictions regarding closed changesets apply
    • changesetIds

      a collection of changeset ids to query for
  • Constructor Details

  • Method Details

    • buildFromUrlQuery

      Replies a changeset query object from the query part of a OSM API URL for querying changesets.
      Parameters:
      query - the query part
      Returns:
      the query object
      Throws:
      ChangesetQuery.ChangesetQueryUrlException - if query doesn't consist of valid query parameters
    • forCurrentUser

      public static ChangesetQuery forCurrentUser()
      Replies a changeset query object restricted to the current user, if known.
      Returns:
      a changeset query object restricted to the current user, if known
      Throws:
      IllegalStateException - if current user is anonymous
      Since:
      12495
    • forUser

      public ChangesetQuery forUser(int uid)
      Restricts the query to changesets owned by the user with id uid.
      Parameters:
      uid - the uid of the user. > 0 expected.
      Returns:
      the query object with the applied restriction
      Throws:
      IllegalArgumentException - if uid <= 0
      See Also:
    • forUser

      public ChangesetQuery forUser(String userName)
      Restricts the query to changesets owned by the user with user name username.

      Caveat: for historical reasons the username might not be unique! It is recommended to use forUser(int) to restrict the query to a specific user.

      Parameters:
      userName - the username. Must not be null.
      Returns:
      the query object with the applied restriction
      Throws:
      IllegalArgumentException - if username is null.
      See Also:
    • isRestrictedToPartiallyIdentifiedUser

      Replies true if this query is restricted to user whom we only know the user name for.
      Returns:
      true if this query is restricted to user whom we only know the user name for
    • getRestrictionToOpen

      Replies true/false if this query is restricted to changesets which are or aren't open.
      Returns:
      whether changesets should or should not be open, or null if there is no restriction
      Since:
      14039
    • getRestrictionToClosed

      Replies true/false if this query is restricted to changesets which are or aren't closed.
      Returns:
      whether changesets should or should not be closed, or null if there is no restriction
      Since:
      14039
    • getClosedAfter

      Replies the date after which changesets have been closed this query is restricted to.
      Returns:
      the date after which changesets have been closed this query is restricted to. null, if no restriction to closure date applies
      Since:
      14039
    • getCreatedBefore

      Replies the date before which changesets have been created this query is restricted to.
      Returns:
      the date before which changesets have been created this query is restricted to. null, if no restriction to creation date applies
      Since:
      14039
    • getAdditionalChangesetIds

      Replies the list of additional changeset ids to query.
      Returns:
      the list of additional changeset ids to query (never null)
      Since:
      14039
    • getBounds

      public final Bounds getBounds()
      Replies the bounding box this query is restricted to.
      Returns:
      the bounding box this query is restricted to. null, if no restriction to a bounding box applies
      Since:
      14039
    • getUserName

      public String getUserName()
      Replies the user name which this query is restricted to. null, if this query isn't restricted to a user name, i.e. if isRestrictedToPartiallyIdentifiedUser() is false.
      Returns:
      the user name which this query is restricted to
    • isRestrictedToFullyIdentifiedUser

      Replies true if this query is restricted to user whom know the user id for.
      Returns:
      true if this query is restricted to user whom know the user id for
    • inBbox

      public ChangesetQuery inBbox(double minLon, double minLat, double maxLon, double maxLat)
      Replies a query which is restricted to a bounding box.
      Parameters:
      minLon - min longitude of the bounding box. Valid longitude value expected.
      minLat - min latitude of the bounding box. Valid latitude value expected.
      maxLon - max longitude of the bounding box. Valid longitude value expected.
      maxLat - max latitude of the bounding box. Valid latitude value expected.
      Returns:
      the restricted changeset query
      Throws:
      IllegalArgumentException - if either of the parameters isn't a valid longitude or latitude value
    • inBbox

      public ChangesetQuery inBbox(LatLon min, LatLon max)
      Replies a query which is restricted to a bounding box.
      Parameters:
      min - the min lat/lon coordinates of the bounding box. Must not be null.
      max - the max lat/lon coordinates of the bounding box. Must not be null.
      Returns:
      the restricted changeset query
      Throws:
      IllegalArgumentException - if min is null
      IllegalArgumentException - if max is null
    • inBbox

      public ChangesetQuery inBbox(Bounds bbox)
      Replies a query which is restricted to a bounding box given by bbox.
      Parameters:
      bbox - the bounding box. Must not be null.
      Returns:
      the changeset query
      Throws:
      IllegalArgumentException - if bbox is null.
    • closedAfter

      Restricts the result to changesets which have been closed after the date given by d. d d is a date relative to the current time zone.
      Parameters:
      d - the date. Must not be null.
      Returns:
      the restricted changeset query
      Throws:
      IllegalArgumentException - if d is null
    • closedAfterAndCreatedBefore

      public ChangesetQuery closedAfterAndCreatedBefore(Instant closedAfter, Instant createdBefore)
      Restricts the result to changesets which have been closed after closedAfter and which have been created before createdBefore. Both dates are expressed relative to the current time zone.
      Parameters:
      closedAfter - only reply changesets closed after this date. Must not be null.
      createdBefore - only reply changesets created before this date. Must not be null.
      Returns:
      the restricted changeset query
      Throws:
      IllegalArgumentException - if closedAfter is null
      IllegalArgumentException - if createdBefore is null
    • beingOpen

      public ChangesetQuery beingOpen(boolean isOpen)
      Restricts the result to changesets which are or aren't open, depending on the value of isOpen
      Parameters:
      isOpen - whether changesets should or should not be open
      Returns:
      the restricted changeset query
    • beingClosed

      public ChangesetQuery beingClosed(boolean isClosed)
      Restricts the result to changesets which are or aren't closed, depending on the value of isClosed
      Parameters:
      isClosed - whether changesets should or should not be open
      Returns:
      the restricted changeset query
    • forChangesetIds

      Restricts the query to the given changeset ids (which are added to previously added ones).
      Parameters:
      changesetIds - the changeset ids
      Returns:
      the query object with the applied restriction
      Throws:
      IllegalArgumentException - if changesetIds is null.
    • getQueryString

      Replies the query string to be used in a query URL for the OSM API.
      Returns:
      the query string
    • toString

      public String toString()
      Overrides:
      toString in class Object