Nuxeo ECM Projects 5.4.3-SNAPSHOT

org.nuxeo.ecm.core.api.impl.blob
Class StreamingBlob

java.lang.Object
  extended by org.nuxeo.ecm.core.api.impl.blob.AbstractBlob
      extended by org.nuxeo.ecm.core.api.impl.blob.DefaultBlob
          extended by org.nuxeo.ecm.core.api.impl.blob.StreamingBlob
All Implemented Interfaces:
Serializable, Blob

public class StreamingBlob
extends DefaultBlob
implements Serializable

Author:
Bogdan Stefanescu
See Also:
Serialized Form

Field Summary
static int MEM_MAX_LIMIT
           
 
Fields inherited from class org.nuxeo.ecm.core.api.impl.blob.AbstractBlob
EMPTY_BYTE_ARRAY, EMPTY_INPUT_STREAM, EMPTY_READER, EMPTY_STRING
 
Constructor Summary
StreamingBlob(StreamSource src)
           
StreamingBlob(StreamSource src, String mimeType)
           
StreamingBlob(StreamSource src, String mimeType, String encoding)
           
StreamingBlob(StreamSource src, String mimeType, String encoding, String filename, String digest)
           
 
Method Summary
static StreamingBlob createFromByteArray(byte[] bytes)
           
static StreamingBlob createFromByteArray(byte[] bytes, String mimeType)
           
static StreamingBlob createFromFile(File file)
           
static StreamingBlob createFromFile(File file, String mimeType)
           
static StreamingBlob createFromStream(InputStream is)
           
static StreamingBlob createFromStream(InputStream is, String mimeType)
           
static StreamingBlob createFromString(String str)
           
static StreamingBlob createFromString(String str, String mimeType)
           
static StreamingBlob createFromURL(URL url)
           
static StreamingBlob createFromURL(URL url, String mimeType)
           
 byte[] getByteArray()
           
 long getLength()
          Gets the data length in bytes if known.
 Reader getReader()
           
 InputStream getStream()
           
 StreamSource getStreamSource()
           
 String getString()
           
 boolean isPersistent()
          Checks whether this blob is persistent.
 Blob persist()
          If the source is cannot be reopen, copy the binary content of the original source to a temporary file and replace the source inplace by a new FileSource instance pointing to the tmp file.
 
Methods inherited from class org.nuxeo.ecm.core.api.impl.blob.DefaultBlob
getDigest, getEncoding, getFilename, getMimeType, setDigest, setEncoding, setFilename, setMimeType
 
Methods inherited from class org.nuxeo.ecm.core.api.impl.blob.AbstractBlob
copy, copy, transferTo, transferTo, transferTo
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MEM_MAX_LIMIT

public static final int MEM_MAX_LIMIT
See Also:
Constant Field Values
Constructor Detail

StreamingBlob

public StreamingBlob(StreamSource src)

StreamingBlob

public StreamingBlob(StreamSource src,
                     String mimeType)

StreamingBlob

public StreamingBlob(StreamSource src,
                     String mimeType,
                     String encoding)

StreamingBlob

public StreamingBlob(StreamSource src,
                     String mimeType,
                     String encoding,
                     String filename,
                     String digest)
Method Detail

createFromStream

public static StreamingBlob createFromStream(InputStream is)

createFromStream

public static StreamingBlob createFromStream(InputStream is,
                                             String mimeType)

createFromByteArray

public static StreamingBlob createFromByteArray(byte[] bytes)

createFromByteArray

public static StreamingBlob createFromByteArray(byte[] bytes,
                                                String mimeType)

createFromString

public static StreamingBlob createFromString(String str)

createFromString

public static StreamingBlob createFromString(String str,
                                             String mimeType)

createFromFile

public static StreamingBlob createFromFile(File file)

createFromFile

public static StreamingBlob createFromFile(File file,
                                           String mimeType)

createFromURL

public static StreamingBlob createFromURL(URL url)

createFromURL

public static StreamingBlob createFromURL(URL url,
                                          String mimeType)

getByteArray

public byte[] getByteArray()
                    throws IOException
Specified by:
getByteArray in interface Blob
Throws:
IOException

getLength

public long getLength()
Description copied from interface: Blob
Gets the data length in bytes if known.

Specified by:
getLength in interface Blob
Returns:
the data length or -1 if not known

getReader

public Reader getReader()
                 throws IOException
Specified by:
getReader in interface Blob
Throws:
IOException

getStream

public InputStream getStream()
                      throws IOException
Specified by:
getStream in interface Blob
Throws:
IOException

getString

public String getString()
                 throws IOException
Specified by:
getString in interface Blob
Throws:
IOException

isPersistent

public boolean isPersistent()
Description copied from interface: Blob
Checks whether this blob is persistent. (i.e. if Blob.getStream() can be successfully called several times).

Specified by:
isPersistent in interface Blob
Returns:
true if persistent, false otherwise

getStreamSource

public StreamSource getStreamSource()

persist

public Blob persist()
             throws IOException
If the source is cannot be reopen, copy the binary content of the original source to a temporary file and replace the source inplace by a new FileSource instance pointing to the tmp file. return the current instance with a re-openable internal source

Specified by:
persist in interface Blob
Returns:
a persistent version of the blob
Throws:
IOException

Nuxeo ECM Projects 5.4.3-SNAPSHOT

Copyright © 2011 Nuxeo SAS. All Rights Reserved.