Package org.ametys.cms.data
Class Resource
java.lang.Object
org.ametys.cms.data.Resource
- Direct Known Subclasses:
NamedResource
,RichText
Class representing a resource
-
Field Summary
Modifier and TypeFieldDescriptionprotected byte[]
Buffer for small-sized dataprotected String
The resource's encodingprotected ZonedDateTime
The resource's last modification dateprotected String
The resource's mime typeprotected RepositoryData
The resource's repository dataprotected File
Underlying tmp file -
Constructor Summary
ConstructorDescriptionResource()
Default constructorResource
(RepositoryData repositoryData) Constructor to use when reading the resource from the repository -
Method Summary
Modifier and TypeMethodDescriptionprotected void
closeOutputStream
(ByteArrayOutputStream outputStream) Closes the givenOutputStream
Retrieves the encoding of the resource's dataRetrieve the resource's data If the data has already been read, the stream is reseted so it can be read again from the startRetrieves the last modification date of the resource's datalong
Retrieves the length of the resource's dataRetrieves the mime type of the resource's dataRetrieves an output stream that allows to modify the resource's dataRetrieves the resource's repository datavoid
setEncoding
(String encoding) Sets the encoding of the resource's datavoid
Sets the resource's datavoid
setLastModificationDate
(ZonedDateTime lastModificationDate) Sets the last modification date of the resource's datavoid
setMimeType
(String mimeType) Sets the mime type of the resource's data
-
Field Details
-
_mimeType
The resource's mime type -
_encoding
The resource's encoding -
_lastModificationDate
The resource's last modification date -
_tmpFile
Underlying tmp file -
_buffer
Buffer for small-sized data -
_repositoryData
The resource's repository data
-
-
Constructor Details
-
Resource
public Resource()Default constructor -
Resource
Constructor to use when reading the resource from the repository- Parameters:
repositoryData
- the repository data containing the resource's data
-
-
Method Details
-
getInputStream
Retrieve the resource's data If the data has already been read, the stream is reseted so it can be read again from the start- Returns:
- the resource's data, or
null
if there is no data
-
getLength
Retrieves the length of the resource's data- Returns:
- the length of the resource's data
- Throws:
AmetysRepositoryException
- if an error occurs while reading the data in the repository
-
setInputStream
Sets the resource's data- Parameters:
in
- the data to set- Throws:
IOException
- if an error occurs while reading the input stream
-
getOutputStream
Retrieves an output stream that allows to modify the resource's data- Returns:
- the output stream
-
closeOutputStream
Closes the givenOutputStream
- Parameters:
outputStream
- theOutputStream
to close- Throws:
IOException
- if an error occurs while registering the stream
-
getMimeType
Retrieves the mime type of the resource's data- Returns:
- the mime type of the resource's data
-
setMimeType
Sets the mime type of the resource's data- Parameters:
mimeType
- the mime type to set
-
getEncoding
Retrieves the encoding of the resource's data- Returns:
- the encoding of the resource's data
-
setEncoding
Sets the encoding of the resource's data- Parameters:
encoding
- the encoding to set
-
getLastModificationDate
Retrieves the last modification date of the resource's data- Returns:
- the last modification date of the resource's data
-
setLastModificationDate
Sets the last modification date of the resource's data- Parameters:
lastModificationDate
- the last modification date to set
-
getRepositoryData
Retrieves the resource's repository data- Returns:
- the resource's repository data
-