retrofit.mime
Class TypedByteArray

java.lang.Object
  extended by retrofit.mime.TypedByteArray
All Implemented Interfaces:
TypedInput, TypedOutput
Direct Known Subclasses:
TypedString

public class TypedByteArray
extends Object
implements TypedInput, TypedOutput

Byte array and its mime type.

Author:
Bob Lee ([email protected])

Constructor Summary
TypedByteArray(String mimeType, byte[] bytes)
          Constructs a new typed byte array.
 
Method Summary
 boolean equals(Object o)
           
 String fileName()
          Original filename.
 byte[] getBytes()
           
 int hashCode()
           
 InputStream in()
          Read bytes as stream.
 long length()
          Length in bytes.
 String mimeType()
          Returns the mime type.
 void writeTo(OutputStream out)
          Writes these bytes to the given output stream.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TypedByteArray

public TypedByteArray(String mimeType,
                      byte[] bytes)
Constructs a new typed byte array. Sets mimeType to application/unknown if absent.

Throws:
NullPointerException - if bytes are null
Method Detail

getBytes

public byte[] getBytes()

fileName

public String fileName()
Description copied from interface: TypedOutput
Original filename. Used only for multipart requests, may be null.

Specified by:
fileName in interface TypedOutput

mimeType

public String mimeType()
Description copied from interface: TypedInput
Returns the mime type.

Specified by:
mimeType in interface TypedInput
Specified by:
mimeType in interface TypedOutput

length

public long length()
Description copied from interface: TypedInput
Length in bytes. Returns -1 if length is unknown.

Specified by:
length in interface TypedInput
Specified by:
length in interface TypedOutput

writeTo

public void writeTo(OutputStream out)
             throws IOException
Description copied from interface: TypedOutput
Writes these bytes to the given output stream.

Specified by:
writeTo in interface TypedOutput
Throws:
IOException

in

public InputStream in()
               throws IOException
Description copied from interface: TypedInput
Read bytes as stream. Unless otherwise specified, this method may only be called once. It is the responsibility of the caller to close the stream.

Specified by:
in in interface TypedInput
Throws:
IOException

equals

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

hashCode

public int hashCode()
Overrides:
hashCode in class Object


Copyright © 2013 Square, Inc.. All Rights Reserved.