org.jclouds.io.payloads
Class StreamingPayload

java.lang.Object
  extended by org.jclouds.io.payloads.StreamingPayload
All Implemented Interfaces:
com.google.common.io.InputSupplier<InputStream>, Closeable, Payload, WriteTo

public class StreamingPayload
extends Object
implements Payload

Note that not all services accept streaming payloads. For example, Rackspace CloudFiles accepts streaming while Amazon S3 does not.

Author:
Adrian Cole

Field Summary
protected  MutableContentMetadata contentMetadata
           
protected  WriteTo writeTo
           
protected  boolean written
           
 
Constructor Summary
  StreamingPayload(WriteTo writeTo)
           
protected StreamingPayload(WriteTo writeTo, MutableContentMetadata contentMetadata)
           
 
Method Summary
 void close()
          Delegates to release()
 boolean equals(Object obj)
           
 MutableContentMetadata getContentMetadata()
          
 InputStream getInput()
          Creates a new InputStream object of the payload.
 Object getRawContent()
          Payload in its original form.
 int hashCode()
           
 boolean isRepeatable()
          By default we are not repeatable.
 void release()
          By default there are no resources to release.
 void setContentMetadata(MutableContentMetadata in)
           
 String toString()
           
 void writeTo(OutputStream outstream)
          Writes the payload content to the output stream.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

written

protected transient volatile boolean written

writeTo

protected final WriteTo writeTo

contentMetadata

protected MutableContentMetadata contentMetadata
Constructor Detail

StreamingPayload

public StreamingPayload(WriteTo writeTo)

StreamingPayload

protected StreamingPayload(WriteTo writeTo,
                           MutableContentMetadata contentMetadata)
Method Detail

getRawContent

public Object getRawContent()
Description copied from interface: Payload
Payload in its original form.

Specified by:
getRawContent in interface Payload
Throws:
UnsupportedOperationException - this payload is for streaming writes only

getInput

public InputStream getInput()
Description copied from interface: Payload
Creates a new InputStream object of the payload.

Specified by:
getInput in interface com.google.common.io.InputSupplier<InputStream>
Specified by:
getInput in interface Payload
Throws:
UnsupportedOperationException - this payload is for streaming writes only

writeTo

public void writeTo(OutputStream outstream)
             throws IOException
Writes the payload content to the output stream.

Specified by:
writeTo in interface WriteTo
Throws:
IOException

toString

public String toString()
Overrides:
toString in class Object

isRepeatable

public boolean isRepeatable()
By default we are not repeatable.

Specified by:
isRepeatable in interface Payload

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

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

release

public void release()
By default there are no resources to release.

Specified by:
release in interface Payload

close

public void close()
Delegates to release()

Specified by:
close in interface Closeable

getContentMetadata

public MutableContentMetadata getContentMetadata()

Specified by:
getContentMetadata in interface Payload

setContentMetadata

public void setContentMetadata(MutableContentMetadata in)
Specified by:
setContentMetadata in interface Payload


Copyright © 2009-2011 jclouds. All Rights Reserved.