diff options
author | Oleg Besedin | 2011-08-08 19:24:07 +0000 |
---|---|---|
committer | Oleg Besedin | 2011-08-08 19:24:07 +0000 |
commit | 92e3c75a04198d5378c67f9aa43647c0b53b7021 (patch) | |
tree | 389b91d64cc9c1c780246087d1fbb90605e5ac74 /bundles/org.eclipse.equinox.bidi | |
parent | fb18a7ec9257c1f083a24fe4478203166b0e595c (diff) | |
download | rt.equinox.bundles-92e3c75a04198d5378c67f9aa43647c0b53b7021.tar.gz rt.equinox.bundles-92e3c75a04198d5378c67f9aa43647c0b53b7021.tar.xz rt.equinox.bundles-92e3c75a04198d5378c67f9aa43647c0b53b7021.zip |
Bug 183164 - [Implementation for] Display of Complex Expressions
Containing Bidirectional Text
Diffstat (limited to 'bundles/org.eclipse.equinox.bidi')
24 files changed, 684 insertions, 505 deletions
diff --git a/bundles/org.eclipse.equinox.bidi/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.bidi/META-INF/MANIFEST.MF index 5a1e02e77..537b74a3c 100644 --- a/bundles/org.eclipse.equinox.bidi/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.equinox.bidi/META-INF/MANIFEST.MF @@ -8,6 +8,7 @@ Bundle-Localization: plugin Bundle-RequiredExecutionEnvironment: OSGi/Minimum-1.2 Bundle-ActivationPolicy: lazy Export-Package: org.eclipse.equinox.bidi, + org.eclipse.equinox.bidi.advanced, org.eclipse.equinox.bidi.custom, org.eclipse.equinox.bidi.internal;x-internal:=true, org.eclipse.equinox.bidi.internal.consumable;x-internal:=true diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/STextDirection.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/STextDirection.java new file mode 100644 index 000000000..fd3779264 --- /dev/null +++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/STextDirection.java @@ -0,0 +1,37 @@ +/*******************************************************************************
+ * Copyright (c) 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.equinox.bidi;
+
+import org.eclipse.equinox.bidi.advanced.STextEnvironment;
+
+public interface STextDirection {
+
+ /**
+ * Constant specifying that the base direction of a structured text is LTR.
+ * The base direction may depend on whether the GUI is
+ * {@link STextEnvironment#getMirrored mirrored} and may
+ * may be different for Arabic and for Hebrew.
+ * This constant can appear as value returned by the
+ * {@link #getCurDirection getCurDirection} method.
+ */
+ public int DIR_LTR = 0;
+
+ /**
+ * Constant specifying that the base direction of a structured text is RTL.
+ * The base direction may depend on whether the GUI is
+ * {@link STextEnvironment#getMirrored mirrored} and may
+ * may be different for Arabic and for Hebrew.
+ * This constant can appear as value returned by the
+ * {@link #getCurDirection getCurDirection} method.
+ */
+ public int DIR_RTL = 1;
+
+}
\ No newline at end of file diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/STextProcessorFactory.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/STextProcessorFactory.java index 5338c386e..1887b0876 100644 --- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/STextProcessorFactory.java +++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/STextProcessorFactory.java @@ -26,7 +26,7 @@ final public class STextProcessorFactory { * name=value * </pre> */ - public static final STextProcessor PROC_PROPERTY = getProcessor("property"); //$NON-NLS-1$ + public static final String PROPERTY = "property"; //$NON-NLS-1$ /** * Structured text processor for compound names. It expects text to be made of one or more @@ -35,7 +35,7 @@ final public class STextProcessorFactory { * part1_part2_part3 * </pre> */ - public static final STextProcessor PROC_UNDERSCORE = getProcessor("underscore"); //$NON-NLS-1$ + public static final String UNDERSCORE = "underscore"; //$NON-NLS-1$ /** * Structured text processor for comma-delimited lists, such as: @@ -43,7 +43,7 @@ final public class STextProcessorFactory { * part1,part2,part3 * </pre> */ - public static final STextProcessor PROC_COMMA_DELIMITED = getProcessor("comma"); //$NON-NLS-1$ + public static final String COMMA_DELIMITED = "comma"; //$NON-NLS-1$ /** * Structured text processor for strings with the following format: @@ -51,47 +51,47 @@ final public class STextProcessorFactory { * system(user) * </pre> */ - public static final STextProcessor PROC_SYSTEM_USER = getProcessor("system"); //$NON-NLS-1$ + public static final String SYSTEM_USER = "system"; //$NON-NLS-1$ /** * Structured text processor for directory and file paths. */ - public static final STextProcessor PROC_FILE = getProcessor("file"); //$NON-NLS-1$ + public static final String FILE = "file"; //$NON-NLS-1$ /** * Structured text processor for e-mail addresses. */ - public static final STextProcessor PROC_EMAIL = getProcessor("email"); //$NON-NLS-1$ + public static final String EMAIL = "email"; //$NON-NLS-1$ /** * Structured text processor for URLs. */ - public static final STextProcessor PROC_URL = getProcessor("url"); //$NON-NLS-1$ + public static final String URL = "url"; //$NON-NLS-1$ /** * Structured text processor for regular expressions, possibly spanning multiple lines. */ - public static final STextProcessor PROC_REGEXP = getProcessor("regex"); //$NON-NLS-1$ + public static final String REGEXP = "regex"; //$NON-NLS-1$ /** * Structured text processor for XPath expressions. */ - public static final STextProcessor PROC_XPATH = getProcessor("xpath"); //$NON-NLS-1$ + public static final String XPATH = "xpath"; //$NON-NLS-1$ /** * Structured text processor for Java code, possibly spanning multiple lines. */ - public static final STextProcessor PROC_JAVA = getProcessor("java"); //$NON-NLS-1$ + public static final String JAVA = "java"; //$NON-NLS-1$ /** * Structured text processor for SQL statements, possibly spanning multiple lines. */ - public static final STextProcessor PROC_SQL = getProcessor("sql"); //$NON-NLS-1$ + public static final String SQL = "sql"; //$NON-NLS-1$ /** * Structured text processor for arithmetic expressions, possibly with a RTL base direction. */ - public static final STextProcessor PROC_RTL_ARITHMETIC = getProcessor("math"); //$NON-NLS-1$ + public static final String RTL_ARITHMETIC = "math"; //$NON-NLS-1$ /** * Prevents instantiation @@ -117,7 +117,4 @@ final public class STextProcessorFactory { return STextTypesCollector.getInstance().getProcessor(id); } - static public STextProcessor getMultiProcessor(String id) { - return new STextProcessorMultipass(); - } } diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/STextProcessorMultipass.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/STextProcessorMultipass.java deleted file mode 100644 index 70c5abc54..000000000 --- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/STextProcessorMultipass.java +++ /dev/null @@ -1,48 +0,0 @@ -/*******************************************************************************
- * Copyright (c) 2011 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-package org.eclipse.equinox.bidi;
-
-import org.eclipse.equinox.bidi.custom.STextProcessor;
-import org.eclipse.equinox.bidi.internal.STextImpl;
-
-// TBD experimental
-public class STextProcessorMultipass extends STextProcessor {
-
- private int[] state = new int[] {0};
-
- public STextProcessorMultipass() {
-
- }
-
- public String leanToFullText(STextProcessor processor, STextEnvironment environment, String text) {
- return STextImpl.leanToFullText(processor, environment, text, state);
- }
-
- public int[] leanToFullMap(STextProcessor processor, STextEnvironment environment, String text) {
- return STextImpl.leanToFullMap(processor, environment, text, state);
- }
-
- public int[] leanBidiCharOffsets(STextProcessor processor, STextEnvironment environment, String text) {
- return STextImpl.leanBidiCharOffsets(processor, environment, text, state);
- }
-
- public String fullToLeanText(STextProcessor processor, STextEnvironment environment, String text) {
- return STextImpl.fullToLeanText(processor, environment, text, state);
- }
-
- public int[] fullToLeanMap(STextProcessor processor, STextEnvironment environment, String text) {
- return STextImpl.fullToLeanMap(processor, environment, text, state);
- }
-
- public int[] fullBidiCharOffsets(STextProcessor processor, STextEnvironment environment, String text) {
- return STextImpl.fullBidiCharOffsets(processor, environment, text, state);
- }
-}
diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/STextStringRecord.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/STextStringRecord.java index 6dfa2a182..f28bd6b83 100644 --- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/STextStringRecord.java +++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/STextStringRecord.java @@ -11,7 +11,6 @@ package org.eclipse.equinox.bidi; import java.lang.ref.SoftReference; -import org.eclipse.equinox.bidi.custom.STextProcessor; /** * This class records strings which contain structured text. Several static @@ -59,7 +58,7 @@ public class STextStringRecord { private String string; // reference to the processors of the STT segments in the recorded string - private STextProcessor[] processors; + private String[] processors; // reference to the boundaries of the STT segments in the recorded string // (entries 0, 2, 4, ... are start offsets; entries 1, 3, 5, ... are @@ -85,8 +84,7 @@ public class STextStringRecord { * * @param processor the processor appropriate to handle the type * of structured text present in the first segment. - * It may be one of the pre-defined processor instances - * appearing in {@link STextEngine}, or it may be an instance + * It may be one of the pre-defined processor instances, or it may be an instance * created by a plug-in or by the application. * * @param start offset in the string of the starting character of the first @@ -104,7 +102,7 @@ public class STextStringRecord { * if <code>segmentCount</code> is less than 1. * @throws also the same exceptions as {@link #addSegment addSegment}. */ - public static STextStringRecord addRecord(String string, int segmentCount, STextProcessor processor, int start, int limit) { + public static STextStringRecord addRecord(String string, int segmentCount, String processorID, int start, int limit) { if (string == null) throw new IllegalArgumentException("The string argument must not be null!"); //$NON-NLS-1$ if (segmentCount < 1) @@ -128,13 +126,13 @@ public class STextStringRecord { for (int i = 0; i < record.usedSegmentCount; i++) record.processors[i] = null; if (segmentCount > record.totalSegmentCount) { - record.processors = new STextProcessor[segmentCount]; + record.processors = new String[segmentCount]; record.boundaries = new short[segmentCount * 2]; record.totalSegmentCount = segmentCount; } record.usedSegmentCount = 0; record.string = string; - record.addSegment(processor, start, limit); + record.addSegment(processorID, start, limit); return record; } @@ -143,8 +141,7 @@ public class STextStringRecord { * * @param processor the processor appropriate to handle the type * of structured text present in this segment. - * It may be one of the pre-defined processor instances - * appearing in {@link STextEngine}, or it may be an instance + * It may be one of the pre-defined processor instances, or it may be an instance * created by a plug-in or by the application. * * @param start offset in the string of the starting character of the @@ -162,8 +159,8 @@ public class STextStringRecord { * in the call to {@link #addRecord addRecord} which created * the STextStringRecord instance. */ - public void addSegment(STextProcessor processor, int start, int limit) { - if (processor == null) + public void addSegment(String processorID, int start, int limit) { + if (processorID == null) throw new IllegalArgumentException("The processor argument must not be null!"); //$NON-NLS-1$ if (start < 0 || start >= string.length()) throw new IllegalArgumentException("The start position must be at least 0 and less than the length of the string!"); //$NON-NLS-1$ @@ -171,7 +168,7 @@ public class STextStringRecord { throw new IllegalArgumentException("The limit position must be greater than the start position but no greater than the length of the string!"); //$NON-NLS-1$ if (usedSegmentCount >= totalSegmentCount) throw new IllegalStateException("All segments of the record are already used!"); //$NON-NLS-1$ - processors[usedSegmentCount] = processor; + processors[usedSegmentCount] = processorID; boundaries[usedSegmentCount * 2] = (short) start; boundaries[usedSegmentCount * 2 + 1] = (short) limit; usedSegmentCount++; @@ -255,7 +252,7 @@ public class STextStringRecord { * * @see #getSegmentCount */ - public STextProcessor getProcessor(int segmentNumber) { + public String getProcessor(int segmentNumber) { checkSegmentNumber(segmentNumber); return processors[segmentNumber]; } diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/STextUtil.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/STextUtil.java index 32c485923..c77d70ff6 100644 --- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/STextUtil.java +++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/STextUtil.java @@ -10,6 +10,7 @@ ******************************************************************************/ package org.eclipse.equinox.bidi; +import org.eclipse.equinox.bidi.advanced.*; import org.eclipse.equinox.bidi.custom.STextProcessor; /** @@ -61,7 +62,7 @@ public final class STextUtil { * If necessary, leading and trailing directional markers (LRE, RLE and PDF) can * be added depending on the value of the <code>affix</code> argument. * </p> - * @see STextEngine#leanBidiCharOffsets(STextProcessor, STextEnvironment, String, int[]) + * @see STextProcessorNew#leanBidiCharOffsets(String) * * @param text the structured text string * @param offsets an array of offsets to characters in <code>text</code> @@ -69,8 +70,8 @@ public final class STextUtil { * The array must be sorted in ascending order without duplicates. * This argument may be <code>null</code> if there are no marks to add. * @param direction the base direction of the structured text. - * It must be one of the values {@link STextEngine#DIR_LTR}, or - * {@link STextEngine#DIR_RTL}. + * It must be one of the values {@link STextDirection#DIR_LTR}, or + * {@link STextDirection#DIR_RTL}. * @param affix specifies if a prefix and a suffix should be added to * the result * @return a string corresponding to the source <code>text</code> with @@ -86,7 +87,7 @@ public final class STextUtil { String curPrefix, curSuffix, full; char curMark, c; char[] fullChars; - if (direction == STextEngine.DIR_LTR) { + if (direction == STextDirection.DIR_LTR) { curMark = LRM; curPrefix = "\u202a\u200e"; /* LRE+LRM *///$NON-NLS-1$ curSuffix = "\u200e\u202c"; /* LRM+PDF *///$NON-NLS-1$ @@ -188,7 +189,8 @@ public final class STextUtil { // make sure that LRE/PDF are added around the string STextProcessor processor = new STextProcessor(separators); - return STextEngine.leanToFullText(processor, env, str, null); + STextProcessorNew processorNew = STextProcessorFactoryNew.getProcessor(processor, env); + return processorNew.leanToFullText(str); } /** @@ -212,7 +214,8 @@ public final class STextUtil { STextEnvironment env = new STextEnvironment(null, false, STextEnvironment.ORIENT_UNKNOWN); if (!env.isProcessingNeeded()) return str; - return STextEngine.leanToFullText(processor, env, str, null); + STextProcessorNew processorNew = STextProcessorFactoryNew.getProcessor(processor, env); + return processorNew.leanToFullText(str); } /** @@ -259,7 +262,8 @@ public final class STextUtil { STextEnvironment env = new STextEnvironment(null, false, STextEnvironment.ORIENT_UNKNOWN); if (!env.isProcessingNeeded()) return str; - return STextEngine.fullToLeanText(processor, env, str, null); + STextProcessorNew processorNew = STextProcessorFactoryNew.getProcessor(processor, env); + return processorNew.fullToLeanText(str); } } diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/STextEnvironment.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/advanced/STextEnvironment.java index 0755826a7..fc0372ba4 100644 --- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/STextEnvironment.java +++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/advanced/STextEnvironment.java @@ -8,7 +8,7 @@ * Contributors: * IBM Corporation - initial API and implementation ******************************************************************************/ -package org.eclipse.equinox.bidi; +package org.eclipse.equinox.bidi.advanced; import org.eclipse.equinox.bidi.internal.STextActivator; @@ -178,4 +178,40 @@ public class STextEnvironment { } return processingNeeded.booleanValue(); } + + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((language == null) ? 0 : language.hashCode()); + result = prime * result + (mirrored ? 1231 : 1237); + result = prime * result + orientation; + result = prime * result + ((processingNeeded == null) ? 0 : processingNeeded.hashCode()); + return result; + } + + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + STextEnvironment other = (STextEnvironment) obj; + if (language == null) { + if (other.language != null) + return false; + } else if (!language.equals(other.language)) + return false; + if (mirrored != other.mirrored) + return false; + if (orientation != other.orientation) + return false; + if (processingNeeded == null) { + if (other.processingNeeded != null) + return false; + } else if (!processingNeeded.equals(other.processingNeeded)) + return false; + return true; + } + } diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/advanced/STextProcessorFactoryNew.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/advanced/STextProcessorFactoryNew.java new file mode 100644 index 000000000..0389dd8d8 --- /dev/null +++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/advanced/STextProcessorFactoryNew.java @@ -0,0 +1,90 @@ +/*******************************************************************************
+ * Copyright (c) 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.equinox.bidi.advanced;
+
+import java.util.HashMap;
+import java.util.Map;
+import org.eclipse.equinox.bidi.STextProcessorFactory;
+import org.eclipse.equinox.bidi.custom.STextProcessor;
+import org.eclipse.equinox.bidi.internal.STextProcessorImplNew;
+import org.eclipse.equinox.bidi.internal.STextProcessorMultipassImplNew;
+
+final public class STextProcessorFactoryNew {
+
+ /**
+ * The default set of separators used to segment a string: dot, colon, slash, backslash.
+ */
+ private static final String defaultSeparators = ".:/\\"; //$NON-NLS-1$
+
+ static private Map sharedDefaultProcessors = new HashMap(); // String id -> processor
+
+ static private Map sharedProcessors = new HashMap(); // String id -> map { environment -> processor }
+
+ static private STextProcessorNew defaultProcessor;
+
+ private STextProcessorFactoryNew() {
+ // prevents instantiation
+ }
+
+ static public STextProcessorNew getProcessor() {
+ if (defaultProcessor == null) {
+ STextProcessor descriptor = new STextProcessor(defaultSeparators);
+ defaultProcessor = new STextProcessorImplNew(descriptor, STextEnvironment.DEFAULT);
+ }
+ return defaultProcessor;
+ }
+
+ static public STextProcessorNew getProcessor(String type) {
+ STextProcessorNew processor;
+ synchronized (sharedDefaultProcessors) {
+ processor = (STextProcessorNew) sharedDefaultProcessors.get(type);
+ if (processor == null) {
+ STextProcessor descriptor = STextProcessorFactory.getProcessor(type);
+ processor = new STextProcessorImplNew(descriptor, STextEnvironment.DEFAULT);
+ sharedDefaultProcessors.put(type, processor);
+ }
+ }
+ return processor;
+ }
+
+ static public STextProcessorNew getProcessor(String type, STextEnvironment environment) {
+ STextProcessorNew processor;
+ synchronized (sharedProcessors) {
+ Map processors = (Map) sharedProcessors.get(type);
+ if (processors == null) {
+ processors = new HashMap(); // environment -> processor
+ sharedProcessors.put(type, processors);
+ }
+ processor = (STextProcessorNew) processors.get(environment);
+ if (processor == null) {
+ STextProcessor descriptor = STextProcessorFactory.getProcessor(type);
+ processor = new STextProcessorImplNew(descriptor, environment);
+ processors.put(type, processor);
+ }
+ }
+ return processor;
+ }
+
+ // TBD could this be removed?
+ static public STextProcessorNew getProcessor(STextProcessor descriptor, STextEnvironment environment) {
+ return new STextProcessorImplNew(descriptor, environment);
+ }
+
+ static public STextProcessorMultipassNew getMultipassProcessor(String type) {
+ return getMultipassProcessor(type, STextEnvironment.DEFAULT);
+ }
+
+ static public STextProcessorMultipassNew getMultipassProcessor(String type, STextEnvironment environment) {
+ STextProcessor descriptor = STextProcessorFactory.getProcessor(type);
+ return new STextProcessorMultipassImplNew(descriptor, environment);
+ }
+
+}
diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/advanced/STextProcessorMultipassNew.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/advanced/STextProcessorMultipassNew.java new file mode 100644 index 000000000..7314de8a0 --- /dev/null +++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/advanced/STextProcessorMultipassNew.java @@ -0,0 +1,20 @@ +/*******************************************************************************
+ * Copyright (c) 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.equinox.bidi.advanced;
+
+public interface STextProcessorMultipassNew extends STextProcessorNew {
+
+ /**
+ * Resets non-shared processor state to initial.
+ */
+ public void reset();
+
+}
diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/STextEngine.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/advanced/STextProcessorNew.java index 0bc00210f..63a378af8 100644 --- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/STextEngine.java +++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/advanced/STextProcessorNew.java @@ -1,318 +1,262 @@ -/******************************************************************************* - * Copyright (c) 2010, 2011 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - ******************************************************************************/ -package org.eclipse.equinox.bidi; - -import org.eclipse.equinox.bidi.custom.STextProcessor; -import org.eclipse.equinox.bidi.internal.STextImpl; - -/** - * For a general introduction to structured text, see - * {@link <a href="package-summary.html"> the package documentation</a>}. - * <p> - * Several common processors are included in <b>STextEngine</b>. For processors - * supplied by other packages, a processor instance can be obtained using the - * {@link org.eclipse.equinox.bidi.STextProcessorFactory#getProcessor} - * method for the registered processors, or by instantiating a private processor. - * </p><p> - * Most of the methods in this class have a <code>text</code> - * argument which may be just a part of a larger body of text. - * When it is the case that the text is submitted in parts with - * repeated calls, there may be a need to pass information from - * one invocation to the next one. For instance, one invocation - * may detect that a comment or a literal has been started but - * has not been completed. In such cases, a <code>state</code> - * argument must be used. - * </p><p> - * The <code>state</code> argument must be an array of integers - * with at least one element. Only the first element is used by - * the methods of this class. - * </p><p> - * When submitting the initial part of the text, the first element - * of <code>state</code> must contain the value {@link #STATE_INITIAL} - * or any value <= 0. - * </p><p> - * After calling a method with a non-null <code>state</code> argument, - * a value is returned in the first element of <code>state</code>. This - * value should be passed unmodified to the method when calling it again - * with the text which is the continuation of the text submitted in the - * last call. - * </p><p> - * When the text submitted to a method is not a continuation and is not - * expected to have a continuation , e.g. it is processed all by itself, - * the <code>state</code> argument should be specified as <code>null</code>. - * </p><p> - * <b>Code Samples</b> - * </p><p> - * The following code shows how to transform a certain type of structured text - * (directory and file paths) in order to obtain the <i>full</i> - * text corresponding to the given <i>lean</i> text. - * <pre> - * String leanText = "D:\\\u05d0\u05d1\\\u05d2\\\u05d3.ext"; - * String fullText = STextEngine.leanToFullText(STextEngine.PROC_FILE, null, leanText, null); - * System.out.println("full text = " + fullText); - * </pre> - * </p><p> - * The following code shows how to transform successive lines of Java - * code in order to obtain the <i>full</i> - * text corresponding to the <i>lean</i> text of each line. - * <pre> - * int[] state = new int[1]; - * state[0] = STextEngine.STATE_INITIAL; - * String leanText = "int i = 3; // first Java statement"; - * String fullText = STextEngine.leanToFullText(STextEngine.PROC_JAVA, null, leanText, state); - * System.out.println("full text = " + fullText); - * leanText = "i += 4; // next Java statement"; - * fullText = STextEngine.leanToFullText(STextEngine.PROC_JAVA, null, leanText, state); - * System.out.println("full text = " + fullText); - * </pre> - * </p> - * @author Matitiahu Allouche - * - */ -public class STextEngine { - - /** - * Constant specifying that the base direction of a structured text is LTR. - * The base direction may depend on whether the GUI is - * {@link STextEnvironment#getMirrored mirrored} and may - * may be different for Arabic and for Hebrew. - * This constant can appear as value returned by the - * {@link #getCurDirection getCurDirection} method. - */ - public static final int DIR_LTR = 0; - - /** - * Constant specifying that the base direction of a structured text is RTL. - * The base direction may depend on whether the GUI is - * {@link STextEnvironment#getMirrored mirrored} and may - * may be different for Arabic and for Hebrew. - * This constant can appear as value returned by the - * {@link #getCurDirection getCurDirection} method. - */ - public static final int DIR_RTL = 1; - - /** - * Constant to use in the first element of the <code>state</code> - * argument when calling most methods of this class - * to indicate that there is no context of previous lines which - * should be initialized before performing the operation. - */ - public static final int STATE_INITIAL = 0; - - private static final int[] EMPTY_INT_ARRAY = new int[0]; - - /** - * Prevent creation of a STextEngine instance - */ - private STextEngine() { - // nothing to do - } - - /** - * Add directional formatting characters to a structured text - * to ensure correct presentation. - * - * @param processor the processor applicable to the text. If <code>null</code>, - * the method returns unmodified text. - * - * @param environment a bidi environment. If <code>null</code>, the default environment - * is used. - * - * @param text is the structured text string - * - * @param state can be used to specify that the <code>text</code> argument is - * the continuation of text submitted in a previous call and/or to receive information - * to pass to continuation calls. If all calls to this method are independent from one another, - * this argument should be specified as <code>null</code>. - * - * @return the structured text with directional formatting characters added to ensure - * correct presentation. - */ - public static String leanToFullText(STextProcessor processor, STextEnvironment environment, String text, int[] state) { - if (processor == null) - return text; - return STextImpl.leanToFullText(processor, environment, text, state); - } - - /** - * Given a <i>lean</i> string, compute the positions of each of its - * characters within the corresponding <i>full</i> string. - * - * @param processor designates a processor instance. If <code>null</code>, this - * method returns an identity map. - * - * @param environment specifies an environment whose characteristics may affect - * the processor's behavior. If <code>null</code>, the default environment is used. - * - * @param text is the structured text string. - * - * @param state can be used to specify that the <code>text</code> argument is - * the continuation of text submitted in a previous call and/or to receive information - * to pass to continuation calls. If all calls to this method are independent from one another, - * this argument should be specified as <code>null</code>. - * - * @return an array which specifies offsets of the <code>text</code> characters - * in the <i>full</i> string - */ - public static int[] leanToFullMap(STextProcessor processor, STextEnvironment environment, String text, int[] state) { - if (processor == null) { - int[] map = new int[text.length()]; - for (int i = 0; i < map.length; i++) - map[i] = i; - return map; - } - return STextImpl.leanToFullMap(processor, environment, text, state); - } - - /** - * Given a <i>lean</i> string, compute the offsets of characters - * before which directional formatting characters must be added - * in order to ensure correct presentation. - * <p> - * Only LRMs (for a string with LTR base direction) and RLMs (for - * a string with RTL base direction) are considered. Leading and - * trailing LRE, RLE and PDF which might be prefixed or suffixed - * depending on the {@link STextEnvironment#getOrientation orientation} of the - * GUI component used for display are not reflected in this method. - * </p> - * @param processor designates a processor instance - * - * @param environment specifies an environment whose characteristics may affect - * the processor's behavior. If <code>null</code>, the default environment is used. - * - * @param text is the structured text string - * - * @param state can be used to specify that the <code>text</code> argument is - * the continuation of text submitted in a previous call and/or to receive information - * to pass to continuation calls. If all calls to this method are independent from one another, - * this argument should be specified as <code>null</code>. - * - * @return an array of offsets to the characters in the <code>text</code> argument - * before which directional marks must be added to ensure correct presentation. - * The offsets are sorted in ascending order. - */ - public static int[] leanBidiCharOffsets(STextProcessor processor, STextEnvironment environment, String text, int[] state) { - if (processor == null) - return EMPTY_INT_ARRAY; - return STextImpl.leanBidiCharOffsets(processor, environment, text, state); - } - - /** - * Remove directional formatting characters which were added to a - * structured text string to ensure correct presentation. - * - * @param processor designates a processor instance - * - * @param environment specifies an environment whose characteristics may affect - * the processor's behavior. If <code>null</code>, the default environment is used. - * - * @param text is the structured text string including directional formatting characters. - * - * @param state can be used to specify that the <code>text</code> argument is - * the continuation of text submitted in a previous call and/or to receive information - * to pass to continuation calls. If all calls to this method are independent from one another, - * this argument should be specified as <code>null</code>. - * - * @return the structured text string without directional formatting characters - * which might have been added by processing it with {@link #leanToFullText}. - * - */ - public static String fullToLeanText(STextProcessor processor, STextEnvironment environment, String text, int[] state) { - if (processor == null) - return text; - return STextImpl.fullToLeanText(processor, environment, text, state); - } - - /** - * Given a <i>full</i> string, compute the positions of each of its - * characters within the corresponding <i>lean</i> string. - * - * @param processor designates a processor instance - * - * @param environment specifies an environment whose characteristics may affect - * the processor's behavior. If <code>null</code>, the default environment is used. - * - * @param text is the structured text string including directional formatting characters. - * - * @param state can be used to specify that the <code>text</code> argument is - * the continuation of text submitted in a previous call and/or to receive information - * to pass to continuation calls. If all calls to this method are independent from one another, - * this argument should be specified as <code>null</code>. - * - * @return an array of integers with one element for each of the characters - * in the <code>text</code> argument, equal to the offset of the corresponding character - * in the <i>lean</i> string. If there is no corresponding character in the <i>lean</i> string - * (because the specified character is a directional formatting character added when invoking - * {@link #leanToFullText}), the value returned for this character is -1. - */ - public static int[] fullToLeanMap(STextProcessor processor, STextEnvironment environment, String text, int[] state) { - if (processor == null) { - int[] map = new int[text.length()]; - for (int i = 0; i < map.length; i++) - map[i] = i; - return map; - } - return STextImpl.fullToLeanMap(processor, environment, text, state); - } - - /** - * Given a <i>full</i> string, return the offsets of characters - * which are directional formatting characters that have been added - * in order to ensure correct presentation. - * <p> - * LRMs (for a string with LTR base direction), RLMs (for a string with RTL base direction) - * are considered as well as leading and trailing LRE, RLE and PDF which might be prefixed - * or suffixed depending on the {@link STextEnvironment#getOrientation orientation} - * of the GUI component used for display. - * </p> - * @param processor designates a processor instance - * - * @param environment specifies an environment whose characteristics may affect - * the processor's behavior. If <code>null</code>, the default environment is used. - * - * @param text is the structured text string including directional formatting characters - * - * @param state can be used to specify that the <code>text</code> argument is - * the continuation of text submitted in a previous call and/or to receive information - * to pass to continuation calls. If all calls to this method are independent from one another, - * this argument should be specified as <code>null</code>. - * - * @return an array of offsets to the characters in the <code>text</code> argument which - * are directional formatting characters added to ensure correct presentation. The offsets - * are sorted in ascending order. - */ - public static int[] fullBidiCharOffsets(STextProcessor processor, STextEnvironment environment, String text, int[] state) { - if (processor == null) - return EMPTY_INT_ARRAY; - return STextImpl.fullBidiCharOffsets(processor, environment, text, state); - } - - /** - * Get the base direction of a structured text. This base direction may depend on - * whether the text contains Arabic or Hebrew words. If the text contains both, - * the first Arabic or Hebrew letter in the text determines which is the governing script. - * - * @param processor designates a processor instance - * - * @param environment specifies an environment whose characteristics may affect - * the processor's behavior. If <code>null</code>, the default environment is used. - * - * @param text is the structured text string - * - * @return the base direction of the structured text, {@link #DIR_LTR} or {@link #DIR_RTL} - */ - public static int getCurDirection(STextProcessor processor, STextEnvironment environment, String text) { - if (processor == null) - return DIR_LTR; - return processor.getDirection(environment, text); - } - -} +/*******************************************************************************
+ * Copyright (c) 2010, 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.equinox.bidi.advanced;
+
+/**
+ * For a general introduction to structured text, see
+ * {@link <a href="package-summary.html"> the package documentation</a>}.
+ * <p>
+ * Several common processors are included in <b>STextEngine</b>. For processors
+ * supplied by other packages, a processor instance can be obtained using the
+ * {@link org.eclipse.equinox.bidi.STextProcessorFactory#getProcessor}
+ * method for the registered processors, or by instantiating a private processor.
+ * </p><p>
+ * Most of the methods in this class have a <code>text</code>
+ * argument which may be just a part of a larger body of text.
+ * When it is the case that the text is submitted in parts with
+ * repeated calls, there may be a need to pass information from
+ * one invocation to the next one. For instance, one invocation
+ * may detect that a comment or a literal has been started but
+ * has not been completed. In such cases, a <code>state</code>
+ * argument must be used.
+ * </p><p>
+ * The <code>state</code> argument must be an array of integers
+ * with at least one element. Only the first element is used by
+ * the methods of this class.
+ * </p><p>
+ * When submitting the initial part of the text, the first element
+ * of <code>state</code> must contain the value {@link #STATE_INITIAL}
+ * or any value <= 0.
+ * </p><p>
+ * After calling a method with a non-null <code>state</code> argument,
+ * a value is returned in the first element of <code>state</code>. This
+ * value should be passed unmodified to the method when calling it again
+ * with the text which is the continuation of the text submitted in the
+ * last call.
+ * </p><p>
+ * When the text submitted to a method is not a continuation and is not
+ * expected to have a continuation , e.g. it is processed all by itself,
+ * the <code>state</code> argument should be specified as <code>null</code>.
+ * </p><p>
+ * <b>Code Samples</b>
+ * </p><p>
+ * The following code shows how to transform a certain type of structured text
+ * (directory and file paths) in order to obtain the <i>full</i>
+ * text corresponding to the given <i>lean</i> text.
+ * <pre>
+ * String leanText = "D:\\\u05d0\u05d1\\\u05d2\\\u05d3.ext";
+ * String fullText = STextEngine.leanToFullText(STextEngine.PROC_FILE, null, leanText, null);
+ * System.out.println("full text = " + fullText);
+ * </pre>
+ * </p><p>
+ * The following code shows how to transform successive lines of Java
+ * code in order to obtain the <i>full</i>
+ * text corresponding to the <i>lean</i> text of each line.
+ * <pre>
+ * int[] state = new int[1];
+ * state[0] = STextEngine.STATE_INITIAL;
+ * String leanText = "int i = 3; // first Java statement";
+ * String fullText = STextEngine.leanToFullText(STextEngine.PROC_JAVA, null, leanText, state);
+ * System.out.println("full text = " + fullText);
+ * leanText = "i += 4; // next Java statement";
+ * fullText = STextEngine.leanToFullText(STextEngine.PROC_JAVA, null, leanText, state);
+ * System.out.println("full text = " + fullText);
+ * </pre>
+ * </p>
+ * @author Matitiahu Allouche
+ *
+ */
+public interface STextProcessorNew {
+
+ /**
+ * Constant specifying that the base direction of a structured text is LTR.
+ * The base direction may depend on whether the GUI is
+ * {@link STextEnvironment#getMirrored mirrored} and may
+ * may be different for Arabic and for Hebrew.
+ * This constant can appear as value returned by the
+ * {@link #getCurDirection getCurDirection} method.
+ */
+ public static final int DIR_LTR = 0;
+
+ /**
+ * Constant specifying that the base direction of a structured text is RTL.
+ * The base direction may depend on whether the GUI is
+ * {@link STextEnvironment#getMirrored mirrored} and may
+ * may be different for Arabic and for Hebrew.
+ * This constant can appear as value returned by the
+ * {@link #getCurDirection getCurDirection} method.
+ */
+ public static final int DIR_RTL = 1;
+
+ /**
+ * Add directional formatting characters to a structured text
+ * to ensure correct presentation.
+ *
+ * @param processor the processor applicable to the text. If <code>null</code>,
+ * the method returns unmodified text.
+ *
+ * @param environment a bidi environment. If <code>null</code>, the default environment
+ * is used.
+ *
+ * @param text is the structured text string
+ *
+ * @param state can be used to specify that the <code>text</code> argument is
+ * the continuation of text submitted in a previous call and/or to receive information
+ * to pass to continuation calls. If all calls to this method are independent from one another,
+ * this argument should be specified as <code>null</code>.
+ *
+ * @return the structured text with directional formatting characters added to ensure
+ * correct presentation.
+ */
+ public String leanToFullText(String text);
+
+ /**
+ * Given a <i>lean</i> string, compute the positions of each of its
+ * characters within the corresponding <i>full</i> string.
+ *
+ * @param processor designates a processor instance. If <code>null</code>, this
+ * method returns an identity map.
+ *
+ * @param environment specifies an environment whose characteristics may affect
+ * the processor's behavior. If <code>null</code>, the default environment is used.
+ *
+ * @param text is the structured text string.
+ *
+ * @param state can be used to specify that the <code>text</code> argument is
+ * the continuation of text submitted in a previous call and/or to receive information
+ * to pass to continuation calls. If all calls to this method are independent from one another,
+ * this argument should be specified as <code>null</code>.
+ *
+ * @return an array which specifies offsets of the <code>text</code> characters
+ * in the <i>full</i> string
+ */
+ public int[] leanToFullMap(String text);
+
+ /**
+ * Given a <i>lean</i> string, compute the offsets of characters
+ * before which directional formatting characters must be added
+ * in order to ensure correct presentation.
+ * <p>
+ * Only LRMs (for a string with LTR base direction) and RLMs (for
+ * a string with RTL base direction) are considered. Leading and
+ * trailing LRE, RLE and PDF which might be prefixed or suffixed
+ * depending on the {@link STextEnvironment#getOrientation orientation} of the
+ * GUI component used for display are not reflected in this method.
+ * </p>
+ * @param processor designates a processor instance
+ *
+ * @param environment specifies an environment whose characteristics may affect
+ * the processor's behavior. If <code>null</code>, the default environment is used.
+ *
+ * @param text is the structured text string
+ *
+ * @param state can be used to specify that the <code>text</code> argument is
+ * the continuation of text submitted in a previous call and/or to receive information
+ * to pass to continuation calls. If all calls to this method are independent from one another,
+ * this argument should be specified as <code>null</code>.
+ *
+ * @return an array of offsets to the characters in the <code>text</code> argument
+ * before which directional marks must be added to ensure correct presentation.
+ * The offsets are sorted in ascending order.
+ */
+ public int[] leanBidiCharOffsets(String text);
+
+ /**
+ * Remove directional formatting characters which were added to a
+ * structured text string to ensure correct presentation.
+ *
+ * @param processor designates a processor instance
+ *
+ * @param environment specifies an environment whose characteristics may affect
+ * the processor's behavior. If <code>null</code>, the default environment is used.
+ *
+ * @param text is the structured text string including directional formatting characters.
+ *
+ * @param state can be used to specify that the <code>text</code> argument is
+ * the continuation of text submitted in a previous call and/or to receive information
+ * to pass to continuation calls. If all calls to this method are independent from one another,
+ * this argument should be specified as <code>null</code>.
+ *
+ * @return the structured text string without directional formatting characters
+ * which might have been added by processing it with {@link #leanToFullText}.
+ *
+ */
+ public String fullToLeanText(String text);
+
+ /**
+ * Given a <i>full</i> string, compute the positions of each of its
+ * characters within the corresponding <i>lean</i> string.
+ *
+ * @param processor designates a processor instance
+ *
+ * @param environment specifies an environment whose characteristics may affect
+ * the processor's behavior. If <code>null</code>, the default environment is used.
+ *
+ * @param text is the structured text string including directional formatting characters.
+ *
+ * @param state can be used to specify that the <code>text</code> argument is
+ * the continuation of text submitted in a previous call and/or to receive information
+ * to pass to continuation calls. If all calls to this method are independent from one another,
+ * this argument should be specified as <code>null</code>.
+ *
+ * @return an array of integers with one element for each of the characters
+ * in the <code>text</code> argument, equal to the offset of the corresponding character
+ * in the <i>lean</i> string. If there is no corresponding character in the <i>lean</i> string
+ * (because the specified character is a directional formatting character added when invoking
+ * {@link #leanToFullText}), the value returned for this character is -1.
+ */
+ public int[] fullToLeanMap(String text);
+
+ /**
+ * Given a <i>full</i> string, return the offsets of characters
+ * which are directional formatting characters that have been added
+ * in order to ensure correct presentation.
+ * <p>
+ * LRMs (for a string with LTR base direction), RLMs (for a string with RTL base direction)
+ * are considered as well as leading and trailing LRE, RLE and PDF which might be prefixed
+ * or suffixed depending on the {@link STextEnvironment#getOrientation orientation}
+ * of the GUI component used for display.
+ * </p>
+ * @param processor designates a processor instance
+ *
+ * @param environment specifies an environment whose characteristics may affect
+ * the processor's behavior. If <code>null</code>, the default environment is used.
+ *
+ * @param text is the structured text string including directional formatting characters
+ *
+ * @param state can be used to specify that the <code>text</code> argument is
+ * the continuation of text submitted in a previous call and/or to receive information
+ * to pass to continuation calls. If all calls to this method are independent from one another,
+ * this argument should be specified as <code>null</code>.
+ *
+ * @return an array of offsets to the characters in the <code>text</code> argument which
+ * are directional formatting characters added to ensure correct presentation. The offsets
+ * are sorted in ascending order.
+ */
+ public int[] fullBidiCharOffsets(String text);
+
+ /**
+ * Get the base direction of a structured text. This base direction may depend on
+ * whether the text contains Arabic or Hebrew words. If the text contains both,
+ * the first Arabic or Hebrew letter in the text determines which is the governing script.
+ *
+ * @param processor designates a processor instance
+ *
+ * @param environment specifies an environment whose characteristics may affect
+ * the processor's behavior. If <code>null</code>, the default environment is used.
+ *
+ * @param text is the structured text string
+ *
+ * @return the base direction of the structured text, {@link #DIR_LTR} or {@link #DIR_RTL}
+ */
+ public int getCurDirection(String text);
+
+}
diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/custom/STextCharTypes.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/custom/STextCharTypes.java index c2ce57f5f..f74bd7b57 100644 --- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/custom/STextCharTypes.java +++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/custom/STextCharTypes.java @@ -10,7 +10,7 @@ ******************************************************************************/
package org.eclipse.equinox.bidi.custom;
-import org.eclipse.equinox.bidi.STextEnvironment;
+import org.eclipse.equinox.bidi.advanced.STextEnvironment;
/**
* The class determines bidirectional types of characters in a string.
diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/custom/STextProcessor.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/custom/STextProcessor.java index 7f37bb906..7b183c853 100644 --- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/custom/STextProcessor.java +++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/custom/STextProcessor.java @@ -10,8 +10,9 @@ ******************************************************************************/ package org.eclipse.equinox.bidi.custom; -import org.eclipse.equinox.bidi.STextEngine; -import org.eclipse.equinox.bidi.STextEnvironment; +import org.eclipse.equinox.bidi.STextDirection; +import org.eclipse.equinox.bidi.advanced.STextEnvironment; +import org.eclipse.equinox.bidi.advanced.STextProcessorNew; import org.eclipse.equinox.bidi.internal.STextImpl; /** @@ -23,11 +24,7 @@ import org.eclipse.equinox.bidi.internal.STextImpl; * <ul> * <li>Processor instances may be accessed simultaneously by * several threads. They should have no instance variables.</li> - * <li>All the user methods in {@link STextEngine} implement a logic - * common to all processors, located in {@link STextImpl}. - * These methods all have a first argument which is a processor - * instance. - * The common logic uses processor methods to query the + * <li>The common logic uses processor methods to query the * characteristics of the specific processor: * <ul> * <li>the separators which separate the structured text into @@ -57,7 +54,6 @@ import org.eclipse.equinox.bidi.internal.STextImpl; * conditionally (by calling {@link #processSeparator processSeparator}).</li> * </ul> * - * @see STextEngine * @author Matitiahu Allouche */ public class STextProcessor { @@ -83,8 +79,7 @@ public class STextProcessor { * Locate occurrences of special strings within a structured text * and return their indexes one after the other in successive calls. * <p> - * This method is called repeatedly from the code implementing - * {@link STextEngine#leanToFullText} if the number of special cases + * This method is called repeatedly if the number of special cases * returned by {@link #getSpecialsCount} is greater than zero. * </p><p> * A processor handling special cases must override this method. @@ -139,7 +134,7 @@ public class STextProcessor { /** * This method handles special cases specific to this processor. - * It is called by {@link STextEngine#leanToFullText} when a special case occurrence + * It is called when a special case occurrence * is located by {@link #indexOfSpecial}. * <p> * If a special processing cannot be completed within a current call to @@ -149,8 +144,7 @@ public class STextProcessor { * putting its value in the first element of the <code>state</code> * parameter. * The meaning of this state is internal to the processor. - * On a later call to {@link STextEngine#leanToFullText} specifying that - * state value, <code>processSpecial</code> will be called with that value + * On a later call, <code>processSpecial</code> will be called with that value * for parameter <code>caseNumber</code> and <code>-1</code> for parameter * <code>separLocation</code> and should perform whatever initializations are required * depending on the state. @@ -195,8 +189,8 @@ public class STextProcessor { * * @param separLocation the position returned by * {@link #indexOfSpecial indexOfSpecial}. In calls to - * {@link STextEngine#leanToFullText leanToFullText} and other - * methods of {@link STextEngine} specifying a non-null + * {@link STextProcessorNew#leanToFullText leanToFullText} and other + * methods of {@link STextProcessorNew} specifying a non-null * <code>state</code> parameter, <code>processSpecial</code> is * called when initializing the processing with the value of * <code>caseNumber</code> equal to the value returned in the @@ -329,10 +323,10 @@ public class STextProcessor { * whether the structured text contains Arabic or Hebrew * letters.<br> * The value returned is either - * {@link STextEngine#DIR_LTR DIR_LTR} or {@link STextEngine#DIR_RTL DIR_RTL}. + * {@link STextDirection#DIR_LTR DIR_LTR} or {@link STextDirection#DIR_RTL DIR_RTL}. */ public int getDirection(STextEnvironment environment, String text) { - return STextEngine.DIR_LTR; + return STextDirection.DIR_LTR; } /** @@ -358,10 +352,10 @@ public class STextProcessor { * whether the structured text contains Arabic or Hebrew * letters.<br> * The value returned is either - * {@link STextEngine#DIR_LTR DIR_LTR} or {@link STextEngine#DIR_RTL DIR_RTL}. + * {@link STextDirection#DIR_LTR DIR_LTR} or {@link STextDirection#DIR_RTL DIR_RTL}. */ public int getDirection(STextEnvironment environment, String text, STextCharTypes charTypes) { - return STextEngine.DIR_LTR; + return STextDirection.DIR_LTR; } /** diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextDelims.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextDelims.java index 07682a39a..110bcc46f 100644 --- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextDelims.java +++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextDelims.java @@ -10,7 +10,8 @@ ******************************************************************************/ package org.eclipse.equinox.bidi.internal; -import org.eclipse.equinox.bidi.STextEnvironment; +import org.eclipse.equinox.bidi.advanced.STextEnvironment; + import org.eclipse.equinox.bidi.custom.*; /** diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextDelimsEsc.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextDelimsEsc.java index 60eb1e4c0..37d521738 100644 --- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextDelimsEsc.java +++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextDelimsEsc.java @@ -10,7 +10,8 @@ ******************************************************************************/ package org.eclipse.equinox.bidi.internal; -import org.eclipse.equinox.bidi.STextEnvironment; +import org.eclipse.equinox.bidi.advanced.STextEnvironment; + import org.eclipse.equinox.bidi.custom.*; /** diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextImpl.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextImpl.java index 819c57112..cdbc3f4f6 100644 --- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextImpl.java +++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextImpl.java @@ -10,18 +10,11 @@ ******************************************************************************/ package org.eclipse.equinox.bidi.internal; -import org.eclipse.equinox.bidi.STextEngine; -import org.eclipse.equinox.bidi.STextEnvironment; +import org.eclipse.equinox.bidi.STextDirection; +import org.eclipse.equinox.bidi.advanced.STextEnvironment; +import org.eclipse.equinox.bidi.advanced.STextProcessorNew; import org.eclipse.equinox.bidi.custom.*; -/** - * <code>STextImpl</code> provides the code which implements the API in - * {@link STextEngine}. All its public methods are shadows of similarly - * signed methods of <code>STextEngine</code>, and their documentation - * is by reference to the methods in <code>STextEngine</code>. - * - * @author Matitiahu Allouche - */ public class STextImpl { static final String EMPTY_STRING = ""; //$NON-NLS-1$ @@ -101,13 +94,10 @@ public class STextImpl { return nextLocation + (((long) idxLocation) << 32); } - /** - * @see STextProcessor#processSeparator STextProcessor.processSeparator - */ public static void processSeparator(String text, STextCharTypes charTypes, STextOffsets offsets, int separLocation) { int len = text.length(); int direction = charTypes.getDirection(); - if (direction == STextEngine.DIR_RTL) { + if (direction == STextDirection.DIR_RTL) { // the structured text base direction is RTL for (int i = separLocation - 1; i >= 0; i--) { byte charType = charTypes.getBidiTypeAt(i); @@ -165,45 +155,45 @@ public class STextImpl { /** * When the orientation is <code>ORIENT_LTR</code> and the * structured text has a RTL base direction, - * {@link STextEngine#leanToFullText leanToFullText} + * {@link STextProcessorNew#leanToFullText leanToFullText} * adds RLE+RLM at the head of the <i>full</i> text and RLM+PDF at its * end. * <p> * When the orientation is <code>ORIENT_RTL</code> and the * structured text has a LTR base direction, - * {@link STextEngine#leanToFullText leanToFullText} + * {@link STextProcessorNew#leanToFullText leanToFullText} * adds LRE+LRM at the head of the <i>full</i> text and LRM+PDF at its * end. * <p> * When the orientation is <code>ORIENT_CONTEXTUAL_LTR</code> or * <code>ORIENT_CONTEXTUAL_RTL</code> and the data content would resolve * to a RTL orientation while the structured text has a LTR base - * direction, {@link STextEngine#leanToFullText leanToFullText} + * direction, {@link STextProcessorNew#leanToFullText leanToFullText} * adds LRM at the head of the <i>full</i> text. * <p> * When the orientation is <code>ORIENT_CONTEXTUAL_LTR</code> or * <code>ORIENT_CONTEXTUAL_RTL</code> and the data content would resolve * to a LTR orientation while the structured text has a RTL base - * direction, {@link STextEngine#leanToFullText leanToFullText} + * direction, {@link STextProcessorNew#leanToFullText leanToFullText} * adds RLM at the head of the <i>full</i> text. * <p> * When the orientation is <code>ORIENT_UNKNOWN</code> and the * structured text has a LTR base direction, - * {@link STextEngine#leanToFullText leanToFullText} + * {@link STextProcessorNew#leanToFullText leanToFullText} * adds LRE+LRM at the head of the <i>full</i> text and LRM+PDF at its * end. * <p> * When the orientation is <code>ORIENT_UNKNOWN</code> and the * structured text has a RTL base direction, - * {@link STextEngine#leanToFullText leanToFullText} + * {@link STextProcessorNew#leanToFullText leanToFullText} * adds RLE+RLM at the head of the <i>full</i> text and RLM+PDF at its * end. * <p> * When the orientation is <code>ORIENT_IGNORE</code>, - * {@link STextEngine#leanToFullText leanToFullText} does not add any directional + * {@link STextProcessorNew#leanToFullText leanToFullText} does not add any directional * formatting characters as either prefix or suffix of the <i>full</i> text. * <p> - * @see STextEngine#leanToFullText STextEngine.leanToFullText + * @see STextProcessorNew#leanToFullText STextEngine.leanToFullText */ public static String leanToFullText(STextProcessor processor, STextEnvironment environment, String text, int[] state) { int len = text.length(); @@ -252,9 +242,6 @@ public class STextImpl { return new String(fullChars); } - /** - * @see STextEngine#leanToFullMap STextEngine.leanToFullMap - */ public static int[] leanToFullMap(STextProcessor processor, STextEnvironment environment, String text, int[] state) { int len = text.length(); if (len == 0) @@ -275,9 +262,6 @@ public class STextImpl { return map; } - /** - * @see STextEngine#leanBidiCharOffsets STextEngine.leanBidiCharOffsets - */ public static int[] leanBidiCharOffsets(STextProcessor processor, STextEnvironment environment, String text, int[] state) { int len = text.length(); if (len == 0) @@ -287,12 +271,20 @@ public class STextImpl { return offsets.getArray(); } + /** + * Constant to use in the first element of the <code>state</code> + * argument when calling most methods of this class + * to indicate that there is no context of previous lines which + * should be initialized before performing the operation. + */ + public static final int STATE_INITIAL = 0; // TBD move + static STextOffsets leanToFullCommon(STextProcessor processor, STextEnvironment environment, String text, int[] state, STextCharTypes charTypes) { if (environment == null) environment = STextEnvironment.DEFAULT; if (state == null) { state = new int[1]; - state[0] = STextEngine.STATE_INITIAL; + state[0] = STATE_INITIAL; } int len = text.length(); int direction = processor.getDirection(environment, text, charTypes); @@ -306,10 +298,10 @@ public class STextImpl { } // current position int curPos = 0; - if (state[0] > STextEngine.STATE_INITIAL) { + if (state[0] > STATE_INITIAL) { offsets.ensureRoom(); int initState = state[0]; - state[0] = STextEngine.STATE_INITIAL; + state[0] = STATE_INITIAL; curPos = processor.processSpecial(environment, text, charTypes, offsets, state, initState, -1); } while (true) { @@ -351,18 +343,11 @@ public class STextImpl { return offsets; } - /** - * @see STextEngine#fullToLeanText STextEngine.fullToLeanText - */ public static String fullToLeanText(STextProcessor processor, STextEnvironment environment, String text, int[] state) { if (text.length() == 0) return text; if (environment == null) environment = STextEnvironment.DEFAULT; - if (state == null) { - state = new int[1]; - state[0] = STextEngine.STATE_INITIAL; - } int dir = processor.getDirection(environment, text); char curMark = MARKS[dir]; char curEmbed = EMBEDS[dir]; @@ -446,9 +431,6 @@ public class STextImpl { return lean; } - /** - * @see STextEngine#fullToLeanMap STextEngine.fullToLeanMap - */ public static int[] fullToLeanMap(STextProcessor processor, STextEnvironment environment, String full, int[] state) { int lenFull = full.length(); if (lenFull == 0) @@ -480,9 +462,6 @@ public class STextImpl { return map; } - /** - * @see STextEngine#fullBidiCharOffsets STextEngine.fullBidiCharOffsets - */ public static int[] fullBidiCharOffsets(STextProcessor processor, STextEnvironment environment, String full, int[] state) { int lenFull = full.length(); if (lenFull == 0) diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextProcessorImplNew.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextProcessorImplNew.java new file mode 100644 index 000000000..3cc752f15 --- /dev/null +++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextProcessorImplNew.java @@ -0,0 +1,57 @@ +/*******************************************************************************
+ * Copyright (c) 2010, 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.equinox.bidi.internal;
+
+import org.eclipse.equinox.bidi.advanced.STextEnvironment;
+import org.eclipse.equinox.bidi.advanced.STextProcessorNew;
+import org.eclipse.equinox.bidi.custom.STextProcessor;
+
+public class STextProcessorImplNew implements STextProcessorNew {
+
+ protected STextProcessor structuredTextDescriptor;
+ protected STextEnvironment environment;
+
+ private final static int[] initialState = new int[] {0};
+
+ public STextProcessorImplNew(STextProcessor structuredTextDescriptor, STextEnvironment environment) {
+ this.structuredTextDescriptor = structuredTextDescriptor;
+ this.environment = environment;
+ }
+
+ public String leanToFullText(String text) {
+ return STextImpl.leanToFullText(structuredTextDescriptor, environment, text, initialState);
+ }
+
+ public int[] leanToFullMap(String text) {
+ return STextImpl.leanToFullMap(structuredTextDescriptor, environment, text, initialState);
+ }
+
+ public int[] leanBidiCharOffsets(String text) {
+ return STextImpl.leanBidiCharOffsets(structuredTextDescriptor, environment, text, initialState);
+ }
+
+ public String fullToLeanText(String text) {
+ return STextImpl.fullToLeanText(structuredTextDescriptor, environment, text, initialState);
+ }
+
+ public int[] fullToLeanMap(String text) {
+ return STextImpl.fullToLeanMap(structuredTextDescriptor, environment, text, initialState);
+ }
+
+ public int[] fullBidiCharOffsets(String text) {
+ return STextImpl.fullBidiCharOffsets(structuredTextDescriptor, environment, text, initialState);
+ }
+
+ public int getCurDirection(String text) {
+ return structuredTextDescriptor.getDirection(environment, text);
+ }
+
+}
diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextProcessorMultipassImplNew.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextProcessorMultipassImplNew.java new file mode 100644 index 000000000..230dc1609 --- /dev/null +++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextProcessorMultipassImplNew.java @@ -0,0 +1,66 @@ +/*******************************************************************************
+ * Copyright (c) 2010, 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.equinox.bidi.internal;
+
+import org.eclipse.equinox.bidi.advanced.STextEnvironment;
+import org.eclipse.equinox.bidi.advanced.STextProcessorMultipassNew;
+import org.eclipse.equinox.bidi.custom.STextProcessor;
+
+public class STextProcessorMultipassImplNew extends STextProcessorImplNew implements STextProcessorMultipassNew {
+
+ /**
+ * Constant to use in the first element of the <code>state</code>
+ * argument when calling most methods of this class
+ * to indicate that there is no context of previous lines which
+ * should be initialized before performing the operation.
+ */
+ public static final int STATE_INITIAL = 0;
+
+ private int[] state;
+
+ public STextProcessorMultipassImplNew(STextProcessor structuredTextDescriptor, STextEnvironment environment) {
+ super(structuredTextDescriptor, environment);
+ reset();
+ }
+
+ public String leanToFullText(String text) {
+ return STextImpl.leanToFullText(structuredTextDescriptor, environment, text, state);
+ }
+
+ public int[] leanToFullMap(String text) {
+ return STextImpl.leanToFullMap(structuredTextDescriptor, environment, text, state);
+ }
+
+ public int[] leanBidiCharOffsets(String text) {
+ return STextImpl.leanBidiCharOffsets(structuredTextDescriptor, environment, text, state);
+ }
+
+ public String fullToLeanText(String text) {
+ return STextImpl.fullToLeanText(structuredTextDescriptor, environment, text, state);
+ }
+
+ public int[] fullToLeanMap(String text) {
+ return STextImpl.fullToLeanMap(structuredTextDescriptor, environment, text, state);
+ }
+
+ public int[] fullBidiCharOffsets(String text) {
+ return STextImpl.fullBidiCharOffsets(structuredTextDescriptor, environment, text, state);
+ }
+
+ public int getCurDirection(String text) {
+ return structuredTextDescriptor.getDirection(environment, text);
+ }
+
+ public void reset() {
+ state = new int[] {STATE_INITIAL};
+ }
+
+}
diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextSingle.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextSingle.java index 1ca2d241f..42e1be0ed 100644 --- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextSingle.java +++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/STextSingle.java @@ -10,7 +10,8 @@ ******************************************************************************/ package org.eclipse.equinox.bidi.internal; -import org.eclipse.equinox.bidi.STextEnvironment; +import org.eclipse.equinox.bidi.advanced.STextEnvironment; + import org.eclipse.equinox.bidi.custom.*; /** diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextEmail.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextEmail.java index d132ef645..940f192a5 100644 --- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextEmail.java +++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextEmail.java @@ -10,8 +10,8 @@ ******************************************************************************/ package org.eclipse.equinox.bidi.internal.consumable; -import org.eclipse.equinox.bidi.STextEngine; -import org.eclipse.equinox.bidi.STextEnvironment; +import org.eclipse.equinox.bidi.STextDirection; +import org.eclipse.equinox.bidi.advanced.STextEnvironment; import org.eclipse.equinox.bidi.custom.STextCharTypes; import org.eclipse.equinox.bidi.internal.STextDelimsEsc; @@ -32,7 +32,7 @@ public class STextEmail extends STextDelimsEsc { } /** - * @return {@link STextEngine#DIR_RTL DIR_RTL} if the following + * @return {@link STextDirection#DIR_RTL DIR_RTL} if the following * conditions are satisfied: * <ul> * <li>The current locale (as expressed by the environment @@ -40,12 +40,12 @@ public class STextEmail extends STextDelimsEsc { * <li>The domain part of the email address contains * at least one RTL character.</li> * </ul> - * Otherwise, returns {@link STextEngine#DIR_LTR DIR_LTR}. + * Otherwise, returns {@link STextDirection#DIR_LTR DIR_LTR}. */ public int getDirection(STextEnvironment environment, String text, STextCharTypes charTypes) { String language = environment.getLanguage(); if (!language.equals("ar")) //$NON-NLS-1$ - return STextEngine.DIR_LTR; + return STextDirection.DIR_LTR; int domainStart; domainStart = text.indexOf('@'); if (domainStart < 0) @@ -53,9 +53,9 @@ public class STextEmail extends STextDelimsEsc { for (int i = domainStart; i < text.length(); i++) { byte charType = charTypes.getBidiTypeAt(i); if (charType == AL || charType == R) - return STextEngine.DIR_RTL; + return STextDirection.DIR_RTL; } - return STextEngine.DIR_LTR; + return STextDirection.DIR_LTR; } /** diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextJava.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextJava.java index 601e4fd15..6fb4fcdae 100644 --- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextJava.java +++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextJava.java @@ -10,8 +10,8 @@ ******************************************************************************/ package org.eclipse.equinox.bidi.internal.consumable; -import org.eclipse.equinox.bidi.STextEngine; -import org.eclipse.equinox.bidi.STextEnvironment; +import org.eclipse.equinox.bidi.advanced.STextEnvironment; +import org.eclipse.equinox.bidi.advanced.STextProcessorNew; import org.eclipse.equinox.bidi.custom.*; import org.eclipse.equinox.bidi.internal.STextActivator; @@ -22,7 +22,7 @@ import org.eclipse.equinox.bidi.internal.STextActivator; * <p> * In applications like an editor where parts of the text might be modified * while other parts are not, the user may want to call - * {@link STextEngine#leanToFullText leanToFullText} + * {@link STextProcessorNew#leanToFullText} * separately on each line and save the initial state of each line (this is * the final state of the previous line which can be retrieved using * the value returned in the first element of the <code>state</code> argument). @@ -30,7 +30,7 @@ import org.eclipse.equinox.bidi.internal.STextActivator; * of a line and its initial state have not changed, the user can be sure that * the last <i>full</i> text computed for this line has not changed either. * - * @see STextEngine#leanToFullText explanation of state in leanToFullText + * @see STextProcessorNew#leanToFullText explanation of state in leanToFullText * * @author Matitiahu Allouche */ diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextMath.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextMath.java index 8834f5a07..0aa241d3c 100644 --- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextMath.java +++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextMath.java @@ -10,8 +10,8 @@ ******************************************************************************/ package org.eclipse.equinox.bidi.internal.consumable; -import org.eclipse.equinox.bidi.STextEngine; -import org.eclipse.equinox.bidi.STextEnvironment; +import org.eclipse.equinox.bidi.STextDirection; +import org.eclipse.equinox.bidi.advanced.STextEnvironment; import org.eclipse.equinox.bidi.custom.STextCharTypes; import org.eclipse.equinox.bidi.custom.STextProcessor; @@ -34,7 +34,7 @@ public class STextMath extends STextProcessor { } /** - * @return {@link STextEngine#DIR_RTL DIR_RTL} if the following + * @return {@link STextDirection#DIR_RTL DIR_RTL} if the following * conditions are satisfied: * <ul> * <li>The current locale (as expressed by the environment @@ -43,24 +43,24 @@ public class STextMath extends STextProcessor { * <li>If there is no strong character in the text, there is * at least one Arabic-Indic digit in the text.</li> * </ul> - * Otherwise, returns {@link STextEngine#DIR_LTR DIR_LTR}. + * Otherwise, returns {@link STextDirection#DIR_LTR DIR_LTR}. */ public int getDirection(STextEnvironment environment, String text, STextCharTypes charTypes) { String language = environment.getLanguage(); if (!language.equals("ar")) //$NON-NLS-1$ - return STextEngine.DIR_LTR; + return STextDirection.DIR_LTR; boolean flagAN = false; for (int i = 0; i < text.length(); i++) { byte charType = charTypes.getBidiTypeAt(i); if (charType == AL) - return STextEngine.DIR_RTL; + return STextDirection.DIR_RTL; if (charType == L || charType == R) - return STextEngine.DIR_LTR; + return STextDirection.DIR_LTR; if (charType == AN) flagAN = true; } if (flagAN) - return STextEngine.DIR_RTL; - return STextEngine.DIR_LTR; + return STextDirection.DIR_RTL; + return STextDirection.DIR_LTR; } } diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextRegex.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextRegex.java index d3cf7f18e..4c504a2e8 100644 --- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextRegex.java +++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextRegex.java @@ -10,8 +10,9 @@ ******************************************************************************/ package org.eclipse.equinox.bidi.internal.consumable; -import org.eclipse.equinox.bidi.STextEngine; -import org.eclipse.equinox.bidi.STextEnvironment; +import org.eclipse.equinox.bidi.STextDirection; +import org.eclipse.equinox.bidi.advanced.STextEnvironment; +import org.eclipse.equinox.bidi.advanced.STextProcessorNew; import org.eclipse.equinox.bidi.custom.*; /** @@ -20,7 +21,7 @@ import org.eclipse.equinox.bidi.custom.*; * <p> * In applications like an editor where parts of the text might be modified * while other parts are not, the user may want to call - * {@link STextEngine#leanToFullText leanToFullText} + * {@link STextProcessorNew#leanToFullText} * separately on each line and save the initial state of each line (this is * the final state of the previous line which can be retrieved using * the value returned in the first element of the <code>state</code> argument). @@ -28,7 +29,7 @@ import org.eclipse.equinox.bidi.custom.*; * of a line and its initial state have not changed, the user can be sure that * the last <i>full</i> text computed for this line has not changed either. * - * @see STextEngine#leanToFullText explanation of state in leanToFullText + * @see STextProcessorNew#leanToFullText explanation of state in leanToFullText * * @author Matitiahu Allouche */ @@ -219,7 +220,7 @@ public class STextRegex extends STextProcessor { } /** - * @return {@link STextEngine#DIR_RTL DIR_RTL} if the following + * @return {@link STextDirection#DIR_RTL DIR_RTL} if the following * conditions are satisfied: * <ul> * <li>The current locale (as expressed by the environment @@ -228,22 +229,22 @@ public class STextRegex extends STextProcessor { * <li>If there is no strong character in the text, the * GUI is mirrored. * </ul> - * Otherwise, returns {@link STextEngine#DIR_LTR DIR_LTR}. + * Otherwise, returns {@link STextDirection#DIR_LTR DIR_LTR}. */ public int getDirection(STextEnvironment environment, String text, STextCharTypes charTypes) { String language = environment.getLanguage(); if (!language.equals("ar")) //$NON-NLS-1$ - return STextEngine.DIR_LTR; + return STextDirection.DIR_LTR; for (int i = 0; i < text.length(); i++) { byte charType = charTypes.getBidiTypeAt(i); if (charType == AL || charType == R) - return STextEngine.DIR_RTL; + return STextDirection.DIR_RTL; if (charType == L) - return STextEngine.DIR_LTR; + return STextDirection.DIR_LTR; } if (environment.getMirrored()) - return STextEngine.DIR_RTL; - return STextEngine.DIR_LTR; + return STextDirection.DIR_RTL; + return STextDirection.DIR_LTR; } } diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextSql.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextSql.java index ff2750a16..90a53f036 100644 --- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextSql.java +++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextSql.java @@ -10,8 +10,8 @@ ******************************************************************************/ package org.eclipse.equinox.bidi.internal.consumable; -import org.eclipse.equinox.bidi.STextEngine; -import org.eclipse.equinox.bidi.STextEnvironment; +import org.eclipse.equinox.bidi.advanced.STextEnvironment; +import org.eclipse.equinox.bidi.advanced.STextProcessorNew; import org.eclipse.equinox.bidi.custom.*; import org.eclipse.equinox.bidi.internal.STextActivator; @@ -22,7 +22,7 @@ import org.eclipse.equinox.bidi.internal.STextActivator; * <p> * In applications like an editor where parts of the text might be modified * while other parts are not, the user may want to call - * {@link STextEngine#leanToFullText leanToFullText} + * {@link STextProcessorNew#leanToFullText} * separately on each line and save the initial state of each line (this is * the final state of the previous line which can be retrieved from the * value returned in the first element of the <code>state</code> argument). @@ -30,7 +30,7 @@ import org.eclipse.equinox.bidi.internal.STextActivator; * of a line and its initial state have not changed, the user can be sure that * the last <i>full</i> text computed for this line has not changed either. * - * @see STextEngine#leanToFullText explanation of state in leanToFullText + * @see STextProcessorNew#leanToFullText explanation of state in leanToFullText * * @author Matitiahu Allouche */ diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextXPath.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextXPath.java index 7ead88bba..40000ab23 100644 --- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextXPath.java +++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/internal/consumable/STextXPath.java @@ -10,7 +10,8 @@ ******************************************************************************/ package org.eclipse.equinox.bidi.internal.consumable; -import org.eclipse.equinox.bidi.STextEnvironment; +import org.eclipse.equinox.bidi.advanced.STextEnvironment; + import org.eclipse.equinox.bidi.internal.STextDelims; /** |