Package com.google.api.client.http
Class AbstractInputStreamContent
- java.lang.Object
-
- com.google.api.client.http.AbstractInputStreamContent
-
- All Implemented Interfaces:
HttpContent,StreamingContent
- Direct Known Subclasses:
ByteArrayContent,FileContent,InputStreamContent
public abstract class AbstractInputStreamContent extends java.lang.Object implements HttpContent
Serializes HTTP request content from an input stream into an output stream.The
typefield is required. Subclasses should implement theHttpContent.getLength(),getInputStream(), andHttpContent.retrySupported()for their specific type of input stream. By default, all content is read from the input stream. If instead you want to limit the maximum amount of content read from the input stream, you may useByteStreams.limit(InputStream, long).Implementations don't need to be thread-safe.
- Since:
- 1.4
-
-
Field Summary
Fields Modifier and Type Field Description private booleancloseInputStreamWhether the input stream should be closed at the end ofwriteTo(java.io.OutputStream).private java.lang.StringtypeContent type ornullfor none.
-
Constructor Summary
Constructors Constructor Description AbstractInputStreamContent(java.lang.String type)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description booleangetCloseInputStream()Returns whether the input stream should be closed at the end ofwriteTo(java.io.OutputStream).abstract java.io.InputStreamgetInputStream()Return an input stream for the specific implementation type ofAbstractInputStreamContent.java.lang.StringgetType()Returns the content type ornullfor none.AbstractInputStreamContentsetCloseInputStream(boolean closeInputStream)Sets whether the input stream should be closed at the end ofwriteTo(java.io.OutputStream).AbstractInputStreamContentsetType(java.lang.String type)Sets the content type ornullfor none.voidwriteTo(java.io.OutputStream out)Writes the byte content to the given output stream.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.google.api.client.http.HttpContent
getLength, retrySupported
-
-
-
-
Field Detail
-
type
private java.lang.String type
Content type ornullfor none.
-
closeInputStream
private boolean closeInputStream
Whether the input stream should be closed at the end ofwriteTo(java.io.OutputStream). Default istrue.
-
-
Method Detail
-
getInputStream
public abstract java.io.InputStream getInputStream() throws java.io.IOExceptionReturn an input stream for the specific implementation type ofAbstractInputStreamContent. If the specific implementation will returntrueforHttpContent.retrySupported()this should be a factory function which will create a newInputStreamfrom the source data whenever invoked.- Throws:
java.io.IOException- Since:
- 1.7
-
writeTo
public void writeTo(java.io.OutputStream out) throws java.io.IOExceptionDescription copied from interface:StreamingContentWrites the byte content to the given output stream.Implementations must not close the output stream, and instead should flush the output stream. Some callers may assume that the the output stream has not been closed, and will fail to work if it has been closed.
- Specified by:
writeToin interfaceHttpContent- Specified by:
writeToin interfaceStreamingContent- Parameters:
out- output stream- Throws:
java.io.IOException
-
getType
public java.lang.String getType()
Description copied from interface:HttpContentReturns the content type ornullfor none.- Specified by:
getTypein interfaceHttpContent
-
getCloseInputStream
public final boolean getCloseInputStream()
Returns whether the input stream should be closed at the end ofwriteTo(java.io.OutputStream). Default istrue.- Since:
- 1.7
-
setType
public AbstractInputStreamContent setType(java.lang.String type)
Sets the content type ornullfor none. Subclasses should override by calling super.- Since:
- 1.5
-
setCloseInputStream
public AbstractInputStreamContent setCloseInputStream(boolean closeInputStream)
Sets whether the input stream should be closed at the end ofwriteTo(java.io.OutputStream). Default istrue. Subclasses should override by calling super.- Since:
- 1.7
-
-