The java.awt.datatransfer.DataFlavor class

The java.awt.datatransfer.DataFlavor class encapsulates a MIME type to represent the data format of an object stored on the clipboard as raw bytes. Each data flavor has a representation class, a MIME type, and a human presentable name. The representation class is the Java class which approximates the data. For example, the plain text flavor uses the representation class java.io.InputStream and the MIME type "text/plain; charset=unicode". The human presentable name is just a slightly more reader-friendly variant of the MIME type like "JPEG picture" instead of "image/jpeg".

Currently two specific data flavors are defined, DataFlavor.plainTextFlavor and DataFlavor.stringFlavor.

There are two constructors that allow you to create new data flavors:

 public DataFlavor(Class representationClass, 
  String humanPresentableName)
 public DataFlavor(String mimeType, String humanPresentableName)
The first constructor specifies the representation class and the human presentable name. However the MIME type is normally set to "application/x-java-serialized-object". The second constructor lets you set the MIME type but uses the representation class InputStream.

Given a data flavor, the following methods retreive and set information about the flavor:

 public String getMimeType()
 public Class getRepresentationClass()
 public String getHumanPresentableName()
 public void setHumanPresentableName(String humanPresentableName)
 public boolean equals(DataFlavor dataFlavor)
 public boolean isMimeTypeEqual(String mimeType)
 public final boolean isMimeTypeEqual(DataFlavor dataFlavor)

Previous | Next | Top
Last Modified April 22, 1999
Copyright 1997, 1999 Elliotte Rusty Harold
elharo@metalab.unc.edu