java.text
Class RBTableBuilder

java.lang.Object
  extended byjava.text.RBTableBuilder

final class RBTableBuilder
extends Object

This class contains all the code to parse a RuleBasedCollator pattern and build a RBCollationTables object from it. A particular instance of tis class exists only during the actual build process-- once an RBCollationTables object has been built, the RBTableBuilder object goes away. This object carries all of the state which is only needed during the build process, plus a "shadow" copy of all of the state that will go into the tables object itself. This object communicates with RBCollationTables through a separate class, RBCollationTables.BuildAPI, this is an inner class of RBCollationTables and provides a separate private API for communication with RBTableBuilder. This class isn't just an inner class of RBCollationTables itself because of its large size. For source-code readability, it seemed better for the builder to have its own source file.


Field Summary
(package private) static int CHARINDEX
           
private  sun.text.IntHashtable contractFlags
           
private  Vector contractTable
           
private  Vector expandTable
           
private  boolean frenchSec
           
private static int IGNORABLEMASK
           
private static int INITIALTABLESIZE
           
private  boolean isOverIgnore
           
private  StringBuffer key
           
private  sun.text.CompactIntArray mapping
           
private static int MAXKEYSIZE
           
private  short maxSecOrder
           
private  short maxTerOrder
           
private  MergeCollation mPattern
           
private static int PRIMARYORDERINCREMENT
           
private  boolean seAsianSwapping
           
private static int SECONDARYORDERINCREMENT
           
private  RBCollationTables.BuildAPI tables
           
private static int TERTIARYORDERINCREMENT
           
 
Constructor Summary
RBTableBuilder(RBCollationTables.BuildAPI tables)
           
 
Method Summary
private  void addComposedChars()
          Add expanding entries for pre-composed unicode characters so that this collator can be used reasonably well with decomposition turned off.
private  void addContractFlags(String chars)
           
private  void addContractOrder(String groupChars, int anOrder)
           
private  void addContractOrder(String groupChars, int anOrder, boolean fwd)
          Adds the contracting string into the collation table.
private  void addExpandOrder(String contractChars, String expandChars, int anOrder)
          Adds the expanding string into the collation table.
private  int addExpansion(int anOrder, String expandChars)
          Create a new entry in the expansion table that contains the orderings for the given characers.
private  void addOrder(char ch, int anOrder)
          Adds a character and its designated order into the collation table.
 void build(String pattern, int decmp)
          Create a table-based collation object with the given rules.
private  void commit()
          Look up for unmapped values in the expanded character table.
private  int getCharOrder(char ch)
           
private  int getContractOrder(String groupChars)
          If the given string has been specified as a contracting string in this collation table, return its ordering.
(package private)  Vector getContractValues(char ch)
          Get the entry of hash table of the contracting string in the collation table.
(package private)  Vector getContractValues(int index)
           
private  int increment(int aStrength, int lastValue)
          Increment of the last order based on the comparison level.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CHARINDEX

static final int CHARINDEX
See Also:
Constant Field Values

IGNORABLEMASK

private static final int IGNORABLEMASK
See Also:
Constant Field Values

PRIMARYORDERINCREMENT

private static final int PRIMARYORDERINCREMENT
See Also:
Constant Field Values

SECONDARYORDERINCREMENT

private static final int SECONDARYORDERINCREMENT
See Also:
Constant Field Values

TERTIARYORDERINCREMENT

private static final int TERTIARYORDERINCREMENT
See Also:
Constant Field Values

INITIALTABLESIZE

private static final int INITIALTABLESIZE
See Also:
Constant Field Values

MAXKEYSIZE

private static final int MAXKEYSIZE
See Also:
Constant Field Values

tables

private RBCollationTables.BuildAPI tables

mPattern

private MergeCollation mPattern

isOverIgnore

private boolean isOverIgnore

key

private StringBuffer key

contractFlags

private sun.text.IntHashtable contractFlags

frenchSec

private boolean frenchSec

seAsianSwapping

private boolean seAsianSwapping

mapping

private sun.text.CompactIntArray mapping

contractTable

private Vector contractTable

expandTable

private Vector expandTable

maxSecOrder

private short maxSecOrder

maxTerOrder

private short maxTerOrder
Constructor Detail

RBTableBuilder

public RBTableBuilder(RBCollationTables.BuildAPI tables)
Method Detail

build

public void build(String pattern,
                  int decmp)
           throws ParseException
Create a table-based collation object with the given rules. This is the main function that actually builds the tables and stores them back in the RBCollationTables object. It is called ONLY by the RBCollationTables constructor.

Throws:
ParseException - If the rules format is incorrect.
See Also:
java.util.RuleBasedCollator#RuleBasedCollator

addComposedChars

private void addComposedChars()
                       throws ParseException
Add expanding entries for pre-composed unicode characters so that this collator can be used reasonably well with decomposition turned off.

Throws:
ParseException

commit

private final void commit()
Look up for unmapped values in the expanded character table. When the expanding character tables are built by addExpandOrder, it doesn't know what the final ordering of each character in the expansion will be. Instead, it just puts the raw character code into the table, adding CHARINDEX as a flag. Now that we've finished building the mapping table, we can go back and look up that character to see what its real collation order is and stick that into the expansion table. That lets us avoid doing a two-stage lookup later.


increment

private final int increment(int aStrength,
                            int lastValue)
Increment of the last order based on the comparison level.


addOrder

private final void addOrder(char ch,
                            int anOrder)
Adds a character and its designated order into the collation table.


addContractOrder

private final void addContractOrder(String groupChars,
                                    int anOrder)

addContractOrder

private final void addContractOrder(String groupChars,
                                    int anOrder,
                                    boolean fwd)
Adds the contracting string into the collation table.


getContractOrder

private int getContractOrder(String groupChars)
If the given string has been specified as a contracting string in this collation table, return its ordering. Otherwise return UNMAPPED.


getCharOrder

private final int getCharOrder(char ch)

getContractValues

Vector getContractValues(char ch)
Get the entry of hash table of the contracting string in the collation table.

Parameters:
ch - the starting character of the contracting string

getContractValues

Vector getContractValues(int index)

addExpandOrder

private final void addExpandOrder(String contractChars,
                                  String expandChars,
                                  int anOrder)
                           throws ParseException
Adds the expanding string into the collation table.

Throws:
ParseException

addExpansion

private int addExpansion(int anOrder,
                         String expandChars)
Create a new entry in the expansion table that contains the orderings for the given characers. If anOrder is valid, it is added to the beginning of the expanded list of orders.


addContractFlags

private void addContractFlags(String chars)