Package org.openstreetmap.josm.io
Class Capabilities
- java.lang.Object
-
- org.openstreetmap.josm.io.Capabilities
-
public class Capabilities extends java.lang.Object
Represents the OSM API server capabilities. Example capabilities document:<osm version="0.6" generator="OpenStreetMap server"> <api> <version minimum="0.6" maximum="0.6"/> <area maximum="0.25"/> <tracepoints per_page="5000"/> <waynodes maximum="2000"/> <changesets maximum_elements="10000"/> <timeout seconds="300"/> <status database="online" api="online" gpx="online"/> </api> <policy> <imagery> <blacklist regex=".*\.google\.com/.*"/> <blacklist regex=".*209\.85\.2\d\d.*"/> <blacklist regex=".*209\.85\.1[3-9]\d.*"/> <blacklist regex=".*209\.85\.12[89].*"/> </imagery> </policy> </osm>
This class is used in conjunction with a very primitive parser and simply stuffs the each tag and its attributes into a hash of hashes, with the exception of the "blacklist" tag which gets a list of its own. The DOM hierarchy is disregarded.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Capabilities.CapabilitiesParser
A parser for the "capabilities" response XML.
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.String>>
capabilities
private java.util.List<java.lang.String>
imageryBlacklist
-
Constructor Summary
Constructors Constructor Description Capabilities()
Constructs newCapabilities
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
Clears the API capabilities.java.lang.String
get(java.lang.String element, java.lang.String attribute)
Returns the value of configuration item in the capabilities as string value.java.lang.Double
getDouble(java.lang.String element, java.lang.String attribute)
Returns the value of configuration item in the capabilities as double value.java.util.List<java.lang.String>
getImageryBlacklist()
Returns the full list of imagery blacklist regular expressions.java.lang.Long
getLong(java.lang.String element, java.lang.String attribute)
Returns the value of configuration item in the capabilities as long value.int
getMaxChangesetSize()
Returns the max number of objects in a changeset.long
getMaxWayNodes()
Returns the max number of nodes in a way.boolean
isDefined(java.lang.String element, java.lang.String attribute)
Determines if given element and attribute are defined.boolean
isOnImageryBlacklist(java.lang.String url)
Checks if the given URL is blacklisted by one of the of the regular expressions.void
put(java.lang.String element, java.lang.String attribute, java.lang.String value)
Adds a new configuration item.boolean
supportsVersion(java.lang.String version)
Determines if a given API version is supported.private static void
warnIllegalValue(java.lang.String attr, java.lang.String elem, java.lang.Object val)
-
-
-
Field Detail
-
capabilities
private final java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.String>> capabilities
-
imageryBlacklist
private final java.util.List<java.lang.String> imageryBlacklist
-
-
Constructor Detail
-
Capabilities
public Capabilities()
Constructs newCapabilities
.
-
-
Method Detail
-
isDefined
public boolean isDefined(java.lang.String element, java.lang.String attribute)
Determines if given element and attribute are defined.- Parameters:
element
- the name of the elementattribute
- the name of the attribute- Returns:
true
if defined,false
otherwise
-
get
public java.lang.String get(java.lang.String element, java.lang.String attribute)
Returns the value of configuration item in the capabilities as string value.- Parameters:
element
- the name of the elementattribute
- the name of the attribute- Returns:
- the value;
null
, if the respective configuration item does not exist
-
getDouble
public java.lang.Double getDouble(java.lang.String element, java.lang.String attribute)
Returns the value of configuration item in the capabilities as double value.- Parameters:
element
- the name of the elementattribute
- the name of the attribute- Returns:
- the value;
null
, if the respective configuration item does not exist - Throws:
java.lang.NumberFormatException
- if the value is not a valid double
-
getLong
public java.lang.Long getLong(java.lang.String element, java.lang.String attribute)
Returns the value of configuration item in the capabilities as long value.- Parameters:
element
- the name of the elementattribute
- the name of the attribute- Returns:
- the value;
null
, if the respective configuration item does not exist - Throws:
java.lang.NumberFormatException
- if the value is not a valid long
-
put
public void put(java.lang.String element, java.lang.String attribute, java.lang.String value)
Adds a new configuration item.- Parameters:
element
- the name of the elementattribute
- the name of the attributevalue
- the value as string
-
clear
public final void clear()
Clears the API capabilities.
-
supportsVersion
public boolean supportsVersion(java.lang.String version)
Determines if a given API version is supported.- Parameters:
version
- The API version to check- Returns:
true
is version is between the minimum supported version and the maximum one,false
otherwise
-
warnIllegalValue
private static void warnIllegalValue(java.lang.String attr, java.lang.String elem, java.lang.Object val)
-
getMaxChangesetSize
public int getMaxChangesetSize()
Returns the max number of objects in a changeset. -1 if either the capabilities don't include this parameter or if the parameter value is illegal (not a number, a negative number)- Returns:
- the max number of objects in a changeset
-
getMaxWayNodes
public long getMaxWayNodes()
Returns the max number of nodes in a way. -1 if either the capabilities don't include this parameter or if the parameter value is illegal (not a number, a negative number)- Returns:
- the max number of nodes in a way
-
isOnImageryBlacklist
public boolean isOnImageryBlacklist(java.lang.String url)
Checks if the given URL is blacklisted by one of the of the regular expressions.- Parameters:
url
- Imagery URL to check- Returns:
true
if URL is blacklisted,false
otherwise
-
getImageryBlacklist
public java.util.List<java.lang.String> getImageryBlacklist()
Returns the full list of imagery blacklist regular expressions.- Returns:
- full list of imagery blacklist regular expressions
-
-