Categories:
Audio (13)
Biotech (29)
Bytecode (36)
Database (77)
Framework (7)
Game (7)
General (507)
Graphics (53)
I/O (35)
IDE (2)
JAR Tools (101)
JavaBeans (21)
JDBC (121)
JDK (426)
JSP (20)
Logging (108)
Mail (58)
Messaging (8)
Network (84)
PDF (97)
Report (7)
Scripting (84)
Security (32)
Server (121)
Servlet (26)
SOAP (24)
Testing (54)
Web (15)
XML (309)
Collections:
Other Resources:
JDK 17 java.base.jmod - Base Module
JDK 17 java.base.jmod is the JMOD file for JDK 17 Base module.
JDK 17 Base module compiled class files are stored in \fyicenter\jdk-17.0.5\jmods\java.base.jmod.
JDK 17 Base module compiled class files are also linked and stored in the \fyicenter\jdk-17.0.5\lib\modules JImage file.
JDK 17 Base module source code files are stored in \fyicenter\jdk-17.0.5\lib\src.zip\java.base.
You can click and view the content of each source code file in the list below.
✍: FYIcenter
⏎ java/text/MergeCollation.java
/* * Copyright (c) 1996, 2019, Oracle and/or its affiliates. All rights reserved. * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. * * * * * * * * * * * * * * * * * * * * */ /* * (C) Copyright Taligent, Inc. 1996, 1997 - All Rights Reserved * (C) Copyright IBM Corp. 1996, 1997 - 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.ArrayList; /** * Utility class for normalizing and merging patterns for collation. * Patterns are strings of the form <entry>*, where <entry> has the * form: * <pattern> := <entry>* * <entry> := <separator><chars>{"/"<extension>} * <separator> := "=", ",", ";", "<", "&" * <chars>, and <extension> are both arbitrary strings. * unquoted whitespaces are ignored. * 'xxx' can be used to quote characters * One difference from Collator is that & is used to reset to a current * point. Or, in other words, it introduces a new sequence which is to * be added to the old. * That is: "a < b < c < d" is the same as "a < b & b < c & c < d" OR * "a < b < d & b < c" * XXX: make '' be a single quote. * @see PatternEntry * @author Mark Davis, Helena Shih */ final class MergeCollation { /** * Creates from a pattern * @throws ParseException If the input pattern is incorrect. */ public MergeCollation(String pattern) throws ParseException { for (int i = 0; i < statusArray.length; i++) statusArray[i] = 0; setPattern(pattern); } /** * recovers current pattern */ public String getPattern() { return getPattern(true); } /** * recovers current pattern. * @param withWhiteSpace puts spacing around the entries, and \n * before & and < */ public String getPattern(boolean withWhiteSpace) { StringBuffer result = new StringBuffer(); PatternEntry tmp = null; ArrayList<PatternEntry> extList = null; int i; for (i = 0; i < patterns.size(); ++i) { PatternEntry entry = patterns.get(i); if (!entry.extension.isEmpty()) { if (extList == null) extList = new ArrayList<>(); extList.add(entry); } else { if (extList != null) { PatternEntry last = findLastWithNoExtension(i-1); for (int j = extList.size() - 1; j >= 0 ; j--) { tmp = extList.get(j); tmp.addToBuffer(result, false, withWhiteSpace, last); } extList = null; } entry.addToBuffer(result, false, withWhiteSpace, null); } } if (extList != null) { PatternEntry last = findLastWithNoExtension(i-1); for (int j = extList.size() - 1; j >= 0 ; j--) { tmp = extList.get(j); tmp.addToBuffer(result, false, withWhiteSpace, last); } extList = null; } return result.toString(); } private final PatternEntry findLastWithNoExtension(int i) { for (--i;i >= 0; --i) { PatternEntry entry = patterns.get(i); if (entry.extension.isEmpty()) { return entry; } } return null; } /** * emits the pattern for collation builder. * @return emits the string in the format understable to the collation * builder. */ public String emitPattern() { return emitPattern(true); } /** * emits the pattern for collation builder. * @param withWhiteSpace puts spacing around the entries, and \n * before & and < * @return emits the string in the format understable to the collation * builder. */ public String emitPattern(boolean withWhiteSpace) { StringBuffer result = new StringBuffer(); for (int i = 0; i < patterns.size(); ++i) { PatternEntry entry = patterns.get(i); if (entry != null) { entry.addToBuffer(result, true, withWhiteSpace, null); } } return result.toString(); } /** * sets the pattern. */ public void setPattern(String pattern) throws ParseException { patterns.clear(); addPattern(pattern); } /** * adds a pattern to the current one. * @param pattern the new pattern to be added */ public void addPattern(String pattern) throws ParseException { if (pattern == null) return; PatternEntry.Parser parser = new PatternEntry.Parser(pattern); PatternEntry entry = parser.next(); while (entry != null) { fixEntry(entry); entry = parser.next(); } } /** * gets count of separate entries * @return the size of pattern entries */ public int getCount() { return patterns.size(); } /** * gets count of separate entries * @param index the offset of the desired pattern entry * @return the requested pattern entry */ public PatternEntry getItemAt(int index) { return patterns.get(index); } //============================================================ // privates //============================================================ ArrayList<PatternEntry> patterns = new ArrayList<>(); // a list of PatternEntries private transient PatternEntry saveEntry = null; private transient PatternEntry lastEntry = null; // This is really used as a local variable inside fixEntry, but we cache // it here to avoid newing it up every time the method is called. private transient StringBuffer excess = new StringBuffer(); // // When building a MergeCollation, we need to do lots of searches to see // whether a given entry is already in the table. Since we're using an // array, this would make the algorithm O(N*N). To speed things up, we // use this bit array to remember whether the array contains any entries // starting with each Unicode character. If not, we can avoid the search. // Using BitSet would make this easier, but it's significantly slower. // private transient byte[] statusArray = new byte[8192]; private final byte BITARRAYMASK = (byte)0x1; private final int BYTEPOWER = 3; private final int BYTEMASK = (1 << BYTEPOWER) - 1; /* If the strength is RESET, then just change the lastEntry to be the current. (If the current is not in patterns, signal an error). If not, then remove the current entry, and add it after lastEntry (which is usually at the end). */ private final void fixEntry(PatternEntry newEntry) throws ParseException { // check to see whether the new entry has the same characters as the previous // entry did (this can happen when a pattern declaring a difference between two // strings that are canonically equivalent is normalized). If so, and the strength // is anything other than IDENTICAL or RESET, throw an exception (you can't // declare a string to be unequal to itself). --rtg 5/24/99 if (lastEntry != null && newEntry.chars.equals(lastEntry.chars) && newEntry.extension.equals(lastEntry.extension)) { if (newEntry.strength != Collator.IDENTICAL && newEntry.strength != PatternEntry.RESET) { throw new ParseException("The entries " + lastEntry + " and " + newEntry + " are adjacent in the rules, but have conflicting " + "strengths: A character can't be unequal to itself.", -1); } else { // otherwise, just skip this entry and behave as though you never saw it return; } } boolean changeLastEntry = true; if (newEntry.strength != PatternEntry.RESET) { int oldIndex = -1; if ((newEntry.chars.length() == 1)) { char c = newEntry.chars.charAt(0); int statusIndex = c >> BYTEPOWER; byte bitClump = statusArray[statusIndex]; byte setBit = (byte)(BITARRAYMASK << (c & BYTEMASK)); if (bitClump != 0 && (bitClump & setBit) != 0) { oldIndex = patterns.lastIndexOf(newEntry); } else { // We're going to add an element that starts with this // character, so go ahead and set its bit. statusArray[statusIndex] = (byte)(bitClump | setBit); } } else { oldIndex = patterns.lastIndexOf(newEntry); } if (oldIndex != -1) { patterns.remove(oldIndex); } excess.setLength(0); int lastIndex = findLastEntry(lastEntry, excess); if (excess.length() != 0) { newEntry.extension = excess + newEntry.extension; if (lastIndex != patterns.size()) { lastEntry = saveEntry; changeLastEntry = false; } } if (lastIndex == patterns.size()) { patterns.add(newEntry); saveEntry = newEntry; } else { patterns.add(lastIndex, newEntry); } } if (changeLastEntry) { lastEntry = newEntry; } } private final int findLastEntry(PatternEntry entry, StringBuffer excessChars) throws ParseException { if (entry == null) return 0; if (entry.strength != PatternEntry.RESET) { // Search backwards for string that contains this one; // most likely entry is last one int oldIndex = -1; if ((entry.chars.length() == 1)) { int index = entry.chars.charAt(0) >> BYTEPOWER; if ((statusArray[index] & (BITARRAYMASK << (entry.chars.charAt(0) & BYTEMASK))) != 0) { oldIndex = patterns.lastIndexOf(entry); } } else { oldIndex = patterns.lastIndexOf(entry); } if ((oldIndex == -1)) throw new ParseException("couldn't find last entry: " + entry, oldIndex); return oldIndex + 1; } else { int i; for (i = patterns.size() - 1; i >= 0; --i) { PatternEntry e = patterns.get(i); if (e.chars.regionMatches(0,entry.chars,0, e.chars.length())) { excessChars.append(entry.chars, e.chars.length(), entry.chars.length()); break; } } if (i == -1) throw new ParseException("couldn't find: " + entry, i); return i + 1; } } }
⏎ java/text/MergeCollation.java
Or download all of them as a single archive file:
File name: java.base-17.0.5-src.zip File size: 8883851 bytes Release date: 2022-09-13 Download
2023-09-26, 68856👍, 1💬
Popular Posts:
JLayer is a library that decodes/plays/converts MPEG 1/2/2.5 Layer 1/2/3 (i.e. MP3) in real time for...
How to read XML document with XML Schema validation from socket connections with the socket\DelayedI...
xml-commons External Source Code Files are provided in the source package file, xml-commons-external...
Snappy-Java is a Java port of the "snappy", a fast C++ compresser/decompresser developed by Google. ...
Jaxen, Release 1.1.1, is an open source XPath library written in Java. It is adaptable to many diffe...