FileDocCategorySizeDatePackage
message_disposition_notification.javaAPI DocApache James 2.3.15067Fri Jan 12 12:56:34 GMT 2007org.apache.james.util.mail.handlers

message_disposition_notification

public class message_disposition_notification extends AbstractDataContentHandler

Data Content Handler for...

MIME type name
message
MIME subtype name
disposition-notification

Fields Summary
Constructors Summary
public message_disposition_notification()
Default Constructor.

        super();
    
Methods Summary
protected java.lang.ObjectcomputeContent(javax.activation.DataSource aDataSource)

see
org.apache.james.util.mail.handlers.AbstractDataContentHandler#computeContent(javax.activation.DataSource)

        String encoding = getCharacterSet(aDataSource.getContentType());
        Reader reader = null;
        Writer writer = new StringWriter(2048);
        String content = null;
        try
        {
            reader = new BufferedReader(new InputStreamReader(aDataSource
                    .getInputStream(), encoding), 2048);
            while (reader.ready())
                writer.write(reader.read());
            writer.flush();
            content = writer.toString();
        }
        catch (IllegalArgumentException e)
        {
            throw new MessagingException("Encoding = \"" + encoding + "\"", e);
        }
        catch (IOException e)
        {
            throw new MessagingException(
                    "Exception obtaining content from DataSource", e);
        }
        finally
        {
            try
            {
                writer.close();
            }
            catch (IOException e1)
            {
                // No-op
            }
        }
        return content;
    
protected javax.activation.ActivationDataFlavorcomputeDataFlavor()

see
org.apache.james.util.mail.handlers.AbstractDataContentHandler#computeDataFlavor()

        return new ActivationDataFlavor(String.class,
                "message/disposition-notification", "Message String");
    
protected java.lang.StringgetCharacterSet(java.lang.String aType)

        String characterSet = null;
        try
        {
            characterSet = new ContentType(aType).getParameter("charset");
        }
        catch (ParseException e)
        {
            // no-op
        }
        finally
        {
            if (null == characterSet)
                characterSet = "us-ascii";
        }
        return MimeUtility.javaCharset(characterSet);
    
public voidwriteTo(java.lang.Object aPart, java.lang.String aMimeType, java.io.OutputStream aStream)

see
javax.activation.DataContentHandler#writeTo(java.lang.Object, java.lang.String, java.io.OutputStream)

        if (!(aPart instanceof String))
            throw new IOException("Type \"" + aPart.getClass().getName()
                    + "\" is not supported.");

        String encoding = getCharacterSet(getDataFlavor().getMimeType());
        Writer writer = null;
        try
        {
            writer = new BufferedWriter(new OutputStreamWriter(aStream,
                    encoding), 2048);
        }
        catch (IllegalArgumentException e)
        {
            throw new UnsupportedEncodingException(encoding);
        }
        writer.write((String) aPart);
        writer.flush();