Bidirectional (BiDi) text layout transformation

The IBM® BiDi (bidirectional) engine can perform BiDi Layout transformation on data being stored and retrieved from the database.

The IBM Bidi engine bases text transformations on the following characteristics of text data:

  • Numeral shape (Arabic or Hindi)
  • Orientation (right-to-left or left-to-right)
  • Shaping (shaped or unshaped)
  • Symmetric swapping (yes or no)
  • Text type (logical or visual)

Enable Bidi text layout transformation for your database by setting the enableBidiLayoutTransformation, clientBidiStringType, and serverBidiStringType properties on a Connection or DataSource. Set enableBidiLayoutTransformation to true, then specify the String type of the client application and data server with the clientBidiStringType and serverBidiStringType properties respectively. The following table summarizes which string type values to specify for particular combinations of text data attributes.

Table 1. String type values and corresponding attributes for the clientBidiStringType and serverBidiStringType properties
  Text Attributes
String type value integer constant String type value Type of text Orientation Symmetric swapping Numeral shape Text shapes
4 DB2BaseDataSource.BIDI_ST4 Visual Left-to-right No Nominal Shaped
5 DB2BaseDataSource.BIDI_ST5 Implicit Left-to-right Yes Nominal Nominal
6 DB2BaseDataSource.BIDI_ST6 Implicit Right-to-left Yes Nominal Nominal
7 DB2BaseDataSource.BIDI_ST7 Visual Right-to-left No Nominal Shaped
8 DB2BaseDataSource.BIDI_ST8 Visual Right-to-left No Nominal Shaped
9 DB2BaseDataSource.BIDI_ST9 Implicit Right-to-left Yes Nominal Shaped
10
DB2Base
DataSource.
BIDI_ST10
DB2BaseDataSource.BIDI_ST10
Implicit Contextual left-to-right Yes Nominal Nominal
11 DB2BaseDataSource.BIDI_ST11 Implicit Contextual right-to-left Yes Nominal Nominal
BiDi text layout transformations can be performed on:
  • Strings enclosed in single apostrophes in SQL statements:
    ResultSet rs = st.executeQuery( "SELECT * FROM PARAM.JCCTEST WHERE 
    product=' <text_to_transform> '")
  • Parameter values for PreparedStatements and CallableStatements:
                           
            Connection conn = null;                       
                   
            PreparedStatement pstmt = 
    conn.prepareStatement( "SELECT PRODCUT FROM PARAM.JCCTEST WHERE PRODCUT=?" );
            pstmt.setString(1,  "<text_to_transform>" );                                
  • Values retrieved through getXXX() methods on ResultSet and CallableStatement objects:
                           
            ResultSet rs = pstmt.executeQuery();                       
                                   
            while (rs.next()){                                                             
              System.out.println(rs.getString(1));   
      
             // BiDi layout transformation will be performed the on
     return value from getString()                        
            }