Added
Link Here
|
1 |
/******************************************************************************* |
2 |
* Copyright (c) 2010 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 |
******************************************************************************/ |
11 |
package org.eclipse.equinox.bidi; |
12 |
|
13 |
import org.eclipse.equinox.bidi.custom.IBidiComplexProcessor; |
14 |
|
15 |
import org.eclipse.equinox.bidi.custom.BidiComplexStringProcessor; |
16 |
|
17 |
import org.eclipse.equinox.bidi.internal.BidiComplexImpl; |
18 |
|
19 |
/** |
20 |
* This class acts as a mediator between applications and complex |
21 |
* expression processors. |
22 |
* The purpose of complex expression processors is to add directional |
23 |
* formatting characters to ensure correct display. |
24 |
* This class shields applications from the |
25 |
* intricacies of complex expression processors. |
26 |
* <p> |
27 |
* For a general introduction to complex expressions, see |
28 |
* {@link <a href="package-summary.html"> |
29 |
* the package documentation</a>}. |
30 |
* |
31 |
* <h2>Code Sample</h2> |
32 |
* |
33 |
* <p>The following code shows how to instantiate a BidiComplexHelper adapted for a |
34 |
* certain type of complex expression (directory and file paths), and how |
35 |
* to obtain the <i>full</i> text corresponding to the <i>lean</i> text |
36 |
* of such an expression. |
37 |
* |
38 |
* <pre> |
39 |
* |
40 |
* BidiComplexHelper helper = new BidiComplexHelper(IBidiComplexExpressionTypes.FILE); |
41 |
* String leanText = "D:\\\u05d0\u05d1\\\u05d2\\\u05d3.ext"; |
42 |
* String fullText = helper.leanToFullText(leanText); |
43 |
* System.out.println("full text = " + fullText); |
44 |
* |
45 |
* </pre> |
46 |
* This class provides a user-oriented API but does not provides |
47 |
* an actual implementation. The real work is done by the class |
48 |
* {@link BidiComplexImpl}. Users of the API need not be concerned by, and |
49 |
* should not depend upon, details of the implementation by |
50 |
* <code>BidiComplexImpl</code>. |
51 |
* |
52 |
* @author Matitiahu Allouche |
53 |
* |
54 |
*/ |
55 |
public class BidiComplexHelper { |
56 |
/** |
57 |
* Constant to use as <code>initState</code> argument when calling |
58 |
* {@link #leanToFullText(java.lang.String, int) leanToFullText} or |
59 |
* {@link #fullToLeanText(java.lang.String, int) fullToLeanText} |
60 |
* to indicate that there is no context of previous lines which |
61 |
* should be initialized before performing the operation. |
62 |
*/ |
63 |
public static final int STATE_NOTHING_GOING = -1; |
64 |
|
65 |
private static final int[] EMPTY_INT_ARRAY = new int[0]; |
66 |
|
67 |
/** |
68 |
* Reference to the {@link BidiComplexImpl} instance which accomplishes |
69 |
* most of the work. This member should be accessed only by |
70 |
* complex expression processors (implementing {@link IBidiComplexProcessor}). |
71 |
*/ |
72 |
public BidiComplexImpl impl; |
73 |
|
74 |
/** |
75 |
* Create a <code>BidiComplexHelper</code> instance which does nothing tangible |
76 |
* but does it quickly. We will call it a <i>no-op helper</i>. |
77 |
* The {@link #BidiComplexHelper() no-op helper} does not modify text submitted to it, and can be |
78 |
* used when it is known that no complex expression processing |
79 |
* is needed, for instance because no bidi text is expected. With this |
80 |
* helper, the cost of invoking the complex expression API is minimal. |
81 |
*/ |
82 |
public BidiComplexHelper() { |
83 |
// let impl stay null |
84 |
} |
85 |
|
86 |
/** |
87 |
* Create a <code>BidiComplexHelper</code> instance to process expressions |
88 |
* of type <code>type</code> with a |
89 |
* {@link BidiComplexEnvironment#DEFAULT DEFAULT} environment. |
90 |
* |
91 |
* @param type represents the type of the complex expression. It must |
92 |
* be one of the values in {@link IBidiComplexExpressionTypes}, or a type |
93 |
* added in a plug-in extension. |
94 |
* |
95 |
* @throws IllegalArgumentException if the <code>type</code> is not |
96 |
* supported. |
97 |
*/ |
98 |
public BidiComplexHelper(String type) { |
99 |
this(type, null); |
100 |
} |
101 |
|
102 |
/** |
103 |
* Create a <code>BidiComplexHelper</code> instance to process expressions |
104 |
* of type <code>type</code> operating under the environment |
105 |
* {@link BidiComplexEnvironment environment}. |
106 |
* |
107 |
* @param type represents the type of the complex expression. It must |
108 |
* be one of the values in {@link IBidiComplexExpressionTypes}, or a type |
109 |
* added in a plug-in extension. |
110 |
* |
111 |
* @param environment represents the environment where the complex expression |
112 |
* will be displayed. It is better to specify the environment |
113 |
* when instantiating a <code>BidiComplexHelper</code> than to specify |
114 |
* it later using {@link #setEnvironment setEnvironment}.<br> |
115 |
* <code>null</code> can be specified here for a |
116 |
* {@link BidiComplexEnvironment#DEFAULT DEFAULT} environment. |
117 |
* |
118 |
* @throws IllegalArgumentException if the <code>type</code> is not |
119 |
* supported. |
120 |
*/ |
121 |
public BidiComplexHelper(String type, BidiComplexEnvironment environment) { |
122 |
IBidiComplexProcessor processor = BidiComplexStringProcessor.getProcessor(type); |
123 |
if (processor == null) { |
124 |
throw new IllegalArgumentException("Invalid processor type!"); //$NON-NLS-1$ |
125 |
} |
126 |
impl = new BidiComplexImpl(this, processor, environment); |
127 |
} |
128 |
|
129 |
/** |
130 |
* Create a <code>BidiComplexHelper</code> instance to process complex |
131 |
* expressions by means of a given processor <code>myProcessor</code>, |
132 |
* operating under the environment {@link BidiComplexEnvironment environment}. |
133 |
* |
134 |
* @param myProcessor is a complex expression processor. |
135 |
* |
136 |
* @param environment represents the environment where the complex expression |
137 |
* will be displayed. It is better to specify the environment |
138 |
* when instantiating a <code>BidiComplexHelper</code> than to specify |
139 |
* it later using {@link #setEnvironment setEnvironment}.<br> |
140 |
* <code>null</code> can be specified here for a |
141 |
* {@link BidiComplexEnvironment#DEFAULT DEFAULT} environment. |
142 |
*/ |
143 |
public BidiComplexHelper(IBidiComplexProcessor myProcessor, BidiComplexEnvironment environment) { |
144 |
impl = new BidiComplexImpl(this, myProcessor, environment); |
145 |
} |
146 |
|
147 |
/** Add directional formatting characters to a complex expression |
148 |
* to ensure correct presentation. |
149 |
* |
150 |
* @param text is the text of the complex expression. |
151 |
* |
152 |
* @return the complex expression with directional formatting |
153 |
* characters added at proper locations to ensure correct |
154 |
* presentation.<br> |
155 |
* The {@link #BidiComplexHelper() no-op helper} returns <code>text</code>. |
156 |
*/ |
157 |
public String leanToFullText(String text) { |
158 |
return leanToFullText(text, STATE_NOTHING_GOING); |
159 |
} |
160 |
|
161 |
/** |
162 |
* Add directional formatting characters to a complex expression |
163 |
* to ensure correct presentation. |
164 |
* |
165 |
* @param text is the text of the complex expression. |
166 |
* |
167 |
* @param initState specifies that the first parameter is the |
168 |
* continuation of text submitted in a previous call. |
169 |
* The <code>initState</code> of the present call must be |
170 |
* the final state obtained by calling |
171 |
* {@link #getFinalState() getFinalState} |
172 |
* after the previous call. |
173 |
* <br>If the present call is not a continuation of |
174 |
* text submitted in a previous call, the value |
175 |
* {@link #STATE_NOTHING_GOING} should be used as argument. |
176 |
* |
177 |
* @return the complex expression with directional formatting |
178 |
* characters added at proper locations to ensure correct |
179 |
* presentation.<br> |
180 |
* The {@link #BidiComplexHelper() no-op helper} returns <code>text</code>. |
181 |
* |
182 |
* @see #getFinalState getFinalState |
183 |
*/ |
184 |
public String leanToFullText(String text, int initState) { |
185 |
if (impl == null) |
186 |
return text; |
187 |
return impl.leanToFullText(text, initState); |
188 |
} |
189 |
|
190 |
/** |
191 |
* Given a complex expression, get the offsets of characters before |
192 |
* which directional formatting characters must be added in order to |
193 |
* ensure correct presentation. |
194 |
* Only LRMs (for an expression with LTR base direction) and RLMs (for |
195 |
* an expression with RTL base direction) are considered. Leading and |
196 |
* trailing LRE, RLE and PDF which might be prefixed or suffixed |
197 |
* depending on the {@link BidiComplexEnvironment#orientation orientation} of the |
198 |
* GUI component used for display are not reflected in this method. |
199 |
* <p> |
200 |
* This method assumes that a successful call to |
201 |
* {@link #leanToFullText leanToFullText} has been performed, and it |
202 |
* returns the offsets relevant for the last text submitted. |
203 |
* |
204 |
* @return an array of offsets to the characters in the last submitted |
205 |
* complex expression before which directional marks must be |
206 |
* added to ensure correct presentation. |
207 |
* The offsets are sorted in ascending order.<br> |
208 |
* The {@link #BidiComplexHelper() no-op helper} returns an array of 0 elements. |
209 |
*/ |
210 |
public int[] leanBidiCharOffsets() { |
211 |
if (impl == null) |
212 |
return EMPTY_INT_ARRAY; |
213 |
return impl.leanBidiCharOffsets(); |
214 |
} |
215 |
|
216 |
/** |
217 |
* Get the offsets of characters in the <i>full</i> text of a |
218 |
* complex expression corresponding to directional formatting |
219 |
* characters which have been added in order to ensure correct presentation. |
220 |
* LRMs (for an expression with LTR base direction), RLMs (for |
221 |
* an expression with RTL base direction) are considered as well as |
222 |
* leading and trailing LRE, RLE and PDF which might be prefixed or suffixed |
223 |
* depending on the {@link BidiComplexEnvironment#orientation orientation} of the |
224 |
* GUI component used for display. |
225 |
* <p> |
226 |
* This method assumes that a successful call to |
227 |
* {@link #leanToFullText leanToFullText} has been performed, and it |
228 |
* returns the offsets relevant for the last text submitted. |
229 |
* |
230 |
* @return an array of offsets to the characters in the <i>full</i> |
231 |
* text of the last submitted complex expression which are |
232 |
* directional formatting characters added to ensure correct |
233 |
* presentation. |
234 |
* The offsets are sorted in ascending order.<br> |
235 |
* The {@link #BidiComplexHelper() no-op helper} returns an array of 0 elements. |
236 |
*/ |
237 |
public int[] fullBidiCharOffsets() { |
238 |
if (impl == null) |
239 |
return EMPTY_INT_ARRAY; |
240 |
return impl.fullBidiCharOffsets(); |
241 |
} |
242 |
|
243 |
/** |
244 |
* Remove directional formatting characters which were added to a |
245 |
* complex expression to ensure correct presentation. |
246 |
* |
247 |
* @param text is the text of the complex expression including |
248 |
* directional formatting characters. |
249 |
* |
250 |
* @return the complex expression without directional formatting |
251 |
* characters which might have been added by processing it |
252 |
* with {@link #leanToFullText leanToFullText}.<br> |
253 |
* The {@link #BidiComplexHelper() no-op helper} returns <code>text</code> |
254 |
* |
255 |
*/ |
256 |
public String fullToLeanText(String text) { |
257 |
return fullToLeanText(text, STATE_NOTHING_GOING); |
258 |
} |
259 |
|
260 |
/** |
261 |
* Remove directional formatting characters which were added to a |
262 |
* complex expression to ensure correct presentation. |
263 |
* |
264 |
* @param text is the text of the complex expression including |
265 |
* directional formatting characters. |
266 |
* |
267 |
* @param initState specifies that the first parameter is the |
268 |
* continuation of text submitted in a previous call. |
269 |
* The <code>initState</code> of the present call must be |
270 |
* the final state obtained by calling |
271 |
* {@link #getFinalState getFinalState} after the previous call. |
272 |
* <br>If the present call is not a continuation of |
273 |
* text submitted in a previous call, the value |
274 |
* {@link #STATE_NOTHING_GOING} should be used as argument. |
275 |
* |
276 |
* @return the complex expression without directional formatting |
277 |
* characters which might have been added by processing it |
278 |
* with {@link #leanToFullText leanToFullText}.<br> |
279 |
* The {@link #BidiComplexHelper() no-op helper} returns <code>text</code> |
280 |
* |
281 |
* @see #getFinalState getFinalState |
282 |
*/ |
283 |
public String fullToLeanText(String text, int initState) { |
284 |
if (impl == null) |
285 |
return text; |
286 |
return impl.fullToLeanText(text, initState); |
287 |
} |
288 |
|
289 |
/** |
290 |
* Retrieve the final state achieved in a previous call to |
291 |
* {@link #leanToFullText leanToFullText} or |
292 |
* {@link #fullToLeanText fullToLeanText}. |
293 |
* This state is an opaque value which is meaningful only |
294 |
* within calls to the same complex expression processor. |
295 |
* The only externalized value is |
296 |
* {@link #STATE_NOTHING_GOING} which means that |
297 |
* there is nothing to remember from the last call. |
298 |
* <p> |
299 |
* The state should be used only for complex expressions which come |
300 |
* in parts, like when spanning multiple lines. The user can make |
301 |
* a separate call to |
302 |
* <code>leanToFullText</code> or <code>fullToLeanText</code> for each |
303 |
* line in the expression. The final state value retrieved after the |
304 |
* call for one line should be used as the initial state in the call |
305 |
* which processes the next line. |
306 |
* <p> |
307 |
* If a line within a complex expression has already been processed by |
308 |
* <code>leanToFullText</code> and the <i>lean</i> version of that line has |
309 |
* not changed, and its initial state has not changed either, the user |
310 |
* can be sure that the <i>full</i> version of that line is also |
311 |
* identical to the result of the previous processing. |
312 |
* |
313 |
* @see #leanToFullText(String text, int initState) |
314 |
* @see #fullToLeanText(String text, int initState) |
315 |
* |
316 |
* @return the last final state.<br> |
317 |
* The {@link #BidiComplexHelper() no-op helper} returns {@link #STATE_NOTHING_GOING}. |
318 |
*/ |
319 |
public int getFinalState() { |
320 |
if (impl == null) |
321 |
return STATE_NOTHING_GOING; |
322 |
return impl.getFinalState(); |
323 |
} |
324 |
|
325 |
/** |
326 |
* After transforming a <i>lean</i> string into a <i>full</i> string |
327 |
* using {@link #leanToFullText leanToFullText}, compute the index in the |
328 |
* <i>full</i> string of the character corresponding to the |
329 |
* character with the specified position in the <i>lean</i> string. |
330 |
* |
331 |
* @param position is the index of a character in the <i>lean</i> string. |
332 |
* It must be a non-negative number smaller than the length |
333 |
* of the <i>lean</i> text. |
334 |
* |
335 |
* @return the index of the corresponding character in the |
336 |
* <i>full</i> string.<br> |
337 |
* The {@link #BidiComplexHelper() no-op helper} returns <code>position</code>. |
338 |
*/ |
339 |
public int leanToFullPos(int position) { |
340 |
if (impl == null) |
341 |
return position; |
342 |
return impl.leanToFullPos(position); |
343 |
} |
344 |
|
345 |
/** |
346 |
* After transforming a <i>lean</i> string into a <i>full</i> string |
347 |
* using {@link #leanToFullText leanToFullText}, compute the index in the |
348 |
* <i>lean</i> string of the character corresponding to the |
349 |
* character with the specified position in the <i>full</i> string. |
350 |
* |
351 |
* @param position is the index of a character in the <i>full</i> string. |
352 |
* It must be a non-negative number smaller than the length |
353 |
* of the <i>full</i> text. |
354 |
* |
355 |
* @return the index of the corresponding character in the |
356 |
* <i>lean</i> string. If there is no corresponding |
357 |
* character in the <i>lean</i> string (because the |
358 |
* specified character is a directional formatting character |
359 |
* added when invoking {@link #leanToFullText leanToFullText}), |
360 |
* the value returned will be that corresponding to the |
361 |
* next character which is not a directional formatting |
362 |
* character.<br> |
363 |
* If <code>position</code> corresponds to a directional formatting |
364 |
* character beyond all characters of the original |
365 |
* <i>lean</i> text, the value returned is the length of the |
366 |
* <i>lean</i> text.<br> |
367 |
* The {@link #BidiComplexHelper() no-op helper} returns <code>position</code>. |
368 |
*/ |
369 |
public int fullToLeanPos(int position) { |
370 |
if (impl == null) |
371 |
return position; |
372 |
return impl.fullToLeanPos(position); |
373 |
} |
374 |
|
375 |
/** |
376 |
* Get the base direction of the complex expression last |
377 |
* submitted to {@link #leanToFullText leanToFullText}. |
378 |
* This base direction may depend on |
379 |
* whether the expression contains Arabic or Hebrew words |
380 |
* (if it contains both, the first Arabic or Hebrew letter in the |
381 |
* expression determines which is the governing script) and on |
382 |
* whether the GUI is {@link BidiComplexEnvironment#mirrored mirrored}. |
383 |
* |
384 |
* @return the base direction of the last submitted complex |
385 |
* expression. It must be one of the values |
386 |
* {@link BidiComplexFeatures#DIR_LTR} or {@link BidiComplexFeatures#DIR_RTL}.<br> |
387 |
* The {@link #BidiComplexHelper() no-op helper} returns <code>DIR_LTR</code>. |
388 |
*/ |
389 |
public int getCurDirection() { |
390 |
if (impl == null) |
391 |
return BidiComplexFeatures.DIR_LTR; |
392 |
return impl.getCurDirection(); |
393 |
} |
394 |
|
395 |
/** |
396 |
* Get the current environment under which the <code>BidiComplexHelper</code> |
397 |
* operates. |
398 |
* This environment may have been specified in the constructor or |
399 |
* specified later using {@link #setEnvironment setEnvironment}.<br> |
400 |
* |
401 |
* @return the current environment.<br> |
402 |
* The {@link #BidiComplexHelper() no-op helper} returns a {@link BidiComplexEnvironment#DEFAULT DEFAULT} |
403 |
* environment. |
404 |
* |
405 |
* @see #setEnvironment setEnvironment |
406 |
*/ |
407 |
public BidiComplexEnvironment getEnvironment() { |
408 |
if (impl == null) |
409 |
return BidiComplexEnvironment.DEFAULT; |
410 |
return impl.getEnvironment(); |
411 |
} |
412 |
|
413 |
/** |
414 |
* Specify the environment under which the <code>BidiComplexHelper</code> |
415 |
* must operate. |
416 |
* <p> |
417 |
* <b>Note</b> that calling this method causes the processor |
418 |
* associated with this instance of <code>BidiComplexHelper</code> |
419 |
* to re-initialize its features. The effect of a previous call |
420 |
* to {@link #setFeatures(BidiComplexFeatures) setFeatures} is lost.<br> |
421 |
* The {@link #BidiComplexHelper() no-op helper} does nothing. |
422 |
* |
423 |
* @see #getEnvironment getEnvironment |
424 |
* @see IBidiComplexProcessor#updateEnvironment IBidiComplexProcessor.updateEnvironment |
425 |
*/ |
426 |
public void setEnvironment(BidiComplexEnvironment environment) { |
427 |
if (impl == null) { |
428 |
return; // do nothing |
429 |
} |
430 |
impl.setEnvironment(environment); |
431 |
} |
432 |
|
433 |
/** |
434 |
* Get the current features of the processor associated with this |
435 |
* <code>BidiComplexHelper</code> instance. |
436 |
* |
437 |
* @return the current features.<br> |
438 |
* The {@link #BidiComplexHelper() no-op helper} returns {@link BidiComplexFeatures#DEFAULT DEFAULT} |
439 |
* features. |
440 |
* |
441 |
* @see #setFeatures setFeatures |
442 |
*/ |
443 |
public BidiComplexFeatures getFeatures() { |
444 |
if (impl == null) |
445 |
return BidiComplexFeatures.DEFAULT; |
446 |
return impl.getFeatures(); |
447 |
} |
448 |
|
449 |
/** |
450 |
* Specify the features to be applied to the processor associated with this |
451 |
* <code>BidiComplexHelper</code> instance. |
452 |
* Note that the value of {@link BidiComplexFeatures#specialsCount specialsCount} |
453 |
* cannot be changed (the new value will be ignored).<br> |
454 |
* The {@link #BidiComplexHelper() no-op helper} does nothing. |
455 |
* |
456 |
* @see #getFeatures getFeatures |
457 |
*/ |
458 |
public void setFeatures(BidiComplexFeatures features) { |
459 |
if (impl == null) { |
460 |
return; // do nothing |
461 |
} |
462 |
impl.setFeatures(features); |
463 |
} |
464 |
|
465 |
/** |
466 |
* This method can be called from within |
467 |
* {@link IBidiComplexProcessor#indexOfSpecial indexOfSpecial} or |
468 |
* {@link IBidiComplexProcessor#processSpecial processSpecial} in implementations |
469 |
* of {@link IBidiComplexProcessor} to retrieve the bidirectional class of |
470 |
* characters in the <i>lean</i> text. |
471 |
* |
472 |
* @param index position of the character in the <i>lean</i> text. |
473 |
* It must be a non-negative number smaller than the length |
474 |
* of the <i>lean</i> text. |
475 |
* |
476 |
* @return the bidirectional class of the character. It is one of the |
477 |
* values which can be returned by |
478 |
* <code>java.lang.Character#getDirectionality</code>. |
479 |
* However, it is recommended to use <code>getDirProp</code> |
480 |
* rather than <code>java.lang.Character.getDirectionality</code> |
481 |
* since <code>getDirProp</code> manages a cache of character |
482 |
* properties and so can be more efficient than calling the |
483 |
* java.lang.Character method.<br> |
484 |
* The {@link #BidiComplexHelper() no-op helper} returns |
485 |
* <code>Character.DIRECTIONALITY_UNDEFINED</code>. |
486 |
*/ |
487 |
public byte getDirProp(int index) { |
488 |
if (impl == null) |
489 |
return Character.DIRECTIONALITY_UNDEFINED; |
490 |
return impl.getDirProp(index); |
491 |
} |
492 |
|
493 |
/** |
494 |
* This method can be called from within |
495 |
* {@link IBidiComplexProcessor#indexOfSpecial indexOfSpecial} or |
496 |
* {@link IBidiComplexProcessor#processSpecial processSpecial} in implementations |
497 |
* of {@link IBidiComplexProcessor} to set or override the bidirectional |
498 |
* class of characters in the <i>lean</i> text. |
499 |
* |
500 |
* @param index position of the character in the <i>lean</i> text. |
501 |
* It must be a non-negative number smaller than the length |
502 |
* of the <i>lean</i> text. |
503 |
* |
504 |
* @param dirProp bidirectional class of the character. It is one of the |
505 |
* values which can be returned by |
506 |
* <code>java.lang.Character.getDirectionality</code>.<br> |
507 |
* The {@link #BidiComplexHelper() no-op helper} does nothing. |
508 |
*/ |
509 |
public void setDirProp(int index, byte dirProp) { |
510 |
if (impl != null) |
511 |
impl.getDirProp(index); |
512 |
} |
513 |
|
514 |
/** |
515 |
* This method can be called from within |
516 |
* {@link IBidiComplexProcessor#indexOfSpecial indexOfSpecial} or |
517 |
* {@link IBidiComplexProcessor#processSpecial processSpecial} in implementations |
518 |
* of {@link IBidiComplexProcessor} |
519 |
* to specify that a mark character must be added before the character |
520 |
* at the specified position of the <i>lean</i> text when generating the |
521 |
* <i>full</i> text. The mark character will be LRM for complex expressions |
522 |
* with a LTR base direction, and RLM for complex expressions with RTL |
523 |
* base direction. The mark character is not added physically by this |
524 |
* method, but its position is noted and will be used when generating |
525 |
* the <i>full</i> text. |
526 |
* |
527 |
* @param offset position of the character in the <i>lean</i> text. |
528 |
* It must be a non-negative number smaller than the length |
529 |
* of the <i>lean</i> text. |
530 |
* For the benefit of efficiency, it is better to insert |
531 |
* multiple marks in ascending order of the offsets.<br> |
532 |
* The {@link #BidiComplexHelper() no-op helper} does nothing. |
533 |
*/ |
534 |
public void insertMark(int offset) { |
535 |
if (impl != null) |
536 |
impl.insertMark(offset); |
537 |
} |
538 |
|
539 |
/** |
540 |
* This method can be called from within |
541 |
* {@link IBidiComplexProcessor#indexOfSpecial indexOfSpecial} or |
542 |
* {@link IBidiComplexProcessor#processSpecial processSpecial} in |
543 |
* implementations of {@link IBidiComplexProcessor} to add a |
544 |
* directional mark before an |
545 |
* operator if needed for correct display, depending on the |
546 |
* base direction of the expression and on the class of the |
547 |
* characters in the <i>lean</i> text preceding and following |
548 |
* the operator itself.<br> |
549 |
* The {@link #BidiComplexHelper() no-op helper} does nothing. |
550 |
* |
551 |
* @param operLocation offset of the operator in the <i>lean</i> text. |
552 |
* It must be a non-negative number smaller than the length |
553 |
* of the <i>lean</i> text. |
554 |
*/ |
555 |
public void processOperator(int operLocation) { |
556 |
if (impl != null) |
557 |
impl.processOperator(operLocation); |
558 |
} |
559 |
|
560 |
/** |
561 |
* This method can be called from within |
562 |
* {@link IBidiComplexProcessor#indexOfSpecial indexOfSpecial} or |
563 |
* {@link IBidiComplexProcessor#processSpecial processSpecial} in |
564 |
* implementations of {@link IBidiComplexProcessor} to |
565 |
* set the final state which should be used for the next call to |
566 |
* {@link #leanToFullText(java.lang.String, int)}.<br> |
567 |
* The {@link #BidiComplexHelper() no-op helper} does nothing. |
568 |
*/ |
569 |
public void setFinalState(int newState) { |
570 |
if (impl != null) |
571 |
impl.setFinalState(newState); |
572 |
} |
573 |
|
574 |
} |