first commit
This commit is contained in:
commit
4d332ef662
27586 changed files with 3281783 additions and 0 deletions
|
|
@ -0,0 +1,52 @@
|
|||
package javax.activation;
|
||||
|
||||
import java.awt.datatransfer.DataFlavor;
|
||||
import java.awt.datatransfer.UnsupportedFlavorException;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
|
||||
class DataSourceDataContentHandler implements DataContentHandler {
|
||||
private DataSource ds = null;
|
||||
|
||||
private DataFlavor[] transferFlavors = null;
|
||||
|
||||
private DataContentHandler dch = null;
|
||||
|
||||
public DataSourceDataContentHandler(DataContentHandler paramDataContentHandler, DataSource paramDataSource) {
|
||||
this.ds = paramDataSource;
|
||||
this.dch = paramDataContentHandler;
|
||||
}
|
||||
|
||||
public DataFlavor[] getTransferDataFlavors() {
|
||||
if (this.transferFlavors == null)
|
||||
if (this.dch != null) {
|
||||
this.transferFlavors = this.dch.getTransferDataFlavors();
|
||||
} else {
|
||||
this.transferFlavors = new DataFlavor[1];
|
||||
this.transferFlavors[0] = new ActivationDataFlavor(this.ds.getContentType(), this.ds.getContentType());
|
||||
}
|
||||
return this.transferFlavors;
|
||||
}
|
||||
|
||||
public Object getTransferData(DataFlavor paramDataFlavor, DataSource paramDataSource) throws UnsupportedFlavorException, IOException {
|
||||
if (this.dch != null)
|
||||
return this.dch.getTransferData(paramDataFlavor, paramDataSource);
|
||||
if (paramDataFlavor.equals(getTransferDataFlavors()[0]))
|
||||
return paramDataSource.getInputStream();
|
||||
throw new UnsupportedFlavorException(paramDataFlavor);
|
||||
}
|
||||
|
||||
public Object getContent(DataSource paramDataSource) throws IOException {
|
||||
if (this.dch != null)
|
||||
return this.dch.getContent(paramDataSource);
|
||||
return paramDataSource.getInputStream();
|
||||
}
|
||||
|
||||
public void writeTo(Object paramObject, String paramString, OutputStream paramOutputStream) throws IOException {
|
||||
if (this.dch != null) {
|
||||
this.dch.writeTo(paramObject, paramString, paramOutputStream);
|
||||
} else {
|
||||
throw new UnsupportedDataTypeException("no DCH for content type " + this.ds.getContentType());
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue