Use the HATS Bidirectional API
If you create HATS applications that use bidirectional (Arabic or Hebrew) code pages, and you add business logic or create your own custom components or widgets, you can use the bidirectional API to handle the recognition of host components and the presentation of widgets on the Web page. This chapter describes this API. Before using the material in this chapter be familiar with the bidirectional concepts described in HATS User's and Administrator's Guide.
Data Conversion APIs
Two APIs for handling text conversion from visual to logical and vice versa are included in the HostScreen class. Use these APIs when creating custom widgets and components to handle extraction of data.
ConvertVisualToLogical
ConvertVisualToLogical public java.lang.String ConvertVisualToLogical(java.lang.String inputBuffer, boolean isleft-to-rightVisual, boolean isleft-to-rightImplicit)
Converts the given string from visual to implicit format and returns the implicit format of the string.
- inputBuffer
- The input string in visual format.
- isLTRVisual
- If true, inputBuffer is in visual left-to-right form.
- isLTRimplicit
- If true, the output buffer is in implicit left-to-right form.
ConvertLogicalToVisual
public java.lang.String ConvertLogicalToVisual(java.lang.String inputBuffer, boolean isleft-to-rightImplicit, boolean isleft-to-rightVisual)
Converts the given string from implicit to visual format and returns the visual format of the string.
- inputBuffer
- The input string in implicit format.
- isLTRimplicit
- If true, inputBuffer is in implicit left-to-right form.
- isLTRVisual
- If true, the output buffer is in visual left-to-right form.
Global Variable APIs
There are two getter methods that you can use to get the value of global variables. Using these methods you can get the global variable value either in implicit format or in visual format. These two methods are in class com.ibm.hats.common.BaseInfo.
getGlobalVariable
public IGlobalVariable getGlobalVariable(String name, boolean createIfNotExist,boolean bidiImplicit)
Gets the named global variable, optionally creating it if it doesn't already exist.
- createIfNotExist
- whether or not it should create a non-existent global variable
- bidiImplicit
- whether to get the global variable value in implicit format if true or in visual format if false.
getSharedGlobalVariable
public IGlobalVariable getSharedGlobalVariable(String name, boolean createIfNotExist,boolean bidiImplicit)
Gets the named shared global variable, optionally creating it if it doesn't already exist.
- createIfNotExist
- whether or not it should create a non-existent global variable
- bidiImplicit
- whether to get the global variable value in implicit format if true or in visual format if false.
BIDI OrderBean
Use the methods of the BIDI OrderBean for the correct display of bidirectional data. It contains the following parameters:
- BidiString
- String. Contains bidirectional text
- FromTextVisual
- Boolean. Indicates if the source bidi text is visual. Default is true.
- FromOriLTR
- Boolean. Indicates if the orientation of the source bidi text is LTR. Default is true.
- ToTextVisual
- Boolean. Indicates if the target bidi text is visual. Default is true.
- ToOriLTR
- Boolean. Indicates if the orientation of the target bidi text is LTR. Default is true.
- NeedShape
- Boolean. Indicates if bidi text is Arabic text and if it needs shaping. Default is false.
- CharSet
- String. Defines the character encoding for the JSP.
- NumShape
- String. Defines the numerals shaping method. Default is "Nominal."
- SymSwap
- Boolean. Indicates if symmetric swapping is on. Default is false.
BIDI OrderBean methods
- setBidiString
- public void setBidiString (String BdString)
Sets the bidi text to be reordered to the given string. Parameters: BdString- the bidi string that needs reordering.
- getBidiString
- public String getBidiString ()
Gets the bidi text. Returns: the bidi string that needs reordering.
- setFromTextVisual
- public void setFromTextVisual (boolean on)
Sets the source bidi text type as visual. Parameters: on - if true, defines this source bidi text as visual if false, defines this source bidi text as implicit.
- setFromOriLTR
- public void setfromOriLTR (boolean on)
Sets the source bidi text orientation as LTR. Parameters: on - if true, defines this source bidi text as LTR if false, defines this source bidi text as RTL.
- setToTextVisual
- public void setToTextVisual (boolean on)
Sets the target bidi text type as visual. Parameters: on - if true, defines this target bidi text as visual if false, defines this target bidi text as implicit.
- setToOriLTR
- public void setToOriLTR (boolean on)
Sets the target bidi text orientation as LTR. Parameters: on - if true, defines this target bidi text as LTR if false, defines this target bidi text as RTL.
- setEncoding
- public void setEncoding (String CharSet)
Sets the encoding charset. Parameters: CharSet - A character-encoding name.
- setNeedShape
- public void setNeedShape (boolean on)
Sets the need to perform shaping. Parameters: on - if true, indicates the need to perform shaping on the bidi text.
- Order
- public void Order ()
Performs the ordering of the bidi text. Parameters: none.
- CompressLamAlef
- public String CompressLamAlef(String input,boolean direction)
Returns a string in which a Lam character followed by an Alef character is replaced by one LamAlef character. Parameters: direction - if true, indicates input text is in visual form , if false input text implicit form. input - input string containing LamAlef characters to be compressed.
- ExpandLamAlef
- public String ExpandLamAlef(String input,boolean direction)
Returns a string in which a Lam Alef character is replaced by a Lam followed by an Alef character. Parameters: direction - if true , indicates input text is in visual form , if false input text implicit form. input - input string containing LamAlef characters to be expanded.
- setNumerals
- public void setNumerals(String NumShape)
Sets the Numerals Shape of the output buffer. Parameters: NumShape - a string that takes one of three values: "NOMINAL": Numerals are in Latin Format; "CONTEXTUAL" : Numerals follow numbers; "NATIONAL": Numerals are in National Format.
- setSymSwap
- public void setSymSwap (boolean on)
Sets the Symmetric swapping option with Visual RTL orientation Parameters: on - if true, symmetric swapping is enabled for swapping characters in RTL screens; if false (default), symmetric swapping is disabled for swapping characters in RTL screens.
- ShapeArabicData
- public String ShapeArabicData(String strInBuffer,boolean isLTRVisual, boolean EnableNumSwap)
Returns a string in which Arabic data is shaped. Parameters: strInBuffer - the bidi string that needs shaping; isLTRVisual - if true, bidi string is left to right visual, if false bidi string is right to left visual; EnableNumSwap - if true enable Numeric swapping, if false disable numeric swapping.
- DeshapeArabicData
- public String DeshapeArabicData (String strInBuffer,boolean isLTRVisual,boolean EnableNumSwap)
Returns a string in which Arabic data is deshaped. Parameters: strInBuffer - the bidi string that needs deshaping isLTRVisual - if true bidi string is left to right visual, if false bidi string is right to left visual; EnableNumSwap - if true enable numeric swapping, if false disable numeric swapping .
- ConvertLogicalToVisual
- public java.lang.String ConvertLogicalToVisual(java.lang.String inputBuffer, boolean isLTRimplicit, boolean isLTRVisual)
Converts the given string from implicit to visual format and returns the visual format of the string. Parameters: InputBuffer -the input string in implicit format; IsLTRimplicit - if true, inputBuffer is in implicit left-to-right form; IsLTRVisual - if true, the output buffer is in visual left-to-right form.
- ConvertVisualToLogical
- public java.lang.String ConvertVisualToLogical(java.lang.String inputBuffer, boolean isLTRVisual, boolean isLTRimplicit)
Converts the given string from visual to implicit format and returns the implicit format of the string. Parameters: InputBuffer -the input string in visual format; IsLTRimplicit - if true, the output uffer is in implicit left-to-right form; IsLTRVisual - if true, the inputBuffer is in visual left-to-right form.
Home