public class Capabilities extends java.lang.Object
<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="50000"/> <timeout seconds="300"/> </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.
Modifier and Type | Class and Description |
---|---|
static class |
Capabilities.CapabilitiesParser
A parser for the "capabilities" response XML.
|
Modifier and Type | Field and Description |
---|---|
private java.util.Map<java.lang.String,java.util.HashMap<java.lang.String,java.lang.String>> |
capabilities |
private java.util.List<java.lang.String> |
imageryBlacklist |
Constructor and Description |
---|
Capabilities()
Constructs new
Capabilities . |
Modifier and Type | Method and 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.
|
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 final java.util.Map<java.lang.String,java.util.HashMap<java.lang.String,java.lang.String>> capabilities
private final java.util.List<java.lang.String> imageryBlacklist
public Capabilities()
Capabilities
.public boolean isDefined(java.lang.String element, java.lang.String attribute)
element
- the name of the elementattribute
- the name of the attributetrue
if defined, false
otherwisepublic java.lang.String get(java.lang.String element, java.lang.String attribute)
element
- the name of the elementattribute
- the name of the attributenull
, if the respective configuration item does not existpublic java.lang.Double getDouble(java.lang.String element, java.lang.String attribute) throws java.lang.NumberFormatException
element
- the name of the elementattribute
- the name of the attributenull
, if the respective configuration item does not existjava.lang.NumberFormatException
- if the value is not a valid doublepublic java.lang.Long getLong(java.lang.String element, java.lang.String attribute)
element
- the name of the elementattribute
- the name of the attributenull
, if the respective configuration item does not existjava.lang.NumberFormatException
- if the value is not a valid longpublic void put(java.lang.String element, java.lang.String attribute, java.lang.String value)
element
- the name of the elementattribute
- the name of the attributevalue
- the value as stringpublic final void clear()
public boolean supportsVersion(java.lang.String version)
version
- The API version to checktrue
is version is between the minimum supported version and the maximum one, false
otherwisepublic int getMaxChangesetSize()
public boolean isOnImageryBlacklist(java.lang.String url)
url
- Imagery URL to checktrue
if URL is blacklisted, false
otherwisepublic java.util.List<java.lang.String> getImageryBlacklist()