/** * Produce the raw bytes of the content. This method is used * when creating a DataHandler object for the content. Subclasses * that can provide a separate input stream for just the Part * content might want to override this method. <p> * * @return an InputStream containing the raw bytes * @exception MessagingException for failures * @see #content * @see MimeMessage#getContentStream */ protected InputStream getContentStream() throws MessagingException { if (contentStream != null) return ((SharedInputStream)contentStream).newStream(0, -1); if (content != null) return new ByteArrayInputStream(content); throw new MessagingException("No MimeBodyPart content"); }
/** * Produce the raw bytes of the content. This method is used * when creating a DataHandler object for the content. Subclasses * that can provide a separate input stream for just the Part * content might want to override this method. <p> * * @return an InputStream containing the raw bytes * @exception MessagingException for failures * @see #content * @see MimeMessage#getContentStream */ protected InputStream getContentStream() throws MessagingException { if (contentStream != null) return ((SharedInputStream)contentStream).newStream(0, -1); if (content != null) return new ByteArrayInputStream(content); throw new MessagingException("No MimeBodyPart content"); }
/** * Produce the raw bytes of the content. The data is fetched using * the POP3 RETR command. * * @see #contentStream */ protected synchronized InputStream getContentStream() throws MessagingException { if (contentStream != null) return ((SharedInputStream)contentStream).newStream(0, -1); InputStream cstream = getRawStream(true); /* * Keep a hard reference to the data if we're using a file * cache or if the "mail.pop3.keepmessagecontent" prop is set. */ TempFile cache = folder.getFileCache(); if (cache != null || ((POP3Store)(folder.getStore())).keepMessageContent) contentStream = ((SharedInputStream)cstream).newStream(0, -1); return cstream; }
/** * Produce the raw bytes of the content. The data is fetched using * the POP3 RETR command. * * @see #contentStream */ @Override protected synchronized InputStream getContentStream() throws MessagingException { if (contentStream != null) return ((SharedInputStream)contentStream).newStream(0, -1); InputStream cstream = getRawStream(true); /* * Keep a hard reference to the data if we're using a file * cache or if the "mail.pop3.keepmessagecontent" prop is set. */ TempFile cache = folder.getFileCache(); if (cache != null || ((POP3Store)(folder.getStore())).keepMessageContent) contentStream = ((SharedInputStream)cstream).newStream(0, -1); return cstream; }
/** * Produce the raw bytes of the content. This method is used during * parsing, to create a DataHandler object for the content. Subclasses * that can provide a separate input stream for just the message * content might want to override this method. <p> * * This implementation returns a SharedInputStream, if * <code>contentStream</code> is not null. Otherwise, it * returns a ByteArrayInputStream constructed * out of the <code>content</code> byte array. * * @return an InputStream containing the raw bytes * @exception MessagingException for failures * @see #content */ protected InputStream getContentStream() throws MessagingException { if (contentStream != null) return ((SharedInputStream)contentStream).newStream(0, -1); if (content != null) return new SharedByteArrayInputStream(content); throw new MessagingException("No MimeMessage content"); }
/** * Produce the raw bytes of the content. This method is used during * parsing, to create a DataHandler object for the content. Subclasses * that can provide a separate input stream for just the message * content might want to override this method. <p> * * This implementation returns a SharedInputStream, if * <code>contentStream</code> is not null. Otherwise, it * returns a ByteArrayInputStream constructed * out of the <code>content</code> byte array. * * @return an InputStream containing the raw bytes * @exception MessagingException for failures * @see #content */ protected InputStream getContentStream() throws MessagingException { if (contentStream != null) return ((SharedInputStream)contentStream).newStream(0, -1); if (content != null) return new SharedByteArrayInputStream(content); throw new MessagingException("No MimeMessage content"); }
/** * Parse the InputStream setting the <code>headers</code> and * <code>content</code> fields appropriately. Also resets the * <code>modified</code> flag. <p> * * This method is intended for use by subclasses that need to * control when the InputStream is parsed. * * @param is The message input stream * @exception MessagingException for failures */ protected void parse(InputStream is) throws MessagingException { if (!(is instanceof ByteArrayInputStream) && !(is instanceof BufferedInputStream) && !(is instanceof SharedInputStream)) is = new BufferedInputStream(is); headers = createInternetHeaders(is); if (is instanceof SharedInputStream) { SharedInputStream sis = (SharedInputStream)is; contentStream = sis.newStream(sis.getPosition(), -1); } else { try { content = ASCIIUtility.getBytes(is); } catch (IOException ioex) { throw new MessagingException("IOException", ioex); } } modified = false; }
/** * Parse the InputStream setting the <code>headers</code> and * <code>content</code> fields appropriately. Also resets the * <code>modified</code> flag. <p> * * This method is intended for use by subclasses that need to * control when the InputStream is parsed. * * @param is The message input stream * @exception MessagingException for failures */ protected void parse(InputStream is) throws MessagingException { if (!(is instanceof ByteArrayInputStream) && !(is instanceof BufferedInputStream) && !(is instanceof SharedInputStream)) is = new BufferedInputStream(is); headers = createInternetHeaders(is); if (is instanceof SharedInputStream) { SharedInputStream sis = (SharedInputStream)is; contentStream = sis.newStream(sis.getPosition(), -1); } else { try { content = ASCIIUtility.getBytes(is); } catch (IOException ioex) { throw new MessagingException("IOException", ioex); } } modified = false; }
contentStream = sis.newStream(sis.getPosition(), -1); } else { try {
contentStream = sis.newStream(sis.getPosition(), -1); } else { try {
InputStream in = ((SharedInputStream)rawcontent).newStream(0, -1); try { byte[] buf = new byte[16*1024];
InputStream in = ((SharedInputStream)rawcontent).newStream(0, -1); try { byte[] buf = new byte[16*1024];
part = createMimeBodyPartIs(sin.newStream(start, end)); } else {
part = createMimeBodyPartIs(sin.newStream(start, end)); } else {
rawcontent = ((SharedInputStream)rawcontent).newStream( skipHeader ? hdrSize : 0, -1); return rawcontent;
rawcontent = ((SharedInputStream)rawcontent).newStream( skipHeader ? hdrSize : 0, -1); return rawcontent;
@Override public InputStream getHeaderContent() throws IOException { long headerEnd = bodyStartOctet; if (headerEnd < 0) { headerEnd = 0; } return content.newStream(0, headerEnd); }
public InputStream getInputStream() { // If the underlying stream implements SharedInputStream, then get // a new stream so the stream source can be read multiple times. InputStream returnStream = (mediaStream instanceof SharedInputStream) ? ((SharedInputStream)mediaStream).newStream(sharedMediaStreamStart, -1) : mediaStream; return returnStream; }
public InputStream getInputStream() { // If the underlying stream implements SharedInputStream, then get // a new stream so the stream source can be read multiple times. InputStream returnStream = (mediaStream instanceof SharedInputStream) ? ((SharedInputStream)mediaStream).newStream(sharedMediaStreamStart, -1) : mediaStream; return returnStream; }
@Override public InputStream getHeaderContent() throws IOException { int headerEnd = getBodyStartOctet() - 2; if (headerEnd < 0) { headerEnd = 0; } return content.newStream(0, headerEnd); }