Class PathHandler

java.lang.Object
org.ka2ddo.yaac.webserver.PathHandler
Direct Known Subclasses:
BulletinsPage, FavIcon, FileCopierPage, HistoryPage, IconPage, IndexPage, MapPage, MessagesPage, MonitorDigiPage, MonitorStationsPage, MonitorWxPage, RobotsTxtPage, StationsPage, WeatherPage

public abstract class PathHandler extends Object
This is the generic web page generator class which should be subclassed to produce a particular page.
Author:
Andrew Pavlin, KA2DDO
  • Field Details

    • TEXT_HTML_CHARSET_UTF_8

      public static final String TEXT_HTML_CHARSET_UTF_8
      Predefined constant Content-Type string for HTML.
      See Also:
    • PURPLE

      protected static final Color PURPLE
      Color to use for station ages that are in the future (i.e., their station clock is off).
    • MINUTES_30

      protected static final long MINUTES_30
      Number of milliseconds in 30 minutes.
      See Also:
    • MINUTES_15

      protected static final long MINUTES_15
      Number of milliseconds in 15 minutes.
      See Also:
    • httpServer

      protected HttpServer httpServer
      Reference to HttpServer instance that uses invocations of this PathHandler instance.
  • Constructor Details

    • PathHandler

      public PathHandler()
  • Method Details

    • escPrint

      protected static void escPrint(PrintWriter pw, String text)
      This method prints a String to the output PrintWriter, doing HTML escapes for any reserved characters.
      Parameters:
      pw - PrintWriter to receive the escaped text
      text - String to output with escapes
    • escPrint

      protected static void escPrint(NonshareableBufferedPrintStream ps, String text)
      This method prints a String to the output PrintStream, doing HTML escapes for any reserved characters.
      Parameters:
      ps - NonshareableBufferedPrintStream to receive the escaped text
      text - String to output with escapes
    • outputFooterLinks

      protected static void outputFooterLinks(NonshareableBufferedPrintStream pOut, ResourceBundle msgBundle)
      Output the standard footer links for the YAAC webserver.
      Parameters:
      pOut - NonshareableBufferedPrintStream to write the HTML text to
      msgBundle - ResourceBundle to handle any text localizations
    • processPage

      public abstract String processPage(HttpConnectionThread hct, LinkedHashMap<String,String> requestHeaders, DataInput in, OutputStream out, String path) throws IOException
      Given an inbound HTTP request, generate a page using its parameters.
      Parameters:
      hct - HttpConnectionThread issuing the call
      requestHeaders - the HTTP request headers the browser sent
      in - DataInput for reading the body of the HTTP request
      out - OutputStream to write the generated page to
      path - the remainder of the URL following the prefix identifying this particular page, in case the user is providing parameters to the page
      Returns:
      the Content-Type header value to return to tell the remote browser how to interpret the page
      Throws:
      IOException - if the page could not be generated for some reason
    • getHttpServer

      public HttpServer getHttpServer()
      Get the HttpServer instance associated with this PathHandler.
      Returns:
      HttpServer instance
    • setHttpServer

      public void setHttpServer(HttpServer httpServer)
      Set the HttpServer instance associated with this PathHandler. Note that a PathHandler instance cannot be shared between multiple HttpServer instances.
      Parameters:
      httpServer - HttpServer instance to associate