wt.federation
Class FederatedHttpBodyPart

java.lang.Object
  extended bywt.federation.FederatedHttpBodyPart
All Implemented Interfaces:
Externalizable, Serializable

public class FederatedHttpBodyPart
extends Object
implements Externalizable

Defines and manages MIME body parts contained in HTTP request and response messages.

Supported API: true

Extendable: false

See Also:
Serialized Form

Field Summary
private static String CLASSNAME
           
private  Object content
           
static long EXTERNALIZATION_VERSION_UID
           
private  Hashtable headings
           
private  boolean lastPart
           
protected static long OLD_FORMAT_VERSION_UID
           
private static String RESOURCE
           
(package private) static long serialVersionUID
           
 
Constructor Summary
FederatedHttpBodyPart()
          Constructor returning an instance initialized with an empty set of MIME headings and null content.
FederatedHttpBodyPart(FederatedHttpInputStream inputStream, String boundary)
          Constructor returning an instance initialized from the result of reading the specified input stream.
FederatedHttpBodyPart(String contentType)
          Constructor returning an instance initialized with the specified MIME content type and null content.
 
Method Summary
 void addHeading(String line)
          Parses and adds the specified line to the set of MIME headings.
 void addHeading(String keyword, String value)
          Adds the heading specified by keyword/value pair to the set of MIME headings.
static String getBoundary(String contentType)
          Returns the boundary string specified within a Content-Type heading.
 Object getContent()
          Gets the value of the attribute: content.
 String getHeading(String keyword)
          Returns the heading with the specified keyword.
 Hashtable getHeadings()
          Gets the value of the attribute: headings.
 FederatedHttpBodyPart getPart(int index)
          Returns the body part associated with the specified index.
 int getSize()
          Returns the size, in octets, of the body part.
 boolean isLastPart()
          Returns true if this body part is the last body part of a MIME multipart object (its boundary line is the final boundary of the multipart object).
 boolean isMultipart()
          Returns true if the content of the body part is a nested multipart object.
 void readExternal(ObjectInput input)
          Reads the non-transient fields of this class from an external source.
private  boolean readOldVersion(ObjectInput input, long readSerialVersionUID, boolean passThrough, boolean superDone)
          Reads the non-transient fields of this class from an external source, which is not the current version.
protected  boolean readVersion(FederatedHttpBodyPart thisObject, ObjectInput input, long readSerialVersionUID, boolean passThrough, boolean superDone)
          Reads the non-transient fields of this class from an external source.
 void removeHeading(String keyword)
          Removes the heading with the specified keyword.
 void setContent(Object a_Content)
          Sets the value of the attribute: content.
 void setHeadings(Hashtable a_Headings)
          Sets the value of the attribute: headings.
 void writeExternal(ObjectOutput output)
          Writes the non-transient fields of this class to an external source.
 int writeTo(OutputStream outputStream)
          Writes the body part in HTTP MIME format to the specified output stream, and returns the number of octets written.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RESOURCE

private static final String RESOURCE
See Also:
Constant Field Values

CLASSNAME

private static final String CLASSNAME

headings

private Hashtable headings

content

private Object content

serialVersionUID

static final long serialVersionUID
See Also:
Constant Field Values

EXTERNALIZATION_VERSION_UID

public static final long EXTERNALIZATION_VERSION_UID
See Also:
Constant Field Values

OLD_FORMAT_VERSION_UID

protected static final long OLD_FORMAT_VERSION_UID
See Also:
Constant Field Values

lastPart

private boolean lastPart
Constructor Detail

FederatedHttpBodyPart

public FederatedHttpBodyPart()
                      throws WTPropertyVetoException
Constructor returning an instance initialized with an empty set of MIME headings and null content.

Supported API: true

Throws:
WTPropertyVetoException

FederatedHttpBodyPart

public FederatedHttpBodyPart(String contentType)
                      throws WTPropertyVetoException
Constructor returning an instance initialized with the specified MIME content type and null content.

Supported API: true

Parameters:
contentType -
Throws:
WTPropertyVetoException

FederatedHttpBodyPart

public FederatedHttpBodyPart(FederatedHttpInputStream inputStream,
                             String boundary)
                      throws WTPropertyVetoException,
                             FederationServicesException
Constructor returning an instance initialized from the result of reading the specified input stream. Reading stops when the specified MIME boundary is detected.

Supported API: true

Parameters:
inputStream -
boundary -
Throws:
WTPropertyVetoException
FederationServicesException
Method Detail

writeExternal

public void writeExternal(ObjectOutput output)
                   throws IOException
Writes the non-transient fields of this class to an external source.

Supported API: false

Specified by:
writeExternal in interface Externalizable
Parameters:
output -
Throws:
IOException

readExternal

public void readExternal(ObjectInput input)
                  throws IOException,
                         ClassNotFoundException
Reads the non-transient fields of this class from an external source.

Supported API: false

Specified by:
readExternal in interface Externalizable
Parameters:
input -
Throws:
IOException
ClassNotFoundException

readVersion

protected boolean readVersion(FederatedHttpBodyPart thisObject,
                              ObjectInput input,
                              long readSerialVersionUID,
                              boolean passThrough,
                              boolean superDone)
                       throws IOException,
                              ClassNotFoundException
Reads the non-transient fields of this class from an external source.

Supported API: false

Parameters:
thisObject -
input -
readSerialVersionUID -
passThrough -
superDone -
Returns:
boolean
Throws:
IOException
ClassNotFoundException

readOldVersion

private boolean readOldVersion(ObjectInput input,
                               long readSerialVersionUID,
                               boolean passThrough,
                               boolean superDone)
                        throws IOException,
                               ClassNotFoundException
Reads the non-transient fields of this class from an external source, which is not the current version.

Parameters:
input -
readSerialVersionUID -
passThrough -
superDone -
Returns:
boolean
Throws:
IOException
ClassNotFoundException

getHeadings

public Hashtable getHeadings()
Gets the value of the attribute: headings.

Supported API: false

Returns:
Hashtable

setHeadings

public void setHeadings(Hashtable a_Headings)
                 throws WTPropertyVetoException
Sets the value of the attribute: headings.

Supported API: false

Parameters:
a_Headings -
Throws:
WTPropertyVetoException

getContent

public Object getContent()
Gets the value of the attribute: content.

Supported API: false

Returns:
Object

setContent

public void setContent(Object a_Content)
                throws WTPropertyVetoException
Sets the value of the attribute: content.

Supported API: false

Parameters:
a_Content -
Throws:
WTPropertyVetoException

getSize

public int getSize()
            throws FederationServicesException
Returns the size, in octets, of the body part. This can be used in calculating the Content-Length value to be specified in an HTTP request message.

Supported API: true

Returns:
int
Throws:
FederationServicesException

writeTo

public int writeTo(OutputStream outputStream)
            throws FederationServicesException
Writes the body part in HTTP MIME format to the specified output stream, and returns the number of octets written. If the output stream argument is null, nothing is written, but the number of bytes that would have been written are returned.

Supported API: true

Parameters:
outputStream -
Returns:
int
Throws:
FederationServicesException

addHeading

public void addHeading(String line)
Parses and adds the specified line to the set of MIME headings.

Supported API: true

Parameters:
line -

addHeading

public void addHeading(String keyword,
                       String value)
Adds the heading specified by keyword/value pair to the set of MIME headings.

Supported API: true

Parameters:
keyword -
value -

getHeading

public String getHeading(String keyword)
Returns the heading with the specified keyword.

Supported API: true

Parameters:
keyword -
Returns:
String

removeHeading

public void removeHeading(String keyword)
Removes the heading with the specified keyword.

Supported API: true

Parameters:
keyword -

isMultipart

public boolean isMultipart()
Returns true if the content of the body part is a nested multipart object.

Supported API: true

Returns:
boolean

getBoundary

public static String getBoundary(String contentType)
Returns the boundary string specified within a Content-Type heading.

Supported API: true

Parameters:
contentType -
Returns:
String

getPart

public FederatedHttpBodyPart getPart(int index)
Returns the body part associated with the specified index. If the object is not a multipart object, the object returns itself if the specified index is 0. Null is returned if the specified index is greater than the index of the last body part in the multipart object (or the index is greater than 0 when the object is not a multipart).

Supported API: true

Parameters:
index -
Returns:
FederatedHttpBodyPart

isLastPart

public boolean isLastPart()
Returns true if this body part is the last body part of a MIME multipart object (its boundary line is the final boundary of the multipart object).

Supported API: true

Returns:
boolean