Class BidiText
- java.lang.Object
-
- com.ibm.as400.access.BidiText
-
public class BidiText 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
Fields Modifier and Type Field and Description int
count
length of the "interesting" data within the character arraychar[]
data
character array containing the dataBidiFlagSet
flags
BidiFlagSet qualifying the character dataint
offset
offset of the "interesting" data within the character array
-
Constructor Summary
Constructors 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
Methods Modifier and Type Method and Description boolean
equals(BidiText other)
Compares two BidiText objects.boolean
equals(java.lang.Object other)
void
setCharsRef(char[] newData, int newOffset, int newLength)
Replaces the character data reference in the BidiText object.char[]
toCharArray()
Extracts the character data from a BidiText in character array formatjava.lang.String
toString()
Extracts the character data from a BidiText in string formatBidiText
transform(BidiFlagSet dstFlags)
Transforms the data in the "this" BidiText object and return the resulting BidiText object.BidiText
transform(BidiTransform bdx)
Transforms the data in the "this" BidiText object and return the resulting BidiText object.
-
-
-
Field Detail
-
flags
public BidiFlagSet flags
BidiFlagSet qualifying the character data
-
data
public char[] data
character array containing the data
-
offset
public int offset
offset of the "interesting" data within the character array
-
count
public int count
length of the "interesting" data within the character array
-
-
Constructor Detail
-
BidiText
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
public BidiText(BidiFlagSet initFlags)
Constructs a BidiText object based on an existing BidiFlagSet. There is no data and no character array.- Parameters:
initFlags
-
-
BidiText
public BidiText(BidiFlagSet initFlags, 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
public 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.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
public BidiText(BidiFlagSet initFlags, 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
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.
-
equals
public boolean equals(java.lang.Object other)
- Overrides:
equals
in classjava.lang.Object
-
setCharsRef
public void setCharsRef(char[] newData, int newOffset, 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
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
public java.lang.String toString()
Extracts the character data from a BidiText in string format- Overrides:
toString
in classjava.lang.Object
- Returns:
- A string containing a copy of the "interesting" data.
-
transform
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
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.
-
-