Class CollectionResource

java.lang.Object
com.aquima.web.context.CollectionResource
All Implemented Interfaces:
org.springframework.core.io.InputStreamSource, org.springframework.core.io.Resource

public class CollectionResource extends Object implements org.springframework.core.io.Resource
A Resource implementation which can hold multiple Resource's, allowing for backup Resources for createRelative() lookups. - Calls to createRelative will return a new CollectionResource, containing the results of identical calls on each of the stored Resources. - All other method calls are forwarded to the first Resource stored in the collection.
Since:
8.3
Author:
hj.van.veenendaal
  • Constructor Details

    • CollectionResource

      public CollectionResource(String path, org.springframework.core.io.Resource... resources)
      Initializes a new CollectionResource with the specified path (as needed for the createRelative() method) and Resource's. The first Resource in the array will be the first Resource of the collection.
      Parameters:
      path - The path of the CollectionResource
      resources - The resources to store in the CollectionResource
  • Method Details

    • addResource

      public void addResource(org.springframework.core.io.Resource resource)
      Adds a Resource to the collection.
      Parameters:
      resource - the Resource to add to the collection
    • getFile

      public File getFile() throws IOException
      Specified by:
      getFile in interface org.springframework.core.io.Resource
      Throws:
      IOException
    • createRelative

      public org.springframework.core.io.Resource createRelative(String relativePath) throws IOException
      Specified by:
      createRelative in interface org.springframework.core.io.Resource
      Throws:
      IOException
    • contentLength

      public long contentLength() throws IOException
      Specified by:
      contentLength in interface org.springframework.core.io.Resource
      Throws:
      IOException
    • exists

      public boolean exists()
      Specified by:
      exists in interface org.springframework.core.io.Resource
    • isOpen

      public boolean isOpen()
      Specified by:
      isOpen in interface org.springframework.core.io.Resource
    • isReadable

      public boolean isReadable()
      Specified by:
      isReadable in interface org.springframework.core.io.Resource
    • lastModified

      public long lastModified() throws IOException
      Specified by:
      lastModified in interface org.springframework.core.io.Resource
      Throws:
      IOException
    • getURL

      public URL getURL() throws IOException
      Specified by:
      getURL in interface org.springframework.core.io.Resource
      Throws:
      IOException
    • getURI

      public URI getURI() throws IOException
      Specified by:
      getURI in interface org.springframework.core.io.Resource
      Throws:
      IOException
    • getFilename

      public String getFilename()
      Specified by:
      getFilename in interface org.springframework.core.io.Resource
    • getDescription

      public String getDescription()
      Specified by:
      getDescription in interface org.springframework.core.io.Resource
    • getInputStream

      public InputStream getInputStream() throws IOException
      Specified by:
      getInputStream in interface org.springframework.core.io.InputStreamSource
      Throws:
      IOException
    • toString

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

      public boolean equals(Object other)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object