ElegantJ Data Tables Java API Specification v1.1

com.elegantj.data.dataprovider.http
Class HTTPTextDataProvider

java.lang.Object
  extended bycom.elegantj.data.dataprovider.AbstractDataProvider
      extended bycom.elegantj.data.dataprovider.text.TextDataProvider
          extended bycom.elegantj.data.dataprovider.http.HTTPTextDataProvider
All Implemented Interfaces:
DataProvider, java.io.Externalizable, java.io.Serializable

public class HTTPTextDataProvider
extends TextDataProvider
implements java.io.Externalizable

This class encapsulates functionality of an HTTP text data provider.
The basic functionality can be summarized as follows:
- Create an HTTP request to GET or POST the data.
- Send the HTTP request to the web server.
- Read the response from the web server.
This bean provides powerful designing aspects by providing following user friendly property.
DataProvider the data provider
URL the URL of the source file
RowSeparator the row separator string
ColumnSeparator the column separator string
TextQualifier the text qualifier string
FirstRowAsColumnNames indicates whether the first row of the retrieved data is column names or not
ColumnsDelimited indicates whether the columns are delimited or fixed width
SkippedColumns the comma separated indexes of the columns to be skipped
ColumnsWidth the comma separated width of the columns
SortCriteria the criteria for sorting the data
FilterCriteria the criteria for filtering the data
FilterState indicates whether the filter criteria is applied or not
SaveOnlyFilteredData indicates to save only filtered rows or all rows
FetchSize the maximum number of rows which can be retrieved
AppendDataOnFetchNext indicates whether the next fetched data is appended or replaced to existing data
SkippedRows the total number of rows to be skipped
Method the HTTP method name such as GET, POST, HEAD

See Also:
Serialized Form

Field Summary
 
Fields inherited from class com.elegantj.data.dataprovider.text.TextDataProvider
DEFAULT_COLUMN_SEPARATOR, DEFAULT_ROW_SEPARATOR, DEFAULT_TEXT_QUALIFIER, forInput, in, out
 
Fields inherited from class com.elegantj.data.dataprovider.AbstractDataProvider
c1, changes, clientTable, columnNames, currentIndex, dataTable
 
Constructor Summary
HTTPTextDataProvider()
           
 
Method Summary
 void clearHTTPRequestHeaders()
          Clears the HTTP request headers.
 void clearHTTPResponseHeaders()
          Clears the HTTP response headers.
 boolean close()
          Closes input / output stream of the text file
 void closeConnection()
          Closes the HTTP connection.
 java.lang.String getHTTPRequest()
          Returns the HTTP request.
 java.lang.String getHTTPRequestEntityBody()
          Returns the entity body of the HTTP request.
 java.lang.String getHTTPRequestEntityHeader()
          Returns the entity header of the HTTP request.
 java.lang.String getHTTPRequestEntityHeaderProperty(java.lang.String field)
          Returns the value for specified entity header field of HTTP entity header.
 java.lang.String getHTTPRequestGeneralHeader()
          Returns the general header of the HTTP request.
 java.lang.String getHTTPRequestGeneralHeaderProperty(java.lang.String field)
          Returns the value for specified general header field of HTTP request header.
 java.lang.String getHTTPRequestHeader()
          Returns the request header of the HTTP request.
 java.lang.String getHTTPRequestHeaderProperty(java.lang.String field)
          Returns the value for specified request header field of HTTP request header.
 java.lang.String getHTTPResponse()
          Returns the HTTP response.
 byte[] getHTTPResponseEntityBody()
          Returns the entity body of the HTTP response.
 java.lang.String getHTTPResponseHeader()
          Returns the response header of the HTTP response.
 java.lang.String getHTTPResponseHeaderProperty(java.lang.String field)
          Returns the value for specified response header field of HTTP response header.
 java.io.InputStream getInputStream()
          Returns the input stream to read the HTTP response.
 java.lang.String getMethod()
          Returns the name of the HTTP method.
 java.io.OutputStream getOutputStream()
          Returns the output stream to write the HTTP request.
 void getResponseFromServer()
          Reads HTTP response from the web server.
 void getResponseHeaderFromServer()
          Reads HTTP response header from the web server.
 boolean open(boolean input)
          Opens input stream or output stream of the text file
 boolean openConnection()
          Opens an HTTP connection with the host and port specified in the URL.
 void readExternal(java.io.ObjectInput in)
           
 void sendRequestToServer()
          Sends the HTTP request to the web server.
 void setFile(java.lang.String path)
          Not applicable
 void setFileAsEntityBody(java.io.File file)
          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)
          Sets the entity header property for the HTTP entity header.
 void setHTTPRequestGeneralHeaderProperty(java.lang.String field, java.lang.String value)
          Sets the general header property for the HTTP request header.
 void setHTTPRequestHeaderProperty(java.lang.String field, java.lang.String value)
          Sets the request header property for the HTTP request header.
 void setMethod(java.lang.String method)
          Sets the name of the HTTP method.
 void setStringBufferAsEntityBody(java.lang.String buffer)
          Set the specified string buffer as the entity body for the HTTP POST request.
 void setURLConnectionEnabled(boolean b)
          Not applicable
 void writeExternal(java.io.ObjectOutput out)
          Externalizable interface implementation to save and retrieve the state of this bean
 
Methods inherited from class com.elegantj.data.dataprovider.text.TextDataProvider
getFile, getSkippedColumns, getURL, isFetchNext, isURLConnectionEnabled, nextData, retrieve, retrieveData, save, saveData, setSkippedColumns, setURL
 
Methods inherited from class com.elegantj.data.dataprovider.AbstractDataProvider
addDataListener, addPropertyChangeListener, addRow, appendData, dataChanged, dataChanged, deleteRow, equals, exportToSQL, exportToSQL, exportToSQL, exportToSQL, exportToText, exportToText, exportToText, exportToText, exportToXML, exportToXML, filterData, find, find, findNext, fireDataChanged, firePropertyChange, firstRecord, getColumnCount, getColumnIndex, getColumnNames, getColumnsArray, getColumnSeparator, getColumnsWidth, getColumnTag, getColumnType, getComputable, getCurrentIndex, getCurrentRecord, getData, getDataAt, getDataAt, getDataCount, getDataProvider, getDeletedCount, getFetchSize, getFilterCriteria, getFilteredCount, getLicenseKey, getModifiedCount, getRootTag, getRowSeparator, getRowTag, getSkippedRows, getSortColumns, getSortCriteria, getTextQualifier, insertDataAt, isAppendDataOnFetchNext, isColumnsDelimited, isFilterState, isFirstRowAsColumnNames, isSaveOnlyFilteredData, lastRecord, modifyDataAt, nextRecord, parseInt, previousRecord, refreshData, removeAll, removeAt, removeDataListener, removePropertyChangeListener, removeRange, rollbackModifications, saveModifications, scrollToRow, setAppendDataOnFetchNext, setColumnsDelimited, setColumnSeparator, setColumnsWidth, setColumnTag, setData, setDataArray, setDataProvider, setFetchSize, setFilterCriteria, setFilterState, setFirstRowAsColumnNames, setLicenseKey, setRootTag, setRowSeparator, setRowTag, setSaveOnlyFilteredData, setSkippedRows, setSortCriteria, setTextQualifier, sortData, sortData, sortData, sortData, sortData, sortData, sortData, sortData, sortData
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HTTPTextDataProvider

public HTTPTextDataProvider()
Method Detail

openConnection

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

Returns:
true if connected successfully, false otherwise.

closeConnection

public void closeConnection()
Closes the HTTP connection.


getInputStream

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

Returns:
The input stream to read the HTTP response.

getOutputStream

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

Returns:
The output stream to write the HTTP request.

clearHTTPRequestHeaders

public void clearHTTPRequestHeaders()
Clears the HTTP request headers.


clearHTTPResponseHeaders

public void clearHTTPResponseHeaders()
Clears the HTTP response headers.


setMethod

public void setMethod(java.lang.String method)
Sets the name of the HTTP method. Possible HTTP methods are "GET", "HEAD", or "POST".


getMethod

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

Returns:
The name of the HTTP method.

setURLConnectionEnabled

public void setURLConnectionEnabled(boolean b)
Not applicable

Overrides:
setURLConnectionEnabled in class TextDataProvider
Parameters:
b - true to enable the URL connection

setFile

public void setFile(java.lang.String path)
Not applicable

Overrides:
setFile in class TextDataProvider
Parameters:
path - the path of the text file

open

public boolean open(boolean input)
Opens input stream or output stream of the text file

Overrides:
open in class TextDataProvider
Parameters:
input - true to open the input stream, false to open the output stream
Returns:
true if the connection is successfully opened, otherwise false

close

public boolean close()
Closes input / output stream of the text file

Overrides:
close in class TextDataProvider
Returns:
true if the connection is successfully closed, otherwise false

setHTTPRequestGeneralHeaderProperty

public void setHTTPRequestGeneralHeaderProperty(java.lang.String field,
                                                java.lang.String value)
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)
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()
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)
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)
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()
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)
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)
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()
Returns the entity header of the HTTP request.

Returns:
The entity header of the HTTP request.

getHTTPRequestEntityBody

public java.lang.String getHTTPRequestEntityBody()
Returns the entity body of the HTTP request.

Returns:
The entity body of the HTTP request.

getHTTPRequest

public java.lang.String getHTTPRequest()
Returns the HTTP request.

Returns:
The HTTP request.

getHTTPResponseHeaderProperty

public java.lang.String getHTTPResponseHeaderProperty(java.lang.String field)
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()
Returns the response header of the HTTP response.

Returns:
The response header of the HTTP response.

getHTTPResponseEntityBody

public byte[] getHTTPResponseEntityBody()
Returns the entity body of the HTTP response.

Returns:
The entity body of the HTTP response.

getHTTPResponse

public java.lang.String getHTTPResponse()
Returns the HTTP response.

Returns:
The HTTP response.

sendRequestToServer

public void sendRequestToServer()
Sends the HTTP request to the web server.


getResponseHeaderFromServer

public void getResponseHeaderFromServer()
Reads HTTP response header from the web server.


getResponseFromServer

public void getResponseFromServer()
Reads HTTP response from the web server.


setStringBufferAsEntityBody

public void setStringBufferAsEntityBody(java.lang.String buffer)
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)
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.

writeExternal

public void writeExternal(java.io.ObjectOutput out)
                   throws java.io.IOException
Externalizable interface implementation to save and retrieve the state of this bean

Specified by:
writeExternal in interface java.io.Externalizable
Overrides:
writeExternal in class TextDataProvider
Throws:
java.io.IOException

readExternal

public void readExternal(java.io.ObjectInput in)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException
Specified by:
readExternal in interface java.io.Externalizable
Overrides:
readExternal in class TextDataProvider
Throws:
java.io.IOException
java.lang.ClassNotFoundException

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.