Class UrlAsset

  • All Implemented Interfaces:
    Asset

    public class UrlAsset
    extends java.lang.Object
    implements Asset
    Implementation of an Asset backed by a URL. The URL may be of any backing protocol supported by the runtime (ie. has a handler registered).
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.net.URL url  
    • Constructor Summary

      Constructors 
      Constructor Description
      UrlAsset​(java.net.URL url)
      Create a new resource with a URL source.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.net.URL getSource()
      Returns the loaded URL.
      java.io.InputStream openStream()
      Open the URL stream.
      java.lang.String toString()
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • url

        private final java.net.URL url
    • Constructor Detail

      • UrlAsset

        public UrlAsset​(java.net.URL url)
        Create a new resource with a URL source.
        Parameters:
        url - A valid URL
        Throws:
        java.lang.IllegalArgumentException - URL can not be null
    • Method Detail

      • openStream

        public java.io.InputStream openStream()
        Open the URL stream.
        Specified by:
        openStream in interface Asset
        Returns:
        A open stream with the content of the URL
      • getSource

        public java.net.URL getSource()
        Returns the loaded URL.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
        See Also:
        Object.toString()