Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

lutris.jolt.joltsim
Class SimComms  view SimComms download SimComms.java

java.lang.Object
  extended byComms
      extended bylutris.jolt.joltsim.SimComms

public class SimComms
extends Comms

Simulation comms objects. Reads HTTP headers from a file and can print out response. Currently does not handle streaming output.


Field Summary
private  java.io.DataOutputStream bodyOutputStream
           
private  java.io.DataOutputStream headerOutputStream
           
private  HttpPageArgs httpPageArgs
           
private  boolean outputIsStreaming
           
private  int responseStatusCode
           
private  java.lang.String responseStatusReason
           
private  java.lang.String scriptName
           
 
Constructor Summary
SimComms(HttpPageArgs httpPageArgs, java.io.DataOutputStream headerOutputStream, java.io.DataOutputStream bodyOutputStream)
          Public Constructor
 
Method Summary
 java.lang.Exception clientSideRedirectException(java.lang.String url)
          This method causes the current request to be redirected to another location.
 void expireCookie(java.lang.String name)
          This method expires a cookie at the root of the application tree.
 void expireCookie(java.lang.String name, java.lang.String path)
          This method expires a cookie.
 java.lang.String getHttpDocumentRoot()
          Return the document root.
 java.lang.String getHttpPathInfo()
          Returns the document root.
 java.lang.String getHttpQueryString()
          Return the query string of this request.
 java.lang.String[] getHttpRedirectArg(java.lang.String name)
          This method returns all values associated with a HTTP (CGI) redirect arguments.
 Cookie[] getHttpRedirectCookie(java.lang.String name)
          This method returns all HTTP redirect cookies that have the specified name.
 java.lang.String[] getHttpRedirectHeader(java.lang.String name)
          This method returns an array containing all of the values set for the named HTTP redirect header.
 java.lang.String getHttpRemoteHost()
          Returns the remote host name.
 java.lang.String[] getHttpRequestArg(java.lang.String name)
          This method returns values associated with a HTTP (CGI) request arguments.
 java.lang.String[] getHttpRequestArg(java.lang.String name, java.lang.String defValue)
          This method returns values associated with a HTTP (CGI) request arguments.
 Cookie[] getHttpRequestCookie(java.lang.String name)
          This method returns all HTTP request cookies that have the specified name.
 java.lang.String[] getHttpRequestHeader(java.lang.String name)
          This method returns an array containing all of the values set for the named HTTP request header.
 Cookie[] getHttpResponseCookies(java.lang.String name)
          This method returns all HTTP response cookies that have the specified name.
 java.lang.String[] getHttpResponseHeader(java.lang.String name)
          This method returns an array containing all of the values set for the named HTTP response header.
 java.lang.String getHttpUrl()
          Return the url of this request.
 java.lang.Exception serverSideRedirectException(java.lang.String url)
          This method causes the current request to be redirected to another location.
 void setContentLength(int length)
          This method sets the content length http header.
 void setContentType(java.lang.String contentType)
          This method sets the Contenttype http header.
 void setCookie(KeywordValueTable cookies)
          This method maps a set of cookies into a single "Set-Cookie" header.
 void setCookie(java.lang.String name, java.lang.String value)
          This method sets a cookie header localized to the root of the application tree.
 void setCookie(java.lang.String name, java.lang.String value, java.lang.String expires, java.lang.String domain, java.lang.String path, boolean secure)
          This method sets a cookie header.
 void setHeader(java.lang.String name, java.lang.String value)
          This method sets an output header.
 void setHttpRedirectArg(java.lang.String name, java.lang.String value)
          This method sets a HTTP (CGI) arguments to use when redirecting the page.
 void setHttpRedirectCookie(Cookie cookie)
          This method sets an HTTP redirect cookie.
 void setHttpRedirectHeader(java.lang.String name, java.lang.String value)
          This method sets an HTTP redirect header.
 void setHttpResponseCookie(Cookie cookie)
          This method sets an HTTP response cookie.
 void setHttpResponseHeader(java.lang.String name, java.lang.String value)
          This method sets an HTTP response header.
 void setStatus(int status, java.lang.String reason)
          This method sets the response status header.
private  void startWrite()
          Start writing output if it hasn't already begun.
private  void streamingCheck()
          Generate an error if data is already streaming
 void write(byte[] b)
           
 void write(byte[] b, int off, int len)
           
 void write(int b)
           
 void writeBoolean(boolean v)
           
 void writeByte(int v)
           
 void writeBytes(java.lang.String s)
           
 void writeChar(int v)
           
 void writeChars(java.lang.String s)
           
 void writeDouble(double v)
           
 void writeFloat(float v)
           
 void writeInt(int v)
           
 void writeLong(long v)
           
 void writeShort(int v)
           
 void writeUTF(java.lang.String str)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

httpPageArgs

private HttpPageArgs httpPageArgs

scriptName

private java.lang.String scriptName

responseStatusCode

private int responseStatusCode

responseStatusReason

private java.lang.String responseStatusReason

outputIsStreaming

private boolean outputIsStreaming

headerOutputStream

private java.io.DataOutputStream headerOutputStream

bodyOutputStream

private java.io.DataOutputStream bodyOutputStream
Constructor Detail

SimComms

public SimComms(HttpPageArgs httpPageArgs,
                java.io.DataOutputStream headerOutputStream,
                java.io.DataOutputStream bodyOutputStream)
Public Constructor

Method Detail

streamingCheck

private void streamingCheck()
                     throws java.io.IOException
Generate an error if data is already streaming


setHeader

public void setHeader(java.lang.String name,
                      java.lang.String value)
               throws java.io.IOException
This method sets an output header.


setStatus

public void setStatus(int status,
                      java.lang.String reason)
               throws java.io.IOException
This method sets the response status header.


setCookie

public void setCookie(KeywordValueTable cookies)
               throws java.io.IOException,
                      KeywordValueException
This method maps a set of cookies into a single "Set-Cookie" header. Repeated calls to this method will replace the previous "Set-Cookie" settings.


setCookie

public void setCookie(java.lang.String name,
                      java.lang.String value,
                      java.lang.String expires,
                      java.lang.String domain,
                      java.lang.String path,
                      boolean secure)
               throws java.io.IOException
This method sets a cookie header.


setCookie

public void setCookie(java.lang.String name,
                      java.lang.String value)
               throws java.io.IOException
This method sets a cookie header localized to the root of the application tree.


expireCookie

public void expireCookie(java.lang.String name,
                         java.lang.String path)
                  throws java.io.IOException
This method expires a cookie.


expireCookie

public void expireCookie(java.lang.String name)
                  throws java.io.IOException
This method expires a cookie at the root of the application tree.


setContentLength

public void setContentLength(int length)
                      throws java.io.IOException
This method sets the content length http header.


setContentType

public void setContentType(java.lang.String contentType)
                    throws java.io.IOException
This method sets the Contenttype http header.


getHttpRequestHeader

public java.lang.String[] getHttpRequestHeader(java.lang.String name)
                                        throws java.lang.Exception
This method returns an array containing all of the values set for the named HTTP request header.


getHttpRequestCookie

public Cookie[] getHttpRequestCookie(java.lang.String name)
                              throws java.lang.Exception
This method returns all HTTP request cookies that have the specified name.


getHttpRequestArg

public java.lang.String[] getHttpRequestArg(java.lang.String name)
                                     throws java.lang.Exception
This method returns values associated with a HTTP (CGI) request arguments.


getHttpRequestArg

public java.lang.String[] getHttpRequestArg(java.lang.String name,
                                            java.lang.String defValue)
                                     throws java.lang.Exception
This method returns values associated with a HTTP (CGI) request arguments. If no value is set then the default is returned.


setHttpResponseHeader

public void setHttpResponseHeader(java.lang.String name,
                                  java.lang.String value)
                           throws java.lang.Exception
This method sets an HTTP response header.


getHttpResponseHeader

public java.lang.String[] getHttpResponseHeader(java.lang.String name)
                                         throws java.lang.Exception
This method returns an array containing all of the values set for the named HTTP response header.


setHttpResponseCookie

public void setHttpResponseCookie(Cookie cookie)
                           throws java.lang.Exception
This method sets an HTTP response cookie.


getHttpResponseCookies

public Cookie[] getHttpResponseCookies(java.lang.String name)
                                throws java.lang.Exception
This method returns all HTTP response cookies that have the specified name.


setHttpRedirectHeader

public void setHttpRedirectHeader(java.lang.String name,
                                  java.lang.String value)
                           throws java.lang.Exception
This method sets an HTTP redirect header.


getHttpRedirectHeader

public java.lang.String[] getHttpRedirectHeader(java.lang.String name)
                                         throws java.lang.Exception
This method returns an array containing all of the values set for the named HTTP redirect header.


setHttpRedirectCookie

public void setHttpRedirectCookie(Cookie cookie)
                           throws java.lang.Exception
This method sets an HTTP redirect cookie.


getHttpRedirectCookie

public Cookie[] getHttpRedirectCookie(java.lang.String name)
                               throws java.lang.Exception
This method returns all HTTP redirect cookies that have the specified name.


setHttpRedirectArg

public void setHttpRedirectArg(java.lang.String name,
                               java.lang.String value)
                        throws java.lang.Exception
This method sets a HTTP (CGI) arguments to use when redirecting the page.


getHttpRedirectArg

public java.lang.String[] getHttpRedirectArg(java.lang.String name)
                                      throws java.lang.Exception
This method returns all values associated with a HTTP (CGI) redirect arguments.


getHttpQueryString

public java.lang.String getHttpQueryString()
Return the query string of this request.


getHttpUrl

public java.lang.String getHttpUrl()
Return the url of this request.


getHttpRemoteHost

public java.lang.String getHttpRemoteHost()
Returns the remote host name.


getHttpDocumentRoot

public java.lang.String getHttpDocumentRoot()
Return the document root.


getHttpPathInfo

public java.lang.String getHttpPathInfo()
Returns the document root.


clientSideRedirectException

public java.lang.Exception clientSideRedirectException(java.lang.String url)
This method causes the current request to be redirected to another location. The redirection is performed on the client side via the "Location:" header. Any redirect arguments set in this page are appended to the url. Likewise, any redirect cookies are set.


serverSideRedirectException

public java.lang.Exception serverSideRedirectException(java.lang.String url)
This method causes the current request to be redirected to another location. The redirection is performed locally on the server side. Any redirect arguments set in this page are appended to the url. Likewise, any redirect cookies are passed on to the new url.
    Notes:
  • cookies are not set on the browser.
  • internal (server side) redirection should be handeled carefully. The new url should not contain any relative references to images and objects since the browser has no way of knowing that the page was redirected. If this confuses you then you are better off using client-side redirection.


startWrite

private void startWrite()
                 throws java.io.IOException
Start writing output if it hasn't already begun.


write

public void write(int b)
           throws java.io.IOException

write

public void write(byte[] b)
           throws java.io.IOException

write

public void write(byte[] b,
                  int off,
                  int len)
           throws java.io.IOException

writeBoolean

public void writeBoolean(boolean v)
                  throws java.io.IOException

writeByte

public void writeByte(int v)
               throws java.io.IOException

writeBytes

public void writeBytes(java.lang.String s)
                throws java.io.IOException

writeChar

public void writeChar(int v)
               throws java.io.IOException

writeChars

public void writeChars(java.lang.String s)
                throws java.io.IOException

writeDouble

public void writeDouble(double v)
                 throws java.io.IOException

writeFloat

public void writeFloat(float v)
                throws java.io.IOException

writeInt

public void writeInt(int v)
              throws java.io.IOException

writeLong

public void writeLong(long v)
               throws java.io.IOException

writeShort

public void writeShort(int v)
                throws java.io.IOException

writeUTF

public void writeUTF(java.lang.String str)
              throws java.io.IOException