Class AbstractResource

    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected  path)  
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      boolean exists()
      Simple check for whether Resource.toURL() returns null or not.
      Resource  relativePath)
      Returns a Resource based on a relative path, relative to the folder containing the resource.
      Resource  locale)
      Returns a localized version of the resource.
      getFile()
      Returns the file portion of the Resource path, everything that follows the final forward slash.
      getFolder()
      Returns the portion of the path up to the last forward slash; this is the directory or folder portion of the Resource.
      getPath()
      Return the path (the combination of folder and file).
      boolean isVirtual()
      Returns true if the resource is virtual, meaning this is no underlying file.
      protected abstract Resource  path)
      Factory method provided by subclasses.
      openStream()
      Obtains the URL for the Resource and opens the stream, wrapped by a BufferedInputStream.
      protected void  url)
      Validates that the URL is correct; at this time, a correct URL is one of: null a non-file: URL a file: URL where the case of the file matches the corresponding path element See
      Resource  extension)
      Returns a new Resource with the extension changed (or, if the resource does not have an extension, the extension is added).
      • Methods inherited from class java.lang.

        , , , , , , , , , ,
      • Methods inherited from interface org.apache.tapestry5.commons.Resource

        toURL
    • Constructor Detail

      • AbstractResource

        protected  path)
    • Method Detail

      • getPath

        public final  getPath()
        Description copied from interface: Resource
        Return the path (the combination of folder and file). Starting in 5.4, certain "virtual resources", may return an arbitrary value here.
        Specified by:
        getPath in interface Resource
      • getFile

        public final  getFile()
        Description copied from interface: Resource
        Returns the file portion of the Resource path, everything that follows the final forward slash. Starting in 5.4, certain kinds of "virtual resources" may return null here.
        Specified by:
        getFile in interface Resource
      • getFolder

        public final  getFolder()
        Description copied from interface: Resource
        Returns the portion of the path up to the last forward slash; this is the directory or folder portion of the Resource.
        Specified by:
        getFolder in interface Resource
      • forFile

        public final  relativePath)
        Description copied from interface: Resource
        Returns a Resource based on a relative path, relative to the folder containing the resource. Understands the "." (current folder) and ".." (parent folder) conventions, and treats multiple sequential slashes as a single slash. Virtual resources (resources fabricated at runtime) return themselves.
        Specified by:
        forFile in interface Resource
      • forLocale

        public final  locale)
        Description copied from interface: Resource
        Returns a localized version of the resource. May return null if no such resource exists. Starting in release 5.3.4, the result of this method is cached internally.
        Specified by:
        forLocale in interface Resource
      • withExtension

        public final  extension)
        Description copied from interface: Resource
        Returns a new Resource with the extension changed (or, if the resource does not have an extension, the extension is added). The new Resource may not exist (that is, Resource.toURL() may return null.
        Specified by:
        withExtension in interface Resource
        Parameters:
        extension - to apply to the resource, such as "html" or "properties"
        Returns:
        the new resource
      • exists

        public boolean exists()
        Simple check for whether Resource.toURL() returns null or not.
        Specified by:
        exists in interface Resource
        Returns:
        true if the resource exists, false if it does not
      • openStream

        public  openStream()
                               throws 
        Obtains the URL for the Resource and opens the stream, wrapped by a BufferedInputStream.
        Specified by:
        openStream in interface Resource
        Returns:
        an open, buffered stream to the content, if available
        Throws:
      • newResource

        protected abstract  path)
        Factory method provided by subclasses.
      • validateURL

        protected void  url)
        Validates that the URL is correct; at this time, a correct URL is one of:
        • null
        • a non-file: URL
        • a file: URL where the case of the file matches the corresponding path element
        See
        Parameters:
        url - to validate
        Since:
        5.4