nesstar.api
Class MIMEObject

java.lang.Object
  extended by nesstar.api.MIMEObject

public class MIMEObject
extends Object

A MIME object (actually a MIME text object such as text/html).

Created:
25 September 2003

Field Summary
static String APPLICATION_BINARY
          param
static String APPLICATION_EXE
          param
static String APPLICATION_GZIP
          param
static String APPLICATION_MSWORD
          param
static String APPLICATION_NESSTAR_STAT
          param
static String APPLICATION_PDF
          param
static String APPLICATION_POSTSCRIPT
          param
static String APPLICATION_ZIP
          param
static String CHALLENGE
          To mark that the response is an authentication challenge for the indicated operation
static String CONNECTION_CONTEXT
          HttpMethod *
static String ENCODING_DEFLATE
          param
static String ENCODING_GZIP
          param
static String HEADER_AUTHENTICATION
          param
static String HEADER_VIA
          param
static String HEADER_X_FORWARDED_FOR
          param
static String IMAGE_GIF
          param
static String IMAGE_JPEG
          param
static String ISO_8859_1
           
static String MULTIPART_FORM_DATA
          param
static String MULTIPART_MIXED
          param
static String NESSTAR_BOOKMARK_LIST
          param
static String NESSTAR_EXPLORER
          param
static String NESSTAR_RDF
          param
static String NESSTAR_STAT
          param
 int SC_OK
          param
static String TEXT_HTML
          param
static String TEXT_PLAIN
          param
static String TEXT_RDF
          param
static String TEXT_URL
          param
static String TEXT_XML
          param
static String UTF_8
           
static String VAR_OPID
          param
 
Constructor Summary
MIMEObject(String url)
          Constructor for the MIMEObject object
MIMEObject(String type, byte[] content, String encoding)
          Constructor for the MIMEObject object
MIMEObject(String type, File content)
          Constructor for the MIMEObject object
MIMEObject(String type, File content, String encoding)
          Constructor for the MIMEObject object
MIMEObject(String type, String content)
          Constructor for the MIMEObject object
MIMEObject(String type, String content, int statusCode)
          Constructor for the MIMEObject object
MIMEObject(String type, URL content)
          Constructor for the MIMEObject object
MIMEObject(String url, Vector headers)
          Constructor for the MIMEObject object
MIMEObject(URL url)
          Constructor for the MIMEObject object
MIMEObject(URL url, int timeout, Vector headers, boolean plain)
           
MIMEObject(URL url, String expextedContentType, boolean enforceType)
          Create a MIMEObject reading from a given URL
MIMEObject(URL url, Vector headers)
          Constructor for the MIMEObject object
 
Method Summary
 String getAction()
           
 byte[] getBinaryContent()
          Gets the binaryContent attribute of the MIMEObject object
 String getContent()
          Gets the content attribute of the MIMEObject object
 File getContentAsFile(File file)
           
 File getContentAsFile(String file)
           
 String getContentAsString()
          Gets the content attribute of the MIMEObject object
 int getContentSize()
          Gets the contentSize attribute of the MIMEObject object
 String getEncoding()
          Gets the encoding attribute of the MIMEObject object
 int getStatusCode()
          Gets the statusCode attribute of the MIMEObject object
 String getSuspendedOpID()
          Gets the suspendedOpID attribute of the MIMEObject object
 String getType()
          Gets the type attribute of the MIMEObject object
 String getXMLCharacterEncoding()
          Get the character encoding for a text/xml MIMEObject.
 boolean hasFileContent()
          Test if MIME Object's content is stored in a uncompressed UNICODE string
 boolean hasStringContent()
          Test if MIME Object's content is stored in a uncompressed UNICODE string
static MIMEObject httpExecute(URL url, int timeout)
          Execute the invocation through HTTP
static MIMEObject httpExecute(URL url, int timeout, Vector headers)
          Execute the invocation through HTTP
 boolean isAction()
          check if any action is associated to the MIMEObject
 boolean isBinary()
          Gets the binary attribute of the MIMEObject object
 boolean isChallenge()
          Gets the challenge attribute of the MIMEObject object
 boolean isError()
          Gets the error attribute of the MIMEObject object
 boolean isUnauthorizedError()
          Gets the unauthorizedError attribute of the MIMEObject object
 boolean isZipped()
           
 void methodExecute(org.apache.commons.httpclient.HttpMethod method)
          It seems that the timeout doesn't work as expected so we enforce a total timeout for the method execution *
 void output(OutputStream out)
          Method
 void output(OutputStream out, String encoding)
          Write the content of a MIME object to a byte stream.
static MIMEObject plainHTTPGetExecute(URL url, int timeout)
           
static MIMEObject plainHTTPGetExecute(URL url, int timeout, Vector headers)
           
 void setAction(String action)
          Sets the _action of the MIMEObject object
 void setChallengeForOp(String op)
          Sets the challengeForOp attribute of the MIMEObject object
 void setStatusCode(int statusCode)
          Sets the statusCode attribute of the MIMEObject object
 void setUnauthorizedCode()
          Sets the unauthorizedCode attribute of the MIMEObject object
 String toString()
          Method
 void zip()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

UTF_8

public static final String UTF_8
See Also:
Constant Field Values

ISO_8859_1

public static final String ISO_8859_1
See Also:
Constant Field Values

TEXT_PLAIN

public static final String TEXT_PLAIN
param

See Also:
Constant Field Values

TEXT_HTML

public static final String TEXT_HTML
param

See Also:
Constant Field Values

TEXT_XML

public static final String TEXT_XML
param

See Also:
Constant Field Values

TEXT_RDF

public static final String TEXT_RDF
param

See Also:
Constant Field Values

IMAGE_GIF

public static final String IMAGE_GIF
param

See Also:
Constant Field Values

IMAGE_JPEG

public static final String IMAGE_JPEG
param

See Also:
Constant Field Values

APPLICATION_ZIP

public static final String APPLICATION_ZIP
param

See Also:
Constant Field Values

APPLICATION_GZIP

public static final String APPLICATION_GZIP
param

See Also:
Constant Field Values

APPLICATION_BINARY

public static final String APPLICATION_BINARY
param

See Also:
Constant Field Values

APPLICATION_EXE

public static final String APPLICATION_EXE
param

See Also:
Constant Field Values

APPLICATION_MSWORD

public static final String APPLICATION_MSWORD
param

See Also:
Constant Field Values

APPLICATION_PDF

public static final String APPLICATION_PDF
param

See Also:
Constant Field Values

APPLICATION_POSTSCRIPT

public static final String APPLICATION_POSTSCRIPT
param

See Also:
Constant Field Values

MULTIPART_MIXED

public static final String MULTIPART_MIXED
param

See Also:
Constant Field Values

MULTIPART_FORM_DATA

public static final String MULTIPART_FORM_DATA
param

See Also:
Constant Field Values

HEADER_VIA

public static final String HEADER_VIA
param

See Also:
Constant Field Values

HEADER_AUTHENTICATION

public static final String HEADER_AUTHENTICATION
param

See Also:
Constant Field Values

HEADER_X_FORWARDED_FOR

public static final String HEADER_X_FORWARDED_FOR
param

See Also:
Constant Field Values

VAR_OPID

public static final String VAR_OPID
param

See Also:
Constant Field Values

NESSTAR_RDF

public static final String NESSTAR_RDF
param

See Also:
Constant Field Values

NESSTAR_STAT

public static final String NESSTAR_STAT
param

See Also:
Constant Field Values

APPLICATION_NESSTAR_STAT

public static final String APPLICATION_NESSTAR_STAT
param

See Also:
Constant Field Values

NESSTAR_EXPLORER

public static final String NESSTAR_EXPLORER
param

See Also:
Constant Field Values

NESSTAR_BOOKMARK_LIST

public static final String NESSTAR_BOOKMARK_LIST
param

See Also:
Constant Field Values

ENCODING_GZIP

public static final String ENCODING_GZIP
param

See Also:
Constant Field Values

ENCODING_DEFLATE

public static final String ENCODING_DEFLATE
param

See Also:
Constant Field Values

TEXT_URL

public static final String TEXT_URL
param

See Also:
Constant Field Values

CHALLENGE

public static final String CHALLENGE
To mark that the response is an authentication challenge for the indicated operation

See Also:
Constant Field Values

SC_OK

public final int SC_OK
param

See Also:
Constant Field Values

CONNECTION_CONTEXT

public static final String CONNECTION_CONTEXT
HttpMethod *

See Also:
Constant Field Values
Constructor Detail

MIMEObject

public MIMEObject(String type,
                  String content)
Constructor for the MIMEObject object

Parameters:
type -
content -

MIMEObject

public MIMEObject(String type,
                  String content,
                  int statusCode)
Constructor for the MIMEObject object

Parameters:
type -
content -
statusCode -

MIMEObject

public MIMEObject(String type,
                  byte[] content,
                  String encoding)
Constructor for the MIMEObject object

Parameters:
type -
content -
encoding -

MIMEObject

public MIMEObject(String type,
                  File content)
Constructor for the MIMEObject object

Parameters:
type -
content -

MIMEObject

public MIMEObject(String type,
                  URL content)
Constructor for the MIMEObject object

Parameters:
type -
content -

MIMEObject

public MIMEObject(String type,
                  File content,
                  String encoding)
Constructor for the MIMEObject object

Parameters:
type -
content -
encoding -

MIMEObject

public MIMEObject(URL url,
                  String expextedContentType,
                  boolean enforceType)
           throws Exception
Create a MIMEObject reading from a given URL

Parameters:
expextedContentType - the name says it all
enforceType - if true an execption is generated if the information retrieved is not of the correct type
url - @bug wont handle binary types
Throws:
Exception

MIMEObject

public MIMEObject(URL url,
                  Vector headers)
           throws Exception
Constructor for the MIMEObject object

Parameters:
url -
Throws:
Exception

MIMEObject

public MIMEObject(String url,
                  Vector headers)
           throws Exception
Constructor for the MIMEObject object

Parameters:
url - the url to retrieve
Throws:
Exception

MIMEObject

public MIMEObject(String url)
           throws Exception
Constructor for the MIMEObject object

Parameters:
url - the url to retrieve
Throws:
Exception

MIMEObject

public MIMEObject(URL url)
           throws Exception
Constructor for the MIMEObject object

Parameters:
url - the url to retrieve
Throws:
Exception

MIMEObject

public MIMEObject(URL url,
                  int timeout,
                  Vector headers,
                  boolean plain)
           throws Exception
Throws:
Exception
Method Detail

setStatusCode

public void setStatusCode(int statusCode)
Sets the statusCode attribute of the MIMEObject object

Parameters:
statusCode - The new statusCode value

setUnauthorizedCode

public void setUnauthorizedCode()
Sets the unauthorizedCode attribute of the MIMEObject object


setChallengeForOp

public void setChallengeForOp(String op)
Sets the challengeForOp attribute of the MIMEObject object

Parameters:
op - The new challengeForOp value

setAction

public void setAction(String action)
Sets the _action of the MIMEObject object

Parameters:
action -

getType

public String getType()
Gets the type attribute of the MIMEObject object

Returns:
The type value

getEncoding

public String getEncoding()
Gets the encoding attribute of the MIMEObject object

Returns:
The encoding value

getStatusCode

public int getStatusCode()
Gets the statusCode attribute of the MIMEObject object

Returns:
The statusCode value

getContentSize

public int getContentSize()
Gets the contentSize attribute of the MIMEObject object

Returns:
The size in number of bytes of the content

isError

public boolean isError()
Gets the error attribute of the MIMEObject object

Returns:
The error value

isUnauthorizedError

public boolean isUnauthorizedError()
Gets the unauthorizedError attribute of the MIMEObject object

Returns:
The unauthorizedError value

isBinary

public boolean isBinary()
Gets the binary attribute of the MIMEObject object

Returns:
The binary value

getContentAsString

public String getContentAsString()
                          throws Exception
Gets the content attribute of the MIMEObject object

Returns:
The content value
Throws:
Exception

getContentAsFile

public File getContentAsFile(String file)
                      throws Exception
Throws:
Exception

getContentAsFile

public File getContentAsFile(File file)
                      throws Exception
Throws:
Exception

getContent

public String getContent()
                  throws Exception
Gets the content attribute of the MIMEObject object

Returns:
The content value
Throws:
Exception

getBinaryContent

public byte[] getBinaryContent()
                        throws Exception
Gets the binaryContent attribute of the MIMEObject object

Returns:
The binaryContent value
Throws:
Exception

getSuspendedOpID

public String getSuspendedOpID()
Gets the suspendedOpID attribute of the MIMEObject object

Returns:
The suspendedOpID value

isChallenge

public boolean isChallenge()
Gets the challenge attribute of the MIMEObject object

Returns:
The challenge value

isAction

public boolean isAction()
check if any action is associated to the MIMEObject

Returns:
true if there is an action

getAction

public String getAction()
Returns:
teh value of the associated action

getXMLCharacterEncoding

public String getXMLCharacterEncoding()
                               throws Exception
Get the character encoding for a text/xml MIMEObject.

Returns:
empty string if not text/xml, otherwise the char encoding from the xml declaration, default is "UTF-8".
Throws:
Exception

isZipped

public boolean isZipped()

output

public void output(OutputStream out)
            throws IOException
Method

Parameters:
out -
Throws:
IOException

output

public void output(OutputStream out,
                   String encoding)
            throws IOException
Write the content of a MIME object to a byte stream. This function uses an explicit encoding for the output byte stream if the content of the MIME Object still is stored in a UNICODE String.

Parameters:
out - the output byte stream
encoding - the character encoding
Throws:
IOException

zip

public void zip()
         throws Exception
Throws:
Exception

hasStringContent

public boolean hasStringContent()
Test if MIME Object's content is stored in a uncompressed UNICODE string

Returns:

hasFileContent

public boolean hasFileContent()
Test if MIME Object's content is stored in a uncompressed UNICODE string

Returns:

toString

public String toString()
Method

Overrides:
toString in class Object
Returns:

httpExecute

public static MIMEObject httpExecute(URL url,
                                     int timeout)
                              throws Exception
Execute the invocation through HTTP

Parameters:
url -
timeout -
Returns:
Throws:
Exception

httpExecute

public static MIMEObject httpExecute(URL url,
                                     int timeout,
                                     Vector headers)
                              throws Exception
Execute the invocation through HTTP

Parameters:
url -
timeout -
headers -
Returns:
Throws:
Exception

plainHTTPGetExecute

public static MIMEObject plainHTTPGetExecute(URL url,
                                             int timeout)
                                      throws Exception
Throws:
Exception

plainHTTPGetExecute

public static MIMEObject plainHTTPGetExecute(URL url,
                                             int timeout,
                                             Vector headers)
                                      throws Exception
Throws:
Exception

methodExecute

public void methodExecute(org.apache.commons.httpclient.HttpMethod method)
                   throws Exception
It seems that the timeout doesn't work as expected so we enforce a total timeout for the method execution *

Throws:
Exception

Nesstar SDK

Copyright©2003 NSD - All Rights Reserved