de.lmu.ifi.dbs.elki.application.jsmap
Class JSONWebServer

java.lang.Object
  extended by de.lmu.ifi.dbs.elki.application.jsmap.JSONWebServer
All Implemented Interfaces:
com.sun.net.httpserver.HttpHandler

public class JSONWebServer
extends Object
implements com.sun.net.httpserver.HttpHandler

A simple web server to serve data base contents to a JavaScript client.


Field Summary
private  Database db
          The database we use for obtaining object bundles
protected static Logging logger
          Our logger
static String PATH_JSON
          The base path we serve data from
private  HierarchicalResult result
          The result tree we serve
private  com.sun.net.httpserver.HttpServer server
          Server instance
 
Constructor Summary
JSONWebServer(int port, HierarchicalResult result)
          Constructor.
 
Method Summary
protected  void bundleToJSON(JSONBuffer re, DBID id)
          Serialize an object bundle to JSON.
 void handle(com.sun.net.httpserver.HttpExchange exchange)
           
private  void outlierMetaToJSON(JSONBuffer re, OutlierScoreMeta meta)
          Serialize outlier metadata as JSON.
protected  void resultToJSON(JSONBuffer re, String name)
          Serialize an arbitrary result into JSON.
 void stop()
          Stop the web server.
private  DBID stringToDBID(String query)
          Parse a string into a DBID.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected static final Logging logger
Our logger


PATH_JSON

public static final String PATH_JSON
The base path we serve data from

See Also:
Constant Field Values

server

private com.sun.net.httpserver.HttpServer server
Server instance


result

private HierarchicalResult result
The result tree we serve


db

private Database db
The database we use for obtaining object bundles

Constructor Detail

JSONWebServer

public JSONWebServer(int port,
                     HierarchicalResult result)
Constructor.

Parameters:
port - Port to listen on
result - Result to serve
Method Detail

stop

public void stop()
Stop the web server.


stringToDBID

private DBID stringToDBID(String query)
Parse a string into a DBID.

Parameters:
query - Query string
Returns:
DBID

bundleToJSON

protected void bundleToJSON(JSONBuffer re,
                            DBID id)
Serialize an object bundle to JSON.

Parameters:
re - Buffer to serialize to
id - Object ID

resultToJSON

protected void resultToJSON(JSONBuffer re,
                            String name)
Serialize an arbitrary result into JSON.

Parameters:
re - Buffer to serialize to
name - Result requested

outlierMetaToJSON

private void outlierMetaToJSON(JSONBuffer re,
                               OutlierScoreMeta meta)
Serialize outlier metadata as JSON.

Parameters:
re - Output buffer
meta - Metadata

handle

public void handle(com.sun.net.httpserver.HttpExchange exchange)
            throws IOException
Specified by:
handle in interface com.sun.net.httpserver.HttpHandler
Throws:
IOException

Release 0.4.0 (2011-09-20_1324)