Class ClassLoaderAsset

  • All Implemented Interfaces:
    Asset

    public class ClassLoaderAsset
    extends java.lang.Object
    implements Asset
    ClassloaderAsset Implementation of a Asset backed by a resource located in the Classloader.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.lang.ClassLoader classLoader  
      private java.lang.String resourceName  
    • Constructor Summary

      Constructors 
      Constructor Description
      ClassLoaderAsset​(java.lang.String resourceName)
      Load a named resource using the current threads context classloader.
      ClassLoaderAsset​(java.lang.String resourceName, java.lang.ClassLoader classLoader)
      Load a named resource using the given classloader.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String getSource()
      Returns the loaded resource.
      java.io.InputStream openStream()
      Opens up the given resource as a stream.
      • Methods inherited from class java.lang.Object

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

      • resourceName

        private java.lang.String resourceName
      • classLoader

        private java.lang.ClassLoader classLoader
    • Constructor Detail

      • ClassLoaderAsset

        public ClassLoaderAsset​(java.lang.String resourceName)
        Load a named resource using the current threads context classloader.
        Parameters:
        resourceName - The name of the resource to load
        Throws:
        java.lang.IllegalArgumentException - resourceName can not be null
        java.lang.IllegalArgumentException - resourceName must be found in given classloader
      • ClassLoaderAsset

        public ClassLoaderAsset​(java.lang.String resourceName,
                                java.lang.ClassLoader classLoader)
        Load a named resource using the given classloader.
        Parameters:
        resourceName - The name of the resource to load
        classLoader - The ClassLoader to use
        Throws:
        java.lang.IllegalArgumentException - resourceName can not be null
        java.lang.IllegalArgumentException - classloader can not be null
        java.lang.IllegalArgumentException - resourceName must be found in given classloader
    • Method Detail

      • getSource

        public java.lang.String getSource()
        Returns the loaded resource.
      • openStream

        public java.io.InputStream openStream()
        Opens up the given resource as a stream.
        Specified by:
        openStream in interface Asset
        Returns:
        A new open InputStream for each call