/** * 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; }
/** * 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; } }
/** * 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"); } }
public void marshal(final Object source, final HierarchicalStreamWriter writer, final MarshallingContext context) { final ActivationDataFlavor dataFlavor = (ActivationDataFlavor)source; final String mimeType = dataFlavor.getMimeType(); if (mimeType != null) { writer.startNode("mimeType"); writer.setValue(mimeType); writer.endNode(); } final String name = dataFlavor.getHumanPresentableName(); if (name != null) { writer.startNode("humanRepresentableName"); writer.setValue(name); writer.endNode(); } final Class representationClass = dataFlavor.getRepresentationClass(); if (representationClass != null) { writer.startNode("representationClass"); context.convertAnother(representationClass); writer.endNode(); } }
/** * Compares the DataFlavor passed in with this DataFlavor; calls * the <code>isMimeTypeEqual</code> method. * * @param dataFlavor the DataFlavor to compare with * @return true if the MIME type and representation class * are the same */ public boolean equals(DataFlavor dataFlavor) { return (isMimeTypeEqual(dataFlavor) && dataFlavor.getRepresentationClass() == representationClass); }
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 }
@Override public void marshal(final Object source, final HierarchicalStreamWriter writer, final MarshallingContext context) { final ActivationDataFlavor dataFlavor = ActivationDataFlavor.class.cast(source); final String mimeType = dataFlavor.getMimeType(); if (mimeType != null) { writer.startNode("mimeType"); writer.setValue(mimeType); writer.endNode(); } final String name = dataFlavor.getHumanPresentableName(); if (name != null) { writer.startNode("humanRepresentableName"); writer.setValue(name); writer.endNode(); } final Class<?> representationClass = dataFlavor.getRepresentationClass(); if (representationClass != null) { writer.startNode("representationClass"); context.convertAnother(representationClass); writer.endNode(); } }
/** * Compares the DataFlavor passed in with this DataFlavor; calls * the <code>isMimeTypeEqual</code> method. * * @param dataFlavor the DataFlavor to compare with * @return true if the MIME type and representation class * are the same */ public boolean equals(DataFlavor dataFlavor) { return (isMimeTypeEqual(dataFlavor) && dataFlavor.getRepresentationClass() == representationClass); }
@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 }
private final DataFlavor localObjectFlavor = new ActivationDataFlavor(Integer.class, "application/x-java-Integer;class=java.lang.Integer", "Integer Row Index"); private JTable table = null;
/** * 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; } }
/** * 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"); } }
public void marshal(final Object source, final HierarchicalStreamWriter writer, final MarshallingContext context) { final ActivationDataFlavor dataFlavor = (ActivationDataFlavor)source; final String mimeType = dataFlavor.getMimeType(); if (mimeType != null) { writer.startNode("mimeType"); writer.setValue(mimeType); writer.endNode(); } final String name = dataFlavor.getHumanPresentableName(); if (name != null) { writer.startNode("humanRepresentableName"); writer.setValue(name); writer.endNode(); } final Class representationClass = dataFlavor.getRepresentationClass(); if (representationClass != null) { writer.startNode("representationClass"); context.convertAnother(representationClass); writer.endNode(); } }
/** * Compares the DataFlavor passed in with this DataFlavor; calls * the <code>isMimeTypeEqual</code> method. * * @param dataFlavor the DataFlavor to compare with * @return true if the MIME type and representation class * are the same */ public boolean equals(DataFlavor dataFlavor) { return (isMimeTypeEqual(dataFlavor) && dataFlavor.getRepresentationClass() == representationClass); }
@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 }
/** * 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; }
@Nullable public byte [] getTransferData (final DataFlavor df, @Nonnull final DataSource ds) throws IOException { if (ADF1.equals (df)) return getContent (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());
public void marshal(final Object source, final HierarchicalStreamWriter writer, final MarshallingContext context) { final ActivationDataFlavor dataFlavor = (ActivationDataFlavor)source; final String mimeType = dataFlavor.getMimeType(); if (mimeType != null) { writer.startNode("mimeType"); writer.setValue(mimeType); writer.endNode(); } final String name = dataFlavor.getHumanPresentableName(); if (name != null) { writer.startNode("humanRepresentableName"); writer.setValue(name); writer.endNode(); } final Class representationClass = dataFlavor.getRepresentationClass(); if (representationClass != null) { writer.startNode("representationClass"); context.convertAnother(representationClass); writer.endNode(); } }
/** * Compares the DataFlavor passed in with this DataFlavor; calls * the <code>isMimeTypeEqual</code> method. * * @param dataFlavor the DataFlavor to compare with * @return true if the MIME type and representation class * are the same */ public boolean equals(DataFlavor dataFlavor) { return (isMimeTypeEqual(dataFlavor) && dataFlavor.getRepresentationClass() == representationClass); }