-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddMimeHeader(String name, String value) Adds a MIME header with the specified name and value to thisAttachmentPartobject.voidClears out the content of thisAttachmentPartobject.static voidstatic voidcopyMimeHeaders(MimeHeaders headers, MimeBodyPart mbp) booleanRetrieves all the headers for thisAttachmentPartobject as an iterator over theMimeHeaderobjects.Returns anInputStreamwhich can be used to obtain the content ofAttachmentPartas Base64 encoded character data, this method would base64 encode the raw bytes of the attachment and return.Gets the content of thisAttachmentPartobject as a Java object.jakarta.activation.DataHandlerGets theDataHandlerobject for thisAttachmentPartobject.getMatchingMimeHeaders(String[] names) Retrieves allMimeHeaderobjects that match a name in the given array.String[]getMimeHeader(String name) Gets all the values of the header identified by the givenString.getNonMatchingMimeHeaders(String[] names) Retrieves allMimeHeaderobjects whose name does not match a name in the given array.Gets the content of thisAttachmentPartobject as an InputStream as if a call had been made togetContentand noDataContentHandlerhad been registered for thecontent-typeof thisAttachmentPart.byte[]Gets the content of thisAttachmentPartobject as a byte[] array as if a call had been made togetContentand noDataContentHandlerhad been registered for thecontent-typeof thisAttachmentPart.intgetSize()Returns the number of bytes in thisAttachmentPartobject.inthashCode()static voidvoidRemoves all the MIME header entries.voidremoveMimeHeader(String header) Removes all MIME headers that match the given name.voidsetBase64Content(InputStream content, String contentType) Sets the content of this attachment part from the Base64 sourceInputStreamand sets the value of theContent-Typeheader to the value contained incontentType, This method would first decode the base64 input and write the resulting raw bytes to the attachment.voidsetContent(Object object, String contentType) Sets the content of this attachment part to that of the givenObjectand sets the value of theContent-Typeheader to the given type.voidsetDataHandler(jakarta.activation.DataHandler dataHandler) Sets the givenDataHandlerobject as the data handler for thisAttachmentPartobject.voidsetMimeHeader(String name, String value) Changes the first header entry that matches the given name to the given value, adding a new header if no existing header matches.voidsetRawContent(InputStream content, String contentType) Sets the content of this attachment part to that contained by theInputStreamcontentand sets the value of theContent-Typeheader to the value contained incontentType.voidsetRawContentBytes(byte[] content, int off, int len, String contentType) Sets the content of this attachment part to that contained by thebyte[]arraycontentand sets the value of theContent-Typeheader to the value contained incontentType.Methods inherited from class jakarta.xml.soap.AttachmentPart
getContentId, getContentLocation, getContentType, setContentId, setContentLocation, setContentType
-
Constructor Details
-
AttachmentPartImpl
public AttachmentPartImpl() -
AttachmentPartImpl
public AttachmentPartImpl(org.jvnet.mimepull.MIMEPart part)
-
-
Method Details
-
getSize
Description copied from class:AttachmentPartReturns the number of bytes in thisAttachmentPartobject.- Specified by:
getSizein classAttachmentPart- Returns:
- the size of this
AttachmentPartobject in bytes or -1 if the size cannot be determined - Throws:
SOAPException- if the content of this attachment is corrupted of if there was an exception while trying to determine the size.
-
clearContent
public void clearContent()Description copied from class:AttachmentPartClears out the content of thisAttachmentPartobject. The MIME header portion is left untouched.- Specified by:
clearContentin classAttachmentPart
-
getContent
Description copied from class:AttachmentPartGets the content of thisAttachmentPartobject as a Java object. The type of the returned Java object depends on (1) theDataContentHandlerobject that is used to interpret the bytes and (2) theContent-Typegiven in the header.For the MIME content types "text/plain", "text/html" and "text/xml", the
DataContentHandlerobject does the conversions to and from the Java types corresponding to the MIME types. For other MIME types,theDataContentHandlerobject can return anInputStreamobject that contains the content data as raw bytes.A SAAJ-compliant implementation must, as a minimum, return a
java.lang.Stringobject corresponding to any content stream with aContent-Typevalue oftext/plain, ajavax.xml.transform.stream.StreamSourceobject corresponding to a content stream with aContent-Typevalue oftext/xml, ajava.awt.Imageobject corresponding to a content stream with aContent-Typevalue ofimage/giforimage/jpeg. For those content types that an installedDataContentHandlerobject does not understand, theDataContentHandlerobject is required to return ajava.io.InputStreamobject with the raw bytes.- Specified by:
getContentin classAttachmentPart- Returns:
- a Java object with the content of this
AttachmentPartobject - Throws:
SOAPException- if there is no content set into thisAttachmentPartobject or if there was a data transformation error
-
setContent
Description copied from class:AttachmentPartSets the content of this attachment part to that of the givenObjectand sets the value of theContent-Typeheader to the given type. The type of theObjectshould correspond to the value given for theContent-Type. This depends on the particular set ofDataContentHandlerobjects in use.- Specified by:
setContentin classAttachmentPart- Parameters:
object- the Java object that makes up the content for this attachment partcontentType- the MIME string that specifies the type of the content- Throws:
IllegalArgumentException- may be thrown if the contentType does not match the type of the content object, or if there was noDataContentHandlerobject for this content object- See Also:
-
getDataHandler
Description copied from class:AttachmentPartGets theDataHandlerobject for thisAttachmentPartobject.- Specified by:
getDataHandlerin classAttachmentPart- Returns:
- the
DataHandlerobject associated with thisAttachmentPartobject - Throws:
SOAPException- if there is no data in thisAttachmentPartobject
-
setDataHandler
public void setDataHandler(jakarta.activation.DataHandler dataHandler) throws IllegalArgumentException Description copied from class:AttachmentPartSets the givenDataHandlerobject as the data handler for thisAttachmentPartobject. Typically, on an incoming message, the data handler is automatically set. When a message is being created and populated with content, thesetDataHandlermethod can be used to get data from various data sources into the message.- Specified by:
setDataHandlerin classAttachmentPart- Parameters:
dataHandler- theDataHandlerobject to be set- Throws:
IllegalArgumentException- if there was a problem with the specifiedDataHandlerobject
-
removeAllMimeHeaders
public void removeAllMimeHeaders()Description copied from class:AttachmentPartRemoves all the MIME header entries.- Specified by:
removeAllMimeHeadersin classAttachmentPart
-
removeMimeHeader
Description copied from class:AttachmentPartRemoves all MIME headers that match the given name.- Specified by:
removeMimeHeaderin classAttachmentPart- Parameters:
header- the string name of the MIME header/s to be removed
-
getMimeHeader
Description copied from class:AttachmentPartGets all the values of the header identified by the givenString.- Specified by:
getMimeHeaderin classAttachmentPart- Parameters:
name- the name of the header; example: "Content-Type"- Returns:
- a
Stringarray giving the value for the specified header - See Also:
-
setMimeHeader
Description copied from class:AttachmentPartChanges the first header entry that matches the given name to the given value, adding a new header if no existing header matches. This method also removes all matching headers but the first.Note that RFC822 headers can only contain US-ASCII characters.
- Specified by:
setMimeHeaderin classAttachmentPart- Parameters:
name- aStringgiving the name of the header for which to searchvalue- aStringgiving the value to be set for the header whose name matches the given name
-
addMimeHeader
Description copied from class:AttachmentPartAdds a MIME header with the specified name and value to thisAttachmentPartobject.Note that RFC822 headers can contain only US-ASCII characters.
- Specified by:
addMimeHeaderin classAttachmentPart- Parameters:
name- aStringgiving the name of the header to be addedvalue- aStringgiving the value of the header to be added
-
getAllMimeHeaders
Description copied from class:AttachmentPartRetrieves all the headers for thisAttachmentPartobject as an iterator over theMimeHeaderobjects.- Specified by:
getAllMimeHeadersin classAttachmentPart- Returns:
- an
Iteratorobject with all the Mime headers for thisAttachmentPartobject
-
getMatchingMimeHeaders
Description copied from class:AttachmentPartRetrieves allMimeHeaderobjects that match a name in the given array.- Specified by:
getMatchingMimeHeadersin classAttachmentPart- Parameters:
names- aStringarray with the name(s) of the MIME headers to be returned- Returns:
- all the MIME headers that match one of the names in the
given array as an
Iteratorobject
-
getNonMatchingMimeHeaders
Description copied from class:AttachmentPartRetrieves allMimeHeaderobjects whose name does not match a name in the given array.- Specified by:
getNonMatchingMimeHeadersin classAttachmentPart- Parameters:
names- aStringarray with the name(s) of the MIME headers not to be returned- Returns:
- all the MIME headers in this
AttachmentPartobject except those that match one of the names in the given array. The nonmatching MIME headers are returned as anIteratorobject.
-
copyMimeHeaders
- Throws:
SOAPException
-
copyMimeHeaders
- Throws:
SOAPException
-
setBase64Content
Description copied from class:AttachmentPartSets the content of this attachment part from the Base64 sourceInputStreamand sets the value of theContent-Typeheader to the value contained incontentType, This method would first decode the base64 input and write the resulting raw bytes to the attachment.A subsequent call to getSize() may not be an exact measure of the content size.
- Specified by:
setBase64Contentin classAttachmentPart- Parameters:
content- the base64 encoded data to add to the attachment partcontentType- the value to set into theContent-Typeheader- Throws:
SOAPException- if there is an error in setting the content
-
getBase64Content
Description copied from class:AttachmentPartReturns anInputStreamwhich can be used to obtain the content ofAttachmentPartas Base64 encoded character data, this method would base64 encode the raw bytes of the attachment and return.- Specified by:
getBase64Contentin classAttachmentPart- Returns:
- an
InputStreamfrom which the Base64 encodedAttachmentPartcan be read. - Throws:
SOAPException- if there is no content set into thisAttachmentPartobject or if there was a data transformation error.
-
setRawContent
Description copied from class:AttachmentPartSets the content of this attachment part to that contained by theInputStreamcontentand sets the value of theContent-Typeheader to the value contained incontentType.A subsequent call to getSize() may not be an exact measure of the content size.
- Specified by:
setRawContentin classAttachmentPart- Parameters:
content- the raw data to add to the attachment partcontentType- the value to set into theContent-Typeheader- Throws:
SOAPException- if there is an error in setting the content
-
setRawContentBytes
public void setRawContentBytes(byte[] content, int off, int len, String contentType) throws SOAPException Description copied from class:AttachmentPartSets the content of this attachment part to that contained by thebyte[]arraycontentand sets the value of theContent-Typeheader to the value contained incontentType.- Specified by:
setRawContentBytesin classAttachmentPart- Parameters:
content- the raw data to add to the attachment partoff- the offset in the byte array of the contentlen- the number of bytes that form the contentcontentType- the value to set into theContent-Typeheader- Throws:
SOAPException- if there is an error in setting the content or content is null
-
getRawContent
Description copied from class:AttachmentPartGets the content of thisAttachmentPartobject as an InputStream as if a call had been made togetContentand noDataContentHandlerhad been registered for thecontent-typeof thisAttachmentPart.Note that reading from the returned InputStream would result in consuming the data in the stream. It is the responsibility of the caller to reset the InputStream appropriately before calling a Subsequent API. If a copy of the raw attachment content is required then the
AttachmentPart.getRawContentBytes()API should be used instead.- Specified by:
getRawContentin classAttachmentPart- Returns:
- an
InputStreamfrom which the raw data contained by theAttachmentPartcan be accessed. - Throws:
SOAPException- if there is no content set into thisAttachmentPartobject or if there was a data transformation error.- See Also:
-
getRawContentBytes
Description copied from class:AttachmentPartGets the content of thisAttachmentPartobject as a byte[] array as if a call had been made togetContentand noDataContentHandlerhad been registered for thecontent-typeof thisAttachmentPart.- Specified by:
getRawContentBytesin classAttachmentPart- Returns:
- a
byte[]array containing the raw data of theAttachmentPart. - Throws:
SOAPException- if there is no content set into thisAttachmentPartobject or if there was a data transformation error.
-
equals
-
hashCode
public int hashCode() -
getMimeHeaders
-
initializeJavaActivationHandlers
public static void initializeJavaActivationHandlers()
-