src/share/classes/sun/awt/datatransfer/DataTransferer.java

Print this page




1776             // Target data is an RMI object
1777         } else if (flavor.isRepresentationClassRemote()) {
1778 
1779             try (ObjectInputStream ois =
1780                      new ObjectInputStream(str))
1781             {
1782                 theObject = RMI.getMarshalledObject(ois.readObject());
1783             }catch (Exception e) {
1784                 throw new IOException(e.getMessage());
1785             }
1786 
1787             // Target data is Serializable
1788         } else if (flavor.isRepresentationClassSerializable()) {
1789             try (ObjectInputStream ois =
1790                      new ObjectInputStream(str))
1791             {
1792                 theObject = ois.readObject();
1793             } catch (Exception e) {
1794                 throw new IOException(e.getMessage());
1795             }






1796         }
1797 



1798 
1799         return theObject;
1800 
1801     }
1802 
1803     /**
1804      * For arbitrary flavors, just use the raw InputStream. For text flavors,
1805      * ReencodingInputStream will decode and reencode the InputStream on demand
1806      * so that we can strip terminators and search-and-replace EOLN.
1807      */
1808     private Object translateStreamToInputStream
1809         (InputStream str, DataFlavor flavor, long format,
1810          Transferable localeTransferable) throws IOException
1811     {
1812         if (isFlavorCharsetTextType(flavor) && isTextFormat(format)) {
1813             str = new ReencodingInputStream
1814                 (str, format, DataTransferer.getTextCharset(flavor),
1815                  localeTransferable);
1816         }
1817 




1776             // Target data is an RMI object
1777         } else if (flavor.isRepresentationClassRemote()) {
1778 
1779             try (ObjectInputStream ois =
1780                      new ObjectInputStream(str))
1781             {
1782                 theObject = RMI.getMarshalledObject(ois.readObject());
1783             }catch (Exception e) {
1784                 throw new IOException(e.getMessage());
1785             }
1786 
1787             // Target data is Serializable
1788         } else if (flavor.isRepresentationClassSerializable()) {
1789             try (ObjectInputStream ois =
1790                      new ObjectInputStream(str))
1791             {
1792                 theObject = ois.readObject();
1793             } catch (Exception e) {
1794                 throw new IOException(e.getMessage());
1795             }
1796             // Target data is Image
1797         } else if (DataFlavor.imageFlavor.equals(flavor)) {
1798             if (!isImageFormat(format)) {
1799                 throw new IOException("data translation failed");
1800             }
1801             theObject = platformImageBytesToImage(inputStreamToByteArray(str), format);
1802         }
1803 
1804         if (theObject == null) {
1805             throw new IOException("data translation failed");
1806         }
1807 
1808         return theObject;
1809 
1810     }
1811 
1812     /**
1813      * For arbitrary flavors, just use the raw InputStream. For text flavors,
1814      * ReencodingInputStream will decode and reencode the InputStream on demand
1815      * so that we can strip terminators and search-and-replace EOLN.
1816      */
1817     private Object translateStreamToInputStream
1818         (InputStream str, DataFlavor flavor, long format,
1819          Transferable localeTransferable) throws IOException
1820     {
1821         if (isFlavorCharsetTextType(flavor) && isTextFormat(format)) {
1822             str = new ReencodingInputStream
1823                 (str, format, DataTransferer.getTextCharset(flavor),
1824                  localeTransferable);
1825         }
1826