165 charset = new String((byte[])transferable.getTransferData(javaTextEncodingFlavor), "UTF-8"); 166 } catch (UnsupportedFlavorException cannotHappen) { 167 } 168 } 169 170 return new URL(new String(bytes, charset)); 171 } 172 173 if (format == CF_STRING) { 174 bytes = Normalizer.normalize(new String(bytes, "UTF8"), Form.NFC).getBytes("UTF8"); 175 } 176 177 return super.translateBytesOrStream(stream, bytes, flavor, format, transferable); 178 } 179 180 181 synchronized protected Long getFormatForNativeAsLong(String str) { 182 Long format = predefinedClipboardNameMap.get(str); 183 184 if (format == null) { 185 format = new Long(registerFormatWithPasteboard(str)); 186 predefinedClipboardNameMap.put(str, format); 187 predefinedClipboardFormatMap.put(format, str); 188 } 189 190 return format; 191 } 192 193 /* 194 * Adds type to native mapping NSDictionary. 195 */ 196 private native long registerFormatWithPasteboard(String type); 197 198 // Get registered native format string for an index, return null if unknown: 199 private native String formatForIndex(long index); 200 201 protected String getNativeForFormat(long format) { 202 String returnValue = null; 203 204 // The most common case - just index the array of predefined names: | 165 charset = new String((byte[])transferable.getTransferData(javaTextEncodingFlavor), "UTF-8"); 166 } catch (UnsupportedFlavorException cannotHappen) { 167 } 168 } 169 170 return new URL(new String(bytes, charset)); 171 } 172 173 if (format == CF_STRING) { 174 bytes = Normalizer.normalize(new String(bytes, "UTF8"), Form.NFC).getBytes("UTF8"); 175 } 176 177 return super.translateBytesOrStream(stream, bytes, flavor, format, transferable); 178 } 179 180 181 synchronized protected Long getFormatForNativeAsLong(String str) { 182 Long format = predefinedClipboardNameMap.get(str); 183 184 if (format == null) { 185 if (java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment().isHeadlessInstance()) { 186 // Do not try to access GUI manager for unknown format 187 return new Long(-1); 188 } 189 format = new Long(registerFormatWithPasteboard(str)); 190 predefinedClipboardNameMap.put(str, format); 191 predefinedClipboardFormatMap.put(format, str); 192 } 193 194 return format; 195 } 196 197 /* 198 * Adds type to native mapping NSDictionary. 199 */ 200 private native long registerFormatWithPasteboard(String type); 201 202 // Get registered native format string for an index, return null if unknown: 203 private native String formatForIndex(long index); 204 205 protected String getNativeForFormat(long format) { 206 String returnValue = null; 207 208 // The most common case - just index the array of predefined names: |