FileDocCategorySizeDatePackage
MimeMessageSource.javaAPI DocApache James 2.3.13113Fri Jan 12 12:56:24 GMT 2007org.apache.james.core

MimeMessageSource

public abstract class MimeMessageSource extends Object
This defines a reusable datasource that can supply an input stream with MimeMessage data. This allows a MimeMessageWrapper or other classes to grab the underlying data.
see
MimeMessageWrapper

Fields Summary
Constructors Summary
Methods Summary
public abstract java.io.InputStreamgetInputStream()
Get an input stream to retrieve the data stored in the datasource

return
a InputStream containing the data
throws
IOException if an error occurs while generating the InputStream

public longgetMessageSize()
Return the size of all the data. Default implementation... others can override to do this much faster

return
the size of the data represented by this source
throws
IOException if an error is encountered while computing the message size

        int size = 0;
        InputStream in = null;
        try {
            in = getInputStream();
            int read = 0;
            byte[] data = new byte[1024];
            while ((read = in.read(data)) > 0) {
                size += read;
            }
        } finally {
            try {
                if (in != null) {
                    in.close();
                }
            } catch (IOException ioe) {
                // Exception ignored because logging is
                // unavailable
            }
        }
        return size;
    
public abstract java.lang.StringgetSourceId()
Returns a unique String ID that represents the location from where this file is loaded. This will be used to identify where the data is, primarily to avoid situations where this data would get overwritten.

return
the String ID