131
132 if (format == CF_URL && URL.class.equals(flavor.getRepresentationClass())) {
133 String[] strings = dragQueryFile(bytes);
134 if(strings == null || strings.length == 0) {
135 return null;
136 }
137 return new URL(strings[0]);
138 } else if(isUriListFlavor(flavor)) {
139 // dragQueryFile works fine with files and url,
140 // it parses and extracts values from property list.
141 // maxosx always returns property list for
142 // CF_URL and CF_FILE
143 String[] strings = dragQueryFile(bytes);
144 if(strings == null) {
145 return null;
146 }
147 String separator = System.getProperty("line.separator");
148 StringBuilder sb = new StringBuilder();
149 if(strings.length > 0) {
150 sb.append(strings[0]);
151 for(int i = 1; i < strings.length; i++) {
152 sb.append(strings[i]);
153 sb.append(separator);
154 }
155 }
156 bytes = sb.toString().getBytes();
157 // now we extracted uri from xml, now we should treat it as
158 // regular string that allows to translate data to target represantation
159 // class by base method
160 format = CF_STRING;
161 } else if (format == CF_STRING) {
162 bytes = Normalizer.normalize(new String(bytes, "UTF8"), Form.NFC).getBytes("UTF8");
163 }
164
165 return super.translateBytes(bytes, flavor, format, transferable);
166 }
167
168 @Override
169 synchronized protected Long getFormatForNativeAsLong(String str) {
170 Long format = predefinedClipboardNameMap.get(str);
|
131
132 if (format == CF_URL && URL.class.equals(flavor.getRepresentationClass())) {
133 String[] strings = dragQueryFile(bytes);
134 if(strings == null || strings.length == 0) {
135 return null;
136 }
137 return new URL(strings[0]);
138 } else if(isUriListFlavor(flavor)) {
139 // dragQueryFile works fine with files and url,
140 // it parses and extracts values from property list.
141 // maxosx always returns property list for
142 // CF_URL and CF_FILE
143 String[] strings = dragQueryFile(bytes);
144 if(strings == null) {
145 return null;
146 }
147 String separator = System.getProperty("line.separator");
148 StringBuilder sb = new StringBuilder();
149 if(strings.length > 0) {
150 sb.append(strings[0]);
151 sb.append(separator);
152 for(int i = 1; i < strings.length; i++) {
153 sb.append(strings[i]);
154 sb.append(separator);
155 }
156 }
157 bytes = sb.toString().getBytes();
158 // now we extracted uri from xml, now we should treat it as
159 // regular string that allows to translate data to target represantation
160 // class by base method
161 format = CF_STRING;
162 } else if (format == CF_STRING) {
163 bytes = Normalizer.normalize(new String(bytes, "UTF8"), Form.NFC).getBytes("UTF8");
164 }
165
166 return super.translateBytes(bytes, flavor, format, transferable);
167 }
168
169 @Override
170 synchronized protected Long getFormatForNativeAsLong(String str) {
171 Long format = predefinedClipboardNameMap.get(str);
|