/** * Given the flavor that matched, return the appropriate type of object. * Usually there's only one flavor so just call getContent. */ protected Object getData(ActivationDataFlavor aFlavor, DataSource ds) throws IOException { return getContent(ds); }
/** * Return the DataFlavors for this <code>DataContentHandler</code>. * * @return The DataFlavors */ public DataFlavor[] getTransferDataFlavors() { ActivationDataFlavor[] adf = getDataFlavors(); if (adf.length == 1) // the common case return new DataFlavor[] { adf[0] }; DataFlavor[] df = new DataFlavor[adf.length]; System.arraycopy(adf, 0, df, 0, adf.length); return df; }
/** * Return the Transfer Data of type DataFlavor from InputStream. * * @param df The DataFlavor * @param ds The DataSource corresponding to the data * @return String object */ public Object getTransferData(DataFlavor df, DataSource ds) throws IOException { ActivationDataFlavor[] adf = getDataFlavors(); for (int i = 0; i < adf.length; i++) { // use ActivationDataFlavor.equals, which properly // ignores Content-Type parameters in comparison if (adf[i].equals(df)) return getData(adf[i], ds); } return null; } }
throws IOException { if (!(obj instanceof String)) throw new IOException("\"" + getDataFlavors()[0].getMimeType() + "\" DataContentHandler requires String object, " + "was given object of type " + obj.getClass().toString()); enc = getCharset(type); osw = new OutputStreamWriter(new NoCloseOutputStream(os), enc); } catch (IllegalArgumentException iex) {
protected Object getData(ActivationDataFlavor aFlavor, DataSource ds) throws IOException { if (aFlavor.getRepresentationClass() == String.class) return super.getContent(ds); else if (aFlavor.getRepresentationClass() == StreamSource.class) return new StreamSource(ds.getInputStream()); else return null; // XXX - should never happen }
enc = getCharset(ds.getContentType()); is = new InputStreamReader(ds.getInputStream(), enc); } catch (IllegalArgumentException iex) {
/** * Write the object to the output stream, using the specified MIME type. */ public void writeTo(Object obj, String type, OutputStream os) throws IOException { if (!(obj instanceof Image)) throw new IOException("\"" + getDataFlavors()[0].getMimeType() + "\" DataContentHandler requires Image object, " + "was given object of type " + obj.getClass().toString()); throw new IOException(getDataFlavors()[0].getMimeType() + " encoding not supported"); } }
/** * Return the DataFlavors for this <code>DataContentHandler</code>. * * @return The DataFlavors */ public DataFlavor[] getTransferDataFlavors() { return new DataFlavor[] { getDF() }; }
/** * Return the DataFlavors for this <code>DataContentHandler</code>. * * @return The DataFlavors */ public DataFlavor[] getTransferDataFlavors() { // throws Exception; return new DataFlavor[] { getDF() }; }
throws IOException { if (!(obj instanceof String)) throw new IOException("\"" + getDataFlavors()[0].getMimeType() + "\" DataContentHandler requires String object, " + "was given object of type " + obj.getClass().toString()); enc = getCharset(type); osw = new OutputStreamWriter(new NoCloseOutputStream(os), enc); } catch (IllegalArgumentException iex) {
/** * Return the Transfer Data of type DataFlavor from InputStream. * * @param df The DataFlavor * @param ds The DataSource corresponding to the data * @return the object * @exception IOException for errors reading the data */ @Override public Object getTransferData(DataFlavor df, DataSource ds) throws IOException { ActivationDataFlavor[] adf = getDataFlavors(); for (int i = 0; i < adf.length; i++) { // use ActivationDataFlavor.equals, which properly // ignores Content-Type parameters in comparison if (adf[i].equals(df)) return getData(adf[i], ds); } return null; } }
@Override protected Object getData(ActivationDataFlavor aFlavor, DataSource ds) throws IOException { if (aFlavor.getRepresentationClass() == String.class) return super.getContent(ds); else if (aFlavor.getRepresentationClass() == StreamSource.class) return new StreamSource(ds.getInputStream()); else return null; // XXX - should never happen }
enc = getCharset(ds.getContentType()); is = new InputStreamReader(ds.getInputStream(), enc); } catch (IllegalArgumentException iex) {
/** * Given the flavor that matched, return the appropriate type of object. * Usually there's only one flavor so just call getContent. * * @param aFlavor the ActivationDataFlavor * @param ds DataSource containing the data * @return the object * @exception IOException for errors reading the data */ protected Object getData(ActivationDataFlavor aFlavor, DataSource ds) throws IOException { return getContent(ds); }
/** * Return the DataFlavors for this <code>DataContentHandler</code>. * * @return The DataFlavors */ @Override public DataFlavor[] getTransferDataFlavors() { ActivationDataFlavor[] adf = getDataFlavors(); if (adf.length == 1) // the common case return new DataFlavor[] { adf[0] }; DataFlavor[] df = new DataFlavor[adf.length]; System.arraycopy(adf, 0, df, 0, adf.length); return df; }
/** * Write the object to the output stream, using the specified MIME type. */ @Override public void writeTo(Object obj, String type, OutputStream os) throws IOException { if (!(obj instanceof Image)) throw new IOException("\"" + getDataFlavors()[0].getMimeType() + "\" DataContentHandler requires Image object, " + "was given object of type " + obj.getClass().toString()); throw new IOException(getDataFlavors()[0].getMimeType() + " encoding not supported"); } }
/** * Return the DataFlavors for this <code>DataContentHandler</code>. * * @return The DataFlavors */ public DataFlavor[] getTransferDataFlavors() { return new DataFlavor[] { getDF() }; }
/** * Return the DataFlavors for this <code>DataContentHandler</code>. * * @return The DataFlavors */ public DataFlavor[] getTransferDataFlavors() { // throws Exception; return new DataFlavor[] { getDF() }; }