src/java.base/share/classes/java/text/RBCollationTables.java
author naoto
Tue, 15 Oct 2019 09:25:59 -0700
changeset 58603 2312d1a04c49
parent 47216 71c04702a3d5
permissions -rw-r--r--
8212749: DecimalFormat.setGroupingSize(int) allows setting negative grouping size 8231984: Clarify semantics of DecimalFormat.getGroupingSize(0) Reviewed-by: rriggs
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
14342
8435a30053c1 7197491: update copyright year to match last edit in jdk8 jdk repository
alanb
parents: 14014
diff changeset
     2
 * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
 * (C) Copyright Taligent, Inc. 1996, 1997 - All Rights Reserved
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
 * (C) Copyright IBM Corp. 1996-1998 - All Rights Reserved
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
 *   The original version of this source code and documentation is copyrighted
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 * and owned by Taligent, Inc., a wholly-owned subsidiary of IBM. These
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 * materials are provided under terms of a License Agreement between Taligent
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * and Sun. This technology is protected by multiple US and International
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * patents. This notice and attribution to Taligent may not be removed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 *   Taligent is a registered trademark of Taligent, Inc.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
package java.text;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
import java.util.Vector;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
import sun.text.UCompactIntArray;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
import sun.text.IntHashtable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * This class contains the static state of a RuleBasedCollator: The various
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * tables that are used by the collation routines.  Several RuleBasedCollators
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * can share a single RBCollationTables object, easing memory requirements and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * improving performance.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
final class RBCollationTables {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    //===========================================================================================
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
    //  The following diagram shows the data structure of the RBCollationTables object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
    //  Suppose we have the rule, where 'o-umlaut' is the unicode char 0x00F6.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    //  "a, A < b, B < c, C, ch, cH, Ch, CH < d, D ... < o, O; 'o-umlaut'/E, 'O-umlaut'/E ...".
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    //  What the rule says is, sorts 'ch'ligatures and 'c' only with tertiary difference and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    //  sorts 'o-umlaut' as if it's always expanded with 'e'.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    // mapping table                     contracting list           expanding list
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
    // (contains all unicode char
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    //  entries)                   ___    ____________       _________________________
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    //  ________                +>|_*_|->|'c' |v('c') |  +>|v('o')|v('umlaut')|v('e')|
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    // |_\u0001_|-> v('\u0001') | |_:_|  |------------|  | |-------------------------|
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    // |_\u0002_|-> v('\u0002') | |_:_|  |'ch'|v('ch')|  | |             :           |
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    // |____:___|               | |_:_|  |------------|  | |-------------------------|
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    // |____:___|               |        |'cH'|v('cH')|  | |             :           |
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    // |__'a'___|-> v('a')      |        |------------|  | |-------------------------|
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    // |__'b'___|-> v('b')      |        |'Ch'|v('Ch')|  | |             :           |
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    // |____:___|               |        |------------|  | |-------------------------|
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    // |____:___|               |        |'CH'|v('CH')|  | |             :           |
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    // |___'c'__|----------------         ------------   | |-------------------------|
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    // |____:___|                                        | |             :           |
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    // |o-umlaut|----------------------------------------  |_________________________|
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    // |____:___|
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    // Noted by Helena Shih on 6/23/97
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    //============================================================================================
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    public RBCollationTables(String rules, int decmp) throws ParseException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
        this.rules = rules;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
        RBTableBuilder builder = new RBTableBuilder(new BuildAPI());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
        builder.build(rules, decmp); // this object is filled in through
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
                                            // the BuildAPI object
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    final class BuildAPI {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
         * Private constructor.  Prevents anyone else besides RBTableBuilder
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
         * from gaining direct access to the internals of this class.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
        private BuildAPI() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
         * This function is used by RBTableBuilder to fill in all the members of this
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
         * object.  (Effectively, the builder class functions as a "friend" of this
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
         * class, but to avoid changing too much of the logic, it carries around "shadow"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
         * copies of all these variables until the end of the build process and then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
         * copies them en masse into the actual tables object once all the construction
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
         * logic is complete.  This function does that "copying en masse".
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
         * @param f2ary The value for frenchSec (the French-secondary flag)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
         * @param swap The value for SE Asian swapping rule
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
         * @param map The collator's character-mapping table (the value for mapping)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
         * @param cTbl The collator's contracting-character table (the value for contractTable)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
         * @param eTbl The collator's expanding-character table (the value for expandTable)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
         * @param cFlgs The hash table of characters that participate in contracting-
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
         *              character sequences (the value for contractFlags)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
         * @param mso The value for maxSecOrder
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
         * @param mto The value for maxTerOrder
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
        void fillInTables(boolean f2ary,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
                          boolean swap,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
                          UCompactIntArray map,
12848
da701d422d2c 7117230: clean up warnings in java.text
dbhole
parents: 5506
diff changeset
   115
                          Vector<Vector<EntryPair>> cTbl,
da701d422d2c 7117230: clean up warnings in java.text
dbhole
parents: 5506
diff changeset
   116
                          Vector<int[]> eTbl,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
                          IntHashtable cFlgs,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
                          short mso,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
                          short mto) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
            frenchSec = f2ary;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
            seAsianSwapping = swap;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
            mapping = map;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
            contractTable = cTbl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
            expandTable = eTbl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
            contractFlags = cFlgs;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
            maxSecOrder = mso;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
            maxTerOrder = mto;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
     * Gets the table-based rules for the collation object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
     * @return returns the collation rules that the table collation object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
     * was created from.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
    public String getRules()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
        return rules;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
    public boolean isFrenchSec() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
        return frenchSec;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
    public boolean isSEAsianSwapping() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
        return seAsianSwapping;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
    // ==============================================================
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
    // internal (for use by CollationElementIterator)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
    // ==============================================================
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
     *  Get the entry of hash table of the contracting string in the collation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
     *  table.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
     *  @param ch the starting character of the contracting string
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
     */
12848
da701d422d2c 7117230: clean up warnings in java.text
dbhole
parents: 5506
diff changeset
   158
    Vector<EntryPair> getContractValues(int ch)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
        int index = mapping.elementAt(ch);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
        return getContractValuesImpl(index - CONTRACTCHARINDEX);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
    //get contract values from contractTable by index
12848
da701d422d2c 7117230: clean up warnings in java.text
dbhole
parents: 5506
diff changeset
   165
    private Vector<EntryPair> getContractValuesImpl(int index)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
        if (index >= 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
        {
12848
da701d422d2c 7117230: clean up warnings in java.text
dbhole
parents: 5506
diff changeset
   169
            return contractTable.elementAt(index);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
        else // not found
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
     * Returns true if this character appears anywhere in a contracting
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
     * character sequence.  (Used by CollationElementIterator.setOffset().)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
    boolean usedInContractSeq(int c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
        return contractFlags.get(c) == 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
      * Return the maximum length of any expansion sequences that end
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
      * with the specified comparison order.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
      *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
      * @param order a collation order returned by previous or next.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
      * @return the maximum length of any expansion seuences ending
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
      *         with the specified order.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
      *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
      * @see CollationElementIterator#getMaxExpansion
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
      */
14014
da3648e13e67 8000269: Cleanup javadoc warnings
alanb
parents: 12848
diff changeset
   195
    int getMaxExpansion(int order) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
        int result = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
        if (expandTable != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
            // Right now this does a linear search through the entire
14014
da3648e13e67 8000269: Cleanup javadoc warnings
alanb
parents: 12848
diff changeset
   200
            // expansion table.  If a collator had a large number of expansions,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
            // this could cause a performance problem, but in practise that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
            // rarely happens
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
            for (int i = 0; i < expandTable.size(); i++) {
12848
da701d422d2c 7117230: clean up warnings in java.text
dbhole
parents: 5506
diff changeset
   204
                int[] valueList = expandTable.elementAt(i);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
                int length = valueList.length;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
                if (length > result && valueList[length-1] == order) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
                    result = length;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
        return result;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
    /**
14014
da3648e13e67 8000269: Cleanup javadoc warnings
alanb
parents: 12848
diff changeset
   217
     * Get the entry of hash table of the expanding string in the collation
da3648e13e67 8000269: Cleanup javadoc warnings
alanb
parents: 12848
diff changeset
   218
     * table.
da3648e13e67 8000269: Cleanup javadoc warnings
alanb
parents: 12848
diff changeset
   219
     * @param idx the index of the expanding string value list
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
     */
14014
da3648e13e67 8000269: Cleanup javadoc warnings
alanb
parents: 12848
diff changeset
   221
    final int[] getExpandValueList(int idx) {
da3648e13e67 8000269: Cleanup javadoc warnings
alanb
parents: 12848
diff changeset
   222
        return expandTable.elementAt(idx - EXPANDCHARINDEX);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
    /**
14014
da3648e13e67 8000269: Cleanup javadoc warnings
alanb
parents: 12848
diff changeset
   226
     * Get the comarison order of a character from the collation table.
da3648e13e67 8000269: Cleanup javadoc warnings
alanb
parents: 12848
diff changeset
   227
     * @return the comparison order of a character.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
     */
14014
da3648e13e67 8000269: Cleanup javadoc warnings
alanb
parents: 12848
diff changeset
   229
    int getUnicodeOrder(int ch) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
        return mapping.elementAt(ch);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
    short getMaxSecOrder() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
        return maxSecOrder;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
    short getMaxTerOrder() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
        return maxTerOrder;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
     * Reverse a string.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
    //shemran/Note: this is used for secondary order value reverse, no
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
    //              need to consider supplementary pair.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
    static void reverse (StringBuffer result, int from, int to)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
        int i = from;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
        char swap;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
        int j = to - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
        while (i < j) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
            swap =  result.charAt(i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
            result.setCharAt(i, result.charAt(j));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
            result.setCharAt(j, swap);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
            i++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
            j--;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
32649
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 25859
diff changeset
   261
    static final int getEntry(Vector<EntryPair> list, String name, boolean fwd) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
        for (int i = 0; i < list.size(); i++) {
12848
da701d422d2c 7117230: clean up warnings in java.text
dbhole
parents: 5506
diff changeset
   263
            EntryPair pair = list.elementAt(i);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
            if (pair.fwd == fwd && pair.entryName.equals(name)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
                return i;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
        return UNMAPPED;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
    // ==============================================================
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
    // constants
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
    // ==============================================================
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
    //sherman/Todo: is the value big enough?????
32649
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 25859
diff changeset
   275
    static final int EXPANDCHARINDEX = 0x7E000000; // Expand index follows
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 25859
diff changeset
   276
    static final int CONTRACTCHARINDEX = 0x7F000000;  // contract indexes follow
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 25859
diff changeset
   277
    static final int UNMAPPED = 0xFFFFFFFF;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
32649
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 25859
diff changeset
   279
    static final int PRIMARYORDERMASK = 0xffff0000;
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 25859
diff changeset
   280
    static final int SECONDARYORDERMASK = 0x0000ff00;
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 25859
diff changeset
   281
    static final int TERTIARYORDERMASK = 0x000000ff;
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 25859
diff changeset
   282
    static final int PRIMARYDIFFERENCEONLY = 0xffff0000;
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 25859
diff changeset
   283
    static final int SECONDARYDIFFERENCEONLY = 0xffffff00;
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 25859
diff changeset
   284
    static final int PRIMARYORDERSHIFT = 16;
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 25859
diff changeset
   285
    static final int SECONDARYORDERSHIFT = 8;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
    // ==============================================================
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
    // instance variables
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
    // ==============================================================
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
    private String rules = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
    private boolean frenchSec = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
    private boolean seAsianSwapping = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
    private UCompactIntArray mapping = null;
12848
da701d422d2c 7117230: clean up warnings in java.text
dbhole
parents: 5506
diff changeset
   295
    private Vector<Vector<EntryPair>> contractTable = null;
da701d422d2c 7117230: clean up warnings in java.text
dbhole
parents: 5506
diff changeset
   296
    private Vector<int[]> expandTable = null;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
    private IntHashtable contractFlags = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
    private short maxSecOrder = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
    private short maxTerOrder = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
}