com.ibm.bidiTools.bdlayout
Class BidiFlagSet

java.lang.Object
  extended by com.ibm.bidiTools.bdlayout.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:

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
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
 boolean equals(BidiFlagSet other)
          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.
 
Methods inherited from class java.lang.Object
equals, getClass, notify, notifyAll, wait, wait, wait
 

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:

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(BidiFlagSet other)
Compares two BidiFlagSets. Two BidiFlagSets are considered equal if they represent the same values for the 5 Bidi flags.

Parameters:
other - 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.
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 class java.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
  shaping         nominal shaped shform1 shform2 shform3 shform4
  

Overrides:
toString in class java.lang.Object
Returns:
A human readable form of the flag values.