com.xml_project.morganaxproc.filesystem
Class XProcHttpRequest

java.lang.Object
  extended by com.xml_project.morganaxproc.filesystem.XProcHttpRequest

public class XProcHttpRequest
extends java.lang.Object

This class contains the data for a http request found in p:http-request.


Nested Class Summary
static class XProcHttpRequest.AuthenticationMethods
           
 
Constructor Summary
XProcHttpRequest(java.net.URI uri, java.lang.String method)
          Constructs a new XProcHttpRequest with an uri and a method.
 
Method Summary
 void addBody(HttpBody body)
          Adds a body to this request
 void addHeader(HttpHeader header)
          Adds a header to this request.
 void addHeaders(nu.xom.Elements headers)
          Adds headers to the request from a list of XOM elements.
 XProcHttpRequest.AuthenticationMethods getAuthMethod()
          Returns the authorization method associated with this request.
static XProcHttpRequest.AuthenticationMethods getAuthMethod(java.lang.String text)
          Static factory method for Authentication Methods
 HttpBody[] getBodies()
          Returns the bodies set for this request.
 java.lang.String getBoundary()
          Returns the mime boundary associated with this request
 java.lang.String getContentType()
          Return the value of the header 'content-type' or an empty string, if the header is no set.
 java.lang.String[] getCredentials()
          Returns the credentials as a string array (user name|password) if they were set for this request.
 java.lang.String getHeader(java.lang.String headername)
          Return the value set for the header with the given name.
 HttpHeader[] getHeaders()
          Returns the headers set for this request.
 java.lang.String getMethod()
          Returns the method associated with this request.
 java.net.URI getURI()
          Return the uri associated with this request.
 boolean isMultipart()
          Returns whether this is a multipart request or not.
 boolean sendAuthentication()
          Returns whether credentials should be sent unrequested.
 void setAuthentication(java.lang.String username, java.lang.String password, XProcHttpRequest.AuthenticationMethods authMethod, boolean sendAuthentication)
          Sets the authentication credentials for this request.
 void setBoundary(java.lang.String boundary)
          Sets the mime boundary to be used.
 void setMultipart()
          Flags this request to be multipart.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XProcHttpRequest

public XProcHttpRequest(java.net.URI uri,
                        java.lang.String method)
Constructs a new XProcHttpRequest with an uri and a method.

Parameters:
uri - a uri made from 'href' found in c:request.
method - the method as found in c:request
Method Detail

setAuthentication

public void setAuthentication(java.lang.String username,
                              java.lang.String password,
                              XProcHttpRequest.AuthenticationMethods authMethod,
                              boolean sendAuthentication)
Sets the authentication credentials for this request.

Parameters:
username - the user name (may be null) as found in c:request
password - the password (may be null) as found in c:request
authMethod - the authentication method (may be null) as found in c:request
sendAuthentication - determines if credentials should be send unrequested as found in c:request.

sendAuthentication

public boolean sendAuthentication()
Returns whether credentials should be sent unrequested.

Returns:
true if credentials should be sent unrequested.

getAuthMethod

public XProcHttpRequest.AuthenticationMethods getAuthMethod()
Returns the authorization method associated with this request.

Returns:
the authorization method.

getCredentials

public java.lang.String[] getCredentials()
Returns the credentials as a string array (user name|password) if they were set for this request. Otherwise (" "|" ") is returned.

Returns:
the credentials as string array

getMethod

public java.lang.String getMethod()
Returns the method associated with this request.

Returns:
the method.

getBoundary

public java.lang.String getBoundary()
Returns the mime boundary associated with this request

Returns:
the mime boundary or null, if no boundary is set.

getURI

public java.net.URI getURI()
Return the uri associated with this request.

Returns:
the uri-

isMultipart

public boolean isMultipart()
Returns whether this is a multipart request or not.

Returns:
true if this is a multipart request, false otherwise.

setMultipart

public void setMultipart()
Flags this request to be multipart.


setBoundary

public void setBoundary(java.lang.String boundary)
Sets the mime boundary to be used.

Parameters:
boundary - the boundary to be used or null.

addHeader

public void addHeader(HttpHeader header)
Adds a header to this request.

Parameters:
header - the header to add.

addHeaders

public void addHeaders(nu.xom.Elements headers)
Adds headers to the request from a list of XOM elements.

Parameters:
headers - the XOM elements with the headers.

addBody

public void addBody(HttpBody body)
Adds a body to this request

Parameters:
body - the body to add.

getHeaders

public HttpHeader[] getHeaders()
Returns the headers set for this request.

Returns:
an array with the headers.

getBodies

public HttpBody[] getBodies()
Returns the bodies set for this request.

Returns:
an array with the bodies.

getHeader

public java.lang.String getHeader(java.lang.String headername)
Return the value set for the header with the given name.

Parameters:
headername - the name of the header to look for.
Returns:
the value set for the header or null, if no value for a header with this name was found.

getContentType

public java.lang.String getContentType()
Return the value of the header 'content-type' or an empty string, if the header is no set.

Returns:
the content type of this request.

getAuthMethod

public static XProcHttpRequest.AuthenticationMethods getAuthMethod(java.lang.String text)
Static factory method for Authentication Methods

Parameters:
text - the method's name or null
Returns:
the AuthentificationMethod or null, if the method is unspecified or unknown.