retrofit.mime
Class TypedFile

java.lang.Object
  extended by retrofit.mime.TypedFile
All Implemented Interfaces:
TypedInput, TypedOutput

public class TypedFile
extends Object
implements TypedInput, TypedOutput

File and its mime type.

Author:
Bob Lee ([email protected])

Constructor Summary
TypedFile(String mimeType, File file)
          Constructs a new typed file.
 
Method Summary
 boolean equals(Object o)
           
 File file()
          Returns the file.
 String fileName()
          Original filename.
 int hashCode()
           
 InputStream in()
          Read bytes as stream.
 long length()
          Length in bytes.
 String mimeType()
          Returns the mime type.
 void moveTo(TypedFile destination)
          Atomically moves the contents of this file to a new location.
 String toString()
           
 void writeTo(OutputStream out)
          Writes these bytes to the given output stream.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TypedFile

public TypedFile(String mimeType,
                 File file)
Constructs a new typed file.

Throws:
NullPointerException - if file or mimeType is null
Method Detail

file

public File file()
Returns the file.


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

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

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

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

moveTo

public void moveTo(TypedFile destination)
            throws IOException
Atomically moves the contents of this file to a new location.

Parameters:
destination - file
Throws:
IOException - if the move fails

toString

public String toString()
Overrides:
toString in class Object

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.