diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/STextProcessor.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/STextProcessor.java index 0d6a2e9..c8c23a1 100644 --- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/STextProcessor.java +++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/STextProcessor.java @@ -14,8 +14,11 @@ import org.eclipse.equinox.bidi.custom.STextTypeHandler; /** - * Provides a number of convenience functions facilitating the - * processing of structured text. + * Provides methods to process structured text. The methods in this class + * are the most straightforward way to transform lean text into + * full text and vice versa (for the meaning of lean and + * full text, please see the + * package documentation). * * @noextend This class is not intended to be subclassed by clients. * @noinstantiate This class is not intended to be instantiated by clients. @@ -50,9 +53,9 @@ } /** - * Processes the given text and returns a string with appropriate - * directional formatting characters. This is equivalent to calling - * {@link #process(String str, String separators)} with the default + * Processes the given (lean) text and returns a string with appropriate + * directional formatting characters (full text). This is equivalent to + * calling {@link #process(String str, String separators)} with the default * set of separators. *
* The processing adds directional formatting characters so that presentation @@ -66,9 +69,11 @@ * d:\myfolder\REDLOF\ELIFYM.java. *
* - * @param str the text to be processed. + * @param str the lean text to process. * - * @return the processed string. + * @return the processed string (full text). + * + * @see #deprocess(String) */ public static String process(String str) { return process(str, defaultSeparators); @@ -77,13 +82,14 @@ /** * Processes a string that has a particular semantic meaning to render * it correctly on bidi locales. - * - * @see #process(String) + * For more details, see {@link #process(String)}. * - * @param str the text to process. + * @param str the lean text to process. * @param separators characters by which the string will be segmented. * - * @return the processed string. + * @return the processed string (full text). + * + * @see #deprocess(String) */ public static String process(String str, String separators) { if ((str == null) || (str.length() <= 1)) @@ -131,17 +137,18 @@ /** * Processes a string that has a particular semantic meaning to render * it correctly on bidi locales. + * For more details, see {@link #process(String)}. * - * @see #process(String) - * - * @param str the text to process. - * @param textType an identifier for the handler instance appropriate - * for the type of the structured text. + * @param str the lean text to process. + * @param textType an identifier for the structured text handler + * appropriate for the type of the text submitted. * It may be one of the identifiers defined in * {@link STextTypeHandlerFactory} or a type handler identifier - * specified in a plug-in. + * registered by a plug-in. * - * @return the processed string + * @return the processed string (full text). + * + * @see #deprocessTyped */ public static String processTyped(String str, String textType) { if ((str == null) || (str.length() <= 1)) @@ -163,9 +170,9 @@ /** * Removes directional formatting characters in the given string. * - * @param str string with directional characters to remove. + * @param str string with directional characters to remove (full text). * - * @return string without directional formatting characters. + * @return string without directional formatting characters (lean text). */ public static String deprocess(String str) { if ((str == null) || (str.length() <= 1)) @@ -195,15 +202,16 @@ /** * Removes directional formatting characters in the given string. * - * @param str string with directional characters to remove. - * - * @param textType an identifier for the handler instance appropriate - * for the type of the structured text. + * @param str string with directional characters to remove (full text). + * @param textType an identifier for the structured text handler + * appropriate for the type of the text submitted. * It may be one of the identifiers defined in * {@link STextTypeHandlerFactory} or a type handler identifier - * specified in a plug-in. + * registered by a plug-in. * - * @return string without directional formatting characters. + * @return string without directional formatting characters (lean text). + * + * @see #processTyped(String, String) */ public static String deprocessTyped(String str, String textType) { if ((str == null) || (str.length() <= 1)) diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/STextTypeHandlerFactory.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/STextTypeHandlerFactory.java index d134e55..4f4513a 100644 --- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/STextTypeHandlerFactory.java +++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/STextTypeHandlerFactory.java @@ -10,12 +10,28 @@ ******************************************************************************/ package org.eclipse.equinox.bidi; +import org.eclipse.equinox.bidi.advanced.STextEnvironment; +import org.eclipse.equinox.bidi.advanced.STextExpertFactory; import org.eclipse.equinox.bidi.custom.STextTypeHandler; import org.eclipse.equinox.bidi.internal.STextTypesCollector; /** * Provides access to registered structured text handlers. - * + *+ * A structured text handler is a subclass of {@link STextTypeHandler} + * adapted for a given type of structured text. + *
+ * The constants in this class are identifiers for structured text
+ * handlers which are defined and supported "out of the box" by this package.
+ * Text handler identifiers can be used when invoking {@link STextProcessor#processTyped(String, String)},
+ * or when invoking getExpert
methods in {@link STextExpertFactory}.
+ *
+ * The {@link #getHandler} method in this class can be used to get a
+ * structured text handler reference for one of the handlers defined in this
+ * package or for additional structured text handlers registered by plug-ins.
+ * Text handler references can be used when invoking
+ * {@link STextExpertFactory#getStatefulExpert(STextTypeHandler, STextEnvironment)}.
+ *
* @noinstantiate This class is not intended to be instantiated by clients.
*/
final public class STextTypeHandlerFactory {
diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/advanced/ISTextExpert.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/advanced/ISTextExpert.java
index 171a2e6..9cea28f 100644
--- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/advanced/ISTextExpert.java
+++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/advanced/ISTextExpert.java
@@ -105,6 +105,7 @@
/**
* Obtains the structured type handler associated with this
* ISTextExpert
instance.
+ *
* @return the type handler instance.
*/
public STextTypeHandler getTypeHandler();
@@ -214,8 +215,18 @@
*
* If necessary, leading and trailing directional formatting characters
* (LRE, RLE and PDF) can be added depending on the value of the
- * affix
argument.
- *
affix
argument.
+ * null
if the expert instance is not a stateful one,
- * or if the last text processing call has nothing to pass to the next call.
+ * or if the last text processing call had nothing to pass to the next call.
+ *
* @return the last established state.
*/
public Object getState();
diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/advanced/STextEnvironment.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/advanced/STextEnvironment.java
index 474fb00..6705ddf 100644
--- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/advanced/STextEnvironment.java
+++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/advanced/STextEnvironment.java
@@ -97,11 +97,11 @@
/**
* Creates an instance of a structured text environment.
*
- * @param lang the language to of the environment, encoded as specified
+ * @param lang the language of the environment, encoded as specified
* in ISO-639. Might be null
, in which case the default
* locale is used.
* @param mirrored specifies if the environment is mirrored.
- * @param orientation the orientation of the GUI component:
+ * @param orientation the orientation of the GUI component, one of the values:
* {@link #ORIENT_LTR ORIENT_LTR},
* {@link #ORIENT_LTR ORIENT_RTL},
* {@link #ORIENT_CONTEXTUAL_LTR ORIENT_CONTEXTUAL_LTR},
@@ -124,6 +124,7 @@
/**
* Returns a 2-letters code representing a language as defined by
* ISO-639.
+ *
* @return language of the environment
*/
public String getLanguage() {
@@ -134,6 +135,7 @@
* Returns a flag indicating that structured text processed
* within this environment should assume that the GUI is mirrored
* (globally going from right to left).
+ *
* @return true
if environment is mirrored
*/
public boolean getMirrored() {
@@ -145,7 +147,7 @@
* component in which the full structured text
* will be displayed.
* - * The orientation values: + * The orientation value is one of the following: *
true
if bidi processing is needed in this environment.
*/
public boolean isProcessingNeeded() {
@@ -185,6 +191,12 @@
return processingNeeded.booleanValue();
}
+ /**
+ * Computes the hashCode based on the values supplied when constructing
+ * the instance and on the result of {@link #isProcessingNeeded()}.
+ *
+ * @return the hash code.
+ */
public int hashCode() {
final int prime = 31;
int result = 1;
@@ -195,6 +207,12 @@
return result;
}
+ /**
+ * Compare 2 environment instances and returns true if both instances
+ * were constructed with the same arguments.
+ *
+ * @return true if the 2 instances can be used interchangeably.
+ */
public boolean equals(Object obj) {
if (this == obj)
return true;
diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/advanced/STextExpertFactory.java b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/advanced/STextExpertFactory.java
index d0f7a12..e6e21b8 100644
--- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/advanced/STextExpertFactory.java
+++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/advanced/STextExpertFactory.java
@@ -19,7 +19,11 @@
/**
* Obtains ISTextExpert instances.
- * There are two kinds of {@link ISTextExpert} instances (called "experts"):
+ * An {@link ISTextExpert} instance (called in short an "expert") provides
+ * the advanced methods to process a certain type of structured text, and
+ * is thus related to a specific
+ * {@link STextTypeHandler structured text type handler}.
+ * There are two kinds of experts:
* Only the stateful kind can remember the state established by a call to * a text processing method and transmit it as initial state in the next call * to a text processing method. + *
In other words, the methods + * {@link ISTextExpert#getState() getState}, + * {@link ISTextExpert#setState setState} and + * {@link ISTextExpert#clearState() clearState} of + * {@link ISTextExpert} are inoperative for experts which are not stateful. *
* Using a stateful expert is more resource intensive, thus not stateful * experts should be used when feasible. diff --git a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/advanced/package.html b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/advanced/package.html index 9b71e0c..438719b 100644 --- a/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/advanced/package.html +++ b/bundles/org.eclipse.equinox.bidi/src/org/eclipse/equinox/bidi/advanced/package.html @@ -4,17 +4,11 @@
- +
This package provides classes for users who need finer control
on structured text handling.
-
-Note that the basic functions are provided in package
-{@link
-org.eclipse.equinox.bidi} and its
-{@link STextProcessor} class.
-
In particular, the user should use the methods in the -{@link ISTextExpert} class +ISTextExpert class in the following cases:
+Note that the basic functions are provided in package +{@link +org.eclipse.equinox.bidi} and its +{@link STextProcessor} class. +
+To access the more sophisticated methods for processing structured text, +the user should proceed as follows:
+ISTextExpert
instance using the methods in
+ STextExpertFactory.
+ This should be done before obtaining a ISTextExpert
instance,
+ and the specific environment must be specified when invoking
+ STextExpertFactory
methods. This will
+ associate a type handler with the given environment and provide
+ a customized ISTextExpert
instance to the user.