Mercurial > projects > dwt-win
annotate dwt/internal/Compatibility.d @ 318:f7a1b148cb35
Fix the languag file support.
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sun, 19 Oct 2008 02:47:56 +0200 |
parents | 8c656d6b7300 |
children |
rev | line source |
---|---|
212
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
2
diff
changeset
|
1 /******************************************************************************* |
246 | 2 * Copyright (c) 2000, 2007 IBM Corporation and others. |
2
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
3 * All rights reserved. This program and the accompanying materials |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
4 * are made available under the terms of the Eclipse Public License v1.0 |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
5 * which accompanies this distribution, and is available at |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
6 * http://www.eclipse.org/legal/epl-v10.html |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
7 * |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
8 * Contributors: |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
9 * IBM Corporation - initial API and implementation |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
10 * Port to the D programming language: |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
11 * Frank Benoit <benoit@tionex.de> |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
12 *******************************************************************************/ |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
13 module dwt.internal.Compatibility; |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
14 |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
15 /+ |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
16 import java.io.*; |
213 | 17 import java.io.File; |
2
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
18 import java.text.MessageFormat; |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
19 import java.util.MissingResourceException; |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
20 import java.util.ResourceBundle; |
213 | 21 import java.util.zip.DeflaterOutputStream; |
2
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
22 import java.util.zip.InflaterInputStream; |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
23 +/ |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
24 |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
25 import dwt.DWT; |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
26 public import dwt.dwthelper.FileInputStream; |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
27 public import dwt.dwthelper.FileOutputStream; |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
28 public import dwt.dwthelper.InflaterInputStream; |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
29 |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
30 import Math = tango.math.Math; |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
31 import Unicode = tango.text.Unicode; |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
32 import tango.sys.Process; |
212
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
2
diff
changeset
|
33 import dwt.dwthelper.utils; |
318
f7a1b148cb35
Fix the languag file support.
Frank Benoit <benoit@tionex.de>
parents:
317
diff
changeset
|
34 import dwt.dwthelper.ResourceBundle; |
213 | 35 import tango.io.Path; |
318
f7a1b148cb35
Fix the languag file support.
Frank Benoit <benoit@tionex.de>
parents:
317
diff
changeset
|
36 import tango.text.convert.Format; |
2
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
37 |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
38 /** |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
39 * This class is a placeholder for utility methods commonly |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
40 * used on J2SE platforms but not supported on some J2ME |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
41 * profiles. |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
42 * <p> |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
43 * It is part of our effort to provide support for both J2SE |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
44 * and J2ME platforms. |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
45 * </p> |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
46 * <p> |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
47 * IMPORTANT: some of the methods have been modified from their |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
48 * J2SE parents. Refer to the description of each method for |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
49 * specific changes. |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
50 * </p> |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
51 * <ul> |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
52 * <li>Exceptions thrown may differ since J2ME's set of |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
53 * exceptions is a subset of J2SE's one. |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
54 * </li> |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
55 * <li>The range of the mathematic functions is subject to |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
56 * change. |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
57 * </li> |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
58 * </ul> |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
59 */ |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
60 public final class Compatibility { |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
61 |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
62 /** |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
63 * Returns the PI constant as a double. |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
64 */ |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
65 public static const real PI = Math.PI; |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
66 |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
67 static const real toRadians = PI / 180; |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
68 |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
69 /** |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
70 * Answers the length of the side adjacent to the given angle |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
71 * of a right triangle. In other words, it returns the integer |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
72 * conversion of length * cos (angle). |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
73 * <p> |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
74 * IMPORTANT: the j2me version has an additional restriction on |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
75 * the argument. length must be between -32767 and 32767 (inclusive). |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
76 * </p> |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
77 * |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
78 * @param angle the angle in degrees |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
79 * @param length the length of the triangle's hypotenuse |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
80 * @return the integer conversion of length * cos (angle) |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
81 */ |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
82 public static int cos(int angle, int length) { |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
83 return cast(int)(Math.cos(angle * toRadians) * length); |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
84 } |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
85 |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
86 /** |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
87 * Answers the length of the side opposite to the given angle |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
88 * of a right triangle. In other words, it returns the integer |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
89 * conversion of length * sin (angle). |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
90 * <p> |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
91 * IMPORTANT: the j2me version has an additional restriction on |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
92 * the argument. length must be between -32767 and 32767 (inclusive). |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
93 * </p> |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
94 * |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
95 * @param angle the angle in degrees |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
96 * @param length the length of the triangle's hypotenuse |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
97 * @return the integer conversion of length * sin (angle) |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
98 */ |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
99 public static int sin(int angle, int length) { |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
100 return cast(int)(Math.sin(angle * toRadians) * length); |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
101 } |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
102 |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
103 /** |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
104 * Answers the most negative (i.e. closest to negative infinity) |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
105 * integer value which is greater than the number obtained by dividing |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
106 * the first argument p by the second argument q. |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
107 * |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
108 * @param p numerator |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
109 * @param q denominator (must be different from zero) |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
110 * @return the ceiling of the rational number p / q. |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
111 */ |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
112 public static int ceil(int p, int q) { |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
113 return cast(int)Math.ceil(cast(float)p / q); |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
114 } |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
115 |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
116 /** |
213 | 117 * Answers whether the indicated file exists or not. |
118 * | |
119 * @param parent the file's parent directory | |
120 * @param child the file's name | |
121 * @return true if the file exists | |
122 */ | |
123 public static bool fileExists(String parent, String child) { | |
124 return FS.exists( FS.join(parent, child)); | |
125 } | |
126 | |
127 /** | |
2
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
128 * Answers the most positive (i.e. closest to positive infinity) |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
129 * integer value which is less than the number obtained by dividing |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
130 * the first argument p by the second argument q. |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
131 * |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
132 * @param p numerator |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
133 * @param q denominator (must be different from zero) |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
134 * @return the floor of the rational number p / q. |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
135 */ |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
136 public static int floor(int p, int q) { |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
137 return cast(int)Math.floor(cast(double)p / q); |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
138 } |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
139 |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
140 /** |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
141 * Answers the result of rounding to the closest integer the number obtained |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
142 * by dividing the first argument p by the second argument q. |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
143 * <p> |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
144 * IMPORTANT: the j2me version has an additional restriction on |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
145 * the arguments. p must be within the range 0 - 32767 (inclusive). |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
146 * q must be within the range 1 - 32767 (inclusive). |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
147 * </p> |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
148 * |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
149 * @param p numerator |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
150 * @param q denominator (must be different from zero) |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
151 * @return the closest integer to the rational number p / q |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
152 */ |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
153 public static int round(int p, int q) { |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
154 return cast(int)Math.round(cast(float)p / q); |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
155 } |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
156 |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
157 /** |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
158 * Returns 2 raised to the power of the argument. |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
159 * |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
160 * @param n an int value between 0 and 30 (inclusive) |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
161 * @return 2 raised to the power of the argument |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
162 * |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
163 * @exception IllegalArgumentException <ul> |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
164 * <li>ERROR_INVALID_RANGE - if the argument is not between 0 and 30 (inclusive)</li> |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
165 * </ul> |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
166 */ |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
167 public static int pow2(int n) { |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
168 if (n >= 1 && n <= 30) |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
169 return 2 << (n - 1); |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
170 else if (n != 0) { |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
171 DWT.error(DWT.ERROR_INVALID_RANGE); |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
172 } |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
173 return 1; |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
174 } |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
175 |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
176 /** |
213 | 177 * Create an DeflaterOutputStream if such things are supported. |
178 * | |
179 * @param stream the output stream | |
180 * @return a deflater stream or <code>null</code> | |
181 * @exception IOException | |
182 * | |
183 * @since 3.4 | |
184 */ | |
185 public static OutputStream newDeflaterOutputStream(OutputStream stream) { | |
186 //DWT_TODO | |
187 implMissing(__FILE__,__LINE__); | |
188 return null; | |
189 //return new DeflaterOutputStream(stream); | |
190 } | |
191 | |
192 /** | |
2
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
193 * Open a file if such things are supported. |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
194 * |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
195 * @param filename the name of the file to open |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
196 * @return a stream on the file if it could be opened. |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
197 * @exception IOException |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
198 */ |
212
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
2
diff
changeset
|
199 public static InputStream newFileInputStream(String filename) { |
2
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
200 return new FileInputStream(filename); |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
201 } |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
202 |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
203 /** |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
204 * Open a file if such things are supported. |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
205 * |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
206 * @param filename the name of the file to open |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
207 * @return a stream on the file if it could be opened. |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
208 * @exception IOException |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
209 */ |
212
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
2
diff
changeset
|
210 public static OutputStream newFileOutputStream(String filename) { |
2
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
211 return new FileOutputStream(filename); |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
212 } |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
213 |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
214 /** |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
215 * Create an InflaterInputStream if such things are supported. |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
216 * |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
217 * @param stream the input stream |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
218 * @return a inflater stream or <code>null</code> |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
219 * @exception IOException |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
220 * |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
221 * @since 3.3 |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
222 */ |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
223 public static InflaterInputStream newInflaterInputStream(InputStream stream) { |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
224 return new InflaterInputStream(stream); |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
225 } |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
226 |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
227 /** |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
228 * Answers whether the character is a letter. |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
229 * |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
230 * @param c the character |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
231 * @return true when the character is a letter |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
232 */ |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
233 public static bool isLetter(dchar c) { |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
234 return Unicode.isLetter(c); |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
235 } |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
236 |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
237 /** |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
238 * Answers whether the character is a letter or a digit. |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
239 * |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
240 * @param c the character |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
241 * @return true when the character is a letter or a digit |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
242 */ |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
243 public static bool isLetterOrDigit(dchar c) { |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
244 return Unicode.isLetterOrDigit(c); |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
245 } |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
246 |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
247 /** |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
248 * Answers whether the character is a Unicode space character. |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
249 * |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
250 * @param c the character |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
251 * @return true when the character is a Unicode space character |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
252 */ |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
253 public static bool isSpaceChar(dchar c) { |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
254 return Unicode.isSpace(c); |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
255 } |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
256 |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
257 /** |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
258 * Answers whether the character is a whitespace character. |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
259 * |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
260 * @param c the character to test |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
261 * @return true if the character is whitespace |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
262 */ |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
263 public static bool isWhitespace(dchar c) { |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
264 return Unicode.isWhitespace(c); |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
265 } |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
266 |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
267 /** |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
268 * Execute a program in a separate platform process if the |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
269 * underlying platform support this. |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
270 * <p> |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
271 * The new process inherits the environment of the caller. |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
272 * </p> |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
273 * |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
274 * @param prog the name of the program to execute |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
275 * |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
276 * @exception ProcessException |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
277 * if the program cannot be executed |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
278 */ |
212
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
2
diff
changeset
|
279 public static void exec(String prog) { |
2
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
280 auto proc = new Process( prog ); |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
281 proc.execute; |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
282 } |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
283 |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
284 /** |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
285 * Execute progArray[0] in a separate platform process if the |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
286 * underlying platform support this. |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
287 * <p> |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
288 * The new process inherits the environment of the caller. |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
289 * <p> |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
290 * |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
291 * @param progArray array containing the program to execute and its arguments |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
292 * |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
293 * @exception ProcessException |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
294 * if the program cannot be executed |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
295 */ |
212
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
2
diff
changeset
|
296 public static void exec(String[] progArray) { |
2
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
297 auto proc = new Process( progArray ); |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
298 proc.execute; |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
299 } |
317
8c656d6b7300
Add support for SWT language files
Frank Benoit <benoit@tionex.de>
parents:
246
diff
changeset
|
300 |
8c656d6b7300
Add support for SWT language files
Frank Benoit <benoit@tionex.de>
parents:
246
diff
changeset
|
301 const ImportData[] SWTMessagesBundleData = [ |
8c656d6b7300
Add support for SWT language files
Frank Benoit <benoit@tionex.de>
parents:
246
diff
changeset
|
302 getImportData!( "swt.internal.SWTMessages.properties" ), |
8c656d6b7300
Add support for SWT language files
Frank Benoit <benoit@tionex.de>
parents:
246
diff
changeset
|
303 getImportData!( "swt.internal.SWTMessages_ar.properties" ), |
8c656d6b7300
Add support for SWT language files
Frank Benoit <benoit@tionex.de>
parents:
246
diff
changeset
|
304 getImportData!( "swt.internal.SWTMessages_cs.properties" ), |
8c656d6b7300
Add support for SWT language files
Frank Benoit <benoit@tionex.de>
parents:
246
diff
changeset
|
305 getImportData!( "swt.internal.SWTMessages_da.properties" ), |
8c656d6b7300
Add support for SWT language files
Frank Benoit <benoit@tionex.de>
parents:
246
diff
changeset
|
306 getImportData!( "swt.internal.SWTMessages_de.properties" ), |
8c656d6b7300
Add support for SWT language files
Frank Benoit <benoit@tionex.de>
parents:
246
diff
changeset
|
307 getImportData!( "swt.internal.SWTMessages_el.properties" ), |
8c656d6b7300
Add support for SWT language files
Frank Benoit <benoit@tionex.de>
parents:
246
diff
changeset
|
308 getImportData!( "swt.internal.SWTMessages_es.properties" ), |
8c656d6b7300
Add support for SWT language files
Frank Benoit <benoit@tionex.de>
parents:
246
diff
changeset
|
309 getImportData!( "swt.internal.SWTMessages_fi.properties" ), |
8c656d6b7300
Add support for SWT language files
Frank Benoit <benoit@tionex.de>
parents:
246
diff
changeset
|
310 getImportData!( "swt.internal.SWTMessages_fr.properties" ), |
8c656d6b7300
Add support for SWT language files
Frank Benoit <benoit@tionex.de>
parents:
246
diff
changeset
|
311 getImportData!( "swt.internal.SWTMessages_hu.properties" ), |
8c656d6b7300
Add support for SWT language files
Frank Benoit <benoit@tionex.de>
parents:
246
diff
changeset
|
312 getImportData!( "swt.internal.SWTMessages_it.properties" ), |
8c656d6b7300
Add support for SWT language files
Frank Benoit <benoit@tionex.de>
parents:
246
diff
changeset
|
313 getImportData!( "swt.internal.SWTMessages_iw.properties" ), |
8c656d6b7300
Add support for SWT language files
Frank Benoit <benoit@tionex.de>
parents:
246
diff
changeset
|
314 getImportData!( "swt.internal.SWTMessages_ja.properties" ), |
8c656d6b7300
Add support for SWT language files
Frank Benoit <benoit@tionex.de>
parents:
246
diff
changeset
|
315 getImportData!( "swt.internal.SWTMessages_ko.properties" ), |
8c656d6b7300
Add support for SWT language files
Frank Benoit <benoit@tionex.de>
parents:
246
diff
changeset
|
316 getImportData!( "swt.internal.SWTMessages_nl.properties" ), |
8c656d6b7300
Add support for SWT language files
Frank Benoit <benoit@tionex.de>
parents:
246
diff
changeset
|
317 getImportData!( "swt.internal.SWTMessages_no.properties" ), |
8c656d6b7300
Add support for SWT language files
Frank Benoit <benoit@tionex.de>
parents:
246
diff
changeset
|
318 getImportData!( "swt.internal.SWTMessages_pl.properties" ), |
8c656d6b7300
Add support for SWT language files
Frank Benoit <benoit@tionex.de>
parents:
246
diff
changeset
|
319 getImportData!( "swt.internal.SWTMessages_pt_BR.properties" ), |
8c656d6b7300
Add support for SWT language files
Frank Benoit <benoit@tionex.de>
parents:
246
diff
changeset
|
320 getImportData!( "swt.internal.SWTMessages_pt.properties" ), |
8c656d6b7300
Add support for SWT language files
Frank Benoit <benoit@tionex.de>
parents:
246
diff
changeset
|
321 getImportData!( "swt.internal.SWTMessages_ru.properties" ), |
8c656d6b7300
Add support for SWT language files
Frank Benoit <benoit@tionex.de>
parents:
246
diff
changeset
|
322 getImportData!( "swt.internal.SWTMessages_sv.properties" ), |
8c656d6b7300
Add support for SWT language files
Frank Benoit <benoit@tionex.de>
parents:
246
diff
changeset
|
323 getImportData!( "swt.internal.SWTMessages_tr.properties" ), |
8c656d6b7300
Add support for SWT language files
Frank Benoit <benoit@tionex.de>
parents:
246
diff
changeset
|
324 getImportData!( "swt.internal.SWTMessages_zh_HK.properties" ), |
8c656d6b7300
Add support for SWT language files
Frank Benoit <benoit@tionex.de>
parents:
246
diff
changeset
|
325 getImportData!( "swt.internal.SWTMessages_zh.properties" ), |
8c656d6b7300
Add support for SWT language files
Frank Benoit <benoit@tionex.de>
parents:
246
diff
changeset
|
326 getImportData!( "swt.internal.SWTMessages_zh_TW.properties" ) |
8c656d6b7300
Add support for SWT language files
Frank Benoit <benoit@tionex.de>
parents:
246
diff
changeset
|
327 ]; |
8c656d6b7300
Add support for SWT language files
Frank Benoit <benoit@tionex.de>
parents:
246
diff
changeset
|
328 |
2
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
329 private static ResourceBundle msgs = null; |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
330 |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
331 /** |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
332 * Returns the NLS'ed message for the given argument. This is only being |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
333 * called from DWT. |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
334 * |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
335 * @param key the key to look up |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
336 * @return the message for the given key |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
337 * |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
338 * @see DWT#getMessage(String) |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
339 */ |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
340 public static String getMessage(String key) { |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
341 String answer = key; |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
342 |
317
8c656d6b7300
Add support for SWT language files
Frank Benoit <benoit@tionex.de>
parents:
246
diff
changeset
|
343 if (key is null) { |
2
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
344 DWT.error (DWT.ERROR_NULL_ARGUMENT); |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
345 } |
317
8c656d6b7300
Add support for SWT language files
Frank Benoit <benoit@tionex.de>
parents:
246
diff
changeset
|
346 if (msgs is null) { |
2
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
347 try { |
317
8c656d6b7300
Add support for SWT language files
Frank Benoit <benoit@tionex.de>
parents:
246
diff
changeset
|
348 msgs = ResourceBundle.getBundle(SWTMessagesBundleData); //$NON-NLS-1$ |
2
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
349 } catch (MissingResourceException ex) { |
317
8c656d6b7300
Add support for SWT language files
Frank Benoit <benoit@tionex.de>
parents:
246
diff
changeset
|
350 answer = key ~ " (no resource bundle)"; //$NON-NLS-1$ |
2
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
351 } |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
352 } |
317
8c656d6b7300
Add support for SWT language files
Frank Benoit <benoit@tionex.de>
parents:
246
diff
changeset
|
353 if (msgs !is null) { |
2
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
354 try { |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
355 answer = msgs.getString(key); |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
356 } catch (MissingResourceException ex2) {} |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
357 } |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
358 return answer; |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
359 } |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
360 |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
361 public static String getMessage(String key, Object[] args) { |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
362 String answer = key; |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
363 |
317
8c656d6b7300
Add support for SWT language files
Frank Benoit <benoit@tionex.de>
parents:
246
diff
changeset
|
364 if (key is null || args is null) { |
2
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
365 DWT.error (DWT.ERROR_NULL_ARGUMENT); |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
366 } |
317
8c656d6b7300
Add support for SWT language files
Frank Benoit <benoit@tionex.de>
parents:
246
diff
changeset
|
367 if (msgs is null) { |
2
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
368 try { |
317
8c656d6b7300
Add support for SWT language files
Frank Benoit <benoit@tionex.de>
parents:
246
diff
changeset
|
369 msgs = ResourceBundle.getBundle(SWTMessagesBundleData); //$NON-NLS-1$ |
2
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
370 } catch (MissingResourceException ex) { |
317
8c656d6b7300
Add support for SWT language files
Frank Benoit <benoit@tionex.de>
parents:
246
diff
changeset
|
371 answer = key ~ " (no resource bundle)"; //$NON-NLS-1$ |
2
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
372 } |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
373 } |
317
8c656d6b7300
Add support for SWT language files
Frank Benoit <benoit@tionex.de>
parents:
246
diff
changeset
|
374 if (msgs !is null) { |
2
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
375 try { |
317
8c656d6b7300
Add support for SWT language files
Frank Benoit <benoit@tionex.de>
parents:
246
diff
changeset
|
376 char[] frmt = msgs.getString(key); |
8c656d6b7300
Add support for SWT language files
Frank Benoit <benoit@tionex.de>
parents:
246
diff
changeset
|
377 switch( args.length ){ |
8c656d6b7300
Add support for SWT language files
Frank Benoit <benoit@tionex.de>
parents:
246
diff
changeset
|
378 case 0: answer = Format(frmt); break; |
8c656d6b7300
Add support for SWT language files
Frank Benoit <benoit@tionex.de>
parents:
246
diff
changeset
|
379 case 1: answer = Format(frmt, args[0]); break; |
8c656d6b7300
Add support for SWT language files
Frank Benoit <benoit@tionex.de>
parents:
246
diff
changeset
|
380 case 2: answer = Format(frmt, args[0], args[1]); break; |
8c656d6b7300
Add support for SWT language files
Frank Benoit <benoit@tionex.de>
parents:
246
diff
changeset
|
381 case 3: answer = Format(frmt, args[0], args[1], args[2]); break; |
8c656d6b7300
Add support for SWT language files
Frank Benoit <benoit@tionex.de>
parents:
246
diff
changeset
|
382 case 4: answer = Format(frmt, args[0], args[1], args[2], args[3]); break; |
8c656d6b7300
Add support for SWT language files
Frank Benoit <benoit@tionex.de>
parents:
246
diff
changeset
|
383 case 5: answer = Format(frmt, args[0], args[1], args[2], args[3], args[4]); break; |
8c656d6b7300
Add support for SWT language files
Frank Benoit <benoit@tionex.de>
parents:
246
diff
changeset
|
384 default: |
8c656d6b7300
Add support for SWT language files
Frank Benoit <benoit@tionex.de>
parents:
246
diff
changeset
|
385 implMissing(__FILE__, __LINE__ ); |
8c656d6b7300
Add support for SWT language files
Frank Benoit <benoit@tionex.de>
parents:
246
diff
changeset
|
386 } |
2
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
387 } catch (MissingResourceException ex2) {} |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
388 } |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
389 return answer; |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
390 } |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
391 |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
392 |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
393 /** |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
394 * Interrupt the current thread. |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
395 * <p> |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
396 * Note that this is not available on CLDC. |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
397 * </p> |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
398 */ |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
399 public static void interrupt() { |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
400 //PORTING_FIXME: how to implement?? |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
401 //Thread.currentThread().interrupt(); |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
402 } |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
403 |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
404 /** |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
405 * Compares two instances of class String ignoring the case of the |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
406 * characters and answers if they are equal. |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
407 * |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
408 * @param s1 string |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
409 * @param s2 string |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
410 * @return true if the two instances of class String are equal |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
411 */ |
212
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
2
diff
changeset
|
412 public static bool equalsIgnoreCase(String s1, String s2) { |
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
2
diff
changeset
|
413 String s1b = new char[ s1.length ]; |
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
2
diff
changeset
|
414 String s2b = new char[ s1.length ]; |
2
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
415 scope(exit){ |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
416 delete s1b; |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
417 delete s2b; |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
418 } |
212
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
2
diff
changeset
|
419 String s1c = Unicode.toFold( s1, s1b ); |
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
2
diff
changeset
|
420 String s2c = Unicode.toFold( s2, s2b ); |
2
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
421 return s1c == s2c; |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
422 } |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
423 |
57151e2793a2
More common modules from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
diff
changeset
|
424 } |