/** * 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; }
/** * 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"); }
public MediaStreamSource(InputStream mediaStream, String mediaType, DateTime lastModified, long contentLength) { super(mediaType); this.mediaStream = mediaStream; this.lastModified = lastModified; this.contentLength = contentLength; if (mediaStream instanceof SharedInputStream) { sharedMediaStreamStart = ((SharedInputStream)mediaStream).getPosition(); } }
/** * 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"); }
public MediaStreamSource(InputStream mediaStream, String mediaType, DateTime lastModified, long contentLength) { super(mediaType); this.mediaStream = mediaStream; this.lastModified = lastModified; this.contentLength = contentLength; if (mediaStream instanceof SharedInputStream) { sharedMediaStreamStart = ((SharedInputStream)mediaStream).getPosition(); } }
/** * 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; }
/** * 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; }
public long getPosition() { return ((SharedInputStream)in).getPosition(); }
contentStream = sis.newStream(sis.getPosition(), -1); } else { try {
/** * 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; }
contentStream = sis.newStream(sis.getPosition(), -1); } else { try {
/** * 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"); }
InternetHeaders headers = null; if (sin != null) { start = sin.getPosition(); buf = new ByteArrayOutputStream(); else end = sin.getPosition(); int b; "missing multipart end boundary"); if (sin != null) end = sin.getPosition(); complete = false; done = true; end = sin.getPosition() - bl - eolLen; part = createMimeBodyPartIs(sin.newStream(start, end)); } else {
/** * 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"); }
InternetHeaders headers = null; if (sin != null) { start = sin.getPosition(); buf = new ByteArrayOutputStream(); else end = sin.getPosition(); int b; "missing multipart end boundary"); if (sin != null) end = sin.getPosition(); complete = false; done = true; end = sin.getPosition() - bl - eolLen; part = createMimeBodyPartIs(sin.newStream(start, end)); } else {
InputStream in = ((SharedInputStream)rawcontent).newStream(0, -1); try { byte[] buf = new byte[16*1024];
headers = new InternetHeaders(rawcontent); hdrSize = (int)((SharedInputStream)rawcontent).getPosition(); } else { (int)((SharedInputStream)rawcontent).getPosition(); rawcontent = ((SharedInputStream)rawcontent).newStream( skipHeader ? hdrSize : 0, -1); return rawcontent;
InputStream in = ((SharedInputStream)rawcontent).newStream(0, -1); try { byte[] buf = new byte[16*1024];
headers = new InternetHeaders(rawcontent); hdrSize = (int)((SharedInputStream)rawcontent).getPosition(); } else { (int)((SharedInputStream)rawcontent).getPosition(); 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); }