Пример #1
0
 /**
  * Returns an object which represents the data to be transferred. The class of the object
  * returned is defined by the representation class of the flavor.
  *
  * @param flavor the requested flavor for the data
  * @see DataFlavor#getRepresentationClass
  * @exception IOException if the data is no longer available in the requested flavor.
  * @exception UnsupportedFlavorException if the requested data flavor is not supported.
  */
 public Object getTransferData(DataFlavor flavor)
     throws UnsupportedFlavorException, IOException {
   if (isPlainFlavor(flavor)) {
     String data = getPlainData();
     data = (data == null) ? "" : data;
     if (String.class.equals(flavor.getRepresentationClass())) {
       return data;
     } else if (Reader.class.equals(flavor.getRepresentationClass())) {
       return new StringReader(data);
     } else if (InputStream.class.equals(flavor.getRepresentationClass())) {
       return new StringBufferInputStream(data);
     }
     // fall through to unsupported
   } else if (isStringFlavor(flavor)) {
     String data = getPlainData();
     data = (data == null) ? "" : data;
     return data;
   }
   throw new UnsupportedFlavorException(flavor);
 }