|
Java example source code file (RBCollationTables.java)
The RBCollationTables.java Java example source code/* * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ /* * (C) Copyright Taligent, Inc. 1996, 1997 - All Rights Reserved * (C) Copyright IBM Corp. 1996-1998 - All Rights Reserved * * The original version of this source code and documentation is copyrighted * and owned by Taligent, Inc., a wholly-owned subsidiary of IBM. These * materials are provided under terms of a License Agreement between Taligent * and Sun. This technology is protected by multiple US and International * patents. This notice and attribution to Taligent may not be removed. * Taligent is a registered trademark of Taligent, Inc. * */ package java.text; import java.util.Vector; import sun.text.UCompactIntArray; import sun.text.IntHashtable; /** * 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. */ final class RBCollationTables { //=========================================================================================== // The following diagram shows the data structure of the RBCollationTables object. // Suppose we have the rule, where 'o-umlaut' is the unicode char 0x00F6. // "a, A < b, B < c, C, ch, cH, Ch, CH < d, D ... < o, O; 'o-umlaut'/E, 'O-umlaut'/E ...". // What the rule says is, sorts 'ch'ligatures and 'c' only with tertiary difference and // sorts 'o-umlaut' as if it's always expanded with 'e'. // // mapping table contracting list expanding list // (contains all unicode char // entries) ___ ____________ _________________________ // ________ +>|_*_|->|'c' |v('c') | +>|v('o')|v('umlaut')|v('e')| // |_\u0001_|-> v('\u0001') | |_:_| |------------| | |-------------------------| // |_\u0002_|-> v('\u0002') | |_:_| |'ch'|v('ch')| | | : | // |____:___| | |_:_| |------------| | |-------------------------| // |____:___| | |'cH'|v('cH')| | | : | // |__'a'___|-> v('a') | |------------| | |-------------------------| // |__'b'___|-> v('b') | |'Ch'|v('Ch')| | | : | // |____:___| | |------------| | |-------------------------| // |____:___| | |'CH'|v('CH')| | | : | // |___'c'__|---------------- ------------ | |-------------------------| // |____:___| | | : | // |o-umlaut|---------------------------------------- |_________________________| // |____:___| // // Noted by Helena Shih on 6/23/97 //============================================================================================ public RBCollationTables(String rules, int decmp) throws ParseException { this.rules = rules; RBTableBuilder builder = new RBTableBuilder(new BuildAPI()); builder.build(rules, decmp); // this object is filled in through // the BuildAPI object } final class BuildAPI { /** * Private constructor. Prevents anyone else besides RBTableBuilder * from gaining direct access to the internals of this class. */ private BuildAPI() { } /** * This function is used by RBTableBuilder to fill in all the members of this * object. (Effectively, the builder class functions as a "friend" of this * class, but to avoid changing too much of the logic, it carries around "shadow" * copies of all these variables until the end of the build process and then * copies them en masse into the actual tables object once all the construction * logic is complete. This function does that "copying en masse". * @param f2ary The value for frenchSec (the French-secondary flag) * @param swap The value for SE Asian swapping rule * @param map The collator's character-mapping table (the value for mapping) * @param cTbl The collator's contracting-character table (the value for contractTable) * @param eTbl The collator's expanding-character table (the value for expandTable) * @param cFlgs The hash table of characters that participate in contracting- * character sequences (the value for contractFlags) * @param mso The value for maxSecOrder * @param mto The value for maxTerOrder */ void fillInTables(boolean f2ary, boolean swap, UCompactIntArray map, Vector<Vector Other Java examples (source code examples)Here is a short list of links related to this Java RBCollationTables.java source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.