/** * Return the DataFlavors for this <code>DataContentHandler</code>. * @return the DataFlavors */ public synchronized DataFlavor[] getTransferDataFlavors() { if (transferFlavors == null) { if (dch != null) { transferFlavors = dch.getTransferDataFlavors(); } else { transferFlavors = new DataFlavor[1]; transferFlavors[0] = new ActivationDataFlavor(obj.getClass(), mimeType, mimeType); } } return transferFlavors; }
public void run() { try { fdch.writeTo(object, objectMimeType, pos); } catch (IOException e) { } finally { try { pos.close(); } catch (IOException ie) { } } } },
public Object getContent(DataSource ds) throws IOException { if (dch != null) return dch.getContent(ds); else return ds.getInputStream(); }
/** * Return the Transfer Data of type DataFlavor from InputStream. * @param df the DataFlavor * @param ds the DataSource * @return the constructed Object */ public Object getTransferData(DataFlavor df, DataSource ds) throws UnsupportedFlavorException, IOException { if (dch != null) return dch.getTransferData(df, ds); else if (df.equals(getTransferDataFlavors()[0])) // only have one now return obj; else throw new UnsupportedFlavorException(df); }
/** * Return the Transfer Data of type DataFlavor from InputStream. * @param df the DataFlavor * @param ds the DataSource * @return the constructed Object */ public Object getTransferData(DataFlavor df, DataSource ds) throws UnsupportedFlavorException, IOException { if (dch != null) return dch.getTransferData(df, ds); else if (df.equals(getTransferDataFlavors()[0])) // only have one now return ds.getInputStream(); else throw new UnsupportedFlavorException(df); }
/** * Write the object to the output stream. */ public void writeTo(Object obj, String mimeType, OutputStream os) throws IOException { if (dch != null) dch.writeTo(obj, mimeType, os); else if (obj instanceof byte[]) os.write((byte[])obj); else if (obj instanceof String) { OutputStreamWriter osw = new OutputStreamWriter(os); osw.write((String)obj); osw.flush(); } else throw new UnsupportedDataTypeException( "no object DCH for MIME type " + this.mimeType); } }
transferFlavors = getDataContentHandler().getTransferDataFlavors(); return transferFlavors;
return getDataContentHandler().getTransferData(flavor, dataSource);
/** * Return the data in its preferred Object form. <p> * * If the DataHandler was instantiated with an object, return * the object. <p> * * If the DataHandler was instantiated with a DataSource, * this method uses a DataContentHandler to return the content * object for the data represented by this DataHandler. If no * <code>DataContentHandler</code> can be found for the * the type of this data, the DataHandler returns an * InputStream for the data. * * @return the content. * @exception IOException if an IOException occurs during * this operation. */ public Object getContent() throws IOException { if (object != null) return object; else return getDataContentHandler().getContent(getDataSource()); }
/** * Write the object to the output stream. */ public void writeTo(Object obj, String mimeType, OutputStream os) throws IOException { if (dch != null) dch.writeTo(obj, mimeType, os); else throw new UnsupportedDataTypeException( "no DCH for content type " + ds.getContentType()); } }
/** * Return the DataFlavors for this <code>DataContentHandler</code>. * @return the DataFlavors */ public DataFlavor[] getTransferDataFlavors() { if (transferFlavors == null) { if (dch != null) { // is there a dch? transferFlavors = dch.getTransferDataFlavors(); } else { transferFlavors = new DataFlavor[1]; transferFlavors[0] = new ActivationDataFlavor(ds.getContentType(), ds.getContentType()); } } return transferFlavors; }
/** * Return the Transfer Data of type DataFlavor from InputStream. * @param df the DataFlavor * @param ds the DataSource * @return the constructed Object */ public Object getTransferData(DataFlavor df, DataSource ds) throws UnsupportedFlavorException, IOException { if (dch != null) return dch.getTransferData(df, ds); else if (df.equals(transferFlavors[0])) // only have one now return obj; else throw new UnsupportedFlavorException(df); }
public Object getContent(DataSource ds) throws IOException { if (dch != null) return dch.getContent(ds); else return ds.getInputStream(); }
dch.writeTo(object, objectMimeType, os);
/** * Return the DataFlavors for this <code>DataContentHandler</code>. * @return the DataFlavors */ public DataFlavor[] getTransferDataFlavors() { if (transferFlavors == null) { if (dch != null) { transferFlavors = dch.getTransferDataFlavors(); } else { transferFlavors = new DataFlavor[1]; transferFlavors[0] = new ActivationDataFlavor(obj.getClass(), mimeType, mimeType); } } return transferFlavors; }
/** * Return the Transfer Data of type DataFlavor from InputStream. * @param df the DataFlavor * @param ds the DataSource * @return the constructed Object */ public Object getTransferData(DataFlavor df, DataSource ds) throws UnsupportedFlavorException, IOException { if (dch != null) return dch.getTransferData(df, ds); else if (df.equals(getTransferDataFlavors()[0])) // only have one now return ds.getInputStream(); else throw new UnsupportedFlavorException(df); }
/** * Return the data in its preferred Object form. <p> * * If the DataHandler was instantiated with an object, return * the object. <p> * * If the DataHandler was instantiated with a DataSource, * this method uses a DataContentHandler to return the content * object for the data represented by this DataHandler. If no * <code>DataContentHandler</code> can be found for the * the type of this data, the DataHandler returns an * InputStream for the data. * * @return the content. * @exception IOException if an IOException occurs during * this operation. */ public Object getContent() throws IOException { if (object != null) return object; else return getDataContentHandler().getContent(getDataSource()); }
public void run() { try { fdch.writeTo(object, objectMimeType, pos); } catch (IOException e) { } finally { try { pos.close(); } catch (IOException ie) { } } } },
transferFlavors = getDataContentHandler().getTransferDataFlavors(); return transferFlavors;
return getDataContentHandler().getTransferData(flavor, dataSource);