com.ibm.bidiTools.bdlayout

Class BidiText

  1. java.lang.Object
  2. extended bycom.ibm.bidiTools.bdlayout.BidiText

  1. public class BidiText
  2. extends java.lang.Object
Bidi text is a combination of a sequence of characters and a set of Bidi flags which represent Bidi attributes used during Bidi Layout transformations.

Layout transformations allow to convert a given instance of Bidi text into another instance with possibly different Bidi flags while conserving the semantics of the text.

A BidiText object contains a BidiFlagSet to store the Bidi flags characterizing its character data. The characters are contained in a character array. This array may contain more data than the Bidi text to process. The part of the array to process is called the "interesting" data, and is defined by its length and its offset from the beginning of the character array.

Multi-threading considerations: Each thread must use its own instances of this class.


Field Summary

Modifier and Type Field and Description
  1. int
count
length of the "interesting" data within the character array
  1. char[]
data
character array containing the data
  1. BidiFlagSet
flags
BidiFlagSet qualifying the character data
  1. int
offset
offset of the "interesting" data within the character array

Constructor Summary

Constructor and Description
BidiText()
Constructor with no arguments to create a flags member with a DEFAULT value.
BidiText(BidiFlagSet initFlags)
Constructs a BidiText object based on an existing BidiFlagSet.
BidiText(BidiFlagSet initFlags,char[] initData)
Constructs a BidiText object based on an existing BidiFlagSet and the data in a character array.
BidiText(BidiFlagSet initFlags,char[] initData,int offset,int length,int capacity)
Constructs a BidiText object based on an existing BidiFlagSet and the data in part of a character array.
BidiText(BidiFlagSet initFlags,java.lang.String str)
Constructs a BidiText object based on an existing BidiFlagSet and the data in a string.

Method Summary

Modifier and Type Method and Description
  1. boolean
equals(BidiText other)
Compares two BidiText objects.
  1. void
setCharsRef(char[] newData,int newOffset,int newLength)
Replaces the character data reference in the BidiText object.
  1. char[]
toCharArray()
Extracts the character data from a BidiText in character array format
  1. java.lang.String
toString()
Extracts the character data from a BidiText in string format
  1. BidiText
transform(BidiFlagSet dstFlags)
Transforms the data in the "this" BidiText object and return the resulting BidiText object.
  1. BidiText
transform(BidiTransform bdx)
Transforms the data in the "this" BidiText object and return the resulting BidiText object.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

Field Detail

flags

  1. public BidiFlagSet flags
BidiFlagSet qualifying the character data

data

  1. public char[] data
character array containing the data

offset

  1. public int offset
offset of the "interesting" data within the character array

count

  1. public int count
length of the "interesting" data within the character array

Constructor Detail

BidiText

  1. public BidiText()
Constructor with no arguments to create a flags member with a DEFAULT value. There is no data and no character array, but a default BidiFlagSet is created and referred to in "flags".

BidiText

  1. public BidiText(BidiFlagSet initFlags)
Constructs a BidiText object based on an existing BidiFlagSet. There is no data and no character array.

BidiText

  1. public BidiText(BidiFlagSet initFlags,
  2. char[] initData)
Constructs a BidiText object based on an existing BidiFlagSet and the data in a character array.

The argument flags and data are duplicated. Changing them will not affect the BidiText instance.

Parameters:
initFlags - The Bidi flags of the data.
initData - The character data.

BidiText

  1. public BidiText(BidiFlagSet initFlags,
  2. char[] initData,
  3. int offset,
  4. int length,
  5. int capacity)
Constructs a BidiText object based on an existing BidiFlagSet and the data in part of a character array.

The argument flags and data are duplicated. Changing them will not affect the BidiText instance.

Parameters:
initFlags - The Bidi flags of the data.
initData - The character data.
offset - The offset of the "interesting" data in initData.
length - The length of the "interesting" data in initData.
capacity - The length of the created character array (may be larger than "length" to reserve space for adding more data).

BidiText

  1. public BidiText(BidiFlagSet initFlags,
  2. java.lang.String str)
Constructs a BidiText object based on an existing BidiFlagSet and the data in a string.

The argument flags and data are duplicated. Changing them will not affect the BidiText instance.

Parameters:
initFlags - The Bidi flags of the data.
str - The character data.

Method Detail

equals

  1. public boolean equals(BidiText other)
Compares two BidiText objects. Two BidiText objects are considered equal if they have the same Bidi flags and the same "interesting" character data,
Parameters:
other - The BidiText to compare to this.
Returns:
true if the BidiText objects are equal, false otherwise.

setCharsRef

  1. public void setCharsRef(char[] newData,
  2. int newOffset,
  3. int newLength)
Replaces the character data reference in the BidiText object. Note that the data is not duplicated, only its reference is written in the BidiText object.

This method avoids the overhead of creating a character array and copying the source data to it, when the source data is already contained in a character array.

This method can be used after creating a BidiText object with no arguments, or to reuse a BidiText object with new data.

This is a convenience method. It is also possible to manipulate directly the data, offset and count members of the BidiText instance.

Parameters:
newData - A reference to the character data.
newOffset - The offset of the "interesting" data in newData.
newLength - The length of the "interesting" data in newData.

toCharArray

  1. public char[] toCharArray()
Extracts the character data from a BidiText in character array format
Returns:
A char array containing a copy of the "interesting" data.

toString

  1. public java.lang.String toString( )
Extracts the character data from a BidiText in string format
Overrides:
toString in class java.lang.Object
Returns:
A string containing a copy of the "interesting" data.

transform

  1. public BidiText transform(BidiFlagSet dstFlags)
Transforms the data in the "this" BidiText object and return the resulting BidiText object. The transformation is done according to the Bidi flags of the source BidiText and the Bidi flags specified in the argument.

The source BidiText is never modified by the transform.

The destination BidiText has its Bidi flags set to those of the argument.

A typical usage of this method could be:

  BidiText        src = new BidiText();       // source text
  BidiFlagSet     dstFlags;                   // Bidi flags for destination
  BidiText        dst;                        // destination reference
  src.flags.setAllFlags( {flag values for source} );
  dstFlags.setAllFlags( {flag values for destination} );
  // assign values to src.data, src.offset, src.count
  dst = src.transform(dstFlags);
  
Parameters:
dstFlags - Bidi flags of the destination BidiText.
Returns:
A BidiText which is the transformation of the "this" BidiText.

transform

  1. public BidiText transform(BidiTransform bdx)
Transforms the data in the "this" BidiText object and return the resulting BidiText object. The transformation is done according to the Bidi flags of the source BidiText and the Bidi flags specified in the BidiTransform argument.

The source BidiText is never modified by the transform.

The destination BidiText has its Bidi flags set to those of the argument.

Output fields of the BidiTransform object are set by this method. srcToDstMap, DstToSrcMap and propertyMap may be set by this method if the corresponding options have been required in BidiTransform when calling it.

By default, transformed output data is written to the destination BidiText character array but no maps are created.

A typical usage of this method could be:

  BidiTransform   bdx = new BidiTransform();
  BidiText        src = new BidiText();       // source text
  BidiText        dst;                        // destination reference
  src.flags.setAllFlags( {flag values for source} );
  bdx.flags.setAllFlags( {flag values for destination} );
  // assign values to src.data, src.offset, src.count
  dst = src.transform(bdx);
  

This method is still in construction. Currently only the default options are implemented. No maps are created.

Parameters:
bdx - The BidiTransform object defining the transformation.
Returns:
A BidiText which is the transformation of the "this" BidiText. If destination data is not required, a null is returned.