Class GlideUrl

java.lang.Object
com.bumptech.glide.load.model.GlideUrl
All Implemented Interfaces:
Key

public class GlideUrl extends Object implements Key
A wrapper for strings representing http/https URLs responsible for ensuring URLs are properly escaped and avoiding unnecessary URL instantiations for loaders that require only string urls rather than URL objects.

Users wishing to replace the class for handling URLs must register a factory using GlideUrl.

To obtain a properly escaped URL, call toURL(). To obtain a properly escaped string URL, call toStringUrl(). To obtain a less safe, but less expensive to calculate cache key, call getCacheKey().

This class can also optionally wrap Headers for convenience.

  • Constructor Details

    • GlideUrl

      public GlideUrl(URL url)
    • GlideUrl

      public GlideUrl(String url)
    • GlideUrl

      public GlideUrl(URL url, Headers headers)
    • GlideUrl

      public GlideUrl(String url, Headers headers)
  • Method Details

    • toURL

      public URL toURL() throws MalformedURLException
      Throws:
      MalformedURLException
    • toStringUrl

      public String toStringUrl()
      Returns a properly escaped String url that can be used to make http/https requests.
      See Also:
    • getHeaders

      public Map<String,String> getHeaders()
      Returns a non-null Map containing headers.
    • getCacheKey

      public String getCacheKey()
      Returns an inexpensive to calculate String suitable for use as a disk cache key.

      This method does not include headers.

      Unlike toStringUrl()} and toURL(), this method does not escape input.

    • toString

      public String toString()
      Overrides:
      toString in class Object
    • updateDiskCacheKey

      public void updateDiskCacheKey(@NonNull MessageDigest messageDigest)
      Description copied from interface: Key
      Adds all uniquely identifying information to the given digest.

      Note - Using MessageDigest.reset() inside of this method will result in undefined behavior.

      Specified by:
      updateDiskCacheKey in interface Key
    • equals

      public boolean equals(Object o)
      Description copied from interface: Key
      For caching to work correctly, implementations must implement this method and Key.hashCode().
      Specified by:
      equals in interface Key
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Description copied from interface: Key
      For caching to work correctly, implementations must implement this method and Key.equals(Object).
      Specified by:
      hashCode in interface Key
      Overrides:
      hashCode in class Object