Package 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
,MonitorDigiPage
,MonitorStationsPage
,MonitorWxPage
,RobotsTxtPage
,StationsPage
,WeatherPage
This is the generic web page generator class which should be subclassed to produce a particular
page.
- Author:
- Andrew Pavlin, KA2DDO
-
Field Summary
Modifier and TypeFieldDescriptionprotected HttpServer
Reference to HttpServer instance that uses invocations of this PathHandler instance.protected static final long
Number of milliseconds in 15 minutes.protected static final long
Number of milliseconds in 30 minutes.protected static final Color
Color to use for station ages that are in the future (i.e., their station clock is off).static final String
Predefined constant Content-Type string for HTML. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected static void
escPrint
(PrintWriter pw, String text) This method prints a String to the output PrintWriter, doing HTML escapes for any reserved characters.protected static void
escPrint
(NonshareableBufferedPrintStream ps, String text) This method prints a String to the output PrintStream, doing HTML escapes for any reserved characters.Get the HttpServer instance associated with this PathHandler.protected static void
outputFooterLinks
(NonshareableBufferedPrintStream pOut, ResourceBundle msgBundle) Output the standard footer links for the YAAC webserver.abstract String
processPage
(HttpConnectionThread hct, LinkedHashMap<String, String> requestHeaders, DataInput in, OutputStream out, String path) Given an inbound HTTP request, generate a page using its parameters.void
setHttpServer
(HttpServer httpServer) Set the HttpServer instance associated with this PathHandler.
-
Field Details
-
TEXT_HTML_CHARSET_UTF_8
Predefined constant Content-Type string for HTML.- See Also:
-
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_30Number of milliseconds in 30 minutes.- See Also:
-
MINUTES_15
protected static final long MINUTES_15Number of milliseconds in 15 minutes.- See Also:
-
httpServer
Reference to HttpServer instance that uses invocations of this PathHandler instance.
-
-
Constructor Details
-
PathHandler
public PathHandler()
-
-
Method Details
-
escPrint
This method prints a String to the output PrintWriter, doing HTML escapes for any reserved characters.- Parameters:
pw
- PrintWriter to receive the escaped texttext
- String to output with escapes
-
processPage
public abstract String processPage(HttpConnectionThread hct, LinkedHashMap<String, String> requestHeaders, DataInput in, OutputStream out, String path) throws IOExceptionGiven an inbound HTTP request, generate a page using its parameters.- Parameters:
hct
- HttpConnectionThread issuing the callrequestHeaders
- the HTTP request headers the browser sentin
- DataInput for reading the body of the HTTP requestout
- OutputStream to write the generated page topath
- 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
Get the HttpServer instance associated with this PathHandler.- Returns:
- HttpServer instance
-
setHttpServer
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
-