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 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 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 retrieve 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 | Cafe au Lait

Copyright 1997, 1999, 2006 Elliotte Rusty Harold
Last Modified April 25, 2006