Package org.nuxeo.ecm.core.api.impl.blob
Class BlobWrapper
- java.lang.Object
-
- org.nuxeo.ecm.core.api.impl.blob.BlobWrapper
-
- All Implemented Interfaces:
Serializable
,Blob
public class BlobWrapper extends Object implements Blob, Serializable
Wraps an existingBlob
to allow setting a different filename.- Since:
- 5.9.2
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description BlobWrapper(Blob blob)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[]
getByteArray()
CloseableFile
getCloseableFile()
Gets aCloseableFile
backing this blob, which must be closed when done by the caller.CloseableFile
getCloseableFile(String ext)
Gets aCloseableFile
backing this blob, which must be closed when done by the caller.String
getDigest()
String
getDigestAlgorithm()
String
getEncoding()
File
getFile()
If this blob is backed by an actual file, returns it.String
getFilename()
long
getLength()
Gets the data length in bytes if known.String
getMimeType()
InputStream
getStream()
Gets anInputStream
for the data of this blob.String
getString()
void
setDigest(String digest)
void
setDigestAlgorithm(String digestAlgorithm)
void
setEncoding(String encoding)
void
setFilename(String filename)
void
setMimeType(String mimeType)
void
transferTo(File file)
void
transferTo(OutputStream out)
-
-
-
Constructor Detail
-
BlobWrapper
public BlobWrapper(Blob blob)
-
-
Method Detail
-
getFilename
public String getFilename()
- Specified by:
getFilename
in interfaceBlob
-
setFilename
public void setFilename(String filename)
- Specified by:
setFilename
in interfaceBlob
-
getMimeType
public String getMimeType()
- Specified by:
getMimeType
in interfaceBlob
-
getEncoding
public String getEncoding()
- Specified by:
getEncoding
in interfaceBlob
-
getDigestAlgorithm
public String getDigestAlgorithm()
- Specified by:
getDigestAlgorithm
in interfaceBlob
-
setMimeType
public void setMimeType(String mimeType)
- Specified by:
setMimeType
in interfaceBlob
-
setEncoding
public void setEncoding(String encoding)
- Specified by:
setEncoding
in interfaceBlob
-
setDigestAlgorithm
public void setDigestAlgorithm(String digestAlgorithm)
- Specified by:
setDigestAlgorithm
in interfaceBlob
-
getStream
public InputStream getStream() throws IOException
Description copied from interface:Blob
Gets anInputStream
for the data of this blob.The contract of
Blob
is that this method can be called several times and will correctly return a newInputStream
each time. In other words, several reads of theBlob
can be done.Like all
InputStream
, the result must be closed when done with it to avoid resource leaks.- Specified by:
getStream
in interfaceBlob
- Returns:
- the stream
- Throws:
IOException
-
getLength
public long getLength()
Description copied from interface:Blob
Gets the data length in bytes if known.
-
getByteArray
public byte[] getByteArray() throws IOException
- Specified by:
getByteArray
in interfaceBlob
- Throws:
IOException
-
getString
public String getString() throws IOException
- Specified by:
getString
in interfaceBlob
- Throws:
IOException
-
transferTo
public void transferTo(OutputStream out) throws IOException
- Specified by:
transferTo
in interfaceBlob
- Throws:
IOException
-
transferTo
public void transferTo(File file) throws IOException
- Specified by:
transferTo
in interfaceBlob
- Throws:
IOException
-
getFile
public File getFile()
Description copied from interface:Blob
If this blob is backed by an actual file, returns it.The returned file may be short-lived (temporary), so should be used immediately.
-
getCloseableFile
public CloseableFile getCloseableFile() throws IOException
Description copied from interface:Blob
Gets aCloseableFile
backing this blob, which must be closed when done by the caller.The returned file may be the original file, a temporary file, or a symbolic link.
- Specified by:
getCloseableFile
in interfaceBlob
- Returns:
- a closeable file, to be closed when done
- Throws:
IOException
-
getCloseableFile
public CloseableFile getCloseableFile(String ext) throws IOException
Description copied from interface:Blob
Gets aCloseableFile
backing this blob, which must be closed when done by the caller.The returned file may be the original file, a temporary file, or a symbolic link.
- Specified by:
getCloseableFile
in interfaceBlob
- Parameters:
ext
- the required extension for the file, ornull
if it doesn't matter- Returns:
- a closeable file, to be closed when done
- Throws:
IOException
-
-