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 }
"Invalid content type \"" + mimeType + "\" for text/xml DCH"); if (obj instanceof String) { super.writeTo(obj, mimeType, os); return;
enc = getCharset(ds.getContentType()); is = new InputStreamReader(ds.getInputStream(), 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 String object */ public Object getTransferData(DataFlavor df, DataSource ds) throws IOException { // use myDF.equals to be sure to get ActivationDataFlavor.equals, // which properly ignores Content-Type parameters in comparison if (getDF().equals(df)) return getContent(ds); else return null; }
/** * 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 String)) throw new IOException("\"" + getDF().getMimeType() + "\" DataContentHandler requires String object, " + "was given object of type " + obj.getClass().toString()); String enc = null; OutputStreamWriter osw = null; try { enc = getCharset(type); osw = new OutputStreamWriter(os, enc); } catch (IllegalArgumentException iex) { /* * An unknown charset of the form ISO-XXX-XXX will cause * the JDK to throw an IllegalArgumentException. The * JDK will attempt to create a classname using this string, * but valid classnames must not contain the character '-', * and this results in an IllegalArgumentException, rather than * the expected UnsupportedEncodingException. Yikes. */ throw new UnsupportedEncodingException(enc); } String s = (String)obj; osw.write(s, 0, s.length()); osw.flush(); }
/** * Return the DataFlavors for this <code>DataContentHandler</code>. * * @return The DataFlavors */ public DataFlavor[] getTransferDataFlavors() { return new DataFlavor[] { getDF() }; }
enc = getCharset(ds.getContentType()); is = new InputStreamReader(ds.getInputStream(), 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 String object */ public Object getTransferData(DataFlavor df, DataSource ds) throws IOException { // use myDF.equals to be sure to get ActivationDataFlavor.equals, // which properly ignores Content-Type parameters in comparison if (getDF().equals(df)) return getContent(ds); else return null; }
throws IOException { if (!(obj instanceof String)) throw new IOException("\"" + getDF().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 DataFlavors for this <code>DataContentHandler</code>. * * @return The DataFlavors */ public DataFlavor[] getTransferDataFlavors() { 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) {
enc = getCharset(ds.getContentType()); is = new InputStreamReader(ds.getInputStream(), enc); } catch (IllegalArgumentException iex) {
@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 }
"Invalid content type \"" + mimeType + "\" for text/xml DCH"); if (obj instanceof String) { super.writeTo(obj, mimeType, os); return;
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) {
enc = getCharset(ds.getContentType()); is = new InputStreamReader(ds.getInputStream(), enc); } catch (IllegalArgumentException iex) {
@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 }
"Invalid content type \"" + mimeType + "\" for text/xml DCH"); if (obj instanceof String) { super.writeTo(obj, mimeType, os); return;
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) {