Class DAO
java.lang.Object
org.deltava.dao.http.DAO
- Direct Known Subclasses:
FlightAwareDAO,GetATIS,GetExternalCharts,GetFAACharts,GetGoogleCAPTCHA,GetGoogleGeocode,GetNOAAWeather,GetSimBrief,GetURL,GetVATSIMData,GetWeatherTileLayers,SendVAPIDPush,SetVATSIMData,TrackDAO
An abstract class to supports Data Access Objects that read from an HTTP URL. This differs from a stream-based Data Access Object only
that HTTP DAOs create their own stream to a URL. This is used in situations where request-specific data is encoded into the URL.
- Since:
- 2.4
- Version:
- 11.2
- Author:
- Luke
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the response compression type.protected StringgetHeaderField(String name) Returns an HTTP response header.protected InputStreamgetIn()Retrieves an input stream to the URL.protected OutputStreamgetOut()Retrieves an output stream to the URL.protected intReturns the HTTP response code for this request.protected voidHelper method to open the connection.voidreset()Resets the connection for subsequent reuse.protected voidsetAuthentication(String userID, String pwd) Sets an authentication request header.voidsetCompression(Compression... cmps) Updates the allowed compression for this request.voidsetConnectTimeout(int timeout) Sets the HTTP connect timeout.voidSets the HTTP method to use if not GET.voidsetReadTimeout(int timeout) Sets the HTTP connect timeout.protected voidsetRequestHeader(String name, String value) Sets a request header.voidsetReturnErrorStream(boolean returnErrStream) Sets whether the error stream should be returned when connecting and an error occurs.
-
Constructor Details
-
DAO
DAO()
-
-
Method Details
-
getCompression
Returns the response compression type.- Returns:
- a Compression enumeration value
-
setMethod
Sets the HTTP method to use if not GET.- Parameters:
method- the method name
-
setConnectTimeout
public void setConnectTimeout(int timeout) Sets the HTTP connect timeout.- Parameters:
timeout- the timeout in milliseconds
-
setReadTimeout
public void setReadTimeout(int timeout) Sets the HTTP connect timeout.- Parameters:
timeout- the timeout in milliseconds
-
setReturnErrorStream
public void setReturnErrorStream(boolean returnErrStream) Sets whether the error stream should be returned when connecting and an error occurs.- Parameters:
returnErrStream- TRUE if the error stream should be returned, otherwise FALSE- See Also:
-
setCompression
Updates the allowed compression for this request.- Parameters:
cmps- the Compression values
-
init
Helper method to open the connection.- Parameters:
url- the URI to connect to- Throws:
IOException- if an error occurs
-
setRequestHeader
-
setAuthentication
-
getResponseCode
Returns the HTTP response code for this request.- Returns:
- the response code
- Throws:
IOException- if an error occuredHTTPDAOException- if the read times out, with stack dump disabled
-
getHeaderField
-
getIn
Retrieves an input stream to the URL.- Returns:
- an InputStream to the data
- Throws:
HTTPDAOException- if the read times out, with stack dump disabledIOException- if an error occurs
-
getOut
Retrieves an output stream to the URL.- Returns:
- an OutputStream to the data
- Throws:
IOException- if an error occurs
-
reset
public void reset()Resets the connection for subsequent reuse.
-