Package com.aquima.web.context
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 multipleResource
'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 Summary
Constructors Constructor Description CollectionResource(String path, org.springframework.core.io.Resource... resources)
Initializes a new CollectionResource with the specified path (as needed for the createRelative() method) andResource
's.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addResource(org.springframework.core.io.Resource resource)
Adds a Resource to the collection.long
contentLength()
org.springframework.core.io.Resource
createRelative(String relativePath)
boolean
equals(Object other)
boolean
exists()
String
getDescription()
File
getFile()
String
getFilename()
InputStream
getInputStream()
URI
getURI()
URL
getURL()
int
hashCode()
boolean
isOpen()
boolean
isReadable()
long
lastModified()
String
toString()
-
-
-
Constructor Detail
-
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) andResource
's. The first Resource in the array will be the first Resource of the collection.- Parameters:
path
- The path of the CollectionResourceresources
- The resources to store in the CollectionResource
-
-
Method Detail
-
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 interfaceorg.springframework.core.io.Resource
- Throws:
IOException
-
createRelative
public org.springframework.core.io.Resource createRelative(String relativePath) throws IOException
- Specified by:
createRelative
in interfaceorg.springframework.core.io.Resource
- Throws:
IOException
-
contentLength
public long contentLength() throws IOException
- Specified by:
contentLength
in interfaceorg.springframework.core.io.Resource
- Throws:
IOException
-
exists
public boolean exists()
- Specified by:
exists
in interfaceorg.springframework.core.io.Resource
-
isOpen
public boolean isOpen()
- Specified by:
isOpen
in interfaceorg.springframework.core.io.Resource
-
isReadable
public boolean isReadable()
- Specified by:
isReadable
in interfaceorg.springframework.core.io.Resource
-
lastModified
public long lastModified() throws IOException
- Specified by:
lastModified
in interfaceorg.springframework.core.io.Resource
- Throws:
IOException
-
getURL
public URL getURL() throws IOException
- Specified by:
getURL
in interfaceorg.springframework.core.io.Resource
- Throws:
IOException
-
getURI
public URI getURI() throws IOException
- Specified by:
getURI
in interfaceorg.springframework.core.io.Resource
- Throws:
IOException
-
getFilename
public String getFilename()
- Specified by:
getFilename
in interfaceorg.springframework.core.io.Resource
-
getDescription
public String getDescription()
- Specified by:
getDescription
in interfaceorg.springframework.core.io.Resource
-
getInputStream
public InputStream getInputStream() throws IOException
- Specified by:
getInputStream
in interfaceorg.springframework.core.io.InputStreamSource
- Throws:
IOException
-
-