Class Capabilities

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

public class Capabilities extends 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.
  • Field Details

  • Constructor Details

    • Capabilities

      public Capabilities()
      Constructs new Capabilities.
  • Method Details

    • isDefined

      public boolean isDefined(String element, String attribute)
      Determines if given element and attribute are defined.
      Parameters:
      element - the name of the element
      attribute - the name of the attribute
      Returns:
      true if defined, false otherwise
    • get

      public String get(String element, String attribute)
      Returns the value of configuration item in the capabilities as string value.
      Parameters:
      element - the name of the element
      attribute - the name of the attribute
      Returns:
      the value; null, if the respective configuration item does not exist
    • getDouble

      public Double getDouble(String element, String attribute)
      Returns the value of configuration item in the capabilities as double value.
      Parameters:
      element - the name of the element
      attribute - the name of the attribute
      Returns:
      the value; null, if the respective configuration item does not exist
      Throws:
      NumberFormatException - if the value is not a valid double
    • getLong

      public Long getLong(String element, String attribute)
      Returns the value of configuration item in the capabilities as long value.
      Parameters:
      element - the name of the element
      attribute - the name of the attribute
      Returns:
      the value; null, if the respective configuration item does not exist
      Throws:
      NumberFormatException - if the value is not a valid long
    • put

      public void put(String element, String attribute, String value)
      Adds a new configuration item.
      Parameters:
      element - the name of the element
      attribute - the name of the attribute
      value - the value as string
    • clear

      public final void clear()
      Clears the API capabilities.
    • supportsVersion

      public boolean supportsVersion(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(String attr, String elem, 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(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

      Returns the full list of imagery blacklist regular expressions.
      Returns:
      full list of imagery blacklist regular expressions