FileDocCategorySizeDatePackage
RBCollationTables.javaAPI DocJava SE 6 API10785Tue Jun 10 00:25:52 BST 2008java.text

RBCollationTables

public final class RBCollationTables extends Object
This class contains the static state of a RuleBasedCollator: The various tables that are used by the collation routines. Several RuleBasedCollators can share a single RBCollationTables object, easing memory requirements and improving performance.

Fields Summary
static final int
EXPANDCHARINDEX
static final int
CONTRACTCHARINDEX
static final int
UNMAPPED
static final int
PRIMARYORDERMASK
static final int
SECONDARYORDERMASK
static final int
TERTIARYORDERMASK
static final int
PRIMARYDIFFERENCEONLY
static final int
SECONDARYDIFFERENCEONLY
static final int
PRIMARYORDERSHIFT
static final int
SECONDARYORDERSHIFT
private String
rules
private boolean
frenchSec
private boolean
seAsianSwapping
private UCompactIntArray
mapping
private Vector
contractTable
private Vector
expandTable
private IntHashtable
contractFlags
private short
maxSecOrder
private short
maxTerOrder
Constructors Summary
public RBCollationTables(String rules, int decmp)

        this.rules = rules;

        RBTableBuilder builder = new RBTableBuilder(new BuildAPI());
        builder.build(rules, decmp); // this object is filled in through
                                            // the BuildAPI object
    
Methods Summary
java.util.VectorgetContractValues(int ch)
Get the entry of hash table of the contracting string in the collation table.

param
ch the starting character of the contracting string

        int index = mapping.elementAt(ch);
        return getContractValuesImpl(index - CONTRACTCHARINDEX);
    
private java.util.VectorgetContractValuesImpl(int index)

        if (index >= 0)
        {
            return (Vector)contractTable.elementAt(index);
        }
        else // not found
        {
            return null;
        }
    
static final intgetEntry(java.util.Vector list, java.lang.String name, boolean fwd)

        for (int i = 0; i < list.size(); i++) {
            EntryPair pair = (EntryPair)list.elementAt(i);
            if (pair.fwd == fwd && pair.entryName.equals(name)) {
                return i;
            }
        }
        return UNMAPPED;
    
final int[]getExpandValueList(int order)
Get the entry of hash table of the expanding string in the collation table.

param
idx the index of the expanding string value list

        return (int[])expandTable.elementAt(order - EXPANDCHARINDEX);
    
intgetMaxExpansion(int order)
Return the maximum length of any expansion sequences that end with the specified comparison order.

param
order a collation order returned by previous or next.
return
the maximum length of any expansion seuences ending with the specified order.
see
CollationElementIterator#getMaxExpansion

        int result = 1;

        if (expandTable != null) {
            // Right now this does a linear search through the entire
            // expandsion table.  If a collator had a large number of expansions,
            // this could cause a performance problem, but in practise that
            // rarely happens
            for (int i = 0; i < expandTable.size(); i++) {
                int[] valueList = (int [])expandTable.elementAt(i);
                int length = valueList.length;

                if (length > result && valueList[length-1] == order) {
                    result = length;
                }
            }
        }

        return result;
    
shortgetMaxSecOrder()

        return maxSecOrder;
    
shortgetMaxTerOrder()

        return maxTerOrder;
    
public java.lang.StringgetRules()
Gets the table-based rules for the collation object.

return
returns the collation rules that the table collation object was created from.

        return rules;
    
intgetUnicodeOrder(int ch)
Get the comarison order of a character from the collation table.

return
the comparison order of a character.

        return mapping.elementAt(ch);
    
public booleanisFrenchSec()

        return frenchSec;
    
public booleanisSEAsianSwapping()

        return seAsianSwapping;
    
static voidreverse(java.lang.StringBuffer result, int from, int to)
Reverse a string.

        int i = from;
        char swap;

        int j = to - 1;
        while (i < j) {
            swap =  result.charAt(i);
            result.setCharAt(i, result.charAt(j));
            result.setCharAt(j, swap);
            i++;
            j--;
        }
    
booleanusedInContractSeq(int c)
Returns true if this character appears anywhere in a contracting character sequence. (Used by CollationElementIterator.setOffset().)

        return contractFlags.get(c) == 1;