org.duracloud.chunk
Class ChunkableContent

java.lang.Object
  extended by org.duracloud.chunk.ChunkableContent
All Implemented Interfaces:
java.lang.Iterable<ChunkInputStream>, java.util.Iterator<ChunkInputStream>

public class ChunkableContent
extends java.lang.Object
implements java.lang.Iterable<ChunkInputStream>, java.util.Iterator<ChunkInputStream>

This class manages the provided content stream by breaking it chunks of the size specified by maxChunkSize.

Author:
Andrew Woods Date: Feb 2, 2010

Constructor Summary
ChunkableContent(java.lang.String contentId, java.io.InputStream largeStream, long contentSize, long maxChunkSize)
           
ChunkableContent(java.lang.String contentId, java.lang.String contentMimetype, java.io.InputStream largeStream, long contentSize, long maxChunkSize)
           
 
Method Summary
 ChunksManifest finalizeManifest()
           
 ChunksManifest getManifest()
           
 long getMaxChunkSize()
           
 boolean hasNext()
          This method indicates if there are any more chunks.
 java.util.Iterator<ChunkInputStream> iterator()
           
 ChunkInputStream next()
          This method returns the next chunk of the wrapped InputStream.
 void remove()
           
 void setPreserveChunkMD5s(boolean preserveChunkMD5s)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ChunkableContent

public ChunkableContent(java.lang.String contentId,
                        java.io.InputStream largeStream,
                        long contentSize,
                        long maxChunkSize)

ChunkableContent

public ChunkableContent(java.lang.String contentId,
                        java.lang.String contentMimetype,
                        java.io.InputStream largeStream,
                        long contentSize,
                        long maxChunkSize)
Method Detail

hasNext

public boolean hasNext()
This method indicates if there are any more chunks.

Specified by:
hasNext in interface java.util.Iterator<ChunkInputStream>
Returns:
true if more chunks are available.

next

public ChunkInputStream next()
This method returns the next chunk of the wrapped InputStream.

Throws a runtime exception if next() is called before previous stream was fully read.

Specified by:
next in interface java.util.Iterator<ChunkInputStream>
Returns:
next chunk as InputStream

remove

public void remove()
Specified by:
remove in interface java.util.Iterator<ChunkInputStream>

iterator

public java.util.Iterator<ChunkInputStream> iterator()
Specified by:
iterator in interface java.lang.Iterable<ChunkInputStream>

setPreserveChunkMD5s

public void setPreserveChunkMD5s(boolean preserveChunkMD5s)

getMaxChunkSize

public long getMaxChunkSize()

getManifest

public ChunksManifest getManifest()

finalizeManifest

public ChunksManifest finalizeManifest()


Copyright © 2009-2011 DuraSpace. All Rights Reserved.