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

abstract class DAO extends Object
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 Details

    • DAO

      DAO()
  • Method Details

    • getCompression

      public Compression getCompression()
      Returns the response compression type.
      Returns:
      a Compression enumeration value
    • setMethod

      public void setMethod(String method)
      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

      public void setCompression(Compression... cmps)
      Updates the allowed compression for this request.
      Parameters:
      cmps - the Compression values
    • init

      protected void init(String url) throws IOException
      Helper method to open the connection.
      Parameters:
      url - the URI to connect to
      Throws:
      IOException - if an error occurs
    • setRequestHeader

      protected void setRequestHeader(String name, String value)
      Sets a request header.
      Parameters:
      name - the header name
      value - the header value
    • setAuthentication

      protected void setAuthentication(String userID, String pwd)
      Sets an authentication request header.
      Parameters:
      userID - the user ID
      pwd - the password
    • getResponseCode

      protected int getResponseCode() throws IOException, HTTPDAOException
      Returns the HTTP response code for this request.
      Returns:
      the response code
      Throws:
      IOException - if an error occured
      HTTPDAOException - if the read times out, with stack dump disabled
    • getHeaderField

      protected String getHeaderField(String name)
      Returns an HTTP response header.
      Parameters:
      name - the header name
      Returns:
      the header value
    • getIn

      protected InputStream getIn() throws IOException, HTTPDAOException
      Retrieves an input stream to the URL.
      Returns:
      an InputStream to the data
      Throws:
      HTTPDAOException - if the read times out, with stack dump disabled
      IOException - if an error occurs
    • getOut

      protected OutputStream getOut() throws IOException
      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.