@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(); } }
public ImageDataContentHandler() { String[] mimeTypes = ImageIO.getReaderMIMETypes(); flavor = new DataFlavor[mimeTypes.length]; for(int i=0; i < mimeTypes.length; i++) { flavor[i] = new ActivationDataFlavor(Image.class, mimeTypes[i], "Image"); } }
@Override @Nonnull @ReturnsMutableObject ("design") protected ActivationDataFlavor [] getDataFlavors () { return FLAVORS; }
@Override @Nonnull protected Object getData (@Nonnull final ActivationDataFlavor aFlavor, @Nonnull final DataSource ds) throws IOException { if (aFlavor.getRepresentationClass () == StreamSource.class) return new StreamSource (ds.getInputStream ()); throw new IOException ("Unsupported flavor " + aFlavor + " on DS " + ds); }
public DataFlavor[] getTransferDataFlavors() { return new DataFlavor[] { new ActivationDataFlavor(InputStream.class, "application/octet-stream", "SFRM Data Stream"), new ActivationDataFlavor(FileRegionDataSource.class, "application/octet-stream", "SFRM Data Stream"), new ActivationDataFlavor(EmptyDataSource.class, "application/octet-stream", "SFRM Data Stream"), new ActivationDataFlavor(String.class, "application/octet-stream", "SFRM Data Stream")}; }
public void testMimeTypeOnly() { final String expected = "" + "<activation-data-flavor>\n" + " <mimeType>application/x-junit</mimeType>\n" + " <representationClass>java.io.InputStream</representationClass>\n" + "</activation-data-flavor>"; assertBothWays(new ActivationDataFlavor("application/x-junit", null), expected); }
public void testMimeTypeAndRepresentation() { final String expected = "" + "<activation-data-flavor>\n" + " <mimeType>application/x-junit</mimeType>\n" + " <humanRepresentableName>JUnit</humanRepresentableName>\n" + " <representationClass>java.io.InputStream</representationClass>\n" + "</activation-data-flavor>"; assertBothWays(new ActivationDataFlavor("application/x-junit", "JUnit"), expected); }
public void testWithAllArguments() { final String expected = "" + "<activation-data-flavor>\n" + " <mimeType>application/x-junit</mimeType>\n" + " <humanRepresentableName>JUnit</humanRepresentableName>\n" + " <representationClass>com.thoughtworks.xstream.converters.extended.ActivationDataFlavorConverterTest</representationClass>\n" + "</activation-data-flavor>"; assertBothWays(new ActivationDataFlavor(ActivationDataFlavorConverterTest.class, "application/x-junit", "JUnit"), expected); }
PKCS7ContentHandler( ActivationDataFlavor adf, DataFlavor[] dfs) { _adf = adf; _dfs = dfs; }
public XmlDataContentHandler() throws ClassNotFoundException { flavors = new DataFlavor[3]; flavors[0] = new ActivationDataFlavor(StreamSource.class, "text/xml", "XML"); flavors[1] = new ActivationDataFlavor(StreamSource.class, "application/xml", "XML"); flavors[2] = new ActivationDataFlavor(String.class, "text/xml", "XML String"); }
protected ActivationDataFlavor getDF() { return myDF; }
public ListItemTransferHandler() { localObjectFlavor = new ActivationDataFlavor( Object[].class, DataFlavor.javaJVMLocalObjectMimeType, "Array of items"); }
/** * Constructs a new handler. */ public ListItemTransferHandler() { super(); localObjectFlavor = new ActivationDataFlavor(Object[].class, DataFlavor.javaJVMLocalObjectMimeType, "Array of items"); }
public ListItemTransferHandler(ResortListener resortListener) { this.resortListener = resortListener; localObjectFlavor = new ActivationDataFlavor(Object[].class, DataFlavor.javaJVMLocalObjectMimeType, "Array of items"); }
@Override public boolean canConvert(final Class<?> type) { return type == ActivationDataFlavor.class; }
/** * Class constructor. */ public PhotManListItemTransferHandler() { m_localObjectFlavor = new ActivationDataFlavor( Object[].class,DataFlavor.javaJVMLocalObjectMimeType,"Array of items"); }