jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/messaging/saaj/soap/ImageDataContentHandler.java
changeset 43852 93a527059d8a
parent 33547 e4c76ac38b12
equal deleted inserted replaced
43752:3c68ef249093 43852:93a527059d8a
     1 /*
     1 /*
     2  * Copyright (c) 1997, 2012, 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
    65      * preference for providing the data (from most richly descriptive to
    65      * preference for providing the data (from most richly descriptive to
    66      * least descriptive).
    66      * least descriptive).
    67      *
    67      *
    68      * @return The DataFlavors.
    68      * @return The DataFlavors.
    69      */
    69      */
       
    70     @Override
    70     public DataFlavor[] getTransferDataFlavors() {
    71     public DataFlavor[] getTransferDataFlavors() {
    71         return (DataFlavor[]) Arrays.copyOf(flavor, flavor.length);
    72         return Arrays.copyOf(flavor, flavor.length);
    72     }
    73     }
    73 
    74 
    74     /**
    75     /**
    75      * Returns an object which represents the data to be transferred.
    76      * Returns an object which represents the data to be transferred.
    76      * The class of the object returned is defined by the representation class
    77      * The class of the object returned is defined by the representation class
    78      *
    79      *
    79      * @param df The DataFlavor representing the requested type.
    80      * @param df The DataFlavor representing the requested type.
    80      * @param ds The DataSource representing the data to be converted.
    81      * @param ds The DataSource representing the data to be converted.
    81      * @return The constructed Object.
    82      * @return The constructed Object.
    82      */
    83      */
       
    84     @Override
    83     public Object getTransferData(DataFlavor df, DataSource ds)
    85     public Object getTransferData(DataFlavor df, DataSource ds)
    84         throws IOException {
    86         throws IOException {
    85         for (int i=0; i < flavor.length; i++) {
    87         for (int i=0; i < flavor.length; i++) {
    86             if (flavor[i].equals(df)) {
    88             if (flavor[i].equals(df)) {
    87                 return getContent(ds);
    89                 return getContent(ds);
    96      * returned by the <code>getTransferDataFlavors</code> method.
    98      * returned by the <code>getTransferDataFlavors</code> method.
    97      *
    99      *
    98      * @param ds The DataSource representing the data to be converted.
   100      * @param ds The DataSource representing the data to be converted.
    99      * @return The constructed Object.
   101      * @return The constructed Object.
   100      */
   102      */
       
   103     @Override
   101     public Object getContent(DataSource ds) throws IOException {
   104     public Object getContent(DataSource ds) throws IOException {
   102         return ImageIO.read(new BufferedInputStream(ds.getInputStream()));
   105         return ImageIO.read(new BufferedInputStream(ds.getInputStream()));
   103     }
   106     }
   104 
   107 
   105     /**
   108     /**
   106      * Convert the object to a byte stream of the specified MIME type
   109      * Convert the object to a byte stream of the specified MIME type
   107      * and write it to the output stream.
   110      * and write it to the output stream.
   108      *
   111      *
   109      * @param obj   The object to be converted.
   112      * @param obj   The object to be converted.
   110      * @param mimeType  The requested MIME type of the resulting byte stream.
   113      * @param type  The requested MIME type of the resulting byte stream.
   111      * @param os    The output stream into which to write the converted
   114      * @param os    The output stream into which to write the converted
   112      *          byte stream.
   115      *          byte stream.
   113      */
   116      */
   114 
   117     @Override
   115     public void writeTo(Object obj, String type, OutputStream os)
   118     public void writeTo(Object obj, String type, OutputStream os)
   116         throws IOException {
   119         throws IOException {
   117 
   120 
   118         try {
   121         try {
   119             BufferedImage bufImage = null;
   122             BufferedImage bufImage = null;