Class StaticResourceServlet.LocalResource

  • All Implemented Interfaces:
    StaticResourceServlet.Resource
    Enclosing class:
    StaticResourceServlet

    public static class StaticResourceServlet.LocalResource
    extends java.lang.Object
    implements StaticResourceServlet.Resource
    This class represents one single resource which is either a file on the file system or a URL from the classpath. Please note that a resource which could not be located results is also represented by a Resource object, but the notFound() method will return true. This is useful, because a not-found resource has also a lookup path so the getPath() method works also in this case.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected LocalResource​(java.lang.String path, java.io.File file, java.net.URL url)
      Constructs a resource which is 1) An empty resource if file and url are null, 2) A file resource if file is not null and url is null, 3) A classpath resource if file is null and url is not.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      byte[] getData()
      Completely reads the resource data from the file system or classpath.
      java.lang.Long getLastModified()  
      java.lang.String getPath()  
      boolean notFound()  
      • Methods inherited from class java.lang.Object

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

      • LocalResource

        protected LocalResource​(java.lang.String path,
                                java.io.File file,
                                java.net.URL url)
        Constructs a resource which is 1) An empty resource if file and url are null, 2) A file resource if file is not null and url is null, 3) A classpath resource if file is null and url is not. The constructor cannot be invoked directly; instead one of the factory methods fetchResource(...) must be used.
        Parameters:
        path - The original path of the resource request. It must not be null.
        file - The reference to the file if this is a file resource. This can be null.
        url - The URL of the classpath resource. This can be null.
    • Method Detail

      • getLastModified

        public java.lang.Long getLastModified()
                                       throws java.io.IOException
        Specified by:
        getLastModified in interface StaticResourceServlet.Resource
        Returns:
        The last modification timestamp of the resource. is NULL if resource does not exist
        Throws:
        java.io.IOException