Mercurial > projects > dwt-win
annotate dwt/program/Program.d @ 212:ab60f3309436
reverted the char[] to String and use the an alias.
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Mon, 05 May 2008 00:12:38 +0200 |
parents | 184ab53b7785 |
children | 36f5cb12e1a2 |
rev | line source |
---|---|
191 | 1 /******************************************************************************* |
2 * Copyright (c) 2000, 2007 IBM Corporation and others. | |
3 * All rights reserved. This program and the accompanying materials | |
4 * are made available under the terms of the Eclipse Public License v1.0 | |
5 * which accompanies this distribution, and is available at | |
6 * http://www.eclipse.org/legal/epl-v10.html | |
7 * | |
8 * Contributors: | |
9 * IBM Corporation - initial API and implementation | |
10 * Port to the D Programming language: | |
11 * Frank Benoit <benoit@tionex.de> | |
12 *******************************************************************************/ | |
13 module dwt.program.Program; | |
14 | |
15 import dwt.DWT; | |
16 import dwt.graphics.Image; | |
17 import dwt.graphics.ImageData; | |
18 import dwt.internal.win32.OS; | |
19 | |
20 import dwt.dwthelper.utils; | |
21 static import tango.text.convert.Utf; | |
22 | |
23 /** | |
24 * Instances of this class represent programs and | |
25 * their associated file extensions in the operating | |
26 * system. | |
27 */ | |
28 public final class Program { | |
212
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
197
diff
changeset
|
29 String name; |
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
197
diff
changeset
|
30 String command; |
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
197
diff
changeset
|
31 String iconName; |
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
197
diff
changeset
|
32 String extension; |
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
197
diff
changeset
|
33 static const String[] ARGUMENTS = ["%1"[], "%l", "%L"]; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ |
191 | 34 |
35 /** | |
36 * Prevents uninitialized instances from being created outside the package. | |
37 */ | |
38 this () { | |
39 } | |
40 | |
212
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
197
diff
changeset
|
41 static String assocQueryString (int assocStr, TCHAR[] key, bool expand) { |
191 | 42 TCHAR[] pszOut = NewTCHARs(0, 1024); |
43 uint[1] pcchOut; | |
44 pcchOut[0] = pszOut.length; | |
45 int result = OS.AssocQueryString(OS.ASSOCF_NOTRUNCATE, assocStr, key.ptr, null, pszOut.ptr, pcchOut.ptr); | |
46 if (result is OS.E_POINTER) { | |
47 pszOut = NewTCHARs(0, pcchOut [0]); | |
48 result = OS.AssocQueryString(OS.ASSOCF_NOTRUNCATE, assocStr, key.ptr, null, pszOut.ptr, pcchOut.ptr); | |
49 } | |
50 if (result is 0) { | |
51 if (!OS.IsWinCE && expand) { | |
52 int length_ = OS.ExpandEnvironmentStrings (pszOut.ptr, null, 0); | |
53 if (length_ !is 0) { | |
54 TCHAR[] lpDst = NewTCHARs (0, length_); | |
55 OS.ExpandEnvironmentStrings (pszOut.ptr, lpDst.ptr, length_); | |
56 return tango.text.convert.Utf.toString( lpDst[ 0 .. Math.max (0, length_ - 1) ] ); | |
57 } else { | |
58 return ""; | |
59 } | |
60 } else { | |
61 return tango.text.convert.Utf.toString( pszOut[ 0 .. Math.max (0, pcchOut [0] - 1)]); | |
62 } | |
63 } | |
64 return null; | |
65 } | |
66 | |
67 /** | |
68 * Finds the program that is associated with an extension. | |
69 * The extension may or may not begin with a '.'. Note that | |
70 * a <code>Display</code> must already exist to guarantee that | |
71 * this method returns an appropriate result. | |
72 * | |
73 * @param extension the program extension | |
74 * @return the program or <code>null</code> | |
75 * | |
76 * @exception IllegalArgumentException <ul> | |
77 * <li>ERROR_NULL_ARGUMENT when extension is null</li> | |
78 * </ul> | |
79 */ | |
212
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
197
diff
changeset
|
80 public static Program findProgram (String extension) { |
191 | 81 if (extension is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); |
82 if (extension.length is 0) return null; | |
83 if (extension.charAt (0) !is '.') extension = "." ~ extension; //$NON-NLS-1$ | |
84 /* Use the character encoding for the default locale */ | |
85 TCHAR[] key = StrToTCHARs (0, extension, true); | |
86 Program program = null; | |
87 if (OS.IsWinCE) { | |
88 void*[1] phkResult; | |
89 if (OS.RegOpenKeyEx ( cast(void*)OS.HKEY_CLASSES_ROOT, key.ptr, 0, OS.KEY_READ, phkResult.ptr) !is 0) { | |
90 return null; | |
91 } | |
92 uint [1] lpcbData; | |
93 int result = OS.RegQueryValueEx (phkResult [0], null, null, null, null, lpcbData.ptr); | |
94 if (result is 0) { | |
95 TCHAR[] lpData = NewTCHARs (0, lpcbData [0] / TCHAR.sizeof); | |
96 result = OS.RegQueryValueEx (phkResult [0], null, null, null, cast(ubyte*)lpData.ptr, lpcbData.ptr); | |
97 if (result is 0) program = getProgram ( TCHARzToStr( lpData.ptr ), extension); | |
98 } | |
99 OS.RegCloseKey (phkResult [0]); | |
100 } else { | |
212
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
197
diff
changeset
|
101 String command = assocQueryString (OS.ASSOCSTR_COMMAND, key, true); |
191 | 102 if (command !is null) { |
212
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
197
diff
changeset
|
103 String name = null; |
191 | 104 if (name is null) name = assocQueryString (OS.ASSOCSTR_FRIENDLYDOCNAME, key, false); |
105 if (name is null) name = assocQueryString (OS.ASSOCSTR_FRIENDLYAPPNAME, key, false); | |
106 if (name is null) name = ""; | |
212
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
197
diff
changeset
|
107 String iconName = assocQueryString (OS.ASSOCSTR_DEFAULTICON, key, true); |
191 | 108 if (iconName is null) iconName = ""; |
109 program = new Program (); | |
110 program.name = name; | |
111 program.command = command; | |
112 program.iconName = iconName; | |
113 program.extension = extension; | |
114 } | |
115 } | |
116 return program; | |
117 } | |
118 | |
119 /** | |
120 * Answer all program extensions in the operating system. Note | |
121 * that a <code>Display</code> must already exist to guarantee | |
122 * that this method returns an appropriate result. | |
123 * | |
124 * @return an array of extensions | |
125 */ | |
212
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
197
diff
changeset
|
126 public static String [] getExtensions () { |
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
197
diff
changeset
|
127 String [] extensions = new String [1024]; |
191 | 128 /* Use the character encoding for the default locale */ |
129 TCHAR[] lpName = NewTCHARs (0, 1024); | |
130 uint [1] lpcName; lpcName[0] = lpName.length; | |
131 FILETIME ft; | |
132 int dwIndex = 0, count = 0; | |
133 while (OS.RegEnumKeyEx ( cast(void*)OS.HKEY_CLASSES_ROOT, dwIndex, lpName.ptr, lpcName.ptr, null, null, null, &ft) !is OS.ERROR_NO_MORE_ITEMS) { | |
212
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
197
diff
changeset
|
134 String extension = TCHARsToStr( lpName[0 .. lpcName[0] ]); |
191 | 135 lpcName [0] = lpName.length; |
136 if (extension.length > 0 && extension.charAt (0) is '.') { | |
137 if (count is extensions.length) { | |
212
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
197
diff
changeset
|
138 String[] newExtensions = new String[]( extensions.length + 1024 ); |
191 | 139 System.arraycopy (extensions, 0, newExtensions, 0, extensions.length); |
140 extensions = newExtensions; | |
141 } | |
142 extensions [count++] = extension; | |
143 } | |
144 dwIndex++; | |
145 } | |
146 if (count !is extensions.length) { | |
212
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
197
diff
changeset
|
147 String[] newExtension = new String[]( count ); |
191 | 148 System.arraycopy (extensions, 0, newExtension, 0, count); |
149 extensions = newExtension; | |
150 } | |
151 return extensions; | |
152 } | |
153 | |
212
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
197
diff
changeset
|
154 static String getKeyValue (String string, bool expand) { |
191 | 155 /* Use the character encoding for the default locale */ |
156 TCHAR[] key = StrToTCHARs (0, string, true); | |
157 void* [1] phkResult; | |
158 if (OS.RegOpenKeyEx (cast(void*)OS.HKEY_CLASSES_ROOT, key.ptr, 0, OS.KEY_READ, phkResult.ptr) !is 0) { | |
159 return null; | |
160 } | |
212
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
197
diff
changeset
|
161 String result = null; |
191 | 162 uint [1] lpcbData; |
163 if (OS.RegQueryValueEx (phkResult [0], null, null, null, null, lpcbData.ptr) is 0) { | |
164 result = ""; | |
165 int length_ = lpcbData [0] / TCHAR.sizeof; | |
166 if (length_ !is 0) { | |
167 /* Use the character encoding for the default locale */ | |
168 TCHAR[] lpData = NewTCHARs (0, length_); | |
169 if (OS.RegQueryValueEx (phkResult [0], null, null, null, cast(ubyte*)lpData.ptr, lpcbData.ptr) is 0) { | |
170 if (!OS.IsWinCE && expand) { | |
171 length_ = OS.ExpandEnvironmentStrings (lpData.ptr, null, 0); | |
172 if (length_ !is 0) { | |
173 TCHAR[] lpDst = NewTCHARs (0, length_); | |
174 OS.ExpandEnvironmentStrings (lpData.ptr, lpDst.ptr, length_); | |
175 result = tango.text.convert.Utf.toString ( lpDst[0 .. Math.max (0, length_ - 1) ] ); | |
176 } | |
177 } else { | |
178 length_ = Math.max (0, lpData.length - 1); | |
179 result = tango.text.convert.Utf.toString ( lpData[0 .. length_]); | |
180 } | |
181 } | |
182 } | |
183 } | |
184 if (phkResult [0] !is null) OS.RegCloseKey (phkResult [0]); | |
185 return result; | |
186 } | |
187 | |
212
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
197
diff
changeset
|
188 static Program getProgram (String key, String extension) { |
191 | 189 |
190 /* Name */ | |
212
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
197
diff
changeset
|
191 String name = getKeyValue (key, false); |
191 | 192 if (name is null || name.length is 0) { |
193 name = key; | |
194 } | |
195 | |
196 /* Command */ | |
212
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
197
diff
changeset
|
197 String DEFAULT_COMMAND = "\\shell"; //$NON-NLS-1$ |
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
197
diff
changeset
|
198 String defaultCommand = getKeyValue (key ~ DEFAULT_COMMAND, true); |
191 | 199 if (defaultCommand is null || defaultCommand.length is 0) defaultCommand = "open"; //$NON-NLS-1$ |
212
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
197
diff
changeset
|
200 String COMMAND = "\\shell\\" ~ defaultCommand ~ "\\command"; //$NON-NLS-1$ |
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
197
diff
changeset
|
201 String command = getKeyValue (key ~ COMMAND, true); |
191 | 202 if (command is null || command.length is 0) return null; |
203 | |
204 /* Icon */ | |
212
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
197
diff
changeset
|
205 String DEFAULT_ICON = "\\DefaultIcon"; //$NON-NLS-1$ |
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
197
diff
changeset
|
206 String iconName = getKeyValue (key ~ DEFAULT_ICON, true); |
191 | 207 if (iconName is null) iconName = ""; //$NON-NLS-1$ |
208 | |
209 /* Program */ | |
210 Program program = new Program (); | |
211 program.name = name; | |
212 program.command = command; | |
213 program.iconName = iconName; | |
214 program.extension = extension; | |
215 return program; | |
216 } | |
217 | |
218 /** | |
219 * Answers all available programs in the operating system. Note | |
220 * that a <code>Display</code> must already exist to guarantee | |
221 * that this method returns an appropriate result. | |
222 * | |
223 * @return an array of programs | |
224 */ | |
225 public static Program [] getPrograms () { | |
226 Program [] programs = new Program [1024]; | |
227 /* Use the character encoding for the default locale */ | |
228 TCHAR[] lpName = NewTCHARs (0, 1024); | |
229 uint [1] lpcName; lpcName[0] = lpName.length; | |
230 FILETIME ft; | |
231 int dwIndex = 0, count = 0; | |
232 while (OS.RegEnumKeyEx (cast(void*)OS.HKEY_CLASSES_ROOT, dwIndex, lpName.ptr, lpcName.ptr, null, null, null, &ft) !is OS.ERROR_NO_MORE_ITEMS) { | |
212
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
197
diff
changeset
|
233 String path = tango.text.convert.Utf.toString ( lpName[0 .. lpcName [0]]); |
191 | 234 lpcName [0] = lpName.length ; |
235 Program program = getProgram (path, null); | |
236 if (program !is null) { | |
237 if (count is programs.length) { | |
238 Program [] newPrograms = new Program [programs.length + 1024]; | |
239 System.arraycopy (programs, 0, newPrograms, 0, programs.length); | |
240 programs = newPrograms; | |
241 } | |
242 programs [count++] = program; | |
243 } | |
244 dwIndex++; | |
245 } | |
246 if (count !is programs.length) { | |
247 Program [] newPrograms = new Program [count]; | |
248 System.arraycopy (programs, 0, newPrograms, 0, count); | |
249 programs = newPrograms; | |
250 } | |
251 return programs; | |
252 } | |
253 | |
254 /** | |
255 * Launches the executable associated with the file in | |
256 * the operating system. If the file is an executable, | |
257 * then the executable is launched. Note that a <code>Display</code> | |
258 * must already exist to guarantee that this method returns | |
259 * an appropriate result. | |
260 * | |
261 * @param fileName the file or program name | |
262 * @return <code>true</code> if the file is launched, otherwise <code>false</code> | |
263 * | |
264 * @exception IllegalArgumentException <ul> | |
265 * <li>ERROR_NULL_ARGUMENT when fileName is null</li> | |
266 * </ul> | |
267 */ | |
212
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
197
diff
changeset
|
268 public static bool launch (String fileName) { |
191 | 269 if (fileName is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); |
270 | |
271 /* Use the character encoding for the default locale */ | |
272 auto hHeap = OS.GetProcessHeap (); | |
273 TCHAR[] buffer = StrToTCHARs (0, fileName, true); | |
274 int byteCount = buffer.length * TCHAR.sizeof; | |
275 auto lpFile = cast(wchar*) OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount); | |
276 OS.MoveMemory (lpFile, buffer.ptr, byteCount); | |
277 SHELLEXECUTEINFO info; | |
278 info.cbSize = SHELLEXECUTEINFO.sizeof; | |
279 info.lpFile = lpFile; | |
280 info.nShow = OS.SW_SHOW; | |
281 bool result = cast(bool) OS.ShellExecuteEx (&info); | |
282 if (lpFile !is null) OS.HeapFree (hHeap, 0, lpFile); | |
283 return result; | |
284 } | |
285 | |
286 /** | |
287 * Executes the program with the file as the single argument | |
288 * in the operating system. It is the responsibility of the | |
289 * programmer to ensure that the file contains valid data for | |
290 * this program. | |
291 * | |
292 * @param fileName the file or program name | |
293 * @return <code>true</code> if the file is launched, otherwise <code>false</code> | |
294 * | |
295 * @exception IllegalArgumentException <ul> | |
296 * <li>ERROR_NULL_ARGUMENT when fileName is null</li> | |
297 * </ul> | |
298 */ | |
212
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
197
diff
changeset
|
299 public bool execute (String fileName) { |
191 | 300 if (fileName is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); |
301 int index = 0; | |
302 bool append = true; | |
212
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
197
diff
changeset
|
303 String prefix = command, suffix = ""; //$NON-NLS-1$ |
191 | 304 while (index < ARGUMENTS.length) { |
305 int i = command.indexOf (ARGUMENTS [index]); | |
306 if (i !is -1) { | |
307 append = false; | |
308 prefix = command.substring (0, i); | |
309 suffix = command.substring (i + ARGUMENTS [index].length , command.length ); | |
310 break; | |
311 } | |
312 index++; | |
313 } | |
314 if (append) fileName = " \"" ~ fileName ~ "\""; | |
212
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
197
diff
changeset
|
315 String commandLine = prefix ~ fileName ~ suffix; |
191 | 316 auto hHeap = OS.GetProcessHeap (); |
317 /* Use the character encoding for the default locale */ | |
318 TCHAR[] buffer = StrToTCHARs (0, commandLine, true); | |
319 int byteCount = buffer.length * TCHAR.sizeof; | |
320 auto lpCommandLine = cast(TCHAR*)OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount); | |
321 OS.MoveMemory (lpCommandLine, buffer.ptr, byteCount); | |
322 STARTUPINFO lpStartupInfo; | |
323 lpStartupInfo.cb = STARTUPINFO.sizeof; | |
324 PROCESS_INFORMATION lpProcessInformation; | |
325 bool success = cast(bool) OS.CreateProcess (null, lpCommandLine, null, null, false, 0, null, null, &lpStartupInfo, &lpProcessInformation); | |
326 if (lpCommandLine !is null) OS.HeapFree (hHeap, 0, lpCommandLine); | |
327 if (lpProcessInformation.hProcess !is null) OS.CloseHandle (lpProcessInformation.hProcess); | |
328 if (lpProcessInformation.hThread !is null) OS.CloseHandle (lpProcessInformation.hThread); | |
329 return success; | |
330 } | |
331 | |
332 /** | |
333 * Returns the receiver's image data. This is the icon | |
334 * that is associated with the receiver in the operating | |
335 * system. | |
336 * | |
337 * @return the image data for the program, may be null | |
338 */ | |
339 public ImageData getImageData () { | |
340 if (extension !is null) { | |
341 SHFILEINFOW shfi; | |
342 int flags = OS.SHGFI_ICON | OS.SHGFI_SMALLICON | OS.SHGFI_USEFILEATTRIBUTES; | |
343 TCHAR[] pszPath = StrToTCHARs (0, extension, true); | |
344 OS.SHGetFileInfo (pszPath.ptr, OS.FILE_ATTRIBUTE_NORMAL, &shfi, SHFILEINFO.sizeof, flags); | |
345 if (shfi.hIcon !is null) { | |
346 Image image = Image.win32_new (null, DWT.ICON, shfi.hIcon); | |
347 ImageData imageData = image.getImageData (); | |
348 image.dispose (); | |
349 return imageData; | |
350 } | |
351 } | |
352 int nIconIndex = 0; | |
212
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
197
diff
changeset
|
353 String fileName = iconName; |
191 | 354 int index = iconName.indexOf (','); |
355 if (index !is -1) { | |
356 fileName = iconName.substring (0, index); | |
212
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
197
diff
changeset
|
357 String iconIndex = iconName.substring (index + 1, iconName.length ).trim (); |
191 | 358 try { |
359 nIconIndex = Integer.parseInt (iconIndex); | |
360 } catch (NumberFormatException e) {} | |
361 } | |
362 /* Use the character encoding for the default locale */ | |
363 TCHAR[] lpszFile = StrToTCHARs (0, fileName, true); | |
364 HICON [1] phiconSmall, phiconLarge; | |
365 OS.ExtractIconEx (lpszFile.ptr, nIconIndex, phiconLarge.ptr, phiconSmall.ptr, 1); | |
366 if (phiconSmall [0] is null) return null; | |
367 Image image = Image.win32_new (null, DWT.ICON, phiconSmall [0]); | |
368 ImageData imageData = image.getImageData (); | |
369 image.dispose (); | |
370 return imageData; | |
371 } | |
372 | |
373 /** | |
374 * Returns the receiver's name. This is as short and | |
375 * descriptive a name as possible for the program. If | |
376 * the program has no descriptive name, this string may | |
377 * be the executable name, path or empty. | |
378 * | |
379 * @return the name of the program | |
380 */ | |
212
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
197
diff
changeset
|
381 public String getName () { |
191 | 382 return name; |
383 } | |
384 | |
385 /** | |
386 * Compares the argument to the receiver, and returns true | |
387 * if they represent the <em>same</em> object using a class | |
388 * specific comparison. | |
389 * | |
390 * @param other the object to compare with this object | |
391 * @return <code>true</code> if the object is the same as this object and <code>false</code> otherwise | |
392 * | |
393 * @see #hashCode() | |
394 */ | |
395 public override int opEquals(Object other) { | |
396 if (this is other) return true; | |
397 if ( auto program = cast(Program)other ) { | |
398 return name.equals(program.name) && command.equals(program.command) | |
399 && iconName.equals(program.iconName); | |
400 } | |
401 return false; | |
402 } | |
403 | |
404 /** | |
405 * Returns an integer hash code for the receiver. Any two | |
406 * objects that return <code>true</code> when passed to | |
407 * <code>equals</code> must return the same value for this | |
408 * method. | |
409 * | |
410 * @return the receiver's hash | |
411 * | |
412 * @see #equals(Object) | |
413 */ | |
414 public override hash_t toHash() { | |
415 return .toHash(name) ^ .toHash(command) ^ .toHash(iconName); | |
416 } | |
417 | |
418 /** | |
419 * Returns a string containing a concise, human-readable | |
420 * description of the receiver. | |
421 * | |
422 * @return a string representation of the program | |
423 */ | |
212
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
197
diff
changeset
|
424 public String toString () { |
191 | 425 return "Program {" ~ name ~ "}"; //$NON-NLS-1$ //$NON-NLS-2$ |
426 } | |
427 | |
428 } |