Package org.openstreetmap.josm.io
Class ChangesetQuery
- java.lang.Object
-
- org.openstreetmap.josm.io.ChangesetQuery
-
public class ChangesetQuery extends java.lang.Object
Data class to collect restrictions (parameters) for downloading changesets from the OSM API.- See Also:
- OSM API 0.6 call "/changesets?"
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classChangesetQuery.ChangesetQueryUrlExceptionException thrown for invalid changeset queries.static classChangesetQuery.ChangesetQueryUrlParserChangeset query URL parser.
-
Field Summary
Fields Modifier and Type Field Description private Boundsboundsthe bounding box this query is restricted to.private java.util.Collection<java.lang.Long>changesetIdsa collection of changeset ids to query forprivate java.lang.Booleanclosedindicates whether only closed changesets are queried.private java.time.InstantclosedAfterthe date after which changesets have been closed this query is restricted to.private java.time.InstantcreatedBeforethe date before which changesets have been created this query is restricted to.private static java.lang.StringDISPLAY_NAMEprivate static java.lang.StringERROR_UNEXPECTED_VALUE_CHANGESET_QUERY_URLstatic intMAX_CHANGESETS_NUMBERMaximum number of changesets returned by the OSM API call "/changesets?"private java.lang.Booleanopenindicates whether only open changesets are queried.private java.lang.Integeruidthe user id this query is restricted to.private java.lang.StringuserNamethe user name this query is restricted to.
-
Constructor Summary
Constructors Constructor Description ChangesetQuery()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ChangesetQuerybeingClosed(boolean isClosed)Restricts the result to changesets which are or aren't closed, depending on the value ofisClosedChangesetQuerybeingOpen(boolean isOpen)Restricts the result to changesets which are or aren't open, depending on the value ofisOpenstatic ChangesetQuerybuildFromUrlQuery(java.lang.String query)Replies a changeset query object from the query part of a OSM API URL for querying changesets.ChangesetQueryclosedAfter(java.time.Instant d)Restricts the result to changesets which have been closed after the date given byd.ChangesetQueryclosedAfterAndCreatedBefore(java.time.Instant closedAfter, java.time.Instant createdBefore)Restricts the result to changesets which have been closed afterclosedAfterand which have been created beforecreatedBefore.ChangesetQueryforChangesetIds(java.util.Collection<java.lang.Long> changesetIds)Restricts the query to the given changeset ids (which are added to previously added ones).static ChangesetQueryforCurrentUser()Replies a changeset query object restricted to the current user, if known.ChangesetQueryforUser(int uid)Restricts the query to changesets owned by the user with iduid.ChangesetQueryforUser(java.lang.String userName)Restricts the query to changesets owned by the user with user nameusername.java.util.Collection<java.lang.Long>getAdditionalChangesetIds()Replies the list of additional changeset ids to query.BoundsgetBounds()Replies the bounding box this query is restricted to.java.time.InstantgetClosedAfter()Replies the date after which changesets have been closed this query is restricted to.java.time.InstantgetCreatedBefore()Replies the date before which changesets have been created this query is restricted to.java.lang.StringgetQueryString()Replies the query string to be used in a query URL for the OSM API.java.lang.BooleangetRestrictionToClosed()Replies true/false if this query is restricted to changesets which are or aren't closed.java.lang.BooleangetRestrictionToOpen()Replies true/false if this query is restricted to changesets which are or aren't open.java.lang.StringgetUserName()Replies the user name which this query is restricted to.ChangesetQueryinBbox(double minLon, double minLat, double maxLon, double maxLat)Replies a query which is restricted to a bounding box.ChangesetQueryinBbox(Bounds bbox)Replies a query which is restricted to a bounding box given bybbox.ChangesetQueryinBbox(LatLon min, LatLon max)Replies a query which is restricted to a bounding box.booleanisRestrictedToFullyIdentifiedUser()Replies true if this query is restricted to user whom know the user id for.booleanisRestrictedToPartiallyIdentifiedUser()Replies true if this query is restricted to user whom we only know the user name for.java.lang.StringtoString()
-
-
-
Field Detail
-
ERROR_UNEXPECTED_VALUE_CHANGESET_QUERY_URL
private static final java.lang.String ERROR_UNEXPECTED_VALUE_CHANGESET_QUERY_URL
-
DISPLAY_NAME
private static final java.lang.String DISPLAY_NAME
- See Also:
- Constant Field Values
-
MAX_CHANGESETS_NUMBER
public static final int MAX_CHANGESETS_NUMBER
Maximum number of changesets returned by the OSM API call "/changesets?"- See Also:
- Constant Field Values
-
uid
private java.lang.Integer uid
the user id this query is restricted to. null, if no restriction to a user id applies
-
userName
private java.lang.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
private java.time.Instant closedAfter
the date after which changesets have been closed this query is restricted to. null, if no restriction to closure date applies
-
createdBefore
private java.time.Instant createdBefore
the date before which changesets have been created this query is restricted to. null, if no restriction to creation date applies
-
open
private java.lang.Boolean open
indicates whether only open changesets are queried. null, if no restrictions regarding open changesets apply
-
closed
private java.lang.Boolean closed
indicates whether only closed changesets are queried. null, if no restrictions regarding closed changesets apply
-
changesetIds
private java.util.Collection<java.lang.Long> changesetIds
a collection of changeset ids to query for
-
-
Constructor Detail
-
ChangesetQuery
public ChangesetQuery()
-
-
Method Detail
-
buildFromUrlQuery
public static ChangesetQuery buildFromUrlQuery(java.lang.String query) throws ChangesetQuery.ChangesetQueryUrlException
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:
java.lang.IllegalStateException- if current user is anonymous- Since:
- 12495
-
forUser
public ChangesetQuery forUser(int uid)
Restricts the query to changesets owned by the user with iduid.- Parameters:
uid- the uid of the user. > 0 expected.- Returns:
- the query object with the applied restriction
- Throws:
java.lang.IllegalArgumentException- if uid <= 0- See Also:
forUser(String)
-
forUser
public ChangesetQuery forUser(java.lang.String userName)
Restricts the query to changesets owned by the user with user nameusername.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:
java.lang.IllegalArgumentException- if username is null.- See Also:
forUser(int)
-
isRestrictedToPartiallyIdentifiedUser
public boolean 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
public java.lang.Boolean 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
nullif there is no restriction - Since:
- 14039
-
getRestrictionToClosed
public java.lang.Boolean 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
nullif there is no restriction - Since:
- 14039
-
getClosedAfter
public java.time.Instant 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
public java.time.Instant 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
public final java.util.Collection<java.lang.Long> 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 java.lang.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. ifisRestrictedToPartiallyIdentifiedUser()is false.- Returns:
- the user name which this query is restricted to
-
isRestrictedToFullyIdentifiedUser
public boolean 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:
java.lang.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:
java.lang.IllegalArgumentException- if min is nulljava.lang.IllegalArgumentException- if max is null
-
inBbox
public ChangesetQuery inBbox(Bounds bbox)
Replies a query which is restricted to a bounding box given bybbox.- Parameters:
bbox- the bounding box. Must not be null.- Returns:
- the changeset query
- Throws:
java.lang.IllegalArgumentException- if bbox is null.
-
closedAfter
public ChangesetQuery closedAfter(java.time.Instant d)
Restricts the result to changesets which have been closed after the date given byd.dd is a date relative to the current time zone.- Parameters:
d- the date. Must not be null.- Returns:
- the restricted changeset query
- Throws:
java.lang.IllegalArgumentException- if d is null
-
closedAfterAndCreatedBefore
public ChangesetQuery closedAfterAndCreatedBefore(java.time.Instant closedAfter, java.time.Instant createdBefore)
Restricts the result to changesets which have been closed afterclosedAfterand which have been created beforecreatedBefore. 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:
java.lang.IllegalArgumentException- if closedAfter is nulljava.lang.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 ofisOpen- 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 ofisClosed- Parameters:
isClosed- whether changesets should or should not be open- Returns:
- the restricted changeset query
-
forChangesetIds
public ChangesetQuery forChangesetIds(java.util.Collection<java.lang.Long> changesetIds)
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:
java.lang.IllegalArgumentException- if changesetIds is null.
-
getQueryString
public java.lang.String getQueryString()
Replies the query string to be used in a query URL for the OSM API.- Returns:
- the query string
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-