Class BidiFlagSet
- java.lang.Object
-
- com.ibm.as400.access.BidiFlagSet
-
public class BidiFlagSet extends java.lang.Object
This class represents a BidiFlagSet object defining the text attributes to be used during a Bidi layout transformation process and the available values for each flag.Bidi text can be stored in different formats, which are characterized by 5 Bidi attributes, whose values may be stored in 5 Bidi flags. These 5 flags constitute a BidiFlagSet.
A BidiFlagSet object contains a value for each of the 5 Bidi flags which represent the Bidi attributes. The 5 attributes are:
- type of text (Implicit or Visual)
- orientation (LTR, RTL, Contextual LTR, Contextual RTL)
- symmetric swapping (Yes or No)
- numeral shapes (Nominal, National, Contextual or Any)
- text shapes (Nominal, Shaped, Initial, Middle, Final or Isolated)
Multi-threading considerations: Different threads may use the same BidiFlagSet instance if they all mean it to represent identical values of the Bidi attributes. For different values of the Bidi attributes, distinct instances of this class must be used.
-
-
Constructor Summary
Constructors Constructor and Description BidiFlagSet()
Constructs a BidiFlagSet with the default value.BidiFlagSet(BidiFlag flag)
Constructs a BidiFlagSet from one BidiFlag.BidiFlagSet(BidiFlag flag1, BidiFlag flag2)
Constructs a BidiFlagSet from two BidiFlags.BidiFlagSet(BidiFlag flag1, BidiFlag flag2, BidiFlag flag3)
Constructs a BidiFlagSet from three BidiFlags.BidiFlagSet(BidiFlag flag1, BidiFlag flag2, BidiFlag flag3, BidiFlag flag4)
Constructs a BidiFlagSet from four BidiFlags.BidiFlagSet(BidiFlag flag1, BidiFlag flag2, BidiFlag flag3, BidiFlag flag4, BidiFlag flag5)
Constructs a BidiFlagSet from five BidiFlags.BidiFlagSet(BidiFlagSet model)
Constructs a BidiFlagSet based on an existing BidiFlagSet.BidiFlagSet(char[] chars)
Constructs a BidiFlagSet from a char array.BidiFlagSet(java.lang.String str)
Constructs a BidiFlagSet from a string.
-
Method Summary
Methods Modifier and Type Method and Description boolean
equals(java.lang.Object obj)
Compares two BidiFlagSets.BidiFlag
getNumerals()
Returns the numeral shapes flag from a BidiFlagSet.BidiFlag
getOrientation()
Returns the orientation flag from a BidiFlagSet.BidiFlag
getSwap()
Returns the symmetric swapping flag from a BidiFlagSet.BidiFlag
getText()
Returns the text shapes flag from a BidiFlagSet.BidiFlag
getType()
Returns the type-of-text flag from a BidiFlagSet.int
hashCode()
Returns a hashcode for a BidiFlagSet.static void
set2AllFlags(BidiFlagSet flags1, BidiFlagSet flags2, java.lang.String str)
Sets all the Bidi flags in 2 BidiFlagSets based on a string.void
setAllFlags(BidiFlagSet model)
Sets all bidi flags based on another BidiFlagSet.void
setAllFlags(java.lang.String str)
Sets all bidi flags from a string.void
setOneFlag(BidiFlag newFlag)
Sets a new value for one of the Bidi flags in a set without changing the other Bidi flags.java.lang.String
toString()
Creates a string that represents the various Bidi flags grouped in a BidiFlagSet.
-
-
-
Constructor Detail
-
BidiFlagSet
public BidiFlagSet()
Constructs a BidiFlagSet with the default value. The default is:Type: implicit Orientation: LTR Swapping: YES Numeral Shapes: Nominal Text Shapes: Nominal
-
BidiFlagSet
public BidiFlagSet(BidiFlagSet model)
Constructs a BidiFlagSet based on an existing BidiFlagSet.- Parameters:
model
- The BidiFlagSet which is copied.
-
BidiFlagSet
public BidiFlagSet(BidiFlag flag)
Constructs a BidiFlagSet from one BidiFlag. The other Bidi flags are set to their default.Example:
BidiFlagset bdfs = new BidiFlagSet(ORIENTATION_RTL);
- Parameters:
flag
- The BidiFlag which is explicitly specified.
-
BidiFlagSet
public BidiFlagSet(BidiFlag flag1, BidiFlag flag2)
Constructs a BidiFlagSet from two BidiFlags. The other Bidi flags are set to their default. If there is a contradiction or a duplication between the arguments, then an IllegalArgumentException is thrown.Example:
BidiFlagset bdfs = new BidiFlagSet(ORIENTATION_RTL, TYPE_VISUAL);
- Parameters:
flag1
- The first BidiFlag which is explicitly specified.flag2
- The second BidiFlag which is explicitly specified.- Throws:
java.lang.IllegalArgumentException
- If the arguments conflict or are duplicates.
-
BidiFlagSet
public BidiFlagSet(BidiFlag flag1, BidiFlag flag2, BidiFlag flag3)
Constructs a BidiFlagSet from three BidiFlags. The other Bidi flags are set to their default. If there is a contradiction or a duplication between the arguments, then an IllegalArgumentException is thrown.Example:
BidiFlagset bdfs = new BidiFlagSet(ORIENTATION_RTL, TYPE_VISUAL, SWAP_YES);
- Parameters:
flag1
- The first BidiFlag which is explicitly specified.flag2
- The second BidiFlag which is explicitly specified.flag3
- The third BidiFlag which is explicitly specified.- Throws:
java.lang.IllegalArgumentException
- If the arguments conflict or are duplicates.
-
BidiFlagSet
public BidiFlagSet(BidiFlag flag1, BidiFlag flag2, BidiFlag flag3, BidiFlag flag4)
Constructs a BidiFlagSet from four BidiFlags. The other Bidi flag is set to its default. If there is a contradiction or a duplication between the arguments, then an IllegalArgumentException is thrown.- Parameters:
flag1
- The first BidiFlag which is explicitly specified.flag2
- The second BidiFlag which is explicitly specified.flag3
- The third BidiFlag which is explicitly specified.flag4
- The fourth BidiFlag which is explicitly specified.- Throws:
java.lang.IllegalArgumentException
- If the arguments conflict or are duplicates.
-
BidiFlagSet
public BidiFlagSet(BidiFlag flag1, BidiFlag flag2, BidiFlag flag3, BidiFlag flag4, BidiFlag flag5)
Constructs a BidiFlagSet from five BidiFlags. If there is a contradiction or a duplication between the arguments, then an IllegalArgumentException is thrown.- Parameters:
flag1
- The first BidiFlag which is explicitly specified.flag2
- The second BidiFlag which is explicitly specified.flag3
- The third BidiFlag which is explicitly specified.flag4
- The fourth BidiFlag which is explicitly specified.flag5
- The fifth BidiFlag which is explicitly specified.- Throws:
java.lang.IllegalArgumentException
- If the arguments conflict or duplicate
-
BidiFlagSet
public BidiFlagSet(char[] chars)
Constructs a BidiFlagSet from a char array. The content of the array must follow the specification for the "S" and "U" parts of the BIDI environment variable, as follows:- character 1: type of text = I (Implicit) or V (Visual)
- character 2: orientation = L (LTR), R (RTL), C (Contextual LTR) or D (Contextual RTL)
- character 3: swapping = Y (Swapping ON) or N (Swapping OFF)
- character 4: text shaping = N (Nominal), S (Shaped), I (Initial), M (Middle), F (Final), B (Isolated)
- character 5: numeral shaping = N (Nominal), H (National), C (Contextual), A (Any)
- character 6: bidi algorithm = U (Unicode), R (Roundtrip)
- character 7: Lamalef mode = G (Grow), S(Shrink), N (Near), B (Begin), E (End), W (groW with space), A (Auto)
- character 8: SeenTail mode = O (One cell), N (Near), B (Begin), E (End), A (Auto)
- character 9: Yeh Hamza mode = O (One cell), N (Near), B (Begin), E (End), A (Auto)
- character 10: Tashkeel mode = Z (Zero width), W (with Width), B (Begin), E (End), A (Auto)
Only characters 1 to 5 are used to build the BidiFlagSet.
- Parameters:
chars
- A character array.
-
BidiFlagSet
public BidiFlagSet(java.lang.String str) throws java.lang.IllegalArgumentException
Constructs a BidiFlagSet from a string. The content of the string must follow the syntax of the modifiers specified in X/Open standard "Portable Layout Services".The string contains sequences in the form "keyword=value" separated by commas.
This format is compatible with the result of the toString method. This format is useful when readibility is more important than efficiency.
The supported keywords are: typeoftext, orientation, context, swapping, numerals and shaping.
The following keywords are ignored but do not cause a syntax error: @ls, implicitalg, checkmode, shapcharset.
Example:
typeoftext=implicit, orientation=rtl, swap=yes, shaping=nominal, numerals=nominal
- Parameters:
str
- A string in the format "flag=value [,...]".- Throws:
java.lang.IllegalArgumentException
- If the syntax of the data is invalid.- See Also:
toString()
-
-
Method Detail
-
equals
public boolean equals(java.lang.Object obj)
Compares two BidiFlagSets. Two BidiFlagSets are considered equal if they represent the same values for the 5 Bidi flags.- Overrides:
equals
in classjava.lang.Object
- Parameters:
obj
- The BidiFlagSet to compare to this.- Returns:
- true if the BidiFlagSets are equal, false otherwise.
-
getNumerals
public BidiFlag getNumerals()
Returns the numeral shapes flag from a BidiFlagSet.- Returns:
- The value of the numeral shapes flag.
The expected value is one of NUMERALS_NOMINAL, NUMERALS_NATIONAL, NUMERALS_CONTEXTUAL, NUMERALS_ANY.
It can be tested as in the following example:if (getNumerals(myFlags) == NUMERALS_NATIONAL) . . .
-
getOrientation
public BidiFlag getOrientation()
Returns the orientation flag from a BidiFlagSet.- Returns:
- The value of the orientation flag.
The expected value is one of ORIENTATION_LTR, ORIENTATION_RTL, ORIENTATION_CONTEXT_LTR, ORIENTATION_CONTEXT_RTL.
It can be tested as in the following example:if (getOrientation(myFlags) == ORIENTATION_RTL) . . .
-
getSwap
public BidiFlag getSwap()
Returns the symmetric swapping flag from a BidiFlagSet.- Returns:
- The value of the symmetric swapping flag.
The expected value is one of SWAP_YES, SWAP_NO.
It can be tested as in the following example:if (getSwap(myFlags) == SWAP_YES) . . .
-
getText
public BidiFlag getText()
Returns the text shapes flag from a BidiFlagSet.- Returns:
- The value of the text shapes flag.
The expected value is one of TEXT_NOMINAL, TEXT_SHAPED, TEXT_INITIAL, TEXT_MIDDLE, TEXT_FINAL, TEXT_ISOLATED.
It can be tested as in the following example:if (getText(myFlags) == TEXT_MIDDLE) . . .
-
getType
public BidiFlag getType()
Returns the type-of-text flag from a BidiFlagSet.- Returns:
- The value of the type-of-text flag.
The expected value is one of TYPE_IMPLICIT, TYPE_VISUAL.
It can be tested as in the following example:if (getType(myFlags) == TYPE_VISUAL) . . .
-
hashCode
public int hashCode()
Returns a hashcode for a BidiFlagSet. The hashcode of a BidiFlagSet is the same as the hashcode of its value.- Overrides:
hashCode
in classjava.lang.Object
- Returns:
- A hashcode value.
-
setAllFlags
public void setAllFlags(BidiFlagSet model)
Sets all bidi flags based on another BidiFlagSet.- Parameters:
model
- The BidiFlagSet which is copied.
-
setAllFlags
public void setAllFlags(java.lang.String str) throws java.lang.IllegalArgumentException
Sets all bidi flags from a string. The content of the string must follow the syntax of modifiers specified in X/Open standard "Portable Layout Services".The string contains sequences of the form "keyword=value" separated by commas.
This format is compatible with the result of the toString method. This format is useful when readibility is more important than efficiency.
The supported keywords are: typeoftext, orientation, context, swapping, numerals and shaping.
The following keywords are ignored but do not cause a syntax error: @ls, implicitalg, checkmode, shapcharset.
Example:
typeoftext=visual, orientation=ltr, swap=no, shaping=shaped, numerals=contextual
- Parameters:
str
- A string in the format "flag=value [,...]".- Throws:
java.lang.IllegalArgumentException
- If the syntax of the data is invalid.- See Also:
toString()
-
set2AllFlags
public static void set2AllFlags(BidiFlagSet flags1, BidiFlagSet flags2, java.lang.String str) throws java.lang.IllegalArgumentException
Sets all the Bidi flags in 2 BidiFlagSets based on a string. The content of the string must follow the syntax of modifiers specified in X/Open standard "Portable Layout Services". This may be used to specify in one operation the Bidi flags of the source and the destination of a transformation.The string contains sequences of the form "keyword=value" or "keyword=value1:value2", with a separating comma. Each keyword is followed by one or two values. In the first case, this value applies to both source and destination. In the second case, the two values are separated by a colon; the first value applies to the source and the second value to the destination.
The supported keywords are: typeoftext, orientation, context, swapping, numerals and shaping.
The following keywords are ignored but do not cause a syntax error: @ls, implicitalg, checkmode, shapcharset.
Example: the source flags are "implicit, ltr, swapping on"; the target flags are "visual, ltr, no swapping". The string will be:
typeoftext=implicit:visual, orientation=ltr, swapping=yes:no
- Parameters:
flags1
- The first BidiFlagSet to be set.flags2
- The second BidiFlagSet to be set.str
- A string in the format "flag=value [,...]".- Throws:
java.lang.IllegalArgumentException
- If the syntax of the data is invalid.
-
setOneFlag
public void setOneFlag(BidiFlag newFlag)
Sets a new value for one of the Bidi flags in a set without changing the other Bidi flags.The new value must be one of the pre-defined values for BidiFlag.
- Parameters:
newFlag
- The new value requested for one of the flags.
-
toString
public java.lang.String toString()
Creates a string that represents the various Bidi flags grouped in a BidiFlagSet. This may be useful for instance for debugging.The format is compatible with the syntax of modifiers in X/Open standard "Portable Layout Services".
For each flag, an expression of the form "keyword=value" is added to the string. Adjacent expressions are separated by a comma and a space.
The keywords and their respective sets of values are:
KEYWORD VALUES ----------- --------------- typeoftext implicit visual orientation ltr rtl contextual context ltr rtl swapping yes no numerals nominal national contextual any shaping nominal shaped shform1 shform2 shform3 shform4
- Overrides:
toString
in classjava.lang.Object
- Returns:
- A human readable form of the flag values.
-
-