DCT Lightfoot v3 API specification

com.dctl.j2me.io.httpserver
Class HttpServerSocket

java.lang.Object
  |
  +--com.dctl.j2me.io.BaseConnection
        |
        +--com.dctl.j2me.io.http.BaseHttpConnection
              |
              +--com.dctl.j2me.io.httpserver.HttpServerSocket
All Implemented Interfaces:
Connection, InputConnection, OutputConnection, StreamConnection

public class HttpServerSocket
extends BaseHttpConnection
implements StreamConnection

An http server socket. Much like an http connection, but has states the other way around


Field Summary
 
Fields inherited from class com.dctl.j2me.io.http.BaseHttpConnection
ACCEPT_PROPERTY, ACCEPT_VALUE, ASCTIME, CHUNKED_ENCODING, CLOSED, COLON_SPACE, COMMA, CONNECTION_CLOSE, CONNECTION_KEEP_ALIVE, CONNECTION_PROPERTY, CONTENT_ENCODING_PROPERTY, CONTENT_LENGTH_PROPERTY, CONTENT_TYPE_PROPERTY, CRLF, DASH, DATE_PROPERTY, DAY, EXPIRES_PROPERTY, FIELDS, handle, HOST_PROPERTY, HOUR, inputNames, inputProperties, is, LAST_MODIFIED_PROPERTY, method, MIN, MONTH, MONTH_STRING, opens, os, outputProperties, PROTOCOL, RECEIVING, responseCode, responseMessage, RFC1123, RFC850, SEC, SENDING, SETUP, SPACE, state, TRANSFER_ENCODING_PROPERTY, USER_AGENT_PROPERTY, USER_AGENT_VALUE, VERSION, YEAR
 
Fields inherited from class com.dctl.j2me.io.BaseConnection
protocol
 
Constructor Summary
HttpServerSocket(int handle, java.lang.String address, int port)
          Create a new connection given the handle
 
Method Summary
protected  java.lang.String generateFirstOutput()
          Generate the first line of output
 java.lang.String getRequestField(java.lang.String name)
          Get a request field
 long getRequestFieldDate(java.lang.String name, int defaultValue)
          Get a request field as a date
 int getRequestFieldInt(java.lang.String name, int defaultValue)
          Get a request field as an integer
 java.lang.String getRequestProperty(java.lang.String key)
          Read a request property
 java.lang.String getURL()
          Get the URL
protected  boolean handleFirstInput(java.lang.String line)
          Handle the first input line
protected  void openConnection()
          Open connection.
 InputStream openInputStream()
          Open the input stream
 OutputStream openOutputStream()
          Open the output stream
 void recycle()
          Recycle the connection
 void setParameters(java.lang.String url, int mode, boolean timeouts)
          Set the parameters
 void setResponseCode(int code)
          Set the response code
 void setResponseMessage(java.lang.String message)
          Set the response message
 void setResponseProperty(java.lang.String name, java.lang.String value)
          Set a response property
 
Methods inherited from class com.dctl.j2me.io.http.BaseHttpConnection
close, getFieldDate, getFieldInt, getFile, getHost, getInputFieldKey, getPort, getProtocol, getQuery, getRef, getRequestMethod, invalidState, openDataInputStream, openDataOutputStream, parseInput, sendOutput, setRequestMethod
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.microedition.io.InputConnection
openDataInputStream
 
Methods inherited from interface javax.microedition.io.Connection
close
 
Methods inherited from interface javax.microedition.io.OutputConnection
openDataOutputStream
 

Constructor Detail

HttpServerSocket

public HttpServerSocket(int handle,
                        java.lang.String address,
                        int port)
Create a new connection given the handle

Parameters:
handle - The handle to use
address - The address
port - The port
Method Detail

recycle

public void recycle()
Recycle the connection

Overrides:
recycle in class BaseHttpConnection

openConnection

protected void openConnection()
                       throws IOException
Open connection. This does nothing because it can't

Specified by:
openConnection in class BaseHttpConnection
Throws:
IOException - because it has to

setParameters

public void setParameters(java.lang.String url,
                          int mode,
                          boolean timeouts)
                   throws IOException
Set the parameters

Specified by:
setParameters in class BaseConnection
Parameters:
url - The url passed in
mode - The mode
timeouts - true if timeout exceptions should occur
Throws:
IOException - if there is an error

handleFirstInput

protected final boolean handleFirstInput(java.lang.String line)
                                  throws IOException
Handle the first input line

Specified by:
handleFirstInput in class BaseHttpConnection
Parameters:
line - The first input line
Returns:
true if the line parsed ok, false if another line is required
Throws:
IOException - if the line is incorrect

generateFirstOutput

protected final java.lang.String generateFirstOutput()
Generate the first line of output

Specified by:
generateFirstOutput in class BaseHttpConnection
Returns:
the line
Throws:
IOException - if there is an error

getRequestProperty

public java.lang.String getRequestProperty(java.lang.String key)
                                    throws IOException
Read a request property

Parameters:
key - The property to read
Returns:
the value
Throws:
IOException - if there is an error

setResponseCode

public void setResponseCode(int code)
Set the response code

Parameters:
code - The code to set

setResponseMessage

public void setResponseMessage(java.lang.String message)
Set the response message

Parameters:
message - The message to send

getRequestFieldInt

public int getRequestFieldInt(java.lang.String name,
                              int defaultValue)
                       throws IOException
Get a request field as an integer

Parameters:
name - The name of the request field
defaultValue - The default value
Throws:
IOException - if there is an error

getRequestFieldDate

public long getRequestFieldDate(java.lang.String name,
                                int defaultValue)
                         throws IOException
Get a request field as a date

Parameters:
name - The name of the request field
defaultValue - the default value
Throws:
IOException - if there is an error

getRequestField

public java.lang.String getRequestField(java.lang.String name)
                                 throws IOException
Get a request field

Parameters:
name - The name of the request field
Returns:
the field or null if it does not exist
Throws:
IOException - if there is an error

getURL

public java.lang.String getURL()
Get the URL

Overrides:
getURL in class BaseHttpConnection
Returns:
the url

setResponseProperty

public void setResponseProperty(java.lang.String name,
                                java.lang.String value)
                         throws IOException
Set a response property

Parameters:
name - The name of the response field
value - The value
Throws:
IOException - if there is an error

openInputStream

public InputStream openInputStream()
                            throws IOException
Open the input stream

Specified by:
openInputStream in interface InputConnection
Overrides:
openInputStream in class BaseHttpConnection
Returns:
the input stream
Throws:
IOException - if there is an error

openOutputStream

public OutputStream openOutputStream()
                              throws IOException
Open the output stream

Specified by:
openOutputStream in interface OutputConnection
Overrides:
openOutputStream in class BaseHttpConnection
Returns:
the output stream
Throws:
IOException - if there is an error

DCT Lightfoot v3 API specification

DCT Lightfoot v3 API specification