Commit 6944cc8e authored by Haejoong Lee's avatar Haejoong Lee

added missing javadoc

parent 86e028d5
......@@ -10,14 +10,14 @@ import fi.iki.elonen.NanoHTTPD.Response;
/**
* Allows to create a chain of HTTP request processors.
*
* @author haejoong
* @author Haejoong Lee <haejoong@ldc.upenn.edu>
*/
abstract public class Proc {
private List<Proc> procs;
/**
* Add a new processor to the processor chain and returns itself.
* @param p
* @param p Proc object
* @return this object.
*/
public Proc add(Proc p) {
......@@ -31,10 +31,19 @@ abstract public class Proc {
/**
* The actual behavior of the object should be implemented here.
* @param session
* @param session An HTTP session object.
* @return a Response object, or null if the HTTP request, described by
* the session object, was not handled.
*/
abstract public Response run(IHTTPSession session);
/**
* Execute the processor chain.
* @param session HTTP session object given to the serve() method of
* NanoHTTPD object.
* @return a Response object, or null if the HTTP request was not
* handled.
*/
public Response exec(IHTTPSession session) {
Iterator<Proc> it = procs.iterator();
while (it.hasNext()) {
......
......@@ -16,13 +16,18 @@ import java.io.IOException;
import java.io.InputStream;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.net.NetworkInterface;
import java.net.InetAddress;
/**
* A web server class designed for a web-based transcription tool
* (see github.com/langtech/transcriber).
*
* @author Haejoong Lee <haejoong@ldc.upenn.edu>
*
*/
public class Server extends NanoHTTPD {
private static String host_; // hostname
private static int port_ = -1; // port number
......@@ -105,7 +110,7 @@ public class Server extends NanoHTTPD {
/**
* Configure hostname.
*
* @param host
* @param host Hostname.
*/
public static void setHost(String host) {
host_ = host;
......@@ -114,16 +119,17 @@ public class Server extends NanoHTTPD {
/**
* Configure port number.
*
* @param port
* @param port Port number.
*/
public static void setPort(int port) {
port_ = port;
}
/**
* Set FileServer object.
* Set AssetManager object to be used for serving static assets, e.g.
* audio and image files.
*
* @param fileServer
* @param am AssetManager for the app.
*/
public static void setAssetManager(AssetManager am) {
am_ = am;
......@@ -140,8 +146,8 @@ public class Server extends NanoHTTPD {
}
/**
*
* @return
* Identify available IP addresses of active network interfaces.
* @return A hash of interface name and IP address.
*/
public static Map<String,String> getIpAddresses() {
Enumeration<NetworkInterface> ifs;
......@@ -168,18 +174,34 @@ public class Server extends NanoHTTPD {
return ips;
}
/**
* Returns the hostname set by setHost() method.
* @return a hostname (IP address).
*/
public String getHost() {
return host_;
}
/**
* Returns the port number set by setPort() method.
* @return a port number.
*/
public int getPort() {
return port_;
}
/**
* Returns the hostname of the active server instance.
* @return hostname, or null if the server is not running.
*/
public String getActiveHost() {
return isAlive() ? current_host_ : null;
}
/**
* Returns the port number of the active server instance.
* @return port number, or null if the server is not running.
*/
public int getActivePort() {
return isAlive() ? current_port_ : null;
}
......
......@@ -12,6 +12,12 @@ import android.text.TextWatcher;
import android.view.View;
import android.widget.TextView;
/**
* Activity for starting and stopping the HTTP server.
*
* @author Haejoong Lee <haejoong@ldc.upenn.edu>
*/
public class HttpServerActivity extends AikumaActivity {
private String hostname;
private int port;
......@@ -86,7 +92,13 @@ public class HttpServerActivity extends AikumaActivity {
}
});
}
/**
* Displays a pop-up menu from which user can select a network interface
* to bind the HTTP server to.
*
* @param view A view.
*/
public void showNetworkInterfaceDialog(View view) {
if (!findViewById(R.id.ip_address).isEnabled())
return;
......@@ -119,6 +131,10 @@ public class HttpServerActivity extends AikumaActivity {
builder.show();
}
/**
* Start the HTTP server responding to the "START" button.
* @param view A view.
*/
public void startServer(View view) {
Boolean success;
log.setText("");
......@@ -141,6 +157,10 @@ public class HttpServerActivity extends AikumaActivity {
findViewById(R.id.button_stop_http).setEnabled(success);
}
/**
* Stop the HTTP server when the "STOP" button is clicked on.
* @param view a View object.
*/
public void stopServer(View view) {
log.setText("Server stopped.");
Server.destroyServer();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment