image_gifpublic class image_gif extends Object implements DataContentHandlerDataContentHandler for image/gif. |
Fields Summary |
---|
private static ActivationDataFlavor | myDF |
Methods Summary |
---|
public java.lang.Object | getContent(javax.activation.DataSource ds)
InputStream is = ds.getInputStream();
int pos = 0;
int count;
byte buf[] = new byte[1024];
while ((count = is.read(buf, pos, buf.length - pos)) != -1) {
pos += count;
if (pos >= buf.length) {
int size = buf.length;
if (size < 256*1024)
size += size;
else
size += 256*1024;
byte tbuf[] = new byte[size];
System.arraycopy(buf, 0, tbuf, 0, pos);
buf = tbuf;
}
}
Toolkit tk = Toolkit.getDefaultToolkit();
return tk.createImage(buf, 0, pos);
| protected javax.activation.ActivationDataFlavor | getDF()
return myDF;
| public java.lang.Object | getTransferData(java.awt.datatransfer.DataFlavor df, javax.activation.DataSource ds)Return the Transfer Data of type DataFlavor from InputStream.
// 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;
| public java.awt.datatransfer.DataFlavor[] | getTransferDataFlavors()Return the DataFlavors for this DataContentHandler . // throws Exception;
return new DataFlavor[] { getDF() };
| public void | writeTo(java.lang.Object obj, java.lang.String type, java.io.OutputStream os)Write the object to the output stream, using the specified MIME type.
if (!(obj instanceof Image))
throw new IOException("\"" + getDF().getMimeType() +
"\" DataContentHandler requires Image object, " +
"was given object of type " + obj.getClass().toString());
throw new IOException(getDF().getMimeType() + " encoding not supported");
|
|