Changeset 213:36f5cb12e1a2 for dwt/dnd/URLTransfer.d
- Timestamp:
- 05/17/08 11:34:28 (8 months ago)
- Files:
-
- dwt/dnd/URLTransfer.d (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
dwt/dnd/URLTransfer.d
r212 r213 1 1 /******************************************************************************* 2 * Copyright (c) 2000, 200 4IBM Corporation and others.2 * Copyright (c) 2000, 20007 IBM Corporation and others. 3 3 * All rights reserved. This program and the accompanying materials 4 4 * are made available under the terms of the Eclipse Public License v1.0 … … 12 12 *******************************************************************************/ 13 13 module dwt.dnd.URLTransfer; 14 15 //import java.net.URL;16 14 17 15 import dwt.internal.ole.win32.COM; … … 29 27 /** 30 28 * The class <code>URLTransfer</code> provides a platform specific mechanism 31 * for converting text in URL format represented as a java <code>String []</code>29 * for converting text in URL format represented as a java <code>String</code> 32 30 * to a platform specific representation of the data and vice versa. See 33 * <code>Transfer</code> for additional information. The first string in the 34 * array is mandatory and must contain the fully specified url. The second 35 * string in the array is optional and if present contains the title for the 36 * page. 31 * <code>Transfer</code> for additional information. The string 32 * must contain a fully specified url. 37 33 * 38 * <p>An example of a java <code>String []</code> containing a URL is shown34 * <p>An example of a java <code>String</code> containing a URL is shown 39 35 * below:</p> 40 36 * 41 37 * <code><pre> 42 * String [] urlData = new String[] {"http://www.eclipse.org", "Eclipse.org Main Page"};38 * String url = "http://www.eclipse.org"; 43 39 * </code></pre> 44 40 */ 45 /*public*/class URLTransfer : ByteArrayTransfer {41 public class URLTransfer : ByteArrayTransfer { 46 42 47 43 static URLTransfer _instance; … … 72 68 73 69 /** 74 * This implementation of <code>javaToNative</code> converts a URL and optionally a title75 * represented by a java <code>String []</code> to a platform specific representation.70 * This implementation of <code>javaToNative</code> converts a URL 71 * represented by a java <code>String</code> to a platform specific representation. 76 72 * For additional information see <code>Transfer#javaToNative</code>. 77 73 * 78 * @param object a java <code>String []</code> containing a URL and optionally, a title74 * @param object a java <code>String</code> containing a URL 79 75 * @param transferData an empty <code>TransferData</code> object; this 80 76 * object will be filled in on return with the platform specific format of the data … … 86 82 transferData.result = COM.E_FAIL; 87 83 // URL is stored as a null terminated byte array 88 String url = (cast(ArrayWrapperString 2)object).array[0];84 String url = (cast(ArrayWrapperString)object).array; 89 85 int codePage = OS.GetACP(); 90 86 wchar[] chars = StrToWCHARs(codePage, url, true ); … … 107 103 /** 108 104 * This implementation of <code>nativeToJava</code> converts a platform specific 109 * representation of a URL and optionally, a title to a java <code>String[]</code>.105 * representation of a URL to a java <code>String</code>. 110 106 * For additional information see <code>Transfer#nativeToJava</code>. 111 107 * 112 108 * @param transferData the platform specific representation of the data to be 113 * beenconverted114 * @return a java <code>String []</code> containing a URL and optionally a title if the109 * converted 110 * @return a java <code>String</code> containing a URL if the 115 111 * conversion was successful; otherwise null 116 112 */ … … 135 131 wchar[] lpWideCharStr = new wchar [cchWideChar - 1]; 136 132 OS.MultiByteToWideChar (codePage, OS.MB_PRECOMPOSED, lpMultiByteStr, -1, lpWideCharStr.ptr, lpWideCharStr.length); 137 return new ArrayWrapperString 2( [ WCHARzToStr( lpWideCharStr.ptr) ]);133 return new ArrayWrapperString( WCHARzToStr( lpWideCharStr.ptr) ); 138 134 } finally { 139 135 OS.GlobalUnlock(hMem); … … 153 149 154 150 bool checkURL(Object object) { 155 if( auto s = cast(ArrayWrapperString2)object ){ 156 if( s.array.length is 0 ) return false; 157 String[] strings = s.array; 158 if (strings[0] is null || strings[0].length is 0) return false; 159 //PORTING_FIXME: how to validata URL? 160 /+try { 161 new URL(strings[0]); 162 } catch (java.net.MalformedURLException e) { 163 return false; 164 }+/ 165 return true; 166 } 167 return false; 151 return object !is null && (null !is cast(ArrayWrapperString)object) && (cast(ArrayWrapperString)object).array.length > 0; 152 168 153 } 169 154
