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
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 Summary
ConstructorsConstructorDescriptionCollectionResource
(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
Modifier and TypeMethodDescriptionvoid
addResource
(org.springframework.core.io.Resource resource) Adds a Resource to the collection.long
org.springframework.core.io.Resource
createRelative
(String relativePath) boolean
boolean
exists()
getFile()
getURI()
getURL()
int
hashCode()
boolean
isOpen()
boolean
long
toString()
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.springframework.core.io.Resource
isFile, readableChannel
-
Constructor Details
-
CollectionResource
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 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
- Specified by:
getFile
in interfaceorg.springframework.core.io.Resource
- Throws:
IOException
-
createRelative
- Specified by:
createRelative
in interfaceorg.springframework.core.io.Resource
- Throws:
IOException
-
contentLength
- 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
- Specified by:
lastModified
in interfaceorg.springframework.core.io.Resource
- Throws:
IOException
-
getURL
- Specified by:
getURL
in interfaceorg.springframework.core.io.Resource
- Throws:
IOException
-
getURI
- Specified by:
getURI
in interfaceorg.springframework.core.io.Resource
- Throws:
IOException
-
getFilename
- Specified by:
getFilename
in interfaceorg.springframework.core.io.Resource
-
getDescription
- Specified by:
getDescription
in interfaceorg.springframework.core.io.Resource
-
getInputStream
- Specified by:
getInputStream
in interfaceorg.springframework.core.io.InputStreamSource
- Throws:
IOException
-
toString
-
equals
-
hashCode
public int hashCode()
-