jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/messaging/saaj/soap/GifDataContentHandler.java
changeset 43852 93a527059d8a
parent 28326 2b9860c0d68a
equal deleted inserted replaced
43752:3c68ef249093 43852:93a527059d8a
     1 /*
     1 /*
     2  * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
    50     /**
    50     /**
    51      * Return the DataFlavors for this <code>DataContentHandler</code>.
    51      * Return the DataFlavors for this <code>DataContentHandler</code>.
    52      *
    52      *
    53      * @return The DataFlavors
    53      * @return The DataFlavors
    54      */
    54      */
       
    55     @Override
    55     public DataFlavor[] getTransferDataFlavors() { // throws Exception;
    56     public DataFlavor[] getTransferDataFlavors() { // throws Exception;
    56         return new DataFlavor[] { getDF()};
    57         return new DataFlavor[] { getDF()};
    57     }
    58     }
    58 
    59 
    59     /**
    60     /**
    60      * Return the Transfer Data of type DataFlavor from InputStream.
    61      * Return the Transfer Data of type DataFlavor from InputStream.
    61      *
    62      *
    62      * @param df The DataFlavor
    63      * @param df The DataFlavor
    63      * @param ins The InputStream corresponding to the data
    64      * @param ds The DataSource
    64      * @return String object
    65      * @return String object
       
    66      * @exception IOException in case of an I/O error
    65      */
    67      */
       
    68     @Override
    66     public Object getTransferData(DataFlavor df, DataSource ds)
    69     public Object getTransferData(DataFlavor df, DataSource ds)
    67         throws IOException {
    70         throws IOException {
    68         // use myDF.equals to be sure to get ActivationDataFlavor.equals,
    71         // use myDF.equals to be sure to get ActivationDataFlavor.equals,
    69         // which properly ignores Content-Type parameters in comparison
    72         // which properly ignores Content-Type parameters in comparison
    70         if (getDF().equals(df))
    73         if (getDF().equals(df))
    71             return getContent(ds);
    74             return getContent(ds);
    72         else
    75         else
    73             return null;
    76             return null;
    74     }
    77     }
    75 
    78 
       
    79     @Override
    76     public Object getContent(DataSource ds) throws IOException {
    80     public Object getContent(DataSource ds) throws IOException {
    77         InputStream is = ds.getInputStream();
    81         InputStream is = ds.getInputStream();
    78         int pos = 0;
    82         int pos = 0;
    79         int count;
    83         int count;
    80         byte buf[] = new byte[1024];
    84         byte buf[] = new byte[1024];
    96         return tk.createImage(buf, 0, pos);
   100         return tk.createImage(buf, 0, pos);
    97     }
   101     }
    98 
   102 
    99     /**
   103     /**
   100      * Write the object to the output stream, using the specified MIME type.
   104      * Write the object to the output stream, using the specified MIME type.
       
   105      * @param obj object to write
       
   106      * @param type requested MIME type of the resulting byte stream
       
   107      * @param os OutputStream
   101      */
   108      */
       
   109     @Override
   102     public void writeTo(Object obj, String type, OutputStream os)
   110     public void writeTo(Object obj, String type, OutputStream os)
   103                         throws IOException {
   111                         throws IOException {
   104         if (obj != null && !(obj instanceof Image))
   112         if (obj != null && !(obj instanceof Image))
   105             throw new IOException("\"" + getDF().getMimeType() +
   113             throw new IOException("\"" + getDF().getMimeType() +
   106                 "\" DataContentHandler requires Image object, " +
   114                 "\" DataContentHandler requires Image object, " +