Javax.xml.soap.AttachmentPart Class



Introduction

The javax.xml.soap.AttachmentPart class is a single attachment to a SOAPMessage object.Following are the important points about soap.AttachmentPart −

  • A SOAPMessage object may contain zero, one, or many AttachmentPart objects.

  • Each AttachmentPart object consists of two parts, application-specific content and associated MIME headers.

  • The MIME headers consists of name/value pairs that can be used to identify and describe the content.

Class declaration

Following is the declaration for javax.xml.soap.AttachmentPart class −

public abstract class AttachmentPart
   extends Object

Class constructors

S.N. Constructor & Description
1 AttachmentPart()

Single Constructor.

Class methods

S.N. Method & Description
1 abstract void addMimeHeader(String name, String value)

This method adds a MIME header with the specified name and value to this AttachmentPart object.

2 abstract void clearContent()

This method Clears out the content of this AttachmentPart object

3 abstract Iterator getAllMimeHeaders()

This method retrieves all the headers for this AttachmentPart object as an iterator over the MimeHeader objects.

4 abstract InputStream getBase64Content()

This method returns an InputStream which can be used to obtain the content of AttachmentPart as Base64 encoded character data, this method would base64 encode the raw bytes of the attachment and return.

5 abstract Object getContent()

This method gets the content of this AttachmentPart object as a Java object.

6 String getContentId()

This method gets the value of the MIME header whose name is "Content-ID".

7 String getContentLocation()

This method gets the value of the MIME header whose name is "Content-Location".

8 String getContentType()

This method gets the value of the MIME header whose name is "Content-Type".

9 abstract DataHandler getDataHandler()

This method gets the DataHandler object for this AttachmentPart object.

10 abstract Iterator getMatchingMimeHeaders(String[] names)

This method retrieves all MimeHeader objects that match a name in the given array.

11 abstract String[] getMimeHeader(String name)

This method gets all the values of the header identified by the given String.

12 abstract Iterator getNonMatchingMimeHeaders(String[] names)

This method retrieves all MimeHeader objects whose name does not match a name in the given array.

13 abstract InputStream getRawContent()

This method gets the content of this AttachmentPart object as an InputStream as if a call had been made to getContent and no DataContentHandler had been registered for the content-type of this AttachmentPart.

14 abstract byte[] getRawContentBytes()

This method gets the content of this AttachmentPart object as a byte[] array as if a call had been made to getContent and no DataContentHandler had been registered for the content-type of this AttachmentPart.

15 abstract int getSize()

This method returns the number of bytes in this AttachmentPart object

16 abstract void removeAllMimeHeaders()

This method removes all the MIME header entries.

17 abstract void removeMimeHeader(String header)

This method removes all MIME headers that match the given name.

18 abstract void setBase64Content(InputStream content, String contentType)

This method sets the content of this attachment part from the Base64 source InputStream and sets the value of the Content-Type header to the value contained in contentType, This method would first decode the base64 input and write the resulting raw bytes to the attachment.

19 abstract void setContent(Object object, String contentType)

This method sets the content of this attachment part to that of the given Object and sets the value of the Content-Type header to the given type

20 void setContentId(String contentId)

This method sets the MIME header whose name is "Content-ID" with the given value.

21 void setContentLocation(String contentLocation)

This method sets the MIME header whose name is "Content-Location" with the given value.

22 void setContentType(String contentType)

This method sets the MIME header whose name is "Content-Type" with the given value

23 abstract void setDataHandler(DataHandler dataHandler)

This method sets the given DataHandler object as the data handler for this AttachmentPart object.

24 abstract void setMimeHeader(String name, String value)

This method changes the first header entry that matches the given name to the given value, adding a new header if no existing header matches.

25 abstract void setRawContent(InputStream content, String contentType)

This method sets the content of this attachment part to that contained by the InputStream content and sets the value of the Content-Type header to the value contained in contentType.

26 abstract void setRawContentBytes(byte[] content, int offset, int len, String contentType)

This method sets the content of this attachment part to that contained by the byte[] array content and sets the value of the Content-Type header to the value contained in contentType.

Methods inherited

This class inherits methods from the following classes −

java.lang.Object

Advertisements