Class AbstractTileSource

  • All Implemented Interfaces:
    TileSource
    Direct Known Subclasses:
    OnlineTileSource, OpenStreetMapMapnik

    public abstract class AbstractTileSource
    extends java.lang.Object
    implements TileSource
    The abstract base class for tiles downloaded from a web server.

    This class defines a default TTL for cached tiles, accessible through the getDefaultTimeToLive() method. The value here will be used as the initial TTL by the TileDownloadLayer using this tile source, but applications can change the TTL at any time (refer to TileDownloadLayer for details). The default value is set to one day, or 86,400,000 milliseconds. Subclasses should set #defaultTTL in their constructor to a value that is appropriate for their tile source.

    • Field Detail

      • apiKey

        protected java.lang.String apiKey
      • authorization

        protected java.lang.String authorization
      • defaultTimeToLive

        protected long defaultTimeToLive
        The default time-to-live (TTL) for cached tiles (one day, or 86,400,000 milliseconds).
      • followRedirects

        protected boolean followRedirects
      • hostNames

        protected final java.lang.String[] hostNames
      • keyName

        protected java.lang.String keyName
      • port

        protected final int port
      • random

        protected final java.util.Random random
      • referer

        protected java.lang.String referer
      • timeoutConnect

        protected int timeoutConnect
      • timeoutRead

        protected int timeoutRead
      • userAgent

        protected java.lang.String userAgent
    • Constructor Detail

      • AbstractTileSource

        protected AbstractTileSource​(java.lang.String[] hostNames,
                                     int port)
    • Method Detail

      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • getApiKey

        public java.lang.String getApiKey()
      • getAuthorization

        public java.lang.String getAuthorization()
        Specified by:
        getAuthorization in interface TileSource
        Returns:
        the Authorization (may be null).
      • getDefaultTimeToLive

        public long getDefaultTimeToLive()
        Returns the default time-to-live (TTL) for cached tiles.
        Specified by:
        getDefaultTimeToLive in interface TileSource
      • getHostName

        protected java.lang.String getHostName()
      • getKeyName

        public java.lang.String getKeyName()
      • getReferer

        public java.lang.String getReferer()
        Specified by:
        getReferer in interface TileSource
        Returns:
        the HTTP referer (may be null).
      • getTimeoutConnect

        public int getTimeoutConnect()
        Specified by:
        getTimeoutConnect in interface TileSource
        Returns:
        the connect timeout value in milliseconds.
      • getTimeoutRead

        public int getTimeoutRead()
        Specified by:
        getTimeoutRead in interface TileSource
        Returns:
        the read timeout value in milliseconds.
      • getUserAgent

        public java.lang.String getUserAgent()
        Specified by:
        getUserAgent in interface TileSource
        Returns:
        the HTTP user agent (may be null).
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • isFollowRedirects

        public boolean isFollowRedirects()
        Specified by:
        isFollowRedirects in interface TileSource
        Returns:
        whether or not to follow HTTP redirects.
      • setApiKey

        public void setApiKey​(java.lang.String apiKey)
      • setAuthorization

        public void setAuthorization​(java.lang.String authorization)
      • setFollowRedirects

        public void setFollowRedirects​(boolean followRedirects)
      • setKeyName

        public void setKeyName​(java.lang.String keyName)
      • setReferer

        public void setReferer​(java.lang.String referer)
      • setTimeoutConnect

        public void setTimeoutConnect​(int timeoutConnect)
      • setTimeoutRead

        public void setTimeoutRead​(int timeoutRead)
      • setUserAgent

        public void setUserAgent​(java.lang.String userAgent)