Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.ka2ddo.yaac.webserver
Class PathHandler

    java.lang.Object
      org.ka2ddo.yaac.webserver.PathHandler

Direct Known Subclasses:
  BulletinsPage, FavIcon, FileCopierPage, HistoryPage, IconPage, IndexPage, MapPage, MessagesPage, MonitorWxPage, RobotsTxtPage, StationsPage

    public abstract class PathHandler

extends java.lang.Object

This is the generic web page generator class which should be subclassed to produce a particular page.

Field Summary
`protected HttpServer` | `httpServer` Reference to HttpServer instance that uses invocations of this PathHandler instance.
`static java.lang.String` | `TEXT_HTML_CHARSET_UTF_8` Predefined constant Content-Type string for HTML.

Constructor Summary
`PathHandler()`

Method Summary
`protected static void` | `escPrint(java.io.PrintWriter pw, java.lang.String text)` This method prints a String to the output PrintWriter, doing HTML escapes for any reserved characters.
`HttpServer` | `getHttpServer()` Get the HttpServer instance associated with this PageHandler.
`abstract java.lang.String` | `processPage(HttpConnectionThread hct, java.util.LinkedHashMap<java.lang.String,java.lang.String> requestHeaders, java.io.DataInputStream in, java.io.OutputStream out, java.lang.String path)` Given an inbound HTTP request, generate a page using its parameters.
`void` | `setHttpServer(HttpServer httpServer)` Set the HttpServer instance associated with this PageHandler.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### TEXT_HTML_CHARSET_UTF_8

    public static final java.lang.String TEXT_HTML_CHARSET_UTF_8

  Predefined constant Content-Type string for HTML.

  See Also:
    Constant Field Values

### httpServer

    protected HttpServer httpServer

  Reference to HttpServer instance that uses invocations of this PathHandler instance.

Constructor Detail

### PathHandler

    public PathHandler()

Method Detail

### escPrint

    protected static void escPrint(java.io.PrintWriter pw,
                                   java.lang.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

### processPage

    public abstract java.lang.String processPage(HttpConnectionThread hct,
                                                 java.util.LinkedHashMap<java.lang.String,java.lang.String> requestHeaders,
                                                 java.io.DataInputStream in,
                                                 java.io.OutputStream out,
                                                 java.lang.String path)
                                          throws java.io.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` - DataInputStream 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:
    `java.io.IOException` - if the page could not be generated for some reason

### getHttpServer

    public HttpServer getHttpServer()

  Get the HttpServer instance associated with this PageHandler.

  Returns:
    HttpServer instance

### setHttpServer

    public void setHttpServer(HttpServer httpServer)

  Set the HttpServer instance associated with this PageHandler. Note that a PageHandler instance cannot be shared between multiple HttpServer instances.

  Parameters:
    `httpServer` - HttpServer instance to associate

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD