Nuxeo ECM Projects 5.4.3-SNAPSHOT

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

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

public class LazyBlob
extends DefaultStreamBlob
implements Serializable

TODO: describe what this blob is and does.

This blob has the limitation you will find in all stream blobs.

Once the stream was acquired there is no more guarantee that another getStream() call will return a valid stream.

This could be fixed by using a temp file to store the stream.

Author:
Bogdan Stefanescu
See Also:
Serialized Form

Nested Class Summary
static class LazyBlob.EmptyInputStream
           
 
Field Summary
static InputStream EMPTY_INPUT_STREAM
           
 
Fields inherited from class org.nuxeo.ecm.core.api.impl.blob.AbstractBlob
EMPTY_BYTE_ARRAY, EMPTY_READER, EMPTY_STRING
 
Constructor Summary
LazyBlob(InputStream in, String encoding, String mimeType, String sid, String dataKey, String repositoryName)
           
LazyBlob(InputStream in, String encoding, String mimeType, String sid, String dataKey, String repositoryName, String filename, String digest, long length)
           
 
Method Summary
 boolean equals(Object obj)
           
 String getDataKey()
           
 long getLength()
          Gets the data length in bytes if known.
 String getRepositoryName()
           
 String getSid()
           
 InputStream getStream()
           
 int hashCode()
           
 boolean isPersistent()
          Checks whether this blob is persistent.
 Blob persist()
          Persist this stream so that Blob.getStream() method can be called successfully several times.
 void reset()
           
 
Methods inherited from class org.nuxeo.ecm.core.api.impl.blob.DefaultStreamBlob
getDigest, getEncoding, getFilename, getMimeType, setDigest, setEncoding, setFilename, setMimeType
 
Methods inherited from class org.nuxeo.ecm.core.api.impl.blob.StreamBlob
asByteArrayBlob, asStringBlob, getByteArray, getReader, getString, readBytes, readBytes, readString
 
Methods inherited from class org.nuxeo.ecm.core.api.impl.blob.AbstractBlob
copy, copy, transferTo, transferTo, transferTo
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EMPTY_INPUT_STREAM

public static final InputStream EMPTY_INPUT_STREAM
Constructor Detail

LazyBlob

public LazyBlob(InputStream in,
                String encoding,
                String mimeType,
                String sid,
                String dataKey,
                String repositoryName,
                String filename,
                String digest,
                long length)

LazyBlob

public LazyBlob(InputStream in,
                String encoding,
                String mimeType,
                String sid,
                String dataKey,
                String repositoryName)
Method Detail

getLength

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

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

getSid

public String getSid()

getDataKey

public String getDataKey()

getRepositoryName

public String getRepositoryName()

reset

public void reset()

getStream

public InputStream getStream()
                      throws IOException
Specified by:
getStream 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

persist

public Blob persist()
             throws IOException
Description copied from interface: Blob
Persist this stream so that Blob.getStream() method can be called successfully several times. The persistence is done in a temporary file or in memory - this is up to the implementation.

Blobs that are already persistent return themselves.

Persistence should update the internal structure of the Blob to make it persistent whenever possible and hence return itself whenever possible. This behavior cannot be guaranteed by every implementation however.

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

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

Nuxeo ECM Projects 5.4.3-SNAPSHOT

Copyright © 2011 Nuxeo SAS. All Rights Reserved.