ElegantJ Data Tables Java API Specification v1.1

com.elegantj.net.http
Class HTTPClient

java.lang.Object
  extended bycom.elegantj.net.http.HTTPClient

public class HTTPClient
extends java.lang.Object

This class encapsulates HTTPClient functionality. It supports HTTP version 1.0.


Field Summary
static java.lang.String HTTP_GET_METHOD
          The HTTP GET method
static java.lang.String HTTP_HEAD_METHOD
          The HTTP HEAD method
static java.lang.String HTTP_POST_METHOD
          The HTTP POST method
 
Constructor Summary
HTTPClient()
          Constructs HTTPClient with empty request and response headers.
 
Method Summary
 void addPropertyChangeListener(java.beans.PropertyChangeListener pcl)
           
 void clearHTTPRequestHeaders()
          Method which clears the HTTP request headers.
 void clearHTTPResponseHeaders()
          Method which clears the HTTP response headers.
 void closeConnection()
          Close the connection.
 java.lang.String getHTTPRequest()
          Method which returns the HTTP request.
 java.lang.String getHTTPRequestEntityBody()
          Method which returns the entity body of the HTTP request.
 java.lang.String getHTTPRequestEntityHeader()
          Method which returns the entity header of the HTTP request.
 java.lang.String getHTTPRequestEntityHeaderProperty(java.lang.String field)
          Method which returns the value for specified entity header field of HTTP entity header.
 java.lang.String getHTTPRequestGeneralHeader()
          Method which returns the general header of the HTTP request.
 java.lang.String getHTTPRequestGeneralHeaderProperty(java.lang.String field)
          Method which returns the value for specified general header field of HTTP request header.
 java.lang.String getHTTPRequestHeader()
          Method which returns the request header of the HTTP request.
 java.lang.String getHTTPRequestHeaderProperty(java.lang.String field)
          Method which returns the value for specified request header field of HTTP request header.
 java.lang.String getHTTPResponse()
          Method which returns the HTTP response.
 byte[] getHTTPResponseEntityBody()
          Method which returns the entity body of the HTTP response.
 java.lang.String getHTTPResponseHeader()
          Method which returns the response header of the HTTP response.
 java.lang.String getHTTPResponseHeaderProperty(java.lang.String field)
          Method which returns the value for specified response header field of HTTP response header.
 java.io.DataInputStream getInputStream()
          Returns the input stream to read the response.
 java.lang.String getMethod()
          Returns the name of the HTTP method.
 java.io.OutputStream getOutputStream()
          Returns the output stream to write the request.
 void getResponseFromServer()
          Method which reads HTTP response from the web server.
 void getResponseHeaderFromServer()
          Method which reads HTTP response header from the web server.
 java.lang.String getURL()
          Method which returns the url for this HTTPClient.
 boolean openConnection()
          Opens a connection with the host and port specified in the URL.
 void removePropertyChangeListener(java.beans.PropertyChangeListener pcl)
           
 void sendRequestToServer()
          Method which sends the HTTP request to the web server.
 void setFileAsEntityBody(java.io.File file)
          Method which set the content of the specified file as the entity body for the HTTP POST request.
 void setHTTPRequestEntityHeaderProperty(java.lang.String field, java.lang.String value)
          Method which sets the entity header property for the HTTP entity header.
 void setHTTPRequestGeneralHeaderProperty(java.lang.String field, java.lang.String value)
          Method which sets the general header property for the HTTP request header.
 void setHTTPRequestHeaderProperty(java.lang.String field, java.lang.String value)
          Method which sets the request header property for the HTTP request header.
 void setMethod(java.lang.String method)
          Method which sets the name of the HTTP method.
 void setStringBufferAsEntityBody(java.lang.String buffer)
          Method which set the specified string buffer as the entity body for the HTTP POST request.
 void setURL(java.lang.String urlStr)
          Method which set the url for this HTTPClient.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HTTP_GET_METHOD

public static final java.lang.String HTTP_GET_METHOD
The HTTP GET method


HTTP_HEAD_METHOD

public static final java.lang.String HTTP_HEAD_METHOD
The HTTP HEAD method


HTTP_POST_METHOD

public static final java.lang.String HTTP_POST_METHOD
The HTTP POST method

Constructor Detail

HTTPClient

public HTTPClient()
Constructs HTTPClient with empty request and response headers.

Method Detail

openConnection

public boolean openConnection()
Opens a connection with the host and port specified in the URL.

Returns:
true if connected successfully, false otherwise.

closeConnection

public void closeConnection()
Close the connection.


getInputStream

public java.io.DataInputStream getInputStream()
Returns the input stream to read the response.

Returns:
The input stream to read the response.

getOutputStream

public java.io.OutputStream getOutputStream()
Returns the output stream to write the request.

Returns:
The output stream to write the request.

clearHTTPRequestHeaders

public void clearHTTPRequestHeaders()
Method which clears the HTTP request headers.


clearHTTPResponseHeaders

public void clearHTTPResponseHeaders()
Method which clears the HTTP response headers.


setMethod

public void setMethod(java.lang.String method)
Method which sets the name of the HTTP method. Possible HTTP methods are HTTPClient.HTTP_GET_METHOD, HTTPClient.HTTP_HEAD_METHOD, or HTTPClient.HTTP_POST_METHOD.


getMethod

public java.lang.String getMethod()
Returns the name of the HTTP method.

Returns:
The name of the HTTP method.

setURL

public void setURL(java.lang.String urlStr)
Method which set the url for this HTTPClient.

Parameters:
urlStr - The url string for this HTTPClient.

getURL

public java.lang.String getURL()
Method which returns the url for this HTTPClient.

Returns:
The url for this HTTPClient.

setHTTPRequestGeneralHeaderProperty

public void setHTTPRequestGeneralHeaderProperty(java.lang.String field,
                                                java.lang.String value)
Method which sets the general header property for the HTTP request header.

Parameters:
field - The name of general header field.
value - The value for that field.

getHTTPRequestGeneralHeaderProperty

public java.lang.String getHTTPRequestGeneralHeaderProperty(java.lang.String field)
Method which returns the value for specified general header field of HTTP request header.

Parameters:
field - The name of general header field.
Returns:
The value for specified general header field of HTTP request header.

getHTTPRequestGeneralHeader

public java.lang.String getHTTPRequestGeneralHeader()
Method which returns the general header of the HTTP request.

Returns:
The general header of the HTTP request.

setHTTPRequestHeaderProperty

public void setHTTPRequestHeaderProperty(java.lang.String field,
                                         java.lang.String value)
Method which sets the request header property for the HTTP request header.

Parameters:
field - The name of request header field.
value - The value for that field.

getHTTPRequestHeaderProperty

public java.lang.String getHTTPRequestHeaderProperty(java.lang.String field)
Method which returns the value for specified request header field of HTTP request header.

Parameters:
field - The name of request header field.
Returns:
The value for specified request header field of HTTP request header.

getHTTPRequestHeader

public java.lang.String getHTTPRequestHeader()
Method which returns the request header of the HTTP request.

Returns:
The request header of the HTTP request.

setHTTPRequestEntityHeaderProperty

public void setHTTPRequestEntityHeaderProperty(java.lang.String field,
                                               java.lang.String value)
Method which sets the entity header property for the HTTP entity header.

Parameters:
field - The name of entity header field.
value - The value for that field.

getHTTPRequestEntityHeaderProperty

public java.lang.String getHTTPRequestEntityHeaderProperty(java.lang.String field)
Method which returns the value for specified entity header field of HTTP entity header.

Parameters:
field - The name of entity header field.
Returns:
The value for specified entity header field of HTTP entity header.

getHTTPRequestEntityHeader

public java.lang.String getHTTPRequestEntityHeader()
Method which returns the entity header of the HTTP request.

Returns:
The entity header of the HTTP request.

getHTTPRequestEntityBody

public java.lang.String getHTTPRequestEntityBody()
Method which returns the entity body of the HTTP request.

Returns:
The entity body of the HTTP request.

getHTTPRequest

public java.lang.String getHTTPRequest()
Method which returns the HTTP request.

Returns:
The HTTP request.

getHTTPResponseHeaderProperty

public java.lang.String getHTTPResponseHeaderProperty(java.lang.String field)
Method which returns the value for specified response header field of HTTP response header.

Parameters:
field - The name of response header field.
Returns:
The value for specified response header field of HTTP response header.

getHTTPResponseHeader

public java.lang.String getHTTPResponseHeader()
Method which returns the response header of the HTTP response.

Returns:
The response header of the HTTP response.

getHTTPResponseEntityBody

public byte[] getHTTPResponseEntityBody()
Method which returns the entity body of the HTTP response.

Returns:
The entity body of the HTTP response.

getHTTPResponse

public java.lang.String getHTTPResponse()
Method which returns the HTTP response.

Returns:
The HTTP response.

sendRequestToServer

public void sendRequestToServer()
Method which sends the HTTP request to the web server.


getResponseHeaderFromServer

public void getResponseHeaderFromServer()
Method which reads HTTP response header from the web server.


getResponseFromServer

public void getResponseFromServer()
Method which reads HTTP response from the web server.


setStringBufferAsEntityBody

public void setStringBufferAsEntityBody(java.lang.String buffer)
Method which set the specified string buffer as the entity body for the HTTP POST request.

Parameters:
buffer - The string buffer which holds the data to post.

setFileAsEntityBody

public void setFileAsEntityBody(java.io.File file)
Method which set the content of the specified file as the entity body for the HTTP POST request. This method also sets appropriate fields for the entity header of HTTP request, so no need to set the entity header fields, when posting data using this method.

Parameters:
file - The file which contains the data to post.

addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener pcl)

removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener pcl)

ElegantJ Data Tables Java API Specification v1.1

Submit a bug or feature

Copyright(c)
Elegant Microweb Technologies Pvt. Ltd.
www.elegantmicroweb.com
www.elegantjbeans.com
All Rights Reserved.