81 long[] formats = clipboard.getClipboardFormats();
82
83 if (formats != null && formats.length > 0) {
84 // Since the SystemFlavorMap will specify many DataFlavors
85 // which map to the same format, we should cache data as we
86 // read it.
87 HashMap cached_data = new HashMap(formats.length, 1.0f);
88
89 Map flavorsForFormats = DataTransferer.getInstance().
90 getFlavorsForFormats(formats, SunClipboard.flavorMap);
91 for (Iterator iter = flavorsForFormats.keySet().iterator();
92 iter.hasNext(); )
93 {
94 DataFlavor flavor = (DataFlavor)iter.next();
95 Long lFormat = (Long)flavorsForFormats.get(flavor);
96
97 fetchOneFlavor(clipboard, flavor, lFormat, cached_data);
98 }
99
100 flavors = DataTransferer.getInstance().
101 setToSortedDataFlavorArray(flavorsToData.keySet(),
102 flavorsForFormats);
103 }
104 } finally {
105 clipboard.closeClipboard();
106 }
107 }
108
109 private boolean fetchOneFlavor(SunClipboard clipboard, DataFlavor flavor,
110 Long lFormat, HashMap cached_data)
111 {
112 if (!flavorsToData.containsKey(flavor)) {
113 long format = lFormat.longValue();
114 Object data = null;
115
116 if (!cached_data.containsKey(lFormat)) {
117 try {
118 data = clipboard.getClipboardData(format);
119 } catch (IOException e) {
120 data = e;
121 } catch (Throwable e) {
122 e.printStackTrace();
|
81 long[] formats = clipboard.getClipboardFormats();
82
83 if (formats != null && formats.length > 0) {
84 // Since the SystemFlavorMap will specify many DataFlavors
85 // which map to the same format, we should cache data as we
86 // read it.
87 HashMap cached_data = new HashMap(formats.length, 1.0f);
88
89 Map flavorsForFormats = DataTransferer.getInstance().
90 getFlavorsForFormats(formats, SunClipboard.flavorMap);
91 for (Iterator iter = flavorsForFormats.keySet().iterator();
92 iter.hasNext(); )
93 {
94 DataFlavor flavor = (DataFlavor)iter.next();
95 Long lFormat = (Long)flavorsForFormats.get(flavor);
96
97 fetchOneFlavor(clipboard, flavor, lFormat, cached_data);
98 }
99
100 flavors = DataTransferer.getInstance().
101 setToSortedDataFlavorArray(flavorsToData.keySet());
102 }
103 } finally {
104 clipboard.closeClipboard();
105 }
106 }
107
108 private boolean fetchOneFlavor(SunClipboard clipboard, DataFlavor flavor,
109 Long lFormat, HashMap cached_data)
110 {
111 if (!flavorsToData.containsKey(flavor)) {
112 long format = lFormat.longValue();
113 Object data = null;
114
115 if (!cached_data.containsKey(lFormat)) {
116 try {
117 data = clipboard.getClipboardData(format);
118 } catch (IOException e) {
119 data = e;
120 } catch (Throwable e) {
121 e.printStackTrace();
|