geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dblev...@apache.org
Subject cvs commit: incubator-geronimo/specs/activation/src/java/javax/activation DataHandler.java
Date Thu, 04 Sep 2003 01:00:02 GMT
dblevins    2003/09/03 18:00:02

  Modified:    specs/activation/src/java/javax/activation DataHandler.java
  Log:
  Patch: GERONIMO-54
  From:  Alex Blewitt
  
  The following provides a very simple implementation of DataHandler in
  JAF to support MimeMessage's ability to handle simple object types and
  text/ types.
  
  Revision  Changes    Path
  1.5       +66 -19    incubator-geronimo/specs/activation/src/java/javax/activation/DataHandler.java
  
  Index: DataHandler.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/specs/activation/src/java/javax/activation/DataHandler.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- DataHandler.java	29 Aug 2003 12:45:53 -0000	1.4
  +++ DataHandler.java	4 Sep 2003 01:00:02 -0000	1.5
  @@ -75,23 +75,70 @@
    */
   public class DataHandler implements Transferable {
       private DataSource _ds;
  -
       public DataHandler(DataSource ds) {
           _ds = ds;
       }
   
  -    public DataHandler(Object obj,
  -                       String mimeType) {
  -        /*@todo implement*/
  +    public DataHandler(Object data, String type) {
  +        _ds = new ObjectDataSource(data, type);
       }
   
  +    static class ObjectDataSource implements DataSource {
  +
  +        private Object _data;
  +        private String _type;
  +        public Object getContent() {
  +            return _data;
  +        }
  +        /**
  +         * Store an object as a data source type
  +         * @param data the object
  +         * @param type the mimeType
  +         */
  +        public ObjectDataSource(Object data, String type) {
  +            _data = data;
  +            _type = type;
  +        }
  +
  +        /* (non-Javadoc)
  +         * @see javax.activation.DataSource#getInputStream()
  +         */
  +        public InputStream getInputStream() throws IOException {
  +            // TODO Auto-generated method stub
  +            return null;
  +        }
  +
  +        /* (non-Javadoc)
  +         * @see javax.activation.DataSource#getOutputStream()
  +         */
  +        public OutputStream getOutputStream() throws IOException {
  +            // TODO Auto-generated method stub
  +            return null;
  +        }
  +
  +        /* (non-Javadoc)
  +         * @see javax.activation.DataSource#getContentType()
  +         */
  +        public String getContentType() {
  +            // TODO Auto-generated method stub
  +            return null;
  +        }
  +
  +        /* (non-Javadoc)
  +         * @see javax.activation.DataSource#getName()
  +         */
  +        public String getName() {
  +            // TODO Auto-generated method stub
  +            return null;
  +        }
  +
  +    }
       public DataHandler(URL url) {
           /*@todo implement*/
       }
   
       public DataSource getDataSource() {
  -        /*@todo implement*/
  -        return null;
  +        return _ds;
       }
   
       public String getName() {
  @@ -100,24 +147,19 @@
       }
   
       public String getContentType() {
  -        /*@todo implement*/
  -        return null;
  +        return _ds.getContentType();
       }
   
       public InputStream getInputStream() throws IOException {
  -        /*@todo implement*/
  -        return null;
  -
  +        return _ds.getInputStream();
       }
   
       public void writeTo(OutputStream os) throws IOException {
  -        /*@todo implement*/
  -
  +        // TODO implement
       }
   
       public OutputStream getOutputStream() throws IOException {
  -        /*@todo implement*/
  -        return null;
  +        return _ds.getOutputStream();
       }
   
       public synchronized DataFlavor[] getTransferDataFlavors() {
  @@ -130,7 +172,8 @@
           return false;
       }
   
  -    public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException,
IOException {
  +    public Object getTransferData(DataFlavor flavor)
  +        throws UnsupportedFlavorException, IOException {
           /*@todo implement*/
           return null;
       }
  @@ -155,8 +198,12 @@
       }
   
       public Object getContent() throws IOException {
  -        /*@todo implement*/
  -        return null;
  +        if (_ds instanceof ObjectDataSource) {
  +            return ((ObjectDataSource) _ds).getContent();
  +        } else {
  +            // TODO not yet implemented
  +            throw new IOException("TODO Not yet implemented");
  +        }
       }
   
       public Object getBean(CommandInfo cmdinfo) {
  
  
  

Mime
View raw message