1 21 22 27 28 package com.sun.mail.dsn; 29 30 import java.io.*; 31 import java.util.Properties ; 32 import java.awt.datatransfer.DataFlavor ; 33 import javax.activation.*; 34 import javax.mail.*; 35 import javax.mail.internet.*; 36 37 38 41 public class message_deliverystatus implements DataContentHandler { 42 43 ActivationDataFlavor ourDataFlavor = new ActivationDataFlavor( 44 DeliveryStatus.class, 45 "message/delivery-status", 46 "Delivery Status"); 47 48 52 public DataFlavor [] getTransferDataFlavors() { 53 return new DataFlavor [] { ourDataFlavor }; 54 } 55 56 62 public Object getTransferData(DataFlavor df, DataSource ds) 63 throws IOException { 64 if (ourDataFlavor.equals(df)) 66 return getContent(ds); 67 else 68 return null; 69 } 70 71 74 public Object getContent(DataSource ds) throws IOException { 75 try { 77 92 return new DeliveryStatus(ds.getInputStream()); 93 } catch (MessagingException me) { 94 throw new IOException("Exception creating DeliveryStatus in " + 95 "message/devliery-status DataContentHandler: " + 96 me.toString()); 97 } 98 } 99 100 102 public void writeTo(Object obj, String mimeType, OutputStream os) 103 throws IOException { 104 if (obj instanceof DeliveryStatus) { 106 DeliveryStatus ds = (DeliveryStatus)obj; 107 try { 108 ds.writeTo(os); 109 } catch (MessagingException me) { 110 throw new IOException(me.toString()); 111 } 112 113 } else { 114 throw new IOException("unsupported object"); 115 } 116 } 117 } 118 | Popular Tags |