|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.google.api.client.http.AbstractInputStreamContent
com.google.api.client.http.ByteArrayContent
public final class ByteArrayContent
Concrete implementation of AbstractInputStreamContent
that generates repeatable input
streams based on the contents of byte array.
Sample use:
static void setJsonContent(HttpRequest request, byte[] json) {
request.setContent(new ByteArrayContent("application/json", json));
}
Implementation is not thread-safe.
Field Summary |
---|
Fields inherited from class com.google.api.client.http.AbstractInputStreamContent |
---|
encoding, type |
Constructor Summary | |
---|---|
ByteArrayContent()
Deprecated. (scheduled to be removed in 1.6) Use new ByteArrayContent(null, new
byte[]{}) |
|
ByteArrayContent(byte[] array)
Deprecated. (scheduled to be removed in 1.6) Use ByteArrayContent(String, byte[]) |
|
ByteArrayContent(String contentString)
Deprecated. (scheduled to be removed in 1.6) Use fromString(String, String) |
|
ByteArrayContent(String type,
byte[] array)
|
Method Summary | |
---|---|
static ByteArrayContent |
fromString(String type,
String contentString)
Returns a new instance with the UTF-8 encoding (using Strings.toBytesUtf8() ) of the
given content string. |
protected InputStream |
getInputStream()
Return an input stream for the specific implementation type of AbstractInputStreamContent . |
long |
getLength()
Returns the content length or less than zero if not known. |
boolean |
retrySupported()
Returns whether or not retry is supported on this content type. |
ByteArrayContent |
setEncoding(String encoding)
Sets the content encoding (for example "gzip" ) or null for none. |
ByteArrayContent |
setType(String type)
Sets the content type or null for none. |
Methods inherited from class com.google.api.client.http.AbstractInputStreamContent |
---|
copy, getEncoding, getType, writeTo |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
@Deprecated public ByteArrayContent(byte[] array)
ByteArrayContent(String, byte[])
array
- Data source for creating input streams.@Deprecated public ByteArrayContent(String contentString)
fromString(String, String)
Strings.toBytesUtf8()
to perform the conversion.
contentString
- String to use as the source data for creating input streams@Deprecated public ByteArrayContent()
new ByteArrayContent(null, new
byte[]{})
public ByteArrayContent(String type, byte[] array)
type
- content type or null
for nonearray
- byte array contentMethod Detail |
---|
public static ByteArrayContent fromString(String type, String contentString)
Strings.toBytesUtf8()
) of the
given content string.
Sample use:
static void setJsonContent(HttpRequest request, String json) {
request.setContent(ByteArrayContent.fromString("application/json", json));
}
type
- content type or null
for nonecontentString
- content stringpublic long getLength()
HttpContent
public boolean retrySupported()
HttpContent
protected InputStream getInputStream()
AbstractInputStreamContent
AbstractInputStreamContent
. If the specific implementation will return true
for
HttpContent.retrySupported()
this should be a factory function which will create a new
InputStream
from the source data whenever invoked.
getInputStream
in class AbstractInputStreamContent
public ByteArrayContent setEncoding(String encoding)
AbstractInputStreamContent
"gzip"
) or null
for none.
setEncoding
in class AbstractInputStreamContent
public ByteArrayContent setType(String type)
AbstractInputStreamContent
null
for none.
setType
in class AbstractInputStreamContent
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |