Faking a Server

HelpBrowser
+ showDialogHelp(String)
+ showSSHelp(String, String)
JEditorPane
+ setText(String)
+ setPage(URL)
URL
+ openConnection() : URLConnection
KahunaURLStreamHandlerFactory
+ createURLStreamHandler(String)
                  : URLStreamHandler
KahunaURLStreamHandler
# openConnection(URL)
                  : URLConnection
KahunaURLConnection
+ KahunaURLConnection(URL)
+ connect()
+ getContentType() : String
+ getInputStream() : InputStream
KahunaServer
+ KahunaServer(ScriptFactory)
+ getPage(URL) : String


class KahunaServer {
    private ScriptFactory scriptFactory;

    public KahunaServer(ScriptFactory scriptFactory) {
        this.scriptFactory = scriptFactory;
    }

    public URL createSSHelpURL(String ssLang, String ssName) {
        return new URL("kahuna", "script.statement",
                       "/" + ssLang + "/" + ssName);
    }

    public String getPage(URL url) throws IOException {
        ScriptStatement ss;

        String fileName = url.getFile();
        int lastSlash = fileName.lastIndexOf('/');
        String ssName = fileName.substring(lastSlash + 1);
        String ssLang = fileName.substring(1, lastSlash);

        ss = scriptFactory.toScriptStatement(ssName, ssLang);

        return ss.getDiscussion();
    }
}