long format = formats[i];
String nat = getNativeForFormat(format);
List flavors = map.getFlavorsForNative(nat);
for (Iterator iter = flavors.iterator(); iter.hasNext(); ) {
DataFlavor flavor = (DataFlavor)iter.next();
// Don't explicitly test for String, since it is just a special
// case of Serializable
if (flavor.isFlavorTextType() ||
flavor.isFlavorJavaFileListType() ||
DataFlavor.imageFlavor.equals(flavor) ||
flavor.isRepresentationClassSerializable() ||
flavor.isRepresentationClassInputStream() ||
flavor.isRepresentationClassRemote())
{
Long lFormat = Long.valueOf(format);
Object mapping =
DataTransferer.createMapping(lFormat, flavor);
flavorMap.put(flavor, lFormat);
mappingSet.add(mapping);
flavorSet.add(flavor);
}
}
}
// Second step: for each DataFlavor try to figure out which of the
// specified formats is the best to translate to this flavor.
// Then map each flavor to the best format.
// For the given flavor, FlavorTable indicates which native will
// best reflect data in the specified flavor to the underlying native
// platform. We assume that this native is the best to translate
// to this flavor.
// Note: FlavorTable allows one-way mappings, so we can occasionally
// map a flavor to the format for which the corresponding
// format-to-flavor mapping doesn't exist. For this reason we have built
// a mappingSet of all format-to-flavor mappings for the specified formats
// and check if the format-to-flavor mapping exists for the
// (flavor,format) pair being added.
for (Iterator flavorIter = flavorSet.iterator();
flavorIter.hasNext(); ) {
DataFlavor flavor = (DataFlavor)flavorIter.next();
List natives = map.getNativesForFlavor(flavor);
for (Iterator nativeIter = natives.iterator();
nativeIter.hasNext(); ) {