Class CollectingAttachmentHandler

java.lang.Object
org.htmlunit.attachment.CollectingAttachmentHandler
All Implemented Interfaces:
Serializable, AttachmentHandler

public class CollectingAttachmentHandler extends Object implements AttachmentHandler
An AttachmentHandler implementation which creates an Attachment for each attached page, collecting all created attachments into a list.
See Also:
  • Constructor Details

    • CollectingAttachmentHandler

      public CollectingAttachmentHandler()
      Creates a new instance.
    • CollectingAttachmentHandler

      public CollectingAttachmentHandler(List<Attachment> list)
      Creates a new instance which collects attachments into the specified list.
      Parameters:
      list - the list to store attachments in
  • Method Details

    • handleAttachment

      public void handleAttachment(Page page, String attachmentFilename)
      Handles the specified attached page. This is some kind of information that the page was handled as attachment. This method will only be called if AttachmentHandler.handleAttachment(WebResponse, String) has returned false for the response.
      Specified by:
      handleAttachment in interface AttachmentHandler
      Parameters:
      page - an attached page, which doesn't get loaded inline
      attachmentFilename - the filename to use for the attachment or null if unspecified
    • getCollectedAttachments

      public List<Attachment> getCollectedAttachments()
      Returns the list of attachments collected by this attachment handler. The returned list is modifiable, so that attachments can be removed after being processed.
      Returns:
      the list of attachments collected by this attachment handler