twitter4j.http
Class HttpResponse

java.lang.Object
  extended by twitter4j.http.HttpResponse

public class HttpResponse
extends java.lang.Object

A data class representing HTTP Response

Author:
Yusuke Yamamoto - yusuke at mac.com

Field Summary
private static java.lang.ThreadLocal<javax.xml.parsers.DocumentBuilder> builders
           
private  java.net.HttpURLConnection con
           
private  java.io.InputStream is
           
private static Logger logger
           
private  org.w3c.dom.Document responseAsDocument
           
private  java.lang.String responseAsString
           
private  int statusCode
           
private  boolean streamConsumed
           
 
Constructor Summary
HttpResponse(java.net.HttpURLConnection con)
           
HttpResponse(java.lang.String content)
           
 
Method Summary
 org.w3c.dom.Document asDocument()
          Returns the response body as org.w3c.dom.Document.
Disconnects the internal HttpURLConnection silently.
 twitter4j.org.json.JSONArray asJSONArray()
          Returns the response body as twitter4j.org.json.JSONArray.
Disconnects the internal HttpURLConnection silently.
 twitter4j.org.json.JSONObject asJSONObject()
          Returns the response body as twitter4j.org.json.JSONObject.
Disconnects the internal HttpURLConnection silently.
 java.io.InputStreamReader asReader()
           
 java.io.InputStream asStream()
          Returns the response stream.
This method cannot be called after calling asString() or asDcoument()
It is suggested to call disconnect() after consuming the stream.
 java.lang.String asString()
          Returns the response body as string.
Disconnects the internal HttpURLConnection silently.
 void disconnect()
           
 java.lang.String getResponseHeader(java.lang.String name)
           
 int getStatusCode()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

logger

private static final Logger logger

builders

private static java.lang.ThreadLocal<javax.xml.parsers.DocumentBuilder> builders

statusCode

private int statusCode

responseAsDocument

private org.w3c.dom.Document responseAsDocument

responseAsString

private java.lang.String responseAsString

is

private java.io.InputStream is

con

private java.net.HttpURLConnection con

streamConsumed

private boolean streamConsumed
Constructor Detail

HttpResponse

public HttpResponse(java.net.HttpURLConnection con)
             throws java.io.IOException
Throws:
java.io.IOException

HttpResponse

HttpResponse(java.lang.String content)
Method Detail

getStatusCode

public int getStatusCode()

getResponseHeader

public java.lang.String getResponseHeader(java.lang.String name)

asStream

public java.io.InputStream asStream()
Returns the response stream.
This method cannot be called after calling asString() or asDcoument()
It is suggested to call disconnect() after consuming the stream. Disconnects the internal HttpURLConnection silently.

Returns:
response body stream
Throws:
TwitterException
See Also:
disconnect()

asString

public java.lang.String asString()
                          throws TwitterException
Returns the response body as string.
Disconnects the internal HttpURLConnection silently.

Returns:
response body
Throws:
TwitterException

asDocument

public org.w3c.dom.Document asDocument()
                                throws TwitterException
Returns the response body as org.w3c.dom.Document.
Disconnects the internal HttpURLConnection silently.

Returns:
response body as org.w3c.dom.Document
Throws:
TwitterException

asJSONObject

public twitter4j.org.json.JSONObject asJSONObject()
                                           throws TwitterException
Returns the response body as twitter4j.org.json.JSONObject.
Disconnects the internal HttpURLConnection silently.

Returns:
response body as twitter4j.org.json.JSONObject
Throws:
TwitterException

asJSONArray

public twitter4j.org.json.JSONArray asJSONArray()
                                         throws TwitterException
Returns the response body as twitter4j.org.json.JSONArray.
Disconnects the internal HttpURLConnection silently.

Returns:
response body as twitter4j.org.json.JSONArray
Throws:
TwitterException

asReader

public java.io.InputStreamReader asReader()

disconnect

public void disconnect()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object