eu.larkc.core.pluginManager.remote.Servlet.Tomcat.servlet
Class HttpRequest

java.lang.Object
  extended by eu.larkc.core.pluginManager.remote.Servlet.Tomcat.servlet.HttpRequest

public class HttpRequest
extends java.lang.Object

Builds various HTTP requests (GET, PUT, POST, DELETE) to interact with remote plug-ins.

Author:
Barry Bishop

Field Summary
 java.lang.String UTF8
          Constant to indicate that utf-8 encoding is used.
 
Constructor Summary
HttpRequest(java.lang.String url)
          Constructor.
 
Method Summary
 void addParameter(java.lang.String parameter, java.lang.String value)
          Adds a parameter to the parameter map.
 void open()
          Open.
 java.io.OutputStream openForWriting()
          Open for writing.
 java.io.InputStream read()
          Read.
 java.lang.String readAsString()
          Read as string.
 void setBody(java.lang.String body)
          Sets the body.
 void setContentType(java.lang.String contentType)
          Sets the content type.
 void setDeleteMethod()
          Sets the delete method.
 void setGetMethod()
          Sets the get method.
 void setMethod(java.lang.String method)
          Sets the method.
 void setPostMethod()
          Sets the post method.
 void setPutMethod()
          Sets the put method.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UTF8

public final java.lang.String UTF8
Constant to indicate that utf-8 encoding is used.

See Also:
Constant Field Values
Constructor Detail

HttpRequest

public HttpRequest(java.lang.String url)
Constructor.

Parameters:
url - target URL of the HTTP request.
Method Detail

addParameter

public void addParameter(java.lang.String parameter,
                         java.lang.String value)
Adds a parameter to the parameter map.

Parameters:
parameter - name of the parameter, used as a key for the parameter map
value - parameter value

setMethod

public void setMethod(java.lang.String method)
Sets the method.

Parameters:
method - the new method

setGetMethod

public void setGetMethod()
Sets the get method.


setPutMethod

public void setPutMethod()
Sets the put method.


setPostMethod

public void setPostMethod()
Sets the post method.


setDeleteMethod

public void setDeleteMethod()
Sets the delete method.


setContentType

public void setContentType(java.lang.String contentType)
Sets the content type.

Parameters:
contentType - the new content type

setBody

public void setBody(java.lang.String body)
Sets the body.

Parameters:
body - the new body

openForWriting

public java.io.OutputStream openForWriting()
                                    throws java.io.IOException
Open for writing.

Returns:
the output stream
Throws:
java.io.IOException - Signals that an I/O exception has occurred.

open

public void open()
          throws java.io.IOException
Open.

Throws:
java.io.IOException - Signals that an I/O exception has occurred.

read

public java.io.InputStream read()
                         throws java.io.IOException
Read.

Returns:
the input stream
Throws:
java.io.IOException - Signals that an I/O exception has occurred.

readAsString

public java.lang.String readAsString()
                              throws java.io.IOException
Read as string.

Returns:
the string
Throws:
java.io.IOException - Signals that an I/O exception has occurred.