public class Capabilities extends 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 Map<String,Map<String,String>> |
capabilities |
private List<String> |
imageryBlacklist |
Constructor and Description |
---|
Capabilities()
Constructs new
Capabilities . |
Modifier and Type | Method and Description |
---|---|
void |
clear()
Clears the API capabilities.
|
String |
get(String element,
String attribute)
Returns the value of configuration item in the capabilities as string value.
|
Double |
getDouble(String element,
String attribute)
Returns the value of configuration item in the capabilities as double value.
|
List<String> |
getImageryBlacklist()
Returns the full list of imagery blacklist regular expressions.
|
Long |
getLong(String element,
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(String element,
String attribute)
Determines if given element and attribute are defined.
|
boolean |
isOnImageryBlacklist(String url)
Checks if the given URL is blacklisted by one of the of the regular expressions.
|
void |
put(String element,
String attribute,
String value)
Adds a new configuration item.
|
boolean |
supportsVersion(String version)
Determines if a given API version is supported.
|
private static void |
warnIllegalValue(String attr,
String elem,
Object val) |
private final List<String> imageryBlacklist
public Capabilities()
Capabilities
.public boolean isDefined(String element, String attribute)
element
- the name of the elementattribute
- the name of the attributetrue
if defined, false
otherwisepublic String get(String element, String attribute)
element
- the name of the elementattribute
- the name of the attributenull
, if the respective configuration item does not existpublic Double getDouble(String element, String attribute) throws NumberFormatException
element
- the name of the elementattribute
- the name of the attributenull
, if the respective configuration item does not existNumberFormatException
- if the value is not a valid doublepublic Long getLong(String element, String attribute)
element
- the name of the elementattribute
- the name of the attributenull
, if the respective configuration item does not existNumberFormatException
- if the value is not a valid longpublic void put(String element, String attribute, String value)
element
- the name of the elementattribute
- the name of the attributevalue
- the value as stringpublic final void clear()
public boolean supportsVersion(String version)
version
- The API version to checktrue
is version is between the minimum supported version and the maximum one, false
otherwiseprivate static void warnIllegalValue(String attr, String elem, Object val)
public int getMaxChangesetSize()
public long getMaxWayNodes()
public boolean isOnImageryBlacklist(String url)
url
- Imagery URL to checktrue
if URL is blacklisted, false
otherwisepublic List<String> getImageryBlacklist()