154 * <plist version=\"1.0\">
155 * <array>
156 * <string>file:///path_to_file</string>
157 * <string></string>
158 * </array>
159 * </plist>
160 * }
161 * </pre>
162 */
163 private String extractURL(String xml) {
164 Pattern urlExtractorPattern = Pattern.compile("<string>(.*)</string>");
165 Matcher matcher = urlExtractorPattern.matcher(xml);
166 if (matcher.find()) {
167 return matcher.group(1);
168 } else {
169 return null;
170 }
171 }
172
173 @Override
174 synchronized protected Long getFormatForNativeAsLong(String str) {
175 Long format = predefinedClipboardNameMap.get(str);
176
177 if (format == null) {
178 if (java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment().isHeadlessInstance()) {
179 // Do not try to access native system for the unknown format
180 return -1L;
181 }
182 format = registerFormatWithPasteboard(str);
183 predefinedClipboardNameMap.put(str, format);
184 predefinedClipboardFormatMap.put(format, str);
185 }
186
187 return format;
188 }
189
190 /*
191 * Adds type to native mapping NSDictionary.
192 */
193 private native long registerFormatWithPasteboard(String type);
194
|
154 * <plist version=\"1.0\">
155 * <array>
156 * <string>file:///path_to_file</string>
157 * <string></string>
158 * </array>
159 * </plist>
160 * }
161 * </pre>
162 */
163 private String extractURL(String xml) {
164 Pattern urlExtractorPattern = Pattern.compile("<string>(.*)</string>");
165 Matcher matcher = urlExtractorPattern.matcher(xml);
166 if (matcher.find()) {
167 return matcher.group(1);
168 } else {
169 return null;
170 }
171 }
172
173 @Override
174 protected synchronized Long getFormatForNativeAsLong(String str) {
175 Long format = predefinedClipboardNameMap.get(str);
176
177 if (format == null) {
178 if (java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment().isHeadlessInstance()) {
179 // Do not try to access native system for the unknown format
180 return -1L;
181 }
182 format = registerFormatWithPasteboard(str);
183 predefinedClipboardNameMap.put(str, format);
184 predefinedClipboardFormatMap.put(format, str);
185 }
186
187 return format;
188 }
189
190 /*
191 * Adds type to native mapping NSDictionary.
192 */
193 private native long registerFormatWithPasteboard(String type);
194
|