Merge
This commit is contained in:
commit
b290c5dc99
@ -92,11 +92,11 @@ FILES_java = \
|
||||
sun/text/normalizer/SymbolTable.java \
|
||||
sun/text/normalizer/Trie.java \
|
||||
sun/text/normalizer/TrieIterator.java \
|
||||
sun/text/normalizer/UBiDiProps.java \
|
||||
sun/text/normalizer/UCharacter.java \
|
||||
sun/text/normalizer/UCharacterIterator.java \
|
||||
sun/text/normalizer/UCharacterProperty.java \
|
||||
sun/text/normalizer/UCharacterPropertyReader.java \
|
||||
sun/text/normalizer/UProperty.java \
|
||||
sun/text/normalizer/UTF16.java \
|
||||
sun/text/normalizer/UnicodeMatcher.java \
|
||||
sun/text/normalizer/UnicodeSet.java \
|
||||
|
@ -64,7 +64,8 @@ BIFILES = $(TEXT_CLASSDIR)/CharacterBreakIteratorData \
|
||||
$(TEXT_CLASSDIR)/SentenceBreakIteratorData
|
||||
|
||||
ICU_FILES = $(TEXT_CLASSDIR)/unorm.icu \
|
||||
$(TEXT_CLASSDIR)/uprops.icu
|
||||
$(TEXT_CLASSDIR)/uprops.icu \
|
||||
$(TEXT_CLASSDIR)/ubidi.icu
|
||||
|
||||
# builder
|
||||
GENERATEBREAKITERATORDATA_JARFILE = \
|
||||
@ -89,7 +90,7 @@ $(BIFILES): $(GENERATEBREAKITERATORDATA_JARFILE) \
|
||||
build: $(BIFILES) $(ICU_FILES)
|
||||
|
||||
#
|
||||
# Extra rules to copy unorm.icu and uprops.icu
|
||||
# Extra rules to copy unorm.icu, uprops.icu, and ubidi.icu
|
||||
#
|
||||
$(TEXT_CLASSDIR)/unorm.icu: $(TEXT_SRCDIR)/unorm.icu
|
||||
$(install-file)
|
||||
@ -97,6 +98,9 @@ $(TEXT_CLASSDIR)/unorm.icu: $(TEXT_SRCDIR)/unorm.icu
|
||||
$(TEXT_CLASSDIR)/uprops.icu: $(TEXT_SRCDIR)/uprops.icu
|
||||
$(install-file)
|
||||
|
||||
$(TEXT_CLASSDIR)/ubidi.icu: $(TEXT_SRCDIR)/ubidi.icu
|
||||
$(install-file)
|
||||
|
||||
clean clobber::
|
||||
$(RM) -r $(TEXT_CLASSES)
|
||||
$(RM) -r $(BIFILES)
|
||||
|
@ -144,6 +144,55 @@ class CharacterData00 extends CharacterData {
|
||||
case 0x1FBC : mapChar = 0x1FB3; break;
|
||||
case 0x1FCC : mapChar = 0x1FC3; break;
|
||||
case 0x1FFC : mapChar = 0x1FF3; break;
|
||||
|
||||
case 0x023A : mapChar = 0x2C65; break;
|
||||
case 0x023E : mapChar = 0x2C66; break;
|
||||
case 0x10A0 : mapChar = 0x2D00; break;
|
||||
case 0x10A1 : mapChar = 0x2D01; break;
|
||||
case 0x10A2 : mapChar = 0x2D02; break;
|
||||
case 0x10A3 : mapChar = 0x2D03; break;
|
||||
case 0x10A4 : mapChar = 0x2D04; break;
|
||||
case 0x10A5 : mapChar = 0x2D05; break;
|
||||
case 0x10A6 : mapChar = 0x2D06; break;
|
||||
case 0x10A7 : mapChar = 0x2D07; break;
|
||||
case 0x10A8 : mapChar = 0x2D08; break;
|
||||
case 0x10A9 : mapChar = 0x2D09; break;
|
||||
case 0x10AA : mapChar = 0x2D0A; break;
|
||||
case 0x10AB : mapChar = 0x2D0B; break;
|
||||
case 0x10AC : mapChar = 0x2D0C; break;
|
||||
case 0x10AD : mapChar = 0x2D0D; break;
|
||||
case 0x10AE : mapChar = 0x2D0E; break;
|
||||
case 0x10AF : mapChar = 0x2D0F; break;
|
||||
case 0x10B0 : mapChar = 0x2D10; break;
|
||||
case 0x10B1 : mapChar = 0x2D11; break;
|
||||
case 0x10B2 : mapChar = 0x2D12; break;
|
||||
case 0x10B3 : mapChar = 0x2D13; break;
|
||||
case 0x10B4 : mapChar = 0x2D14; break;
|
||||
case 0x10B5 : mapChar = 0x2D15; break;
|
||||
case 0x10B6 : mapChar = 0x2D16; break;
|
||||
case 0x10B7 : mapChar = 0x2D17; break;
|
||||
case 0x10B8 : mapChar = 0x2D18; break;
|
||||
case 0x10B9 : mapChar = 0x2D19; break;
|
||||
case 0x10BA : mapChar = 0x2D1A; break;
|
||||
case 0x10BB : mapChar = 0x2D1B; break;
|
||||
case 0x10BC : mapChar = 0x2D1C; break;
|
||||
case 0x10BD : mapChar = 0x2D1D; break;
|
||||
case 0x10BE : mapChar = 0x2D1E; break;
|
||||
case 0x10BF : mapChar = 0x2D1F; break;
|
||||
case 0x10C0 : mapChar = 0x2D20; break;
|
||||
case 0x10C1 : mapChar = 0x2D21; break;
|
||||
case 0x10C2 : mapChar = 0x2D22; break;
|
||||
case 0x10C3 : mapChar = 0x2D23; break;
|
||||
case 0x10C4 : mapChar = 0x2D24; break;
|
||||
case 0x10C5 : mapChar = 0x2D25; break;
|
||||
case 0x1E9E : mapChar = 0x00DF; break;
|
||||
case 0x2C62 : mapChar = 0x026B; break;
|
||||
case 0x2C63 : mapChar = 0x1D7D; break;
|
||||
case 0x2C64 : mapChar = 0x027D; break;
|
||||
case 0x2C6D : mapChar = 0x0251; break;
|
||||
case 0x2C6E : mapChar = 0x0271; break;
|
||||
case 0x2C6F : mapChar = 0x0250; break;
|
||||
case 0xA77D : mapChar = 0x1D79; break;
|
||||
// default mapChar is already set, so no
|
||||
// need to redo it here.
|
||||
// default : mapChar = ch;
|
||||
@ -196,6 +245,54 @@ class CharacterData00 extends CharacterData {
|
||||
case 0x1FB3 : mapChar = 0x1FBC; break;
|
||||
case 0x1FC3 : mapChar = 0x1FCC; break;
|
||||
case 0x1FF3 : mapChar = 0x1FFC; break;
|
||||
|
||||
case 0x0250 : mapChar = 0x2C6F; break;
|
||||
case 0x0251 : mapChar = 0x2C6D; break;
|
||||
case 0x026B : mapChar = 0x2C62; break;
|
||||
case 0x0271 : mapChar = 0x2C6E; break;
|
||||
case 0x027D : mapChar = 0x2C64; break;
|
||||
case 0x1D79 : mapChar = 0xA77D; break;
|
||||
case 0x1D7D : mapChar = 0x2C63; break;
|
||||
case 0x2C65 : mapChar = 0x023A; break;
|
||||
case 0x2C66 : mapChar = 0x023E; break;
|
||||
case 0x2D00 : mapChar = 0x10A0; break;
|
||||
case 0x2D01 : mapChar = 0x10A1; break;
|
||||
case 0x2D02 : mapChar = 0x10A2; break;
|
||||
case 0x2D03 : mapChar = 0x10A3; break;
|
||||
case 0x2D04 : mapChar = 0x10A4; break;
|
||||
case 0x2D05 : mapChar = 0x10A5; break;
|
||||
case 0x2D06 : mapChar = 0x10A6; break;
|
||||
case 0x2D07 : mapChar = 0x10A7; break;
|
||||
case 0x2D08 : mapChar = 0x10A8; break;
|
||||
case 0x2D09 : mapChar = 0x10A9; break;
|
||||
case 0x2D0A : mapChar = 0x10AA; break;
|
||||
case 0x2D0B : mapChar = 0x10AB; break;
|
||||
case 0x2D0C : mapChar = 0x10AC; break;
|
||||
case 0x2D0D : mapChar = 0x10AD; break;
|
||||
case 0x2D0E : mapChar = 0x10AE; break;
|
||||
case 0x2D0F : mapChar = 0x10AF; break;
|
||||
case 0x2D10 : mapChar = 0x10B0; break;
|
||||
case 0x2D11 : mapChar = 0x10B1; break;
|
||||
case 0x2D12 : mapChar = 0x10B2; break;
|
||||
case 0x2D13 : mapChar = 0x10B3; break;
|
||||
case 0x2D14 : mapChar = 0x10B4; break;
|
||||
case 0x2D15 : mapChar = 0x10B5; break;
|
||||
case 0x2D16 : mapChar = 0x10B6; break;
|
||||
case 0x2D17 : mapChar = 0x10B7; break;
|
||||
case 0x2D18 : mapChar = 0x10B8; break;
|
||||
case 0x2D19 : mapChar = 0x10B9; break;
|
||||
case 0x2D1A : mapChar = 0x10BA; break;
|
||||
case 0x2D1B : mapChar = 0x10BB; break;
|
||||
case 0x2D1C : mapChar = 0x10BC; break;
|
||||
case 0x2D1D : mapChar = 0x10BD; break;
|
||||
case 0x2D1E : mapChar = 0x10BE; break;
|
||||
case 0x2D1F : mapChar = 0x10BF; break;
|
||||
case 0x2D20 : mapChar = 0x10C0; break;
|
||||
case 0x2D21 : mapChar = 0x10C1; break;
|
||||
case 0x2D22 : mapChar = 0x10C2; break;
|
||||
case 0x2D23 : mapChar = 0x10C3; break;
|
||||
case 0x2D24 : mapChar = 0x10C4; break;
|
||||
case 0x2D25 : mapChar = 0x10C5; break;
|
||||
// ch must have a 1:M case mapping, but we
|
||||
// can't handle it here. Return ch.
|
||||
// since mapChar is already set, no need
|
||||
@ -315,6 +412,12 @@ class CharacterData00 extends CharacterData {
|
||||
case 0x32BE: retval = 49; break; // CIRCLED NUMBER FORTY NINE
|
||||
case 0x32BF: retval = 50; break; // CIRCLED NUMBER FIFTY
|
||||
|
||||
case 0x0D71: retval = 100; break; // MALAYALAM NUMBER ONE HUNDRED
|
||||
case 0x0D72: retval = 1000; break; // MALAYALAM NUMBER ONE THOUSAND
|
||||
case 0x2186: retval = 50; break; // ROMAN NUMERAL FIFTY EARLY FORM
|
||||
case 0x2187: retval = 50000; break; // ROMAN NUMERAL FIFTY THOUSAND
|
||||
case 0x2188: retval = 100000; break; // ROMAN NUMERAL ONE HUNDRED THOUSAND
|
||||
|
||||
default: retval = -2; break;
|
||||
}
|
||||
break;
|
||||
@ -383,6 +486,54 @@ class CharacterData00 extends CharacterData {
|
||||
case 0x00B5 : mapChar = 0x039C; break;
|
||||
case 0x017F : mapChar = 0x0053; break;
|
||||
case 0x1FBE : mapChar = 0x0399; break;
|
||||
|
||||
case 0x0250 : mapChar = 0x2C6F; break;
|
||||
case 0x0251 : mapChar = 0x2C6D; break;
|
||||
case 0x026B : mapChar = 0x2C62; break;
|
||||
case 0x0271 : mapChar = 0x2C6E; break;
|
||||
case 0x027D : mapChar = 0x2C64; break;
|
||||
case 0x1D79 : mapChar = 0xA77D; break;
|
||||
case 0x1D7D : mapChar = 0x2C63; break;
|
||||
case 0x2C65 : mapChar = 0x023A; break;
|
||||
case 0x2C66 : mapChar = 0x023E; break;
|
||||
case 0x2D00 : mapChar = 0x10A0; break;
|
||||
case 0x2D01 : mapChar = 0x10A1; break;
|
||||
case 0x2D02 : mapChar = 0x10A2; break;
|
||||
case 0x2D03 : mapChar = 0x10A3; break;
|
||||
case 0x2D04 : mapChar = 0x10A4; break;
|
||||
case 0x2D05 : mapChar = 0x10A5; break;
|
||||
case 0x2D06 : mapChar = 0x10A6; break;
|
||||
case 0x2D07 : mapChar = 0x10A7; break;
|
||||
case 0x2D08 : mapChar = 0x10A8; break;
|
||||
case 0x2D09 : mapChar = 0x10A9; break;
|
||||
case 0x2D0A : mapChar = 0x10AA; break;
|
||||
case 0x2D0B : mapChar = 0x10AB; break;
|
||||
case 0x2D0C : mapChar = 0x10AC; break;
|
||||
case 0x2D0D : mapChar = 0x10AD; break;
|
||||
case 0x2D0E : mapChar = 0x10AE; break;
|
||||
case 0x2D0F : mapChar = 0x10AF; break;
|
||||
case 0x2D10 : mapChar = 0x10B0; break;
|
||||
case 0x2D11 : mapChar = 0x10B1; break;
|
||||
case 0x2D12 : mapChar = 0x10B2; break;
|
||||
case 0x2D13 : mapChar = 0x10B3; break;
|
||||
case 0x2D14 : mapChar = 0x10B4; break;
|
||||
case 0x2D15 : mapChar = 0x10B5; break;
|
||||
case 0x2D16 : mapChar = 0x10B6; break;
|
||||
case 0x2D17 : mapChar = 0x10B7; break;
|
||||
case 0x2D18 : mapChar = 0x10B8; break;
|
||||
case 0x2D19 : mapChar = 0x10B9; break;
|
||||
case 0x2D1A : mapChar = 0x10BA; break;
|
||||
case 0x2D1B : mapChar = 0x10BB; break;
|
||||
case 0x2D1C : mapChar = 0x10BC; break;
|
||||
case 0x2D1D : mapChar = 0x10BD; break;
|
||||
case 0x2D1E : mapChar = 0x10BE; break;
|
||||
case 0x2D1F : mapChar = 0x10BF; break;
|
||||
case 0x2D20 : mapChar = 0x10C0; break;
|
||||
case 0x2D21 : mapChar = 0x10C1; break;
|
||||
case 0x2D22 : mapChar = 0x10C2; break;
|
||||
case 0x2D23 : mapChar = 0x10C3; break;
|
||||
case 0x2D24 : mapChar = 0x10C4; break;
|
||||
case 0x2D25 : mapChar = 0x10C5; break;
|
||||
default : mapChar = Character.ERROR; break;
|
||||
}
|
||||
}
|
||||
|
@ -218,6 +218,48 @@ class CharacterData01 extends CharacterData {
|
||||
case 0x10132: retval = 80000; break; // AEGEAN NUMBER EIGHTY THOUSAND
|
||||
case 0x10133: retval = 90000; break; // AEGEAN NUMBER NINETY THOUSAND
|
||||
case 0x10323: retval = 50; break; // OLD ITALIC NUMERAL FIFTY
|
||||
|
||||
case 0x010144: retval = 50; break; // ACROPHONIC ATTIC FIFTY
|
||||
case 0x010145: retval = 500; break; // ACROPHONIC ATTIC FIVE HUNDRED
|
||||
case 0x010146: retval = 5000; break; // ACROPHONIC ATTIC FIVE THOUSAND
|
||||
case 0x010147: retval = 50000; break; // ACROPHONIC ATTIC FIFTY THOUSAND
|
||||
case 0x01014A: retval = 50; break; // ACROPHONIC ATTIC FIFTY TALENTS
|
||||
case 0x01014B: retval = 100; break; // ACROPHONIC ATTIC ONE HUNDRED TALENTS
|
||||
case 0x01014C: retval = 500; break; // ACROPHONIC ATTIC FIVE HUNDRED TALENTS
|
||||
case 0x01014D: retval = 1000; break; // ACROPHONIC ATTIC ONE THOUSAND TALENTS
|
||||
case 0x01014E: retval = 5000; break; // ACROPHONIC ATTIC FIVE THOUSAND TALENTS
|
||||
case 0x010151: retval = 50; break; // ACROPHONIC ATTIC FIFTY STATERS
|
||||
case 0x010152: retval = 100; break; // ACROPHONIC ATTIC ONE HUNDRED STATERS
|
||||
case 0x010153: retval = 500; break; // ACROPHONIC ATTIC FIVE HUNDRED STATERS
|
||||
case 0x010154: retval = 1000; break; // ACROPHONIC ATTIC ONE THOUSAND STATERS
|
||||
case 0x010155: retval = 10000; break; // ACROPHONIC ATTIC TEN THOUSAND STATERS
|
||||
case 0x010156: retval = 50000; break; // ACROPHONIC ATTIC FIFTY THOUSAND STATERS
|
||||
case 0x010166: retval = 50; break; // ACROPHONIC TROEZENIAN FIFTY
|
||||
case 0x010167: retval = 50; break; // ACROPHONIC TROEZENIAN FIFTY ALTERNATE FORM
|
||||
case 0x010168: retval = 50; break; // ACROPHONIC HERMIONIAN FIFTY
|
||||
case 0x010169: retval = 50; break; // ACROPHONIC THESPIAN FIFTY
|
||||
case 0x01016A: retval = 100; break; // ACROPHONIC THESPIAN ONE HUNDRED
|
||||
case 0x01016B: retval = 300; break; // ACROPHONIC THESPIAN THREE HUNDRED
|
||||
case 0x01016C: retval = 500; break; // ACROPHONIC EPIDAUREAN FIVE HUNDRED
|
||||
case 0x01016D: retval = 500; break; // ACROPHONIC TROEZENIAN FIVE HUNDRED
|
||||
case 0x01016E: retval = 500; break; // ACROPHONIC THESPIAN FIVE HUNDRED
|
||||
case 0x01016F: retval = 500; break; // ACROPHONIC CARYSTIAN FIVE HUNDRED
|
||||
case 0x010170: retval = 500; break; // ACROPHONIC NAXIAN FIVE HUNDRED
|
||||
case 0x010171: retval = 1000; break; // ACROPHONIC THESPIAN ONE THOUSAND
|
||||
case 0x010172: retval = 5000; break; // ACROPHONIC THESPIAN FIVE THOUSAND
|
||||
case 0x010174: retval = 50; break; // ACROPHONIC STRATIAN FIFTY MNAS
|
||||
case 0x010341: retval = 90; break; // GOTHIC LETTER NINETY
|
||||
case 0x01034A: retval = 900; break; // GOTHIC LETTER NINE HUNDRED
|
||||
case 0x0103D5: retval = 100; break; // OLD PERSIAN NUMBER HUNDRED
|
||||
case 0x010919: retval = 100; break; // PHOENICIAN NUMBER ONE HUNDRED
|
||||
case 0x010A46: retval = 100; break; // KHAROSHTHI NUMBER ONE HUNDRED
|
||||
case 0x010A47: retval = 1000; break; // KHAROSHTHI NUMBER ONE THOUSAND
|
||||
case 0x01D36C: retval = 40; break; // COUNTING ROD TENS DIGIT FOUR
|
||||
case 0x01D36D: retval = 50; break; // COUNTING ROD TENS DIGIT FIVE
|
||||
case 0x01D36E: retval = 60; break; // COUNTING ROD TENS DIGIT SIX
|
||||
case 0x01D36F: retval = 70; break; // COUNTING ROD TENS DIGIT SEVEN
|
||||
case 0x01D370: retval = 80; break; // COUNTING ROD TENS DIGIT EIGHT
|
||||
case 0x01D371: retval = 90; break; // COUNTING ROD TENS DIGIT NINE
|
||||
default: retval = -2; break;
|
||||
}
|
||||
|
||||
|
@ -1,12 +1,17 @@
|
||||
# SpecialCasing-4.0.0.txt
|
||||
# Date: 2003-03-14, 20:22:04 GMT [MD]
|
||||
# SpecialCasing-5.1.0.txt
|
||||
# Date: 2008-03-03, 21:58:10 GMT [MD]
|
||||
#
|
||||
# Unicode Character Database
|
||||
# Copyright (c) 1991-2008 Unicode, Inc.
|
||||
# For terms of use, see http://www.unicode.org/terms_of_use.html
|
||||
# For documentation, see UCD.html
|
||||
#
|
||||
# Special Casing Properties
|
||||
#
|
||||
# This file is a supplement to the UnicodeData file.
|
||||
# It contains additional information about the casing of Unicode characters.
|
||||
# (For compatibility, the UnicodeData.txt file only contains case mappings for
|
||||
# characters where they are 1-1, and does not have locale-specific mappings.)
|
||||
# characters where they are 1-1, and independent of context and language.
|
||||
# For more information, see the discussion of Case Mappings in the Unicode Standard.
|
||||
#
|
||||
# All code points not listed in this file that do not have a simple case mappings
|
||||
@ -18,31 +23,31 @@
|
||||
#
|
||||
# <code>; <lower> ; <title> ; <upper> ; (<condition_list> ;)? # <comment>
|
||||
#
|
||||
# <code>, <lower>, <title>, and <upper> provide character values in hex. If there is more than
|
||||
# one character, they are separated by spaces. Other than as used to separate elements,
|
||||
# spaces are to be ignored.
|
||||
# <code>, <lower>, <title>, and <upper> provide character values in hex. If there is more
|
||||
# than one character, they are separated by spaces. Other than as used to separate
|
||||
# elements, spaces are to be ignored.
|
||||
#
|
||||
# The <condition_list> is optional. Where present, it consists of one or more locales or contexts,
|
||||
# separated by spaces. In these conditions:
|
||||
# The <condition_list> is optional. Where present, it consists of one or more language IDs
|
||||
# or contexts, separated by spaces. In these conditions:
|
||||
# - A condition list overrides the normal behavior if all of the listed conditions are true.
|
||||
# - The context is always the context of the characters in the original string,
|
||||
# NOT in the resulting string.
|
||||
# - Case distinctions in the condition list are not significant.
|
||||
# - Conditions preceded by "Not_" represent the negation of the condition.
|
||||
# The condition list is not represented in the UCD as a formal property.
|
||||
#
|
||||
# A locale is defined as:
|
||||
# <locale> := <ISO_639_code> ( "_" <ISO_3166_code> ( "_" <variant> )? )?
|
||||
# <ISO_3166_code> := 2-letter ISO country code,
|
||||
# <ISO_639_code> := 2-letter ISO language code
|
||||
# A language ID is defined by BCP 47, with '-' and '_' treated equivalently.
|
||||
#
|
||||
# A context is one of the following, as defined in the Unicode Standard:
|
||||
# Final_Sigma, After_Soft_Dotted, More_Above, Before_Dot, Not_Before_Dot, After_I
|
||||
# A context for a character C is defined by Section 3.13 Default Case
|
||||
# Operations, of The Unicode Standard, Version 5.0.
|
||||
# (This is identical to the context defined by Unicode 4.1.0,
|
||||
# as specified in http://www.unicode.org/versions/Unicode4.1.0/)
|
||||
#
|
||||
# Parsers of this file must be prepared to deal with future additions to this format:
|
||||
# * Additional contexts
|
||||
# * Additional fields
|
||||
# ================================================================================
|
||||
|
||||
# @missing 0000..10FFFF; <slc>; <stc>; <suc>
|
||||
# ================================================================================
|
||||
# Unconditional mappings
|
||||
# ================================================================================
|
||||
@ -170,7 +175,7 @@ FB17; FB17; 0544 056D; 0544 053D; # ARMENIAN SMALL LIGATURE MEN XEH
|
||||
1FF3; 1FF3; 1FFC; 03A9 0399; # GREEK SMALL LETTER OMEGA WITH YPOGEGRAMMENI
|
||||
1FFC; 1FF3; 1FFC; 03A9 0399; # GREEK CAPITAL LETTER OMEGA WITH PROSGEGRAMMENI
|
||||
|
||||
# Some characters with YPOGEGRAMMENI are also have no corresponding titlecases
|
||||
# Some characters with YPOGEGRAMMENI also have no corresponding titlecases
|
||||
|
||||
1FB2; 1FB2; 1FBA 0345; 1FBA 0399; # GREEK SMALL LETTER ALPHA WITH VARIA AND YPOGEGRAMMENI
|
||||
1FB4; 1FB4; 0386 0345; 0386 0399; # GREEK SMALL LETTER ALPHA WITH OXIA AND YPOGEGRAMMENI
|
||||
@ -184,7 +189,14 @@ FB17; FB17; 0544 056D; 0544 053D; # ARMENIAN SMALL LIGATURE MEN XEH
|
||||
1FF7; 1FF7; 03A9 0342 0345; 03A9 0342 0399; # GREEK SMALL LETTER OMEGA WITH PERISPOMENI AND YPOGEGRAMMENI
|
||||
|
||||
# ================================================================================
|
||||
# Conditional mappings
|
||||
# Conditional Mappings
|
||||
# The remainder of this file provides conditional casing data used to produce
|
||||
# full case mappings.
|
||||
# ================================================================================
|
||||
# Language-Insensitive Mappings
|
||||
# These are characters whose full case mappings do not depend on language, but do
|
||||
# depend on context (which characters come before or after). For more information
|
||||
# see the header of this file and the Unicode Standard.
|
||||
# ================================================================================
|
||||
|
||||
# Special case for final form of sigma
|
||||
@ -203,7 +215,10 @@ FB17; FB17; 0544 056D; 0544 053D; # ARMENIAN SMALL LIGATURE MEN XEH
|
||||
# 03C2; 03C3; 03A3; 03A3; Not_Final_Sigma; # GREEK SMALL LETTER FINAL SIGMA
|
||||
|
||||
# ================================================================================
|
||||
# Locale-sensitive mappings
|
||||
# Language-Sensitive Mappings
|
||||
# These are characters whose full case mappings depend on language and perhaps also
|
||||
# context (which characters come before or after). For more information
|
||||
# see the header of this file and the Unicode Standard.
|
||||
# ================================================================================
|
||||
|
||||
# Lithuanian
|
||||
@ -254,3 +269,6 @@ FB17; FB17; 0544 056D; 0544 053D; # ARMENIAN SMALL LIGATURE MEN XEH
|
||||
# Note: the following case is already in the UnicodeData file.
|
||||
|
||||
# 0131; 0131; 0049; 0049; tr; # LATIN SMALL LETTER DOTLESS I
|
||||
|
||||
# EOF
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
1
jdk/make/tools/UnicodeData/VERSION
Normal file
1
jdk/make/tools/UnicodeData/VERSION
Normal file
@ -0,0 +1 @@
|
||||
5.1.0
|
@ -279,20 +279,22 @@ class GTKIconFactory {
|
||||
|
||||
public void paintIcon(SynthContext context, Graphics g, int x, int y,
|
||||
int w, int h) {
|
||||
JToolBar toolbar = (JToolBar)context.getComponent();
|
||||
Orientation orientation =
|
||||
(toolbar.getOrientation() == JToolBar.HORIZONTAL ?
|
||||
Orientation.HORIZONTAL : Orientation.VERTICAL);
|
||||
if (context != null) {
|
||||
JToolBar toolbar = (JToolBar)context.getComponent();
|
||||
Orientation orientation =
|
||||
(toolbar.getOrientation() == JToolBar.HORIZONTAL ?
|
||||
Orientation.HORIZONTAL : Orientation.VERTICAL);
|
||||
|
||||
if (style == null) {
|
||||
style = SynthLookAndFeel.getStyleFactory().getStyle(
|
||||
context.getComponent(), GTKRegion.HANDLE_BOX);
|
||||
if (style == null) {
|
||||
style = SynthLookAndFeel.getStyleFactory().getStyle(
|
||||
context.getComponent(), GTKRegion.HANDLE_BOX);
|
||||
}
|
||||
context = new SynthContext(toolbar, GTKRegion.HANDLE_BOX,
|
||||
style, SynthConstants.ENABLED);
|
||||
|
||||
GTKPainter.INSTANCE.paintIcon(context, g,
|
||||
getMethod(), x, y, w, h, orientation);
|
||||
}
|
||||
context = new SynthContext(toolbar, GTKRegion.HANDLE_BOX,
|
||||
style, SynthConstants.ENABLED);
|
||||
|
||||
GTKPainter.INSTANCE.paintIcon(context, g,
|
||||
getMethod(), x, y, w, h, orientation);
|
||||
}
|
||||
|
||||
public int getIconWidth(SynthContext context) {
|
||||
@ -336,12 +338,14 @@ class GTKIconFactory {
|
||||
|
||||
public void paintIcon(SynthContext context, Graphics g, int x, int y,
|
||||
int w, int h) {
|
||||
ArrowType arrowDir = ArrowType.RIGHT;
|
||||
if (!context.getComponent().getComponentOrientation().isLeftToRight()) {
|
||||
arrowDir = ArrowType.LEFT;
|
||||
if (context != null) {
|
||||
ArrowType arrowDir = ArrowType.RIGHT;
|
||||
if (!context.getComponent().getComponentOrientation().isLeftToRight()) {
|
||||
arrowDir = ArrowType.LEFT;
|
||||
}
|
||||
GTKPainter.INSTANCE.paintIcon(context, g,
|
||||
getMethod(), x, y, w, h, arrowDir);
|
||||
}
|
||||
GTKPainter.INSTANCE.paintIcon(context, g,
|
||||
getMethod(), x, y, w, h, arrowDir);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -39,6 +39,8 @@ import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
|
||||
import sun.awt.shell.ShellFolder;
|
||||
import sun.awt.OSInfo;
|
||||
@ -1143,7 +1145,11 @@ public class WindowsFileChooserUI extends BasicFileChooserUI {
|
||||
|
||||
File[] baseFolders;
|
||||
if (useShellFolder) {
|
||||
baseFolders = (File[])ShellFolder.get("fileChooserComboBoxFolders");
|
||||
baseFolders = AccessController.doPrivileged(new PrivilegedAction<File[]>() {
|
||||
public File[] run() {
|
||||
return (File[]) ShellFolder.get("fileChooserComboBoxFolders");
|
||||
}
|
||||
});
|
||||
} else {
|
||||
baseFolders = fsv.getRoots();
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1996-2006 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* Copyright 1996-2009 Sun Microsystems, Inc. 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
|
||||
@ -27,26 +27,41 @@ package java.beans;
|
||||
|
||||
import com.sun.beans.finder.ClassFinder;
|
||||
|
||||
import java.applet.*;
|
||||
import java.applet.Applet;
|
||||
import java.applet.AppletContext;
|
||||
import java.applet.AppletStub;
|
||||
import java.applet.AudioClip;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
import java.beans.AppletInitializer;
|
||||
import java.awt.GraphicsEnvironment;
|
||||
import java.awt.Image;
|
||||
|
||||
import java.beans.beancontext.BeanContext;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectStreamClass;
|
||||
import java.io.StreamCorruptedException;
|
||||
|
||||
import java.net.URL;
|
||||
import java.lang.reflect.Array;
|
||||
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
|
||||
import java.util.Enumeration;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Iterator;
|
||||
import java.util.Vector;
|
||||
|
||||
import sun.awt.AppContext;
|
||||
|
||||
/**
|
||||
* This class provides some general purpose beans control methods.
|
||||
*/
|
||||
|
||||
public class Beans {
|
||||
private static final Object DESIGN_TIME = new Object();
|
||||
private static final Object GUI_AVAILABLE = new Object();
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@ -59,12 +74,12 @@ public class Beans {
|
||||
* @param beanName the name of the bean within the class-loader.
|
||||
* For example "sun.beanbox.foobah"
|
||||
*
|
||||
* @exception java.lang.ClassNotFoundException if the class of a serialized
|
||||
* @exception ClassNotFoundException if the class of a serialized
|
||||
* object could not be found.
|
||||
* @exception java.io.IOException if an I/O error occurs.
|
||||
* @exception IOException if an I/O error occurs.
|
||||
*/
|
||||
|
||||
public static Object instantiate(ClassLoader cls, String beanName) throws java.io.IOException, ClassNotFoundException {
|
||||
public static Object instantiate(ClassLoader cls, String beanName) throws IOException, ClassNotFoundException {
|
||||
return Beans.instantiate(cls, beanName, null, null);
|
||||
}
|
||||
|
||||
@ -80,12 +95,12 @@ public class Beans {
|
||||
* For example "sun.beanbox.foobah"
|
||||
* @param beanContext The BeanContext in which to nest the new bean
|
||||
*
|
||||
* @exception java.lang.ClassNotFoundException if the class of a serialized
|
||||
* @exception ClassNotFoundException if the class of a serialized
|
||||
* object could not be found.
|
||||
* @exception java.io.IOException if an I/O error occurs.
|
||||
* @exception IOException if an I/O error occurs.
|
||||
*/
|
||||
|
||||
public static Object instantiate(ClassLoader cls, String beanName, BeanContext beanContext) throws java.io.IOException, ClassNotFoundException {
|
||||
public static Object instantiate(ClassLoader cls, String beanName, BeanContext beanContext) throws IOException, ClassNotFoundException {
|
||||
return Beans.instantiate(cls, beanName, beanContext, null);
|
||||
}
|
||||
|
||||
@ -135,19 +150,19 @@ public class Beans {
|
||||
* @param beanContext The BeanContext in which to nest the new bean
|
||||
* @param initializer The AppletInitializer for the new bean
|
||||
*
|
||||
* @exception java.lang.ClassNotFoundException if the class of a serialized
|
||||
* @exception ClassNotFoundException if the class of a serialized
|
||||
* object could not be found.
|
||||
* @exception java.io.IOException if an I/O error occurs.
|
||||
* @exception IOException if an I/O error occurs.
|
||||
*/
|
||||
|
||||
public static Object instantiate(ClassLoader cls, String beanName, BeanContext beanContext, AppletInitializer initializer)
|
||||
throws java.io.IOException, ClassNotFoundException {
|
||||
throws IOException, ClassNotFoundException {
|
||||
|
||||
java.io.InputStream ins;
|
||||
java.io.ObjectInputStream oins = null;
|
||||
InputStream ins;
|
||||
ObjectInputStream oins = null;
|
||||
Object result = null;
|
||||
boolean serialized = false;
|
||||
java.io.IOException serex = null;
|
||||
IOException serex = null;
|
||||
|
||||
// If the given classloader is null, we check if an
|
||||
// system classloader is available and (if so)
|
||||
@ -166,8 +181,8 @@ public class Beans {
|
||||
// Try to find a serialized object with this name
|
||||
final String serName = beanName.replace('.','/').concat(".ser");
|
||||
final ClassLoader loader = cls;
|
||||
ins = (InputStream)java.security.AccessController.doPrivileged
|
||||
(new java.security.PrivilegedAction() {
|
||||
ins = (InputStream)AccessController.doPrivileged
|
||||
(new PrivilegedAction() {
|
||||
public Object run() {
|
||||
if (loader == null)
|
||||
return ClassLoader.getSystemResourceAsStream(serName);
|
||||
@ -185,7 +200,7 @@ public class Beans {
|
||||
result = oins.readObject();
|
||||
serialized = true;
|
||||
oins.close();
|
||||
} catch (java.io.IOException ex) {
|
||||
} catch (IOException ex) {
|
||||
ins.close();
|
||||
// Drop through and try opening the class. But remember
|
||||
// the exception in case we can't find the class either.
|
||||
@ -264,8 +279,8 @@ public class Beans {
|
||||
|
||||
final ClassLoader cloader = cls;
|
||||
objectUrl = (URL)
|
||||
java.security.AccessController.doPrivileged
|
||||
(new java.security.PrivilegedAction() {
|
||||
AccessController.doPrivileged
|
||||
(new PrivilegedAction() {
|
||||
public Object run() {
|
||||
if (cloader == null)
|
||||
return ClassLoader.getSystemResource
|
||||
@ -377,10 +392,11 @@ public class Beans {
|
||||
* @return True if we are running in an application construction
|
||||
* environment.
|
||||
*
|
||||
* @see java.beans.DesignMode
|
||||
* @see DesignMode
|
||||
*/
|
||||
public static boolean isDesignTime() {
|
||||
return designTime;
|
||||
Object value = AppContext.getAppContext().get(DESIGN_TIME);
|
||||
return (value instanceof Boolean) && (Boolean) value;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -393,11 +409,12 @@ public class Beans {
|
||||
* false in a server environment or if an application is
|
||||
* running as part of a batch job.
|
||||
*
|
||||
* @see java.beans.Visibility
|
||||
* @see Visibility
|
||||
*
|
||||
*/
|
||||
public static boolean isGuiAvailable() {
|
||||
return guiAvailable;
|
||||
Object value = AppContext.getAppContext().get(GUI_AVAILABLE);
|
||||
return (value instanceof Boolean) ? (Boolean) value : !GraphicsEnvironment.isHeadless();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -423,7 +440,7 @@ public class Beans {
|
||||
if (sm != null) {
|
||||
sm.checkPropertiesAccess();
|
||||
}
|
||||
designTime = isDesignTime;
|
||||
AppContext.getAppContext().put(DESIGN_TIME, Boolean.valueOf(isDesignTime));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -449,14 +466,7 @@ public class Beans {
|
||||
if (sm != null) {
|
||||
sm.checkPropertiesAccess();
|
||||
}
|
||||
guiAvailable = isGuiAvailable;
|
||||
}
|
||||
|
||||
|
||||
private static boolean designTime;
|
||||
private static boolean guiAvailable;
|
||||
static {
|
||||
guiAvailable = !GraphicsEnvironment.isHeadless();
|
||||
AppContext.getAppContext().put(GUI_AVAILABLE, Boolean.valueOf(isGuiAvailable));
|
||||
}
|
||||
}
|
||||
|
||||
@ -501,7 +511,7 @@ class ObjectInputStreamWithLoader extends ObjectInputStream
|
||||
|
||||
class BeansAppletContext implements AppletContext {
|
||||
Applet target;
|
||||
java.util.Hashtable imageCache = new java.util.Hashtable();
|
||||
Hashtable imageCache = new Hashtable();
|
||||
|
||||
BeansAppletContext(Applet target) {
|
||||
this.target = target;
|
||||
@ -546,8 +556,8 @@ class BeansAppletContext implements AppletContext {
|
||||
return null;
|
||||
}
|
||||
|
||||
public java.util.Enumeration getApplets() {
|
||||
java.util.Vector applets = new java.util.Vector();
|
||||
public Enumeration getApplets() {
|
||||
Vector applets = new Vector();
|
||||
applets.addElement(target);
|
||||
return applets.elements();
|
||||
}
|
||||
@ -573,7 +583,7 @@ class BeansAppletContext implements AppletContext {
|
||||
return null;
|
||||
}
|
||||
|
||||
public java.util.Iterator getStreamKeys(){
|
||||
public Iterator getStreamKeys(){
|
||||
// We do nothing.
|
||||
return null;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2003 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* Copyright 2003-2009 Sun Microsystems, Inc. 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
|
||||
@ -41,6 +41,7 @@ package java.beans;
|
||||
* @author Mark Davidson
|
||||
*/
|
||||
public class IndexedPropertyChangeEvent extends PropertyChangeEvent {
|
||||
private static final long serialVersionUID = -320227448495806870L;
|
||||
|
||||
private int index;
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1996-1998 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* Copyright 1996-2009 Sun Microsystems, Inc. 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
|
||||
@ -36,6 +36,7 @@ package java.beans;
|
||||
|
||||
public
|
||||
class IntrospectionException extends Exception {
|
||||
private static final long serialVersionUID = -3728150539969542619L;
|
||||
|
||||
/**
|
||||
* Constructs an <code>IntrospectionException</code> with a
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1996-2006 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* Copyright 1996-2009 Sun Microsystems, Inc. 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
|
||||
@ -44,6 +44,7 @@ package java.beans;
|
||||
*/
|
||||
|
||||
public class PropertyChangeEvent extends java.util.EventObject {
|
||||
private static final long serialVersionUID = 7042693688939648123L;
|
||||
|
||||
/**
|
||||
* Constructs a new <code>PropertyChangeEvent</code>.
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1996-1998 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* Copyright 1996-2009 Sun Microsystems, Inc. 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
|
||||
@ -33,7 +33,7 @@ package java.beans;
|
||||
|
||||
public
|
||||
class PropertyVetoException extends Exception {
|
||||
|
||||
private static final long serialVersionUID = 129596057694162164L;
|
||||
|
||||
/**
|
||||
* Constructs a <code>PropertyVetoException</code> with a
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1997-2003 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* Copyright 1997-2009 Sun Microsystems, Inc. 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
|
||||
@ -48,6 +48,7 @@ import java.beans.beancontext.BeanContext;
|
||||
*/
|
||||
|
||||
public abstract class BeanContextEvent extends EventObject {
|
||||
private static final long serialVersionUID = 7267998073569045052L;
|
||||
|
||||
/**
|
||||
* Contruct a BeanContextEvent
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1997-2004 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* Copyright 1997-2009 Sun Microsystems, Inc. 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
|
||||
@ -55,6 +55,7 @@ import java.util.Iterator;
|
||||
* @see java.beans.beancontext.BeanContextMembershipListener
|
||||
*/
|
||||
public class BeanContextMembershipEvent extends BeanContextEvent {
|
||||
private static final long serialVersionUID = 3499346510334590959L;
|
||||
|
||||
/**
|
||||
* Contruct a BeanContextMembershipEvent
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1998-2004 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* Copyright 1998-2009 Sun Microsystems, Inc. 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
|
||||
@ -40,6 +40,7 @@ import java.util.Iterator;
|
||||
*/
|
||||
|
||||
public class BeanContextServiceAvailableEvent extends BeanContextEvent {
|
||||
private static final long serialVersionUID = -5333985775656400778L;
|
||||
|
||||
/**
|
||||
* Construct a <code>BeanContextAvailableServiceEvent</code>.
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1998-2004 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* Copyright 1998-2009 Sun Microsystems, Inc. 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
|
||||
@ -37,6 +37,7 @@ import java.beans.beancontext.BeanContextServices;
|
||||
* </p>
|
||||
*/
|
||||
public class BeanContextServiceRevokedEvent extends BeanContextEvent {
|
||||
private static final long serialVersionUID = -1295543154724961754L;
|
||||
|
||||
/**
|
||||
* Construct a <code>BeanContextServiceEvent</code>.
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1998-2006 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* Copyright 1998-2009 Sun Microsystems, Inc. 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
|
||||
@ -60,6 +60,7 @@ import java.util.Locale;
|
||||
|
||||
public class BeanContextServicesSupport extends BeanContextSupport
|
||||
implements BeanContextServices {
|
||||
private static final long serialVersionUID = -8494482757288719206L;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@ -594,6 +595,7 @@ public class BeanContextServicesSupport extends BeanContextSupport
|
||||
*/
|
||||
|
||||
protected static class BCSSServiceProvider implements Serializable {
|
||||
private static final long serialVersionUID = 861278251667444782L;
|
||||
|
||||
BCSSServiceProvider(Class sc, BeanContextServiceProvider bcsp) {
|
||||
super();
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2006 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* Copyright 2002-2009 Sun Microsystems, Inc. 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
|
||||
@ -920,9 +920,9 @@ class Character extends Object implements java.io.Serializable, Comparable<Chara
|
||||
*/
|
||||
public static final UnicodeBlock COMBINING_MARKS_FOR_SYMBOLS =
|
||||
new UnicodeBlock("COMBINING_MARKS_FOR_SYMBOLS", new String[] {"Combining Diacritical Marks for Symbols",
|
||||
"CombiningDiacriticalMarksforSymbols",
|
||||
"Combining Marks for Symbols",
|
||||
"CombiningMarksforSymbols" });
|
||||
"CombiningDiacriticalMarksforSymbols",
|
||||
"Combining Marks for Symbols",
|
||||
"CombiningMarksforSymbols" });
|
||||
|
||||
/**
|
||||
* Constant for the "Letterlike Symbols" Unicode character block.
|
||||
@ -1332,8 +1332,11 @@ class Character extends Object implements java.io.Serializable, Comparable<Chara
|
||||
* @since 1.5
|
||||
*/
|
||||
public static final UnicodeBlock CYRILLIC_SUPPLEMENTARY =
|
||||
new UnicodeBlock("CYRILLIC_SUPPLEMENTARY", new String[] {"Cyrillic Supplementary",
|
||||
"CyrillicSupplementary"});
|
||||
new UnicodeBlock("CYRILLIC_SUPPLEMENTARY",
|
||||
new String[] {"Cyrillic Supplementary",
|
||||
"CyrillicSupplementary",
|
||||
"Cyrillic Supplement",
|
||||
"CyrillicSupplement"});
|
||||
|
||||
/**
|
||||
* Constant for the "Tagalog" Unicode character block.
|
||||
@ -1641,157 +1644,579 @@ class Character extends Object implements java.io.Serializable, Comparable<Chara
|
||||
public static final UnicodeBlock LOW_SURROGATES =
|
||||
new UnicodeBlock("LOW_SURROGATES", new String[] {"Low Surrogates", "LowSurrogates"});
|
||||
|
||||
/**
|
||||
* Constant for the "Arabic Supplement" Unicode character block.
|
||||
* @since 1.7
|
||||
*/
|
||||
public static final UnicodeBlock ARABIC_SUPPLEMENT =
|
||||
new UnicodeBlock("ARABIC_SUPPLEMENT",
|
||||
new String[] { "Arabic Supplement",
|
||||
"ArabicSupplement"});
|
||||
|
||||
/**
|
||||
* Constant for the "NKo" Unicode character block.
|
||||
* @since 1.7
|
||||
*/
|
||||
public static final UnicodeBlock NKO = new UnicodeBlock("NKO");
|
||||
|
||||
/**
|
||||
* Constant for the "Ethiopic Supplement" Unicode character block.
|
||||
* @since 1.7
|
||||
*/
|
||||
public static final UnicodeBlock ETHIOPIC_SUPPLEMENT =
|
||||
new UnicodeBlock("ETHIOPIC_SUPPLEMENT",
|
||||
new String[] { "Ethiopic Supplement",
|
||||
"EthiopicSupplement"});
|
||||
|
||||
/**
|
||||
* Constant for the "New Tai Lue" Unicode character block.
|
||||
* @since 1.7
|
||||
*/
|
||||
public static final UnicodeBlock NEW_TAI_LUE =
|
||||
new UnicodeBlock("NEW_TAI_LUE",
|
||||
new String[] { "New Tai Lue",
|
||||
"NewTaiLue"});
|
||||
|
||||
/**
|
||||
* Constant for the "Buginese" Unicode character block.
|
||||
* @since 1.7
|
||||
*/
|
||||
public static final UnicodeBlock BUGINESE =
|
||||
new UnicodeBlock("BUGINESE");
|
||||
|
||||
/**
|
||||
* Constant for the "Balinese" Unicode character block.
|
||||
* @since 1.7
|
||||
*/
|
||||
public static final UnicodeBlock BALINESE =
|
||||
new UnicodeBlock("BALINESE");
|
||||
|
||||
/**
|
||||
* Constant for the "Sundanese" Unicode character block.
|
||||
* @since 1.7
|
||||
*/
|
||||
public static final UnicodeBlock SUNDANESE =
|
||||
new UnicodeBlock("SUNDANESE");
|
||||
|
||||
/**
|
||||
* Constant for the "Lepcha" Unicode character block.
|
||||
* @since 1.7
|
||||
*/
|
||||
public static final UnicodeBlock LEPCHA = new UnicodeBlock("LEPCHA");
|
||||
|
||||
/**
|
||||
* Constant for the "Ol Chiki" Unicode character block.
|
||||
* @since 1.7
|
||||
*/
|
||||
public static final UnicodeBlock OL_CHIKI =
|
||||
new UnicodeBlock("OL_CHIKI",
|
||||
new String[] { "Ol Chiki",
|
||||
"OlChiki"});
|
||||
|
||||
/**
|
||||
* Constant for the "Phonetic Extensions Supplement" Unicode character
|
||||
* block.
|
||||
* @since 1.7
|
||||
*/
|
||||
public static final UnicodeBlock PHONETIC_EXTENSIONS_SUPPLEMENT =
|
||||
new UnicodeBlock("PHONETIC_EXTENSIONS_SUPPLEMENT",
|
||||
new String[] { "Phonetic Extensions Supplement",
|
||||
"PhoneticExtensionsSupplement"});
|
||||
|
||||
/**
|
||||
* Constant for the "Combining Diacritical Marks Supplement" Unicode
|
||||
* character block.
|
||||
* @since 1.7
|
||||
*/
|
||||
public static final UnicodeBlock COMBINING_DIACRITICAL_MARKS_SUPPLEMENT =
|
||||
new UnicodeBlock("COMBINING_DIACRITICAL_MARKS_SUPPLEMENT",
|
||||
new String[] { "Combining Diacritical Marks Supplement",
|
||||
"CombiningDiacriticalMarksSupplement"});
|
||||
|
||||
/**
|
||||
* Constant for the "Glagolitic" Unicode character block.
|
||||
* @since 1.7
|
||||
*/
|
||||
public static final UnicodeBlock GLAGOLITIC =
|
||||
new UnicodeBlock("GLAGOLITIC");
|
||||
|
||||
/**
|
||||
* Constant for the "Latin Extended-C" Unicode character block.
|
||||
* @since 1.7
|
||||
*/
|
||||
public static final UnicodeBlock LATIN_EXTENDED_C =
|
||||
new UnicodeBlock("LATIN_EXTENDED_C",
|
||||
new String[] { "Latin Extended-C",
|
||||
"LatinExtended-C"});
|
||||
|
||||
/**
|
||||
* Constant for the "Coptic" Unicode character block.
|
||||
* @since 1.7
|
||||
*/
|
||||
public static final UnicodeBlock COPTIC = new UnicodeBlock("COPTIC");
|
||||
|
||||
/**
|
||||
* Constant for the "Georgian Supplement" Unicode character block.
|
||||
* @since 1.7
|
||||
*/
|
||||
public static final UnicodeBlock GEORGIAN_SUPPLEMENT =
|
||||
new UnicodeBlock("GEORGIAN_SUPPLEMENT",
|
||||
new String[] { "Georgian Supplement",
|
||||
"GeorgianSupplement"});
|
||||
|
||||
/**
|
||||
* Constant for the "Tifinagh" Unicode character block.
|
||||
* @since 1.7
|
||||
*/
|
||||
public static final UnicodeBlock TIFINAGH =
|
||||
new UnicodeBlock("TIFINAGH");
|
||||
|
||||
/**
|
||||
* Constant for the "Ethiopic Extended" Unicode character block.
|
||||
* @since 1.7
|
||||
*/
|
||||
public static final UnicodeBlock ETHIOPIC_EXTENDED =
|
||||
new UnicodeBlock("ETHIOPIC_EXTENDED",
|
||||
new String[] { "Ethiopic Extended",
|
||||
"EthiopicExtended"});
|
||||
|
||||
/**
|
||||
* Constant for the "Cyrillic Extended-A" Unicode character block.
|
||||
* @since 1.7
|
||||
*/
|
||||
public static final UnicodeBlock CYRILLIC_EXTENDED_A =
|
||||
new UnicodeBlock("CYRILLIC_EXTENDED_A",
|
||||
new String[] { "Cyrillic Extended-A",
|
||||
"CyrillicExtended-A"});
|
||||
|
||||
/**
|
||||
* Constant for the "Supplemental Punctuation" Unicode character block.
|
||||
* @since 1.7
|
||||
*/
|
||||
public static final UnicodeBlock SUPPLEMENTAL_PUNCTUATION =
|
||||
new UnicodeBlock("SUPPLEMENTAL_PUNCTUATION",
|
||||
new String[] { "Supplemental Punctuation",
|
||||
"SupplementalPunctuation"});
|
||||
|
||||
/**
|
||||
* Constant for the "CJK Strokes" Unicode character block.
|
||||
* @since 1.7
|
||||
*/
|
||||
public static final UnicodeBlock CJK_STROKES =
|
||||
new UnicodeBlock("CJK_STROKES",
|
||||
new String[] { "CJK Strokes",
|
||||
"CJKStrokes"});
|
||||
|
||||
/**
|
||||
* Constant for the "Vai" Unicode character block.
|
||||
* @since 1.7
|
||||
*/
|
||||
public static final UnicodeBlock VAI = new UnicodeBlock("VAI");
|
||||
|
||||
/**
|
||||
* Constant for the "Cyrillic Extended-B" Unicode character block.
|
||||
* @since 1.7
|
||||
*/
|
||||
public static final UnicodeBlock CYRILLIC_EXTENDED_B =
|
||||
new UnicodeBlock("CYRILLIC_EXTENDED_B",
|
||||
new String[] { "Cyrillic Extended-B",
|
||||
"CyrillicExtended-B"});
|
||||
|
||||
/**
|
||||
* Constant for the "Modifier Tone Letters" Unicode character block.
|
||||
* @since 1.7
|
||||
*/
|
||||
public static final UnicodeBlock MODIFIER_TONE_LETTERS =
|
||||
new UnicodeBlock("MODIFIER_TONE_LETTERS",
|
||||
new String[] { "Modifier Tone Letters",
|
||||
"ModifierToneLetters"});
|
||||
|
||||
/**
|
||||
* Constant for the "Latin Extended-D" Unicode character block.
|
||||
* @since 1.7
|
||||
*/
|
||||
public static final UnicodeBlock LATIN_EXTENDED_D =
|
||||
new UnicodeBlock("LATIN_EXTENDED_D",
|
||||
new String[] { "Latin Extended-D",
|
||||
"LatinExtended-D"});
|
||||
|
||||
/**
|
||||
* Constant for the "Syloti Nagri" Unicode character block.
|
||||
* @since 1.7
|
||||
*/
|
||||
public static final UnicodeBlock SYLOTI_NAGRI =
|
||||
new UnicodeBlock("SYLOTI_NAGRI",
|
||||
new String[] { "Syloti Nagri",
|
||||
"SylotiNagri"});
|
||||
|
||||
/**
|
||||
* Constant for the "Phags-pa" Unicode character block.
|
||||
* @since 1.7
|
||||
*/
|
||||
public static final UnicodeBlock PHAGS_PA =
|
||||
new UnicodeBlock("PHAGS_PA", new String[] { "Phags-pa"});
|
||||
|
||||
/**
|
||||
* Constant for the "Saurashtra" Unicode character block.
|
||||
* @since 1.7
|
||||
*/
|
||||
public static final UnicodeBlock SAURASHTRA =
|
||||
new UnicodeBlock("SAURASHTRA");
|
||||
|
||||
/**
|
||||
* Constant for the "Kayah Li" Unicode character block.
|
||||
* @since 1.7
|
||||
*/
|
||||
public static final UnicodeBlock KAYAH_LI =
|
||||
new UnicodeBlock("KAYAH_LI",
|
||||
new String[] { "Kayah Li",
|
||||
"KayahLi"});
|
||||
|
||||
/**
|
||||
* Constant for the "Rejang" Unicode character block.
|
||||
* @since 1.7
|
||||
*/
|
||||
public static final UnicodeBlock REJANG = new UnicodeBlock("REJANG");
|
||||
|
||||
/**
|
||||
* Constant for the "Cham" Unicode character block.
|
||||
* @since 1.7
|
||||
*/
|
||||
public static final UnicodeBlock CHAM = new UnicodeBlock("CHAM");
|
||||
|
||||
/**
|
||||
* Constant for the "Vertical Forms" Unicode character block.
|
||||
* @since 1.7
|
||||
*/
|
||||
public static final UnicodeBlock VERTICAL_FORMS =
|
||||
new UnicodeBlock("VERTICAL_FORMS",
|
||||
new String[] { "Vertical Forms",
|
||||
"VerticalForms"});
|
||||
|
||||
/**
|
||||
* Constant for the "Ancient Greek Numbers" Unicode character block.
|
||||
* @since 1.7
|
||||
*/
|
||||
public static final UnicodeBlock ANCIENT_GREEK_NUMBERS =
|
||||
new UnicodeBlock("ANCIENT_GREEK_NUMBERS",
|
||||
new String[] { "Ancient Greek Numbers",
|
||||
"AncientGreekNumbers"});
|
||||
|
||||
/**
|
||||
* Constant for the "Ancient Symbols" Unicode character block.
|
||||
* @since 1.7
|
||||
*/
|
||||
public static final UnicodeBlock ANCIENT_SYMBOLS =
|
||||
new UnicodeBlock("ANCIENT_SYMBOLS",
|
||||
new String[] { "Ancient Symbols",
|
||||
"AncientSymbols"});
|
||||
|
||||
/**
|
||||
* Constant for the "Phaistos Disc" Unicode character block.
|
||||
* @since 1.7
|
||||
*/
|
||||
public static final UnicodeBlock PHAISTOS_DISC =
|
||||
new UnicodeBlock("PHAISTOS_DISC",
|
||||
new String[] { "Phaistos Disc",
|
||||
"PhaistosDisc"});
|
||||
|
||||
/**
|
||||
* Constant for the "Lycian" Unicode character block.
|
||||
* @since 1.7
|
||||
*/
|
||||
public static final UnicodeBlock LYCIAN = new UnicodeBlock("LYCIAN");
|
||||
|
||||
/**
|
||||
* Constant for the "Carian" Unicode character block.
|
||||
* @since 1.7
|
||||
*/
|
||||
public static final UnicodeBlock CARIAN = new UnicodeBlock("CARIAN");
|
||||
|
||||
/**
|
||||
* Constant for the "Old Persian" Unicode character block.
|
||||
* @since 1.7
|
||||
*/
|
||||
public static final UnicodeBlock OLD_PERSIAN =
|
||||
new UnicodeBlock("OLD_PERSIAN",
|
||||
new String[] { "Old Persian",
|
||||
"OldPersian"});
|
||||
|
||||
/**
|
||||
* Constant for the "Phoenician" Unicode character block.
|
||||
* @since 1.7
|
||||
*/
|
||||
public static final UnicodeBlock PHOENICIAN =
|
||||
new UnicodeBlock("PHOENICIAN");
|
||||
|
||||
/**
|
||||
* Constant for the "Lydian" Unicode character block.
|
||||
* @since 1.7
|
||||
*/
|
||||
public static final UnicodeBlock LYDIAN = new UnicodeBlock("LYDIAN");
|
||||
|
||||
/**
|
||||
* Constant for the "Kharoshthi" Unicode character block.
|
||||
* @since 1.7
|
||||
*/
|
||||
public static final UnicodeBlock KHAROSHTHI =
|
||||
new UnicodeBlock("KHAROSHTHI");
|
||||
|
||||
/**
|
||||
* Constant for the "Cuneiform" Unicode character block.
|
||||
* @since 1.7
|
||||
*/
|
||||
public static final UnicodeBlock CUNEIFORM =
|
||||
new UnicodeBlock("CUNEIFORM");
|
||||
|
||||
/**
|
||||
* Constant for the "Cuneiform Numbers and Punctuation" Unicode
|
||||
* character block.
|
||||
* @since 1.7
|
||||
*/
|
||||
public static final UnicodeBlock CUNEIFORM_NUMBERS_AND_PUNCTUATION =
|
||||
new UnicodeBlock("CUNEIFORM_NUMBERS_AND_PUNCTUATION",
|
||||
new String[] { "Cuneiform Numbers and Punctuation",
|
||||
"CuneiformNumbersandPunctuation"});
|
||||
|
||||
/**
|
||||
* Constant for the "Ancient Greek Musical Notation" Unicode character
|
||||
* block.
|
||||
* @since 1.7
|
||||
*/
|
||||
public static final UnicodeBlock ANCIENT_GREEK_MUSICAL_NOTATION =
|
||||
new UnicodeBlock("ANCIENT_GREEK_MUSICAL_NOTATION",
|
||||
new String[] { "Ancient Greek Musical Notation",
|
||||
"AncientGreekMusicalNotation"});
|
||||
|
||||
/**
|
||||
* Constant for the "Counting Rod Numerals" Unicode character block.
|
||||
* @since 1.7
|
||||
*/
|
||||
public static final UnicodeBlock COUNTING_ROD_NUMERALS =
|
||||
new UnicodeBlock("COUNTING_ROD_NUMERALS",
|
||||
new String[] { "Counting Rod Numerals",
|
||||
"CountingRodNumerals"});
|
||||
|
||||
/**
|
||||
* Constant for the "Mahjong Tiles" Unicode character block.
|
||||
* @since 1.7
|
||||
*/
|
||||
public static final UnicodeBlock MAHJONG_TILES =
|
||||
new UnicodeBlock("MAHJONG_TILES",
|
||||
new String[] { "Mahjong Tiles",
|
||||
"MahjongTiles"});
|
||||
|
||||
/**
|
||||
* Constant for the "Domino Tiles" Unicode character block.
|
||||
* @since 1.7
|
||||
*/
|
||||
public static final UnicodeBlock DOMINO_TILES =
|
||||
new UnicodeBlock("DOMINO_TILES",
|
||||
new String[] { "Domino Tiles",
|
||||
"DominoTiles"});
|
||||
|
||||
private static final int blockStarts[] = {
|
||||
0x0000, // Basic Latin
|
||||
0x0080, // Latin-1 Supplement
|
||||
0x0100, // Latin Extended-A
|
||||
0x0180, // Latin Extended-B
|
||||
0x0250, // IPA Extensions
|
||||
0x02B0, // Spacing Modifier Letters
|
||||
0x0300, // Combining Diacritical Marks
|
||||
0x0370, // Greek and Coptic
|
||||
0x0400, // Cyrillic
|
||||
0x0500, // Cyrillic Supplementary
|
||||
0x0530, // Armenian
|
||||
0x0590, // Hebrew
|
||||
0x0600, // Arabic
|
||||
0x0700, // Syriac
|
||||
0x0750, // unassigned
|
||||
0x0780, // Thaana
|
||||
0x07C0, // unassigned
|
||||
0x0900, // Devanagari
|
||||
0x0980, // Bengali
|
||||
0x0A00, // Gurmukhi
|
||||
0x0A80, // Gujarati
|
||||
0x0B00, // Oriya
|
||||
0x0B80, // Tamil
|
||||
0x0C00, // Telugu
|
||||
0x0C80, // Kannada
|
||||
0x0D00, // Malayalam
|
||||
0x0D80, // Sinhala
|
||||
0x0E00, // Thai
|
||||
0x0E80, // Lao
|
||||
0x0F00, // Tibetan
|
||||
0x1000, // Myanmar
|
||||
0x10A0, // Georgian
|
||||
0x1100, // Hangul Jamo
|
||||
0x1200, // Ethiopic
|
||||
0x1380, // unassigned
|
||||
0x13A0, // Cherokee
|
||||
0x1400, // Unified Canadian Aboriginal Syllabics
|
||||
0x1680, // Ogham
|
||||
0x16A0, // Runic
|
||||
0x1700, // Tagalog
|
||||
0x1720, // Hanunoo
|
||||
0x1740, // Buhid
|
||||
0x1760, // Tagbanwa
|
||||
0x1780, // Khmer
|
||||
0x1800, // Mongolian
|
||||
0x18B0, // unassigned
|
||||
0x1900, // Limbu
|
||||
0x1950, // Tai Le
|
||||
0x1980, // unassigned
|
||||
0x19E0, // Khmer Symbols
|
||||
0x1A00, // unassigned
|
||||
0x1D00, // Phonetic Extensions
|
||||
0x1D80, // unassigned
|
||||
0x1E00, // Latin Extended Additional
|
||||
0x1F00, // Greek Extended
|
||||
0x2000, // General Punctuation
|
||||
0x2070, // Superscripts and Subscripts
|
||||
0x20A0, // Currency Symbols
|
||||
0x20D0, // Combining Diacritical Marks for Symbols
|
||||
0x2100, // Letterlike Symbols
|
||||
0x2150, // Number Forms
|
||||
0x2190, // Arrows
|
||||
0x2200, // Mathematical Operators
|
||||
0x2300, // Miscellaneous Technical
|
||||
0x2400, // Control Pictures
|
||||
0x2440, // Optical Character Recognition
|
||||
0x2460, // Enclosed Alphanumerics
|
||||
0x2500, // Box Drawing
|
||||
0x2580, // Block Elements
|
||||
0x25A0, // Geometric Shapes
|
||||
0x2600, // Miscellaneous Symbols
|
||||
0x2700, // Dingbats
|
||||
0x27C0, // Miscellaneous Mathematical Symbols-A
|
||||
0x27F0, // Supplemental Arrows-A
|
||||
0x2800, // Braille Patterns
|
||||
0x2900, // Supplemental Arrows-B
|
||||
0x2980, // Miscellaneous Mathematical Symbols-B
|
||||
0x2A00, // Supplemental Mathematical Operators
|
||||
0x2B00, // Miscellaneous Symbols and Arrows
|
||||
0x2C00, // unassigned
|
||||
0x2E80, // CJK Radicals Supplement
|
||||
0x2F00, // Kangxi Radicals
|
||||
0x2FE0, // unassigned
|
||||
0x2FF0, // Ideographic Description Characters
|
||||
0x3000, // CJK Symbols and Punctuation
|
||||
0x3040, // Hiragana
|
||||
0x30A0, // Katakana
|
||||
0x3100, // Bopomofo
|
||||
0x3130, // Hangul Compatibility Jamo
|
||||
0x3190, // Kanbun
|
||||
0x31A0, // Bopomofo Extended
|
||||
0x31C0, // unassigned
|
||||
0x31F0, // Katakana Phonetic Extensions
|
||||
0x3200, // Enclosed CJK Letters and Months
|
||||
0x3300, // CJK Compatibility
|
||||
0x3400, // CJK Unified Ideographs Extension A
|
||||
0x4DC0, // Yijing Hexagram Symbols
|
||||
0x4E00, // CJK Unified Ideographs
|
||||
0xA000, // Yi Syllables
|
||||
0xA490, // Yi Radicals
|
||||
0xA4D0, // unassigned
|
||||
0xAC00, // Hangul Syllables
|
||||
0xD7B0, // unassigned
|
||||
0xD800, // High Surrogates
|
||||
0xDB80, // High Private Use Surrogates
|
||||
0xDC00, // Low Surrogates
|
||||
0xE000, // Private Use
|
||||
0xF900, // CJK Compatibility Ideographs
|
||||
0xFB00, // Alphabetic Presentation Forms
|
||||
0xFB50, // Arabic Presentation Forms-A
|
||||
0xFE00, // Variation Selectors
|
||||
0xFE10, // unassigned
|
||||
0xFE20, // Combining Half Marks
|
||||
0xFE30, // CJK Compatibility Forms
|
||||
0xFE50, // Small Form Variants
|
||||
0xFE70, // Arabic Presentation Forms-B
|
||||
0xFF00, // Halfwidth and Fullwidth Forms
|
||||
0xFFF0, // Specials
|
||||
0x10000, // Linear B Syllabary
|
||||
0x10080, // Linear B Ideograms
|
||||
0x10100, // Aegean Numbers
|
||||
0x10140, // unassigned
|
||||
0x10300, // Old Italic
|
||||
0x10330, // Gothic
|
||||
0x10350, // unassigned
|
||||
0x10380, // Ugaritic
|
||||
0x103A0, // unassigned
|
||||
0x10400, // Deseret
|
||||
0x10450, // Shavian
|
||||
0x10480, // Osmanya
|
||||
0x104B0, // unassigned
|
||||
0x10800, // Cypriot Syllabary
|
||||
0x10840, // unassigned
|
||||
0x1D000, // Byzantine Musical Symbols
|
||||
0x1D100, // Musical Symbols
|
||||
0x1D200, // unassigned
|
||||
0x1D300, // Tai Xuan Jing Symbols
|
||||
0x1D360, // unassigned
|
||||
0x1D400, // Mathematical Alphanumeric Symbols
|
||||
0x1D800, // unassigned
|
||||
0x20000, // CJK Unified Ideographs Extension B
|
||||
0x2A6E0, // unassigned
|
||||
0x2F800, // CJK Compatibility Ideographs Supplement
|
||||
0x2FA20, // unassigned
|
||||
0xE0000, // Tags
|
||||
0xE0080, // unassigned
|
||||
0xE0100, // Variation Selectors Supplement
|
||||
0xE01F0, // unassigned
|
||||
0xF0000, // Supplementary Private Use Area-A
|
||||
0x100000, // Supplementary Private Use Area-B
|
||||
0x0000, // 0000..007F; Basic Latin
|
||||
0x0080, // 0080..00FF; Latin-1 Supplement
|
||||
0x0100, // 0100..017F; Latin Extended-A
|
||||
0x0180, // 0180..024F; Latin Extended-B
|
||||
0x0250, // 0250..02AF; IPA Extensions
|
||||
0x02B0, // 02B0..02FF; Spacing Modifier Letters
|
||||
0x0300, // 0300..036F; Combining Diacritical Marks
|
||||
0x0370, // 0370..03FF; Greek and Coptic
|
||||
0x0400, // 0400..04FF; Cyrillic
|
||||
0x0500, // 0500..052F; Cyrillic Supplement
|
||||
0x0530, // 0530..058F; Armenian
|
||||
0x0590, // 0590..05FF; Hebrew
|
||||
0x0600, // 0600..06FF; Arabic
|
||||
0x0700, // 0700..074F; Syria
|
||||
0x0750, // 0750..077F; Arabic Supplement
|
||||
0x0780, // 0780..07BF; Thaana
|
||||
0x07C0, // 07C0..07FF; NKo
|
||||
0x0800, // unassigned
|
||||
0x0900, // 0900..097F; Devanagari
|
||||
0x0980, // 0980..09FF; Bengali
|
||||
0x0A00, // 0A00..0A7F; Gurmukhi
|
||||
0x0A80, // 0A80..0AFF; Gujarati
|
||||
0x0B00, // 0B00..0B7F; Oriya
|
||||
0x0B80, // 0B80..0BFF; Tamil
|
||||
0x0C00, // 0C00..0C7F; Telugu
|
||||
0x0C80, // 0C80..0CFF; Kannada
|
||||
0x0D00, // 0D00..0D7F; Malayalam
|
||||
0x0D80, // 0D80..0DFF; Sinhala
|
||||
0x0E00, // 0E00..0E7F; Thai
|
||||
0x0E80, // 0E80..0EFF; Lao
|
||||
0x0F00, // 0F00..0FFF; Tibetan
|
||||
0x1000, // 1000..109F; Myanmar
|
||||
0x10A0, // 10A0..10FF; Georgian
|
||||
0x1100, // 1100..11FF; Hangul Jamo
|
||||
0x1200, // 1200..137F; Ethiopic
|
||||
0x1380, // 1380..139F; Ethiopic Supplement
|
||||
0x13A0, // 13A0..13FF; Cherokee
|
||||
0x1400, // 1400..167F; Unified Canadian Aboriginal Syllabics
|
||||
0x1680, // 1680..169F; Ogham
|
||||
0x16A0, // 16A0..16FF; Runic
|
||||
0x1700, // 1700..171F; Tagalog
|
||||
0x1720, // 1720..173F; Hanunoo
|
||||
0x1740, // 1740..175F; Buhid
|
||||
0x1760, // 1760..177F; Tagbanwa
|
||||
0x1780, // 1780..17FF; Khmer
|
||||
0x1800, // 1800..18AF; Mongolian
|
||||
0x18B0, // unassigned
|
||||
0x1900, // 1900..194F; Limbu
|
||||
0x1950, // 1950..197F; Tai Le
|
||||
0x1980, // 1980..19DF; New Tai Lue
|
||||
0x19E0, // 19E0..19FF; Khmer Symbols
|
||||
0x1A00, // 1A00..1A1F; Buginese
|
||||
0x1A20, // unassigned
|
||||
0x1B00, // 1B00..1B7F; Balinese
|
||||
0x1B80, // 1B80..1BBF; Sundanese
|
||||
0x1BC0, // unassigned
|
||||
0x1C00, // 1C00..1C4F; Lepcha
|
||||
0x1C50, // 1C50..1C7F; Ol Chiki
|
||||
0x1C80, // unassigned
|
||||
0x1D00, // 1D00..1D7F; Phonetic Extensions
|
||||
0x1D80, // 1D80..1DBF; Phonetic Extensions Supplement
|
||||
0x1DC0, // 1DC0..1DFF; Combining Diacritical Marks Supplement
|
||||
0x1E00, // 1E00..1EFF; Latin Extended Additional
|
||||
0x1F00, // 1F00..1FFF; Greek Extended
|
||||
0x2000, // 2000..206F; General Punctuation
|
||||
0x2070, // 2070..209F; Superscripts and Subscripts
|
||||
0x20A0, // 20A0..20CF; Currency Symbols
|
||||
0x20D0, // 20D0..20FF; Combining Diacritical Marks for Symbols
|
||||
0x2100, // 2100..214F; Letterlike Symbols
|
||||
0x2150, // 2150..218F; Number Forms
|
||||
0x2190, // 2190..21FF; Arrows
|
||||
0x2200, // 2200..22FF; Mathematical Operators
|
||||
0x2300, // 2300..23FF; Miscellaneous Technical
|
||||
0x2400, // 2400..243F; Control Pictures
|
||||
0x2440, // 2440..245F; Optical Character Recognition
|
||||
0x2460, // 2460..24FF; Enclosed Alphanumerics
|
||||
0x2500, // 2500..257F; Box Drawing
|
||||
0x2580, // 2580..259F; Block Elements
|
||||
0x25A0, // 25A0..25FF; Geometric Shapes
|
||||
0x2600, // 2600..26FF; Miscellaneous Symbols
|
||||
0x2700, // 2700..27BF; Dingbats
|
||||
0x27C0, // 27C0..27EF; Miscellaneous Mathematical Symbols-A
|
||||
0x27F0, // 27F0..27FF; Supplemental Arrows-A
|
||||
0x2800, // 2800..28FF; Braille Patterns
|
||||
0x2900, // 2900..297F; Supplemental Arrows-B
|
||||
0x2980, // 2980..29FF; Miscellaneous Mathematical Symbols-B
|
||||
0x2A00, // 2A00..2AFF; Supplemental Mathematical Operators
|
||||
0x2B00, // 2B00..2BFF; Miscellaneous Symbols and Arrows
|
||||
0x2C00, // 2C00..2C5F; Glagolitic
|
||||
0x2C60, // 2C60..2C7F; Latin Extended-C
|
||||
0x2C80, // 2C80..2CFF; Coptic
|
||||
0x2D00, // 2D00..2D2F; Georgian Supplement
|
||||
0x2D30, // 2D30..2D7F; Tifinagh
|
||||
0x2D80, // 2D80..2DDF; Ethiopic Extended
|
||||
0x2DE0, // 2DE0..2DFF; Cyrillic Extended-A
|
||||
0x2E00, // 2E00..2E7F; Supplemental Punctuation
|
||||
0x2E80, // 2E80..2EFF; CJK Radicals Supplement
|
||||
0x2F00, // 2F00..2FDF; Kangxi Radicals
|
||||
0x2FE0, // unassigned
|
||||
0x2FF0, // 2FF0..2FFF; Ideographic Description Characters
|
||||
0x3000, // 3000..303F; CJK Symbols and Punctuation
|
||||
0x3040, // 3040..309F; Hiragana
|
||||
0x30A0, // 30A0..30FF; Katakana
|
||||
0x3100, // 3100..312F; Bopomofo
|
||||
0x3130, // 3130..318F; Hangul Compatibility Jamo
|
||||
0x3190, // 3190..319F; Kanbun
|
||||
0x31A0, // 31A0..31BF; Bopomofo Extended
|
||||
0x31C0, // 31C0..31EF; CJK Strokes
|
||||
0x31F0, // 31F0..31FF; Katakana Phonetic Extensions
|
||||
0x3200, // 3200..32FF; Enclosed CJK Letters and Months
|
||||
0x3300, // 3300..33FF; CJK Compatibility
|
||||
0x3400, // 3400..4DBF; CJK Unified Ideographs Extension A
|
||||
0x4DC0, // 4DC0..4DFF; Yijing Hexagram Symbols
|
||||
0x4E00, // 4E00..9FFF; CJK Unified Ideograph
|
||||
0xA000, // A000..A48F; Yi Syllables
|
||||
0xA490, // A490..A4CF; Yi Radicals
|
||||
0xA4D0, // unassigned
|
||||
0xA500, // A500..A63F; Vai
|
||||
0xA640, // A640..A69F; Cyrillic Extended-B
|
||||
0xA6A0, // unassigned
|
||||
0xA700, // A700..A71F; Modifier Tone Letters
|
||||
0xA720, // A720..A7FF; Latin Extended-D
|
||||
0xA800, // A800..A82F; Syloti Nagri
|
||||
0xA830, // unassigned
|
||||
0xA840, // A840..A87F; Phags-pa
|
||||
0xA880, // A880..A8DF; Saurashtra
|
||||
0xA8E0, // unassigned
|
||||
0xA900, // A900..A92F; Kayah Li
|
||||
0xA930, // A930..A95F; Rejang
|
||||
0xA960, // unassigned
|
||||
0xAA00, // AA00..AA5F; Cham
|
||||
0xAA60, // unassigned
|
||||
0xAC00, // AC00..D7AF; Hangul Syllables
|
||||
0xD7B0, // unassigned
|
||||
0xD800, // D800..DB7F; High Surrogates
|
||||
0xDB80, // DB80..DBFF; High Private Use Surrogates
|
||||
0xDC00, // DC00..DFFF; Low Surrogates
|
||||
0xE000, // E000..F8FF; Private Use Area
|
||||
0xF900, // F900..FAFF; CJK Compatibility Ideographs
|
||||
0xFB00, // FB00..FB4F; Alphabetic Presentation Forms
|
||||
0xFB50, // FB50..FDFF; Arabic Presentation Forms-A
|
||||
0xFE00, // FE00..FE0F; Variation Selectors
|
||||
0xFE10, // FE10..FE1F; Vertical Forms
|
||||
0xFE20, // FE20..FE2F; Combining Half Marks
|
||||
0xFE30, // FE30..FE4F; CJK Compatibility Forms
|
||||
0xFE50, // FE50..FE6F; Small Form Variants
|
||||
0xFE70, // FE70..FEFF; Arabic Presentation Forms-B
|
||||
0xFF00, // FF00..FFEF; Halfwidth and Fullwidth Forms
|
||||
0xFFF0, // FFF0..FFFF; Specials
|
||||
0x10000, // 10000..1007F; Linear B Syllabary
|
||||
0x10080, // 10080..100FF; Linear B Ideograms
|
||||
0x10100, // 10100..1013F; Aegean Numbers
|
||||
0x10140, // 10140..1018F; Ancient Greek Numbers
|
||||
0x10190, // 10190..101CF; Ancient Symbols
|
||||
0x101D0, // 101D0..101FF; Phaistos Disc
|
||||
0x10200, // unassigned
|
||||
0x10280, // 10280..1029F; Lycian
|
||||
0x102A0, // 102A0..102DF; Carian
|
||||
0x102E0, // unassigned
|
||||
0x10300, // 10300..1032F; Old Italic
|
||||
0x10330, // 10330..1034F; Gothic
|
||||
0x10350, // unassigned
|
||||
0x10380, // 10380..1039F; Ugaritic
|
||||
0x103A0, // 103A0..103DF; Old Persian
|
||||
0x103E0, // unassigned
|
||||
0x10400, // 10400..1044F; Desere
|
||||
0x10450, // 10450..1047F; Shavian
|
||||
0x10480, // 10480..104AF; Osmanya
|
||||
0x104B0, // unassigned
|
||||
0x10800, // 10800..1083F; Cypriot Syllabary
|
||||
0x10840, // unassigned
|
||||
0x10900, // 10900..1091F; Phoenician
|
||||
0x10920, // 10920..1093F; Lydian
|
||||
0x10940, // unassigned
|
||||
0x10A00, // 10A00..10A5F; Kharoshthi
|
||||
0x10A60, // unassigned
|
||||
0x12000, // 12000..123FF; Cuneiform
|
||||
0x12400, // 12400..1247F; Cuneiform Numbers and Punctuation
|
||||
0x12480, // unassigned
|
||||
0x1D000, // 1D000..1D0FF; Byzantine Musical Symbols
|
||||
0x1D100, // 1D100..1D1FF; Musical Symbols
|
||||
0x1D200, // 1D200..1D24F; Ancient Greek Musical Notation
|
||||
0x1D250, // unassigned
|
||||
0x1D300, // 1D300..1D35F; Tai Xuan Jing Symbols
|
||||
0x1D360, // 1D360..1D37F; Counting Rod Numerals
|
||||
0x1D380, // unassigned
|
||||
0x1D400, // 1D400..1D7FF; Mathematical Alphanumeric Symbols
|
||||
0x1D800, // unassigned
|
||||
0x1F000, // 1F000..1F02F; Mahjong Tiles
|
||||
0x1F030, // 1F030..1F09F; Domino Tiles
|
||||
0x1F0A0, // unassigned
|
||||
0x20000, // 20000..2A6DF; CJK Unified Ideographs Extension B
|
||||
0x2A6E0, // unassigned
|
||||
0x2F800, // 2F800..2FA1F; CJK Compatibility Ideographs Supplement
|
||||
0x2FA20, // unassigned
|
||||
0xE0000, // E0000..E007F; Tags
|
||||
0xE0080, // unassigned
|
||||
0xE0100, // E0100..E01EF; Variation Selectors Supplement
|
||||
0xE01F0, // unassigned
|
||||
0xF0000, // F0000..FFFFF; Supplementary Private Use Area-A
|
||||
0x100000, // 100000..10FFFF; Supplementary Private Use Area-B
|
||||
};
|
||||
|
||||
private static final UnicodeBlock[] blocks = {
|
||||
@ -1809,8 +2234,9 @@ class Character extends Object implements java.io.Serializable, Comparable<Chara
|
||||
HEBREW,
|
||||
ARABIC,
|
||||
SYRIAC,
|
||||
null,
|
||||
ARABIC_SUPPLEMENT,
|
||||
THAANA,
|
||||
NKO,
|
||||
null,
|
||||
DEVANAGARI,
|
||||
BENGALI,
|
||||
@ -1829,7 +2255,7 @@ class Character extends Object implements java.io.Serializable, Comparable<Chara
|
||||
GEORGIAN,
|
||||
HANGUL_JAMO,
|
||||
ETHIOPIC,
|
||||
null,
|
||||
ETHIOPIC_SUPPLEMENT,
|
||||
CHEROKEE,
|
||||
UNIFIED_CANADIAN_ABORIGINAL_SYLLABICS,
|
||||
OGHAM,
|
||||
@ -1843,11 +2269,19 @@ class Character extends Object implements java.io.Serializable, Comparable<Chara
|
||||
null,
|
||||
LIMBU,
|
||||
TAI_LE,
|
||||
null,
|
||||
NEW_TAI_LUE,
|
||||
KHMER_SYMBOLS,
|
||||
BUGINESE,
|
||||
null,
|
||||
BALINESE,
|
||||
SUNDANESE,
|
||||
null,
|
||||
LEPCHA,
|
||||
OL_CHIKI,
|
||||
null,
|
||||
PHONETIC_EXTENSIONS,
|
||||
null,
|
||||
PHONETIC_EXTENSIONS_SUPPLEMENT,
|
||||
COMBINING_DIACRITICAL_MARKS_SUPPLEMENT,
|
||||
LATIN_EXTENDED_ADDITIONAL,
|
||||
GREEK_EXTENDED,
|
||||
GENERAL_PUNCTUATION,
|
||||
@ -1874,7 +2308,14 @@ class Character extends Object implements java.io.Serializable, Comparable<Chara
|
||||
MISCELLANEOUS_MATHEMATICAL_SYMBOLS_B,
|
||||
SUPPLEMENTAL_MATHEMATICAL_OPERATORS,
|
||||
MISCELLANEOUS_SYMBOLS_AND_ARROWS,
|
||||
null,
|
||||
GLAGOLITIC,
|
||||
LATIN_EXTENDED_C,
|
||||
COPTIC,
|
||||
GEORGIAN_SUPPLEMENT,
|
||||
TIFINAGH,
|
||||
ETHIOPIC_EXTENDED,
|
||||
CYRILLIC_EXTENDED_A,
|
||||
SUPPLEMENTAL_PUNCTUATION,
|
||||
CJK_RADICALS_SUPPLEMENT,
|
||||
KANGXI_RADICALS,
|
||||
null,
|
||||
@ -1886,7 +2327,7 @@ class Character extends Object implements java.io.Serializable, Comparable<Chara
|
||||
HANGUL_COMPATIBILITY_JAMO,
|
||||
KANBUN,
|
||||
BOPOMOFO_EXTENDED,
|
||||
null,
|
||||
CJK_STROKES,
|
||||
KATAKANA_PHONETIC_EXTENSIONS,
|
||||
ENCLOSED_CJK_LETTERS_AND_MONTHS,
|
||||
CJK_COMPATIBILITY,
|
||||
@ -1896,6 +2337,21 @@ class Character extends Object implements java.io.Serializable, Comparable<Chara
|
||||
YI_SYLLABLES,
|
||||
YI_RADICALS,
|
||||
null,
|
||||
VAI,
|
||||
CYRILLIC_EXTENDED_B,
|
||||
null,
|
||||
MODIFIER_TONE_LETTERS,
|
||||
LATIN_EXTENDED_D,
|
||||
SYLOTI_NAGRI,
|
||||
null,
|
||||
PHAGS_PA,
|
||||
SAURASHTRA,
|
||||
null,
|
||||
KAYAH_LI,
|
||||
REJANG,
|
||||
null,
|
||||
CHAM,
|
||||
null,
|
||||
HANGUL_SYLLABLES,
|
||||
null,
|
||||
HIGH_SURROGATES,
|
||||
@ -1906,7 +2362,7 @@ class Character extends Object implements java.io.Serializable, Comparable<Chara
|
||||
ALPHABETIC_PRESENTATION_FORMS,
|
||||
ARABIC_PRESENTATION_FORMS_A,
|
||||
VARIATION_SELECTORS,
|
||||
null,
|
||||
VERTICAL_FORMS,
|
||||
COMBINING_HALF_MARKS,
|
||||
CJK_COMPATIBILITY_FORMS,
|
||||
SMALL_FORM_VARIANTS,
|
||||
@ -1916,11 +2372,18 @@ class Character extends Object implements java.io.Serializable, Comparable<Chara
|
||||
LINEAR_B_SYLLABARY,
|
||||
LINEAR_B_IDEOGRAMS,
|
||||
AEGEAN_NUMBERS,
|
||||
ANCIENT_GREEK_NUMBERS,
|
||||
ANCIENT_SYMBOLS,
|
||||
PHAISTOS_DISC,
|
||||
null,
|
||||
LYCIAN,
|
||||
CARIAN,
|
||||
null,
|
||||
OLD_ITALIC,
|
||||
GOTHIC,
|
||||
null,
|
||||
UGARITIC,
|
||||
OLD_PERSIAN,
|
||||
null,
|
||||
DESERET,
|
||||
SHAVIAN,
|
||||
@ -1928,13 +2391,26 @@ class Character extends Object implements java.io.Serializable, Comparable<Chara
|
||||
null,
|
||||
CYPRIOT_SYLLABARY,
|
||||
null,
|
||||
PHOENICIAN,
|
||||
LYDIAN,
|
||||
null,
|
||||
KHAROSHTHI,
|
||||
null,
|
||||
CUNEIFORM,
|
||||
CUNEIFORM_NUMBERS_AND_PUNCTUATION,
|
||||
null,
|
||||
BYZANTINE_MUSICAL_SYMBOLS,
|
||||
MUSICAL_SYMBOLS,
|
||||
ANCIENT_GREEK_MUSICAL_NOTATION,
|
||||
null,
|
||||
TAI_XUAN_JING_SYMBOLS,
|
||||
COUNTING_ROD_NUMERALS,
|
||||
null,
|
||||
MATHEMATICAL_ALPHANUMERIC_SYMBOLS,
|
||||
null,
|
||||
MAHJONG_TILES,
|
||||
DOMINO_TILES,
|
||||
null,
|
||||
CJK_UNIFIED_IDEOGRAPHS_EXTENSION_B,
|
||||
null,
|
||||
CJK_COMPATIBILITY_IDEOGRAPHS_SUPPLEMENT,
|
||||
|
@ -74,6 +74,7 @@ final class ConditionalSpecialCasing {
|
||||
new Entry(0x00CC, new char[]{0x0069, 0x0307, 0x0300}, new char[]{0x00CC}, "lt", 0), // # LATIN CAPITAL LETTER I WITH GRAVE
|
||||
new Entry(0x00CD, new char[]{0x0069, 0x0307, 0x0301}, new char[]{0x00CD}, "lt", 0), // # LATIN CAPITAL LETTER I WITH ACUTE
|
||||
new Entry(0x0128, new char[]{0x0069, 0x0307, 0x0303}, new char[]{0x0128}, "lt", 0), // # LATIN CAPITAL LETTER I WITH TILDE
|
||||
new Entry(0x0130, new char[]{0x0069, 0x0307}, new char[]{0x0130}, "lt", 0), // # LATIN CAPITAL LETTER I WITH DOT ABOVE
|
||||
|
||||
//# ================================================================================
|
||||
//# Turkish and Azeri
|
||||
@ -84,7 +85,10 @@ final class ConditionalSpecialCasing {
|
||||
new Entry(0x0049, new char[]{0x0131}, new char[]{0x0049}, "tr", NOT_BEFORE_DOT), // # LATIN CAPITAL LETTER I
|
||||
new Entry(0x0049, new char[]{0x0131}, new char[]{0x0049}, "az", NOT_BEFORE_DOT), // # LATIN CAPITAL LETTER I
|
||||
new Entry(0x0069, new char[]{0x0069}, new char[]{0x0130}, "tr", 0), // # LATIN SMALL LETTER I
|
||||
new Entry(0x0069, new char[]{0x0069}, new char[]{0x0130}, "az", 0) // # LATIN SMALL LETTER I
|
||||
new Entry(0x0069, new char[]{0x0069}, new char[]{0x0130}, "az", 0), // # LATIN SMALL LETTER I
|
||||
//# ================================================================================
|
||||
//# Other
|
||||
new Entry(0x0130, new char[]{0x0069, 0x0307}, new char[]{0x0130}, "en", 0), // # LATIN CAPITALLETTER I WITH DOT ABOVE
|
||||
};
|
||||
|
||||
// A hash table that contains the above entries
|
||||
|
@ -2451,14 +2451,21 @@ public final class String
|
||||
}
|
||||
if (localeDependent || srcChar == '\u03A3') { // GREEK CAPITAL LETTER SIGMA
|
||||
lowerChar = ConditionalSpecialCasing.toLowerCaseEx(this, i, locale);
|
||||
} else if (srcChar == '\u0130') { // LATIN CAPITAL LETTER I DOT
|
||||
lowerChar = Character.ERROR;
|
||||
} else {
|
||||
lowerChar = Character.toLowerCase(srcChar);
|
||||
}
|
||||
if ((lowerChar == Character.ERROR) ||
|
||||
(lowerChar >= Character.MIN_SUPPLEMENTARY_CODE_POINT)) {
|
||||
if (lowerChar == Character.ERROR) {
|
||||
lowerCharArray =
|
||||
ConditionalSpecialCasing.toLowerCaseCharArray(this, i, locale);
|
||||
if (!localeDependent && srcChar == '\u0130') {
|
||||
lowerCharArray =
|
||||
ConditionalSpecialCasing.toLowerCaseCharArray(this, i, Locale.ENGLISH);
|
||||
} else {
|
||||
lowerCharArray =
|
||||
ConditionalSpecialCasing.toLowerCaseCharArray(this, i, locale);
|
||||
}
|
||||
} else if (srcCount == 2) {
|
||||
resultOffset += Character.toChars(lowerChar, result, i + resultOffset) - srcCount;
|
||||
continue;
|
||||
|
@ -552,14 +552,15 @@ public class PopupFactory {
|
||||
boolean result = false;
|
||||
Component component = getComponent();
|
||||
if (owner != null && component != null) {
|
||||
Container parent = (Container) SwingUtilities.getRoot(owner);
|
||||
int popupWidth = component.getWidth();
|
||||
int popupHeight = component.getHeight();
|
||||
Rectangle parentBounds = parent.getBounds();
|
||||
|
||||
Container parent = (Container) SwingUtilities.getRoot(owner);
|
||||
if (parent instanceof JFrame ||
|
||||
parent instanceof JDialog ||
|
||||
parent instanceof JWindow) {
|
||||
|
||||
Rectangle parentBounds = parent.getBounds();
|
||||
Insets i = parent.getInsets();
|
||||
parentBounds.x += i.left;
|
||||
parentBounds.y += i.top;
|
||||
@ -577,11 +578,11 @@ public class PopupFactory {
|
||||
.contains(x, y, popupWidth, popupHeight);
|
||||
}
|
||||
} else if (parent instanceof JApplet) {
|
||||
Rectangle parentBounds = parent.getBounds();
|
||||
Point p = parent.getLocationOnScreen();
|
||||
parentBounds.x = p.x;
|
||||
parentBounds.y = p.y;
|
||||
result = parentBounds
|
||||
.contains(x, y, popupWidth, popupHeight);
|
||||
result = parentBounds.contains(x, y, popupWidth, popupHeight);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* Copyright 2005-2009 Sun Microsystems, Inc. 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
|
||||
@ -778,35 +778,33 @@ public abstract class SwingWorker<T, V> implements RunnableFuture<T> {
|
||||
threadFactory);
|
||||
appContext.put(SwingWorker.class, executorService);
|
||||
|
||||
//register shutdown hook for this executor service
|
||||
// Don't use ShutdownHook here as it's not enough. We should track
|
||||
// AppContext disposal instead of JVM shutdown, see 6799345 for details
|
||||
final ExecutorService es = executorService;
|
||||
final Runnable shutdownHook =
|
||||
new Runnable() {
|
||||
final WeakReference<ExecutorService> executorServiceRef =
|
||||
new WeakReference<ExecutorService>(es);
|
||||
public void run() {
|
||||
final ExecutorService executorService =
|
||||
executorServiceRef.get();
|
||||
if (executorService != null) {
|
||||
AccessController.doPrivileged(
|
||||
new PrivilegedAction<Void>() {
|
||||
public Void run() {
|
||||
executorService.shutdown();
|
||||
return null;
|
||||
appContext.addPropertyChangeListener(AppContext.DISPOSED_PROPERTY_NAME,
|
||||
new PropertyChangeListener() {
|
||||
@Override
|
||||
public void propertyChange(PropertyChangeEvent pce) {
|
||||
boolean disposed = (Boolean)pce.getNewValue();
|
||||
if (disposed) {
|
||||
final WeakReference<ExecutorService> executorServiceRef =
|
||||
new WeakReference<ExecutorService>(es);
|
||||
final ExecutorService executorService =
|
||||
executorServiceRef.get();
|
||||
if (executorService != null) {
|
||||
AccessController.doPrivileged(
|
||||
new PrivilegedAction<Void>() {
|
||||
public Void run() {
|
||||
executorService.shutdown();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
});
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
AccessController.doPrivileged(
|
||||
new PrivilegedAction<Void>() {
|
||||
public Void run() {
|
||||
Runtime.getRuntime().addShutdownHook(
|
||||
new Thread(shutdownHook));
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
return executorService;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* Copyright 1997-2009 Sun Microsystems, Inc. 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
|
||||
@ -191,7 +191,12 @@ class TimerQueue implements Runnable
|
||||
} finally {
|
||||
timer.getLock().unlock();
|
||||
}
|
||||
} catch (InterruptedException ignore) {
|
||||
} catch (InterruptedException ie) {
|
||||
// Shouldn't ignore InterruptedExceptions here, so AppContext
|
||||
// is disposed gracefully, see 6799345 for details
|
||||
if (AppContext.getAppContext().isDisposed()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -58,6 +58,8 @@ import sun.awt.OSInfo;
|
||||
import sun.security.action.GetPropertyAction;
|
||||
import sun.swing.SwingUtilities2;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.HashMap;
|
||||
import sun.awt.AppContext;
|
||||
|
||||
|
||||
/**
|
||||
@ -1323,19 +1325,29 @@ public class UIManager implements Serializable
|
||||
return;
|
||||
}
|
||||
|
||||
String metalLnf = getCrossPlatformLookAndFeelClassName();
|
||||
String lnfDefault = metalLnf;
|
||||
// Try to get default LAF from system property, then from AppContext
|
||||
// (6653395), then use cross-platform one by default.
|
||||
String lafName = null;
|
||||
HashMap lafData =
|
||||
(HashMap) AppContext.getAppContext().remove("swing.lafdata");
|
||||
if (lafData != null) {
|
||||
lafName = (String) lafData.remove("defaultlaf");
|
||||
}
|
||||
if (lafName == null) {
|
||||
lafName = getCrossPlatformLookAndFeelClassName();
|
||||
}
|
||||
lafName = swingProps.getProperty(defaultLAFKey, lafName);
|
||||
|
||||
String lnfName = "<undefined>" ;
|
||||
try {
|
||||
lnfName = swingProps.getProperty(defaultLAFKey, lnfDefault);
|
||||
setLookAndFeel(lnfName);
|
||||
setLookAndFeel(lafName);
|
||||
} catch (Exception e) {
|
||||
try {
|
||||
lnfName = swingProps.getProperty(defaultLAFKey, metalLnf);
|
||||
setLookAndFeel(lnfName);
|
||||
} catch (Exception e2) {
|
||||
throw new Error("can't load " + lnfName);
|
||||
throw new Error("Cannot load " + lafName);
|
||||
}
|
||||
|
||||
// Set any properties passed through AppContext (6653395).
|
||||
if (lafData != null) {
|
||||
for (Object key: lafData.keySet()) {
|
||||
UIManager.put(key, lafData.get(key));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -27,6 +27,7 @@ package javax.swing.plaf.basic;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.Callable;
|
||||
import javax.swing.*;
|
||||
import javax.swing.filechooser.*;
|
||||
import javax.swing.event.*;
|
||||
@ -223,113 +224,115 @@ public class BasicDirectoryModel extends AbstractListModel implements PropertyCh
|
||||
this.fid = fid;
|
||||
}
|
||||
|
||||
private void invokeLater(DoChangeContents runnable) {
|
||||
runnables.addElement(runnable);
|
||||
SwingUtilities.invokeLater(runnable);
|
||||
}
|
||||
|
||||
public void run() {
|
||||
run0();
|
||||
setBusy(false, fid);
|
||||
}
|
||||
|
||||
public void run0() {
|
||||
FileSystemView fileSystem = filechooser.getFileSystemView();
|
||||
DoChangeContents doChangeContents = ShellFolder.getInvoker().invoke(new Callable<DoChangeContents>() {
|
||||
public DoChangeContents call() throws Exception {
|
||||
FileSystemView fileSystem = filechooser.getFileSystemView();
|
||||
|
||||
File[] list = fileSystem.getFiles(currentDirectory, filechooser.isFileHidingEnabled());
|
||||
File[] list = fileSystem.getFiles(currentDirectory, filechooser.isFileHidingEnabled());
|
||||
|
||||
Vector<File> acceptsList = new Vector<File>();
|
||||
Vector<File> acceptsList = new Vector<File>();
|
||||
|
||||
if (isInterrupted()) {
|
||||
return;
|
||||
}
|
||||
if (isInterrupted()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// run through the file list, add directories and selectable files to fileCache
|
||||
for (File file : list) {
|
||||
if (filechooser.accept(file)) {
|
||||
acceptsList.addElement(file);
|
||||
}
|
||||
}
|
||||
// run through the file list, add directories and selectable files to fileCache
|
||||
for (File file : list) {
|
||||
if (filechooser.accept(file)) {
|
||||
acceptsList.addElement(file);
|
||||
}
|
||||
}
|
||||
|
||||
if (isInterrupted()) {
|
||||
return;
|
||||
}
|
||||
if (isInterrupted()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// First sort alphabetically by filename
|
||||
sort(acceptsList);
|
||||
// First sort alphabetically by filename
|
||||
sort(acceptsList);
|
||||
|
||||
Vector<File> newDirectories = new Vector<File>(50);
|
||||
Vector<File> newFiles = new Vector<File>();
|
||||
// run through list grabbing directories in chunks of ten
|
||||
for(int i = 0; i < acceptsList.size(); i++) {
|
||||
File f = acceptsList.elementAt(i);
|
||||
boolean isTraversable = filechooser.isTraversable(f);
|
||||
if (isTraversable) {
|
||||
newDirectories.addElement(f);
|
||||
} else if (!isTraversable && filechooser.isFileSelectionEnabled()) {
|
||||
newFiles.addElement(f);
|
||||
}
|
||||
if(isInterrupted()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
Vector<File> newDirectories = new Vector<File>(50);
|
||||
Vector<File> newFiles = new Vector<File>();
|
||||
// run through list grabbing directories in chunks of ten
|
||||
for (int i = 0; i < acceptsList.size(); i++) {
|
||||
File f = acceptsList.elementAt(i);
|
||||
boolean isTraversable = filechooser.isTraversable(f);
|
||||
if (isTraversable) {
|
||||
newDirectories.addElement(f);
|
||||
} else if (!isTraversable && filechooser.isFileSelectionEnabled()) {
|
||||
newFiles.addElement(f);
|
||||
}
|
||||
if (isInterrupted()) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Vector<File> newFileCache = new Vector<File>(newDirectories);
|
||||
newFileCache.addAll(newFiles);
|
||||
Vector<File> newFileCache = new Vector<File>(newDirectories);
|
||||
newFileCache.addAll(newFiles);
|
||||
|
||||
int newSize = newFileCache.size();
|
||||
int oldSize = fileCache.size();
|
||||
int newSize = newFileCache.size();
|
||||
int oldSize = fileCache.size();
|
||||
|
||||
if (newSize > oldSize) {
|
||||
//see if interval is added
|
||||
int start = oldSize;
|
||||
int end = newSize;
|
||||
for (int i = 0; i < oldSize; i++) {
|
||||
if (!newFileCache.get(i).equals(fileCache.get(i))) {
|
||||
start = i;
|
||||
for (int j = i; j < newSize; j++) {
|
||||
if (newFileCache.get(j).equals(fileCache.get(i))) {
|
||||
end = j;
|
||||
if (newSize > oldSize) {
|
||||
//see if interval is added
|
||||
int start = oldSize;
|
||||
int end = newSize;
|
||||
for (int i = 0; i < oldSize; i++) {
|
||||
if (!newFileCache.get(i).equals(fileCache.get(i))) {
|
||||
start = i;
|
||||
for (int j = i; j < newSize; j++) {
|
||||
if (newFileCache.get(j).equals(fileCache.get(i))) {
|
||||
end = j;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
if (start >= 0 && end > start
|
||||
&& newFileCache.subList(end, newSize).equals(fileCache.subList(start, oldSize))) {
|
||||
if (isInterrupted()) {
|
||||
return null;
|
||||
}
|
||||
return new DoChangeContents(newFileCache.subList(start, end), start, null, 0, fid);
|
||||
}
|
||||
} else if (newSize < oldSize) {
|
||||
//see if interval is removed
|
||||
int start = -1;
|
||||
int end = -1;
|
||||
for (int i = 0; i < newSize; i++) {
|
||||
if (!newFileCache.get(i).equals(fileCache.get(i))) {
|
||||
start = i;
|
||||
end = i + oldSize - newSize;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (start >= 0 && end > start
|
||||
&& fileCache.subList(end, oldSize).equals(newFileCache.subList(start, newSize))) {
|
||||
if (isInterrupted()) {
|
||||
return null;
|
||||
}
|
||||
return new DoChangeContents(null, 0, new Vector(fileCache.subList(start, end)), start, fid);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (start >= 0 && end > start
|
||||
&& newFileCache.subList(end, newSize).equals(fileCache.subList(start, oldSize))) {
|
||||
if(isInterrupted()) {
|
||||
return;
|
||||
if (!fileCache.equals(newFileCache)) {
|
||||
if (isInterrupted()) {
|
||||
cancelRunnables(runnables);
|
||||
}
|
||||
return new DoChangeContents(newFileCache, 0, fileCache, 0, fid);
|
||||
}
|
||||
invokeLater(new DoChangeContents(newFileCache.subList(start, end), start, null, 0, fid));
|
||||
newFileCache = null;
|
||||
return null;
|
||||
}
|
||||
} else if (newSize < oldSize) {
|
||||
//see if interval is removed
|
||||
int start = -1;
|
||||
int end = -1;
|
||||
for (int i = 0; i < newSize; i++) {
|
||||
if (!newFileCache.get(i).equals(fileCache.get(i))) {
|
||||
start = i;
|
||||
end = i + oldSize - newSize;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (start >= 0 && end > start
|
||||
&& fileCache.subList(end, oldSize).equals(newFileCache.subList(start, newSize))) {
|
||||
if(isInterrupted()) {
|
||||
return;
|
||||
}
|
||||
invokeLater(new DoChangeContents(null, 0, new Vector<File>(fileCache.subList(start, end)),
|
||||
start, fid));
|
||||
newFileCache = null;
|
||||
}
|
||||
}
|
||||
if (newFileCache != null && !fileCache.equals(newFileCache)) {
|
||||
if (isInterrupted()) {
|
||||
cancelRunnables(runnables);
|
||||
}
|
||||
invokeLater(new DoChangeContents(newFileCache, 0, fileCache, 0, fid));
|
||||
});
|
||||
|
||||
if (doChangeContents != null) {
|
||||
runnables.addElement(doChangeContents);
|
||||
SwingUtilities.invokeLater(doChangeContents);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1004,47 +1004,62 @@ public class BasicSliderUI extends SliderUI{
|
||||
g.setColor(DefaultLookup.getColor(slider, this, "Slider.tickColor", Color.black));
|
||||
|
||||
if ( slider.getOrientation() == JSlider.HORIZONTAL ) {
|
||||
g.translate( 0, tickBounds.y);
|
||||
g.translate(0, tickBounds.y);
|
||||
|
||||
int value = slider.getMinimum();
|
||||
int xPos;
|
||||
if (slider.getMinorTickSpacing() > 0) {
|
||||
int value = slider.getMinimum();
|
||||
|
||||
if ( slider.getMinorTickSpacing() > 0 ) {
|
||||
while ( value <= slider.getMaximum() ) {
|
||||
xPos = xPositionForValue( value );
|
||||
int xPos = xPositionForValue(value);
|
||||
paintMinorTickForHorizSlider( g, tickBounds, xPos );
|
||||
|
||||
// Overflow checking
|
||||
if (Integer.MAX_VALUE - slider.getMinorTickSpacing() < value) {
|
||||
break;
|
||||
}
|
||||
|
||||
value += slider.getMinorTickSpacing();
|
||||
}
|
||||
}
|
||||
|
||||
if ( slider.getMajorTickSpacing() > 0 ) {
|
||||
value = slider.getMinimum();
|
||||
if (slider.getMajorTickSpacing() > 0) {
|
||||
int value = slider.getMinimum();
|
||||
|
||||
while ( value <= slider.getMaximum() ) {
|
||||
xPos = xPositionForValue( value );
|
||||
int xPos = xPositionForValue(value);
|
||||
paintMajorTickForHorizSlider( g, tickBounds, xPos );
|
||||
|
||||
// Overflow checking
|
||||
if (Integer.MAX_VALUE - slider.getMajorTickSpacing() < value) {
|
||||
break;
|
||||
}
|
||||
|
||||
value += slider.getMajorTickSpacing();
|
||||
}
|
||||
}
|
||||
|
||||
g.translate( 0, -tickBounds.y);
|
||||
}
|
||||
else {
|
||||
g.translate(tickBounds.x, 0);
|
||||
} else {
|
||||
g.translate(tickBounds.x, 0);
|
||||
|
||||
int value = slider.getMinimum();
|
||||
int yPos;
|
||||
|
||||
if ( slider.getMinorTickSpacing() > 0 ) {
|
||||
if (slider.getMinorTickSpacing() > 0) {
|
||||
int offset = 0;
|
||||
if(!BasicGraphicsUtils.isLeftToRight(slider)) {
|
||||
offset = tickBounds.width - tickBounds.width / 2;
|
||||
g.translate(offset, 0);
|
||||
}
|
||||
|
||||
while ( value <= slider.getMaximum() ) {
|
||||
yPos = yPositionForValue( value );
|
||||
int value = slider.getMinimum();
|
||||
|
||||
while (value <= slider.getMaximum()) {
|
||||
int yPos = yPositionForValue(value);
|
||||
paintMinorTickForVertSlider( g, tickBounds, yPos );
|
||||
|
||||
// Overflow checking
|
||||
if (Integer.MAX_VALUE - slider.getMinorTickSpacing() < value) {
|
||||
break;
|
||||
}
|
||||
|
||||
value += slider.getMinorTickSpacing();
|
||||
}
|
||||
|
||||
@ -1053,15 +1068,22 @@ public class BasicSliderUI extends SliderUI{
|
||||
}
|
||||
}
|
||||
|
||||
if ( slider.getMajorTickSpacing() > 0 ) {
|
||||
value = slider.getMinimum();
|
||||
if (slider.getMajorTickSpacing() > 0) {
|
||||
if(!BasicGraphicsUtils.isLeftToRight(slider)) {
|
||||
g.translate(2, 0);
|
||||
}
|
||||
|
||||
while ( value <= slider.getMaximum() ) {
|
||||
yPos = yPositionForValue( value );
|
||||
int value = slider.getMinimum();
|
||||
|
||||
while (value <= slider.getMaximum()) {
|
||||
int yPos = yPositionForValue(value);
|
||||
paintMajorTickForVertSlider( g, tickBounds, yPos );
|
||||
|
||||
// Overflow checking
|
||||
if (Integer.MAX_VALUE - slider.getMajorTickSpacing() < value) {
|
||||
break;
|
||||
}
|
||||
|
||||
value += slider.getMajorTickSpacing();
|
||||
}
|
||||
|
||||
@ -1775,8 +1797,6 @@ public class BasicSliderUI extends SliderUI{
|
||||
thumbMiddle = thumbLeft + halfThumbWidth;
|
||||
slider.setValue(valueForXPosition(thumbMiddle));
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -38,6 +38,8 @@ import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
import javax.accessibility.*;
|
||||
|
||||
import sun.awt.shell.ShellFolder;
|
||||
@ -937,7 +939,11 @@ public class MetalFileChooserUI extends BasicFileChooserUI {
|
||||
|
||||
File[] baseFolders;
|
||||
if (useShellFolder) {
|
||||
baseFolders = (File[])ShellFolder.get("fileChooserComboBoxFolders");
|
||||
baseFolders = AccessController.doPrivileged(new PrivilegedAction<File[]>() {
|
||||
public File[] run() {
|
||||
return (File[]) ShellFolder.get("fileChooserComboBoxFolders");
|
||||
}
|
||||
});
|
||||
} else {
|
||||
baseFolders = fsv.getRoots();
|
||||
}
|
||||
|
@ -233,7 +233,7 @@ class SynthTabbedPaneUI extends BasicTabbedPaneUI implements SynthUI, PropertyCh
|
||||
tabContext.getStyle().getGraphicsUtils(tabContext).layoutText(
|
||||
tabContext, metrics, title, icon, SwingUtilities.CENTER,
|
||||
SwingUtilities.CENTER, SwingUtilities.LEADING,
|
||||
SwingUtilities.TRAILING, calcRect,
|
||||
SwingUtilities.CENTER, calcRect,
|
||||
iconRect, textRect, textIconGap);
|
||||
return textRect.y + metrics.getAscent() + getBaselineOffset();
|
||||
}
|
||||
@ -426,7 +426,7 @@ class SynthTabbedPaneUI extends BasicTabbedPaneUI implements SynthUI, PropertyCh
|
||||
|
||||
ss.getStyle().getGraphicsUtils(ss).layoutText(ss, metrics, title,
|
||||
icon, SwingUtilities.CENTER, SwingUtilities.CENTER,
|
||||
SwingUtilities.LEADING, SwingUtilities.TRAILING,
|
||||
SwingUtilities.LEADING, SwingUtilities.CENTER,
|
||||
tabRect, iconRect, textRect, textIconGap);
|
||||
|
||||
tabPane.putClientProperty("html", null);
|
||||
|
@ -30,6 +30,7 @@ import javax.swing.event.*;
|
||||
import java.util.BitSet;
|
||||
import java.util.Locale;
|
||||
|
||||
import javax.swing.UIManager;
|
||||
import sun.swing.SwingUtilities2;
|
||||
|
||||
/**
|
||||
@ -382,11 +383,10 @@ public class GlyphView extends View implements TabableView, Cloneable {
|
||||
Color bg = getBackground();
|
||||
Color fg = getForeground();
|
||||
|
||||
if (c instanceof JTextComponent) {
|
||||
JTextComponent tc = (JTextComponent) c;
|
||||
if (!tc.isEnabled()) {
|
||||
fg = tc.getDisabledTextColor();
|
||||
}
|
||||
if (c != null && ! c.isEnabled()) {
|
||||
fg = (c instanceof JTextComponent ?
|
||||
((JTextComponent)c).getDisabledTextColor() :
|
||||
UIManager.getColor("textInactiveText"));
|
||||
}
|
||||
if (bg != null) {
|
||||
g.setColor(bg);
|
||||
|
@ -25,9 +25,7 @@
|
||||
package javax.swing.text.html;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.awt.image.ImageObserver;
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import java.util.Dictionary;
|
||||
import javax.swing.*;
|
||||
@ -97,6 +95,7 @@ public class ImageView extends View {
|
||||
|
||||
private AttributeSet attr;
|
||||
private Image image;
|
||||
private Image disabledImage;
|
||||
private int width;
|
||||
private int height;
|
||||
/** Bitmask containing some of the above bitmask values. Because the
|
||||
@ -193,6 +192,17 @@ public class ImageView extends View {
|
||||
return image;
|
||||
}
|
||||
|
||||
private Image getImage(boolean enabled) {
|
||||
Image img = getImage();
|
||||
if (! enabled) {
|
||||
if (disabledImage == null) {
|
||||
disabledImage = GrayFilter.createDisabledImage(img);
|
||||
}
|
||||
img = disabledImage;
|
||||
}
|
||||
return img;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets how the image is loaded. If <code>newValue</code> is true,
|
||||
* the image we be loaded when first asked for, otherwise it will
|
||||
@ -338,8 +348,6 @@ public class ImageView extends View {
|
||||
|
||||
Rectangle rect = (a instanceof Rectangle) ? (Rectangle)a :
|
||||
a.getBounds();
|
||||
|
||||
Image image = getImage();
|
||||
Rectangle clip = g.getClipBounds();
|
||||
|
||||
fBounds.setBounds(rect);
|
||||
@ -350,29 +358,29 @@ public class ImageView extends View {
|
||||
rect.width - leftInset - rightInset,
|
||||
rect.height - topInset - bottomInset);
|
||||
}
|
||||
if (image != null) {
|
||||
if (!hasPixels(image)) {
|
||||
// No pixels yet, use the default
|
||||
Icon icon = (image == null) ? getNoImageIcon() :
|
||||
getLoadingImageIcon();
|
||||
|
||||
Container host = getContainer();
|
||||
Image img = getImage(host == null || host.isEnabled());
|
||||
if (img != null) {
|
||||
if (! hasPixels(img)) {
|
||||
// No pixels yet, use the default
|
||||
Icon icon = getLoadingImageIcon();
|
||||
if (icon != null) {
|
||||
icon.paintIcon(getContainer(), g, rect.x + leftInset,
|
||||
rect.y + topInset);
|
||||
icon.paintIcon(host, g,
|
||||
rect.x + leftInset, rect.y + topInset);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Draw the image
|
||||
g.drawImage(image, rect.x + leftInset, rect.y + topInset,
|
||||
g.drawImage(img, rect.x + leftInset, rect.y + topInset,
|
||||
width, height, imageObserver);
|
||||
}
|
||||
}
|
||||
else {
|
||||
Icon icon = getNoImageIcon();
|
||||
|
||||
if (icon != null) {
|
||||
icon.paintIcon(getContainer(), g, rect.x + leftInset,
|
||||
rect.y + topInset);
|
||||
icon.paintIcon(host, g,
|
||||
rect.x + leftInset, rect.y + topInset);
|
||||
}
|
||||
View view = getAltView();
|
||||
// Paint the view representing the alt text, if its non-null
|
||||
@ -855,7 +863,9 @@ public class ImageView extends View {
|
||||
// it will pick up the new height/width, if necessary.
|
||||
public boolean imageUpdate(Image img, int flags, int x, int y,
|
||||
int newWidth, int newHeight ) {
|
||||
if (image == null || image != img || getParent() == null) {
|
||||
if (img != image && img != disabledImage ||
|
||||
image == null || getParent() == null) {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -873,6 +883,8 @@ public class ImageView extends View {
|
||||
if ((state & HEIGHT_FLAG) != HEIGHT_FLAG) {
|
||||
height = DEFAULT_HEIGHT;
|
||||
}
|
||||
} else {
|
||||
disabledImage = null;
|
||||
}
|
||||
if ((state & LOADING_FLAG) == LOADING_FLAG) {
|
||||
// No need to resize or repaint, still in the process
|
||||
@ -885,38 +897,37 @@ public class ImageView extends View {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Resize image if necessary:
|
||||
short changed = 0;
|
||||
if ((flags & ImageObserver.HEIGHT) != 0 && !getElement().
|
||||
getAttributes().isDefined(HTML.Attribute.HEIGHT)) {
|
||||
changed |= 1;
|
||||
}
|
||||
if ((flags & ImageObserver.WIDTH) != 0 && !getElement().
|
||||
getAttributes().isDefined(HTML.Attribute.WIDTH)) {
|
||||
changed |= 2;
|
||||
}
|
||||
if (image == img) {
|
||||
// Resize image if necessary:
|
||||
short changed = 0;
|
||||
if ((flags & ImageObserver.HEIGHT) != 0 && !getElement().
|
||||
getAttributes().isDefined(HTML.Attribute.HEIGHT)) {
|
||||
changed |= 1;
|
||||
}
|
||||
if ((flags & ImageObserver.WIDTH) != 0 && !getElement().
|
||||
getAttributes().isDefined(HTML.Attribute.WIDTH)) {
|
||||
changed |= 2;
|
||||
}
|
||||
|
||||
synchronized(ImageView.this) {
|
||||
if (image != img) {
|
||||
return false;
|
||||
synchronized(ImageView.this) {
|
||||
if ((changed & 1) == 1 && (state & WIDTH_FLAG) == 0) {
|
||||
width = newWidth;
|
||||
}
|
||||
if ((changed & 2) == 2 && (state & HEIGHT_FLAG) == 0) {
|
||||
height = newHeight;
|
||||
}
|
||||
if ((state & LOADING_FLAG) == LOADING_FLAG) {
|
||||
// No need to resize or repaint, still in the process of
|
||||
// loading.
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if ((changed & 1) == 1 && (state & WIDTH_FLAG) == 0) {
|
||||
width = newWidth;
|
||||
}
|
||||
if ((changed & 2) == 2 && (state & HEIGHT_FLAG) == 0) {
|
||||
height = newHeight;
|
||||
}
|
||||
if ((state & LOADING_FLAG) == LOADING_FLAG) {
|
||||
// No need to resize or repaint, still in the process of
|
||||
// loading.
|
||||
if (changed != 0) {
|
||||
// May need to resize myself, asynchronously:
|
||||
safePreferenceChanged();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (changed != 0) {
|
||||
// May need to resize myself, asynchronously:
|
||||
safePreferenceChanged();
|
||||
return true;
|
||||
}
|
||||
|
||||
// Repaint when done or when new pixels arrive:
|
||||
if ((flags & (FRAMEBITS|ALLBITS)) != 0) {
|
||||
|
@ -31,6 +31,7 @@ import java.io.*;
|
||||
import java.net.*;
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.UIManager;
|
||||
import javax.swing.border.*;
|
||||
import javax.swing.event.ChangeListener;
|
||||
import javax.swing.text.*;
|
||||
@ -2161,6 +2162,7 @@ public class StyleSheet extends StyleContext {
|
||||
*/
|
||||
public void paint(Graphics g, float x, float y, float w, float h, View v, int item) {
|
||||
View cv = v.getView(item);
|
||||
Container host = v.getContainer();
|
||||
Object name = cv.getElement().getAttributes().getAttribute
|
||||
(StyleConstants.NameAttribute);
|
||||
// Only draw something if the View is a list item. This won't
|
||||
@ -2171,7 +2173,7 @@ public class StyleSheet extends StyleContext {
|
||||
}
|
||||
// deside on what side draw bullets, etc.
|
||||
isLeftToRight =
|
||||
cv.getContainer().getComponentOrientation().isLeftToRight();
|
||||
host.getComponentOrientation().isLeftToRight();
|
||||
|
||||
// How the list indicator is aligned is not specified, it is
|
||||
// left up to the UA. IE and NS differ on this behavior.
|
||||
@ -2200,15 +2202,15 @@ public class StyleSheet extends StyleContext {
|
||||
}
|
||||
|
||||
// set the color of a decoration
|
||||
if (ss != null) {
|
||||
g.setColor(ss.getForeground(cv.getAttributes()));
|
||||
} else {
|
||||
g.setColor(Color.black);
|
||||
}
|
||||
Color c = (host.isEnabled()
|
||||
? (ss != null
|
||||
? ss.getForeground(cv.getAttributes())
|
||||
: host.getForeground())
|
||||
: UIManager.getColor("textInactiveText"));
|
||||
g.setColor(c);
|
||||
|
||||
if (img != null) {
|
||||
drawIcon(g, (int) x, (int) y, (int) w, (int) h, align,
|
||||
v.getContainer());
|
||||
drawIcon(g, (int) x, (int) y, (int) w, (int) h, align, host);
|
||||
return;
|
||||
}
|
||||
CSS.Value childtype = getChildType(cv);
|
||||
|
@ -31,6 +31,7 @@ import java.awt.Toolkit;
|
||||
import java.io.*;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
/**
|
||||
* @author Michael Martak
|
||||
@ -461,6 +462,35 @@ public abstract class ShellFolder extends File {
|
||||
return null;
|
||||
}
|
||||
|
||||
private static Invoker invoker;
|
||||
|
||||
/**
|
||||
* Provides the single access point to the {@link Invoker}. It is guaranteed that the value
|
||||
* returned by this method will be always the same.
|
||||
*
|
||||
* @return the singleton instance of {@link Invoker}
|
||||
*/
|
||||
public static Invoker getInvoker() {
|
||||
if (invoker == null) {
|
||||
invoker = shellFolderManager.createInvoker();
|
||||
}
|
||||
return invoker;
|
||||
}
|
||||
|
||||
/**
|
||||
* Interface allowing to invoke tasks in different environments on different platforms.
|
||||
*/
|
||||
public static interface Invoker {
|
||||
/**
|
||||
* Invokes a callable task. If the {@code task} throws a checked exception,
|
||||
* it will be wrapped into a {@link RuntimeException}
|
||||
*
|
||||
* @param task a task to invoke
|
||||
* @return the result of {@code task}'s invokation
|
||||
*/
|
||||
<T> T invoke(Callable<T> task);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides a default comparator for the default column set
|
||||
*/
|
||||
|
@ -27,6 +27,7 @@ package sun.awt.shell;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
/**
|
||||
* @author Michael Martak
|
||||
@ -96,9 +97,23 @@ class ShellFolderManager {
|
||||
}
|
||||
|
||||
public boolean isFileSystemRoot(File dir) {
|
||||
if (dir instanceof ShellFolder && !((ShellFolder)dir).isFileSystem()) {
|
||||
if (dir instanceof ShellFolder && !((ShellFolder) dir).isFileSystem()) {
|
||||
return false;
|
||||
}
|
||||
return (dir.getParentFile() == null);
|
||||
}
|
||||
|
||||
protected ShellFolder.Invoker createInvoker() {
|
||||
return new DirectInvoker();
|
||||
}
|
||||
|
||||
private static class DirectInvoker implements ShellFolder.Invoker {
|
||||
public <T> T invoke(Callable<T> task) {
|
||||
try {
|
||||
return task.call();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1996-2007 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* Copyright 1996-2009 Sun Microsystems, Inc. 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
|
||||
@ -29,6 +29,8 @@ import java.awt.*;
|
||||
import java.beans.*;
|
||||
|
||||
public class ColorEditor extends Panel implements PropertyEditor {
|
||||
private static final long serialVersionUID = 1781257185164716054L;
|
||||
|
||||
public ColorEditor() {
|
||||
setLayout(null);
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1996-2007 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* Copyright 1996-2009 Sun Microsystems, Inc. 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
|
||||
@ -29,6 +29,7 @@ import java.awt.*;
|
||||
import java.beans.*;
|
||||
|
||||
public class FontEditor extends Panel implements java.beans.PropertyEditor {
|
||||
private static final long serialVersionUID = 6732704486002715933L;
|
||||
|
||||
public FontEditor() {
|
||||
setLayout(null);
|
||||
|
@ -34,6 +34,7 @@ import java.text.DateFormat;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.*;
|
||||
@ -900,6 +901,16 @@ public class FilePane extends JPanel implements PropertyChangeListener {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sort() {
|
||||
ShellFolder.getInvoker().invoke(new Callable<Void>() {
|
||||
public Void call() throws Exception {
|
||||
DetailsTableRowSorter.super.sort();
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void modelStructureChanged() {
|
||||
super.modelStructureChanged();
|
||||
updateComparators(detailsTableModel.getColumns());
|
||||
|
@ -29,6 +29,8 @@ import java.awt.event.*;
|
||||
import java.beans.*;
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.*;
|
||||
@ -749,7 +751,11 @@ public class SynthFileChooserUIImpl extends SynthFileChooserUI {
|
||||
|
||||
File[] baseFolders;
|
||||
if (useShellFolder) {
|
||||
baseFolders = (File[])ShellFolder.get("fileChooserComboBoxFolders");
|
||||
baseFolders = AccessController.doPrivileged(new PrivilegedAction<File[]>() {
|
||||
public File[] run() {
|
||||
return (File[]) ShellFolder.get("fileChooserComboBoxFolders");
|
||||
}
|
||||
});
|
||||
} else {
|
||||
baseFolders = fsv.getRoots();
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Portions Copyright 2003-2005 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* Portions Copyright 2005-2009 Sun Microsystems, Inc. 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
|
||||
@ -22,10 +22,9 @@
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
*******************************************************************************
|
||||
* (C) Copyright IBM Corp. 1996-2005 - All Rights Reserved *
|
||||
* (C) Copyright IBM Corp. and others, 1996-2009 - All Rights Reserved *
|
||||
* *
|
||||
* The original version of this source code and documentation is copyrighted *
|
||||
* and owned by IBM, These materials are provided under terms of a License *
|
||||
@ -77,6 +76,66 @@ public class CharTrie extends Trie
|
||||
m_friendAgent_ = new FriendAgent();
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a dummy CharTrie.
|
||||
* A dummy trie is an empty runtime trie, used when a real data trie cannot
|
||||
* be loaded.
|
||||
*
|
||||
* The trie always returns the initialValue,
|
||||
* or the leadUnitValue for lead surrogate code points.
|
||||
* The Latin-1 part is always set up to be linear.
|
||||
*
|
||||
* @param initialValue the initial value that is set for all code points
|
||||
* @param leadUnitValue the value for lead surrogate code _units_ that do not
|
||||
* have associated supplementary data
|
||||
* @param dataManipulate object which provides methods to parse the char data
|
||||
*/
|
||||
public CharTrie(int initialValue, int leadUnitValue, DataManipulate dataManipulate) {
|
||||
super(new char[BMP_INDEX_LENGTH+SURROGATE_BLOCK_COUNT], HEADER_OPTIONS_LATIN1_IS_LINEAR_MASK_, dataManipulate);
|
||||
|
||||
int dataLength, latin1Length, i, limit;
|
||||
char block;
|
||||
|
||||
/* calculate the actual size of the dummy trie data */
|
||||
|
||||
/* max(Latin-1, block 0) */
|
||||
dataLength=latin1Length= INDEX_STAGE_1_SHIFT_<=8 ? 256 : DATA_BLOCK_LENGTH;
|
||||
if(leadUnitValue!=initialValue) {
|
||||
dataLength+=DATA_BLOCK_LENGTH;
|
||||
}
|
||||
m_data_=new char[dataLength];
|
||||
m_dataLength_=dataLength;
|
||||
|
||||
m_initialValue_=(char)initialValue;
|
||||
|
||||
/* fill the index and data arrays */
|
||||
|
||||
/* indexes are preset to 0 (block 0) */
|
||||
|
||||
/* Latin-1 data */
|
||||
for(i=0; i<latin1Length; ++i) {
|
||||
m_data_[i]=(char)initialValue;
|
||||
}
|
||||
|
||||
if(leadUnitValue!=initialValue) {
|
||||
/* indexes for lead surrogate code units to the block after Latin-1 */
|
||||
block=(char)(latin1Length>>INDEX_STAGE_2_SHIFT_);
|
||||
i=0xd800>>INDEX_STAGE_1_SHIFT_;
|
||||
limit=0xdc00>>INDEX_STAGE_1_SHIFT_;
|
||||
for(; i<limit; ++i) {
|
||||
m_index_[i]=block;
|
||||
}
|
||||
|
||||
/* data for lead surrogate code units */
|
||||
limit=latin1Length+DATA_BLOCK_LENGTH;
|
||||
for(i=latin1Length; i<limit; ++i) {
|
||||
m_data_[i]=(char)leadUnitValue;
|
||||
}
|
||||
}
|
||||
|
||||
m_friendAgent_ = new FriendAgent();
|
||||
}
|
||||
|
||||
/**
|
||||
* Java friend implementation
|
||||
*/
|
||||
@ -130,7 +189,18 @@ public class CharTrie extends Trie
|
||||
*/
|
||||
public final char getCodePointValue(int ch)
|
||||
{
|
||||
int offset = getCodePointOffset(ch);
|
||||
int offset;
|
||||
|
||||
// fastpath for U+0000..U+D7FF
|
||||
if(0 <= ch && ch < UTF16.LEAD_SURROGATE_MIN_VALUE) {
|
||||
// copy of getRawOffset()
|
||||
offset = (m_index_[ch >> INDEX_STAGE_1_SHIFT_] << INDEX_STAGE_2_SHIFT_)
|
||||
+ (ch & INDEX_STAGE_3_MASK_);
|
||||
return m_data_[offset];
|
||||
}
|
||||
|
||||
// handle U+D800..U+10FFFF
|
||||
offset = getCodePointOffset(ch);
|
||||
|
||||
// return -1 if there is an error, in this case we return the default
|
||||
// value: m_initialValue_
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Portions Copyright 2001-2006 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* Portions Copyright 2005-2009 Sun Microsystems, Inc. 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
|
||||
@ -22,10 +22,9 @@
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
*******************************************************************************
|
||||
* (C) Copyright IBM Corp. 1996-2005 - All Rights Reserved *
|
||||
* (C) Copyright IBM Corp. and others, 1996-2009 - All Rights Reserved *
|
||||
* *
|
||||
* The original version of this source code and documentation is copyrighted *
|
||||
* and owned by IBM, These materials are provided under terms of a License *
|
||||
@ -127,7 +126,7 @@ import java.text.Normalizer;
|
||||
* normalize(FCD) may be implemented with NFD.
|
||||
*
|
||||
* For more details on FCD see the collation design document:
|
||||
* http://oss.software.ibm.com/cvs/icu/~checkout~/icuhtml/design/collation/ICU_collation_design.htm
|
||||
* http://source.icu-project.org/repos/icu/icuhtml/trunk/design/collation/ICU_collation_design.htm
|
||||
*
|
||||
* ICU collation performs either NFD or FCD normalization automatically if
|
||||
* normalization is turned on for the collator object. Beyond collation and
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Portions Copyright 2003-2006 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* Portions Copyright 2005-2009 Sun Microsystems, Inc. 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
|
||||
@ -22,10 +22,9 @@
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
*******************************************************************************
|
||||
* (C) Copyright IBM Corp. 1996-2005 - All Rights Reserved *
|
||||
* (C) Copyright IBM Corp. and others, 1996-2009 - All Rights Reserved *
|
||||
* *
|
||||
* The original version of this source code and documentation is copyrighted *
|
||||
* and owned by IBM, These materials are provided under terms of a License *
|
||||
@ -331,7 +330,7 @@ final class NormalizerDataReader implements ICUBinary.Authenticate {
|
||||
throws IOException{
|
||||
|
||||
//Read the bytes that make up the normTrie
|
||||
dataInputStream.read(normBytes);
|
||||
dataInputStream.readFully(normBytes);
|
||||
|
||||
//normTrieStream= new ByteArrayInputStream(normBytes);
|
||||
|
||||
@ -346,11 +345,11 @@ final class NormalizerDataReader implements ICUBinary.Authenticate {
|
||||
}
|
||||
|
||||
//Read the fcdTrie
|
||||
dataInputStream.read(fcdBytes);
|
||||
dataInputStream.readFully(fcdBytes);
|
||||
|
||||
|
||||
//Read the AuxTrie
|
||||
dataInputStream.read(auxBytes);
|
||||
dataInputStream.readFully(auxBytes);
|
||||
}
|
||||
|
||||
public byte[] getDataFormatVersion(){
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Portions Copyright 2003-2006 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* Portions Copyright 2005-2009 Sun Microsystems, Inc. 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
|
||||
@ -22,10 +22,9 @@
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
*******************************************************************************
|
||||
* (C) Copyright IBM Corp. 1996-2005 - All Rights Reserved *
|
||||
* (C) Copyright IBM Corp. and others, 1996-2009 - All Rights Reserved *
|
||||
* *
|
||||
* The original version of this source code and documentation is copyrighted *
|
||||
* and owned by IBM, These materials are provided under terms of a License *
|
||||
@ -102,7 +101,7 @@ public final class NormalizerImpl {
|
||||
private static final long MIN_SPECIAL = (long)(0xfc000000 & UNSIGNED_INT_MASK);
|
||||
private static final long SURROGATES_TOP = (long)(0xfff00000 & UNSIGNED_INT_MASK);
|
||||
private static final long MIN_HANGUL = (long)(0xfff00000 & UNSIGNED_INT_MASK);
|
||||
private static final long MIN_JAMO_V = (long)(0xfff20000 & UNSIGNED_INT_MASK);
|
||||
// private static final long MIN_JAMO_V = (long)(0xfff20000 & UNSIGNED_INT_MASK);
|
||||
private static final long JAMO_V_TOP = (long)(0xfff30000 & UNSIGNED_INT_MASK);
|
||||
|
||||
|
||||
@ -908,7 +907,7 @@ public final class NormalizerImpl {
|
||||
buffer = composePart(args,prevStarter,src,srcStart,srcLimit,options,nx);
|
||||
|
||||
// compare the normalized version with the original
|
||||
if(0!=strCompare(buffer,0,args.length,src,prevStarter,(srcStart-prevStarter), false)) {
|
||||
if(0!=strCompare(buffer,0,args.length,src,prevStarter,srcStart, false)) {
|
||||
result=NormalizerBase.NO; // normalization differs
|
||||
break;
|
||||
}
|
||||
@ -2291,7 +2290,7 @@ public final class NormalizerImpl {
|
||||
private static final int OPTIONS_NX_MASK=0x1f;
|
||||
private static final int OPTIONS_UNICODE_MASK=0xe0;
|
||||
public static final int OPTIONS_SETS_MASK=0xff;
|
||||
private static final int OPTIONS_UNICODE_SHIFT=5;
|
||||
// private static final int OPTIONS_UNICODE_SHIFT=5;
|
||||
private static final UnicodeSet[] nxCache = new UnicodeSet[OPTIONS_SETS_MASK+1];
|
||||
|
||||
/* Constants for options flags for normalization.*/
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Portions Copyright 2003-2005 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* Portions Copyright 2005-2009 Sun Microsystems, Inc. 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
|
||||
@ -22,10 +22,9 @@
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
*******************************************************************************
|
||||
* (C) Copyright IBM Corp. 1996-2005 - All Rights Reserved *
|
||||
* (C) Copyright IBM Corp. and others, 1996-2009 - All Rights Reserved *
|
||||
* *
|
||||
* The original version of this source code and documentation is copyrighted *
|
||||
* and owned by IBM, These materials are provided under terms of a License *
|
||||
@ -37,10 +36,9 @@
|
||||
|
||||
package sun.text.normalizer;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* <p>A trie is a kind of compressed, serializable table of values
|
||||
@ -81,7 +79,6 @@ public abstract class Trie
|
||||
* This interface specifies methods to be implemented in order for
|
||||
* com.ibm.impl.Trie, to surrogate offset information encapsulated within
|
||||
* the data.
|
||||
* @draft 2.1
|
||||
*/
|
||||
public static interface DataManipulate
|
||||
{
|
||||
@ -92,11 +89,17 @@ public abstract class Trie
|
||||
* @param value data value for a surrogate from the trie, including the
|
||||
* folding offset
|
||||
* @return data offset or 0 if there is no data for the lead surrogate
|
||||
* @draft 2.1
|
||||
*/
|
||||
public int getFoldingOffset(int value);
|
||||
}
|
||||
|
||||
// default implementation
|
||||
private static class DefaultGetFoldingOffset implements DataManipulate {
|
||||
public int getFoldingOffset(int value) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
// protected constructor -------------------------------------------
|
||||
|
||||
/**
|
||||
@ -107,7 +110,6 @@ public abstract class Trie
|
||||
* trie data
|
||||
* @throws IOException thrown when input stream does not have the
|
||||
* right header.
|
||||
* @draft 2.1
|
||||
*/
|
||||
protected Trie(InputStream inputStream,
|
||||
DataManipulate dataManipulate) throws IOException
|
||||
@ -121,7 +123,11 @@ public abstract class Trie
|
||||
throw new IllegalArgumentException("ICU data file error: Trie header authentication failed, please check if you have the most updated ICU data file");
|
||||
}
|
||||
|
||||
m_dataManipulate_ = dataManipulate;
|
||||
if(dataManipulate != null) {
|
||||
m_dataManipulate_ = dataManipulate;
|
||||
} else {
|
||||
m_dataManipulate_ = new DefaultGetFoldingOffset();
|
||||
}
|
||||
m_isLatin1Linear_ = (m_options_ &
|
||||
HEADER_OPTIONS_LATIN1_IS_LINEAR_MASK_) != 0;
|
||||
m_dataOffset_ = input.readInt();
|
||||
@ -135,19 +141,21 @@ public abstract class Trie
|
||||
* @param options used by the trie
|
||||
* @param dataManipulate object containing the information to parse the
|
||||
* trie data
|
||||
* @draft 2.2
|
||||
*/
|
||||
protected Trie(char index[], int options, DataManipulate dataManipulate)
|
||||
{
|
||||
m_options_ = options;
|
||||
m_dataManipulate_ = dataManipulate;
|
||||
if(dataManipulate != null) {
|
||||
m_dataManipulate_ = dataManipulate;
|
||||
} else {
|
||||
m_dataManipulate_ = new DefaultGetFoldingOffset();
|
||||
}
|
||||
m_isLatin1Linear_ = (m_options_ &
|
||||
HEADER_OPTIONS_LATIN1_IS_LINEAR_MASK_) != 0;
|
||||
m_index_ = index;
|
||||
m_dataOffset_ = m_index_.length;
|
||||
}
|
||||
|
||||
|
||||
// protected data members ------------------------------------------
|
||||
|
||||
/**
|
||||
@ -158,7 +166,6 @@ public abstract class Trie
|
||||
protected static final int LEAD_INDEX_OFFSET_ = 0x2800 >> 5;
|
||||
/**
|
||||
* Shift size for shifting right the input index. 1..9
|
||||
* @draft 2.1
|
||||
*/
|
||||
protected static final int INDEX_STAGE_1_SHIFT_ = 5;
|
||||
/**
|
||||
@ -168,31 +175,39 @@ public abstract class Trie
|
||||
* This requires blocks of stage 2 data to be aligned by
|
||||
* DATA_GRANULARITY.
|
||||
* 0..INDEX_STAGE_1_SHIFT
|
||||
* @draft 2.1
|
||||
*/
|
||||
protected static final int INDEX_STAGE_2_SHIFT_ = 2;
|
||||
/**
|
||||
* Number of data values in a stage 2 (data array) block.
|
||||
*/
|
||||
protected static final int DATA_BLOCK_LENGTH=1<<INDEX_STAGE_1_SHIFT_;
|
||||
/**
|
||||
* Mask for getting the lower bits from the input index.
|
||||
* DATA_BLOCK_LENGTH_ - 1.
|
||||
* @draft 2.1
|
||||
* DATA_BLOCK_LENGTH - 1.
|
||||
*/
|
||||
protected static final int INDEX_STAGE_3_MASK_ =
|
||||
(1 << INDEX_STAGE_1_SHIFT_) - 1;
|
||||
protected static final int INDEX_STAGE_3_MASK_ = DATA_BLOCK_LENGTH - 1;
|
||||
/** Number of bits of a trail surrogate that are used in index table lookups. */
|
||||
protected static final int SURROGATE_BLOCK_BITS=10-INDEX_STAGE_1_SHIFT_;
|
||||
/**
|
||||
* Number of index (stage 1) entries per lead surrogate.
|
||||
* Same as number of index entries for 1024 trail surrogates,
|
||||
* ==0x400>>INDEX_STAGE_1_SHIFT_
|
||||
*/
|
||||
protected static final int SURROGATE_BLOCK_COUNT=(1<<SURROGATE_BLOCK_BITS);
|
||||
/** Length of the BMP portion of the index (stage 1) array. */
|
||||
protected static final int BMP_INDEX_LENGTH=0x10000>>INDEX_STAGE_1_SHIFT_;
|
||||
/**
|
||||
* Surrogate mask to use when shifting offset to retrieve supplementary
|
||||
* values
|
||||
* @draft 2.1
|
||||
*/
|
||||
protected static final int SURROGATE_MASK_ = 0x3FF;
|
||||
/**
|
||||
* Index or UTF16 characters
|
||||
* @draft 2.1
|
||||
*/
|
||||
protected char m_index_[];
|
||||
/**
|
||||
* Internal TrieValue which handles the parsing of the data value.
|
||||
* This class is to be implemented by the user
|
||||
* @draft 2.1
|
||||
*/
|
||||
protected DataManipulate m_dataManipulate_;
|
||||
/**
|
||||
@ -200,7 +215,6 @@ public abstract class Trie
|
||||
* index and data into a char array, so this is used to indicate the
|
||||
* initial offset to the data portion.
|
||||
* Note this index always points to the initial value.
|
||||
* @draft 2.1
|
||||
*/
|
||||
protected int m_dataOffset_;
|
||||
/**
|
||||
@ -215,7 +229,6 @@ public abstract class Trie
|
||||
* @param lead lead surrogate
|
||||
* @param trail trailing surrogate
|
||||
* @return offset to data
|
||||
* @draft 2.1
|
||||
*/
|
||||
protected abstract int getSurrogateOffset(char lead, char trail);
|
||||
|
||||
@ -223,14 +236,12 @@ public abstract class Trie
|
||||
* Gets the value at the argument index
|
||||
* @param index value at index will be retrieved
|
||||
* @return 32 bit value
|
||||
* @draft 2.1
|
||||
*/
|
||||
protected abstract int getValue(int index);
|
||||
|
||||
/**
|
||||
* Gets the default initial value
|
||||
* @return 32 bit value
|
||||
* @draft 2.1
|
||||
*/
|
||||
protected abstract int getInitialValue();
|
||||
|
||||
@ -247,7 +258,6 @@ public abstract class Trie
|
||||
* @param offset index offset which ch is to start from
|
||||
* @param ch index to be used after offset
|
||||
* @return offset to the data
|
||||
* @draft 2.1
|
||||
*/
|
||||
protected final int getRawOffset(int offset, char ch)
|
||||
{
|
||||
@ -261,7 +271,6 @@ public abstract class Trie
|
||||
* Treats a lead surrogate as a normal code point.
|
||||
* @param ch BMP character
|
||||
* @return offset to data
|
||||
* @draft 2.1
|
||||
*/
|
||||
protected final int getBMPOffset(char ch)
|
||||
{
|
||||
@ -279,7 +288,6 @@ public abstract class Trie
|
||||
* the next trailing surrogate character.
|
||||
* @param ch lead surrogate character
|
||||
* @return offset to data
|
||||
* @draft 2.1
|
||||
*/
|
||||
protected final int getLeadOffset(char ch)
|
||||
{
|
||||
@ -293,26 +301,27 @@ public abstract class Trie
|
||||
* Gets the offset to data which the codepoint points to
|
||||
* @param ch codepoint
|
||||
* @return offset to data
|
||||
* @draft 2.1
|
||||
*/
|
||||
protected final int getCodePointOffset(int ch)
|
||||
{
|
||||
// if ((ch >> 16) == 0) slower
|
||||
if (ch >= UTF16.CODEPOINT_MIN_VALUE
|
||||
&& ch < UTF16.SUPPLEMENTARY_MIN_VALUE) {
|
||||
if (ch < 0) {
|
||||
return -1;
|
||||
} else if (ch < UTF16.LEAD_SURROGATE_MIN_VALUE) {
|
||||
// fastpath for the part of the BMP below surrogates (D800) where getRawOffset() works
|
||||
return getRawOffset(0, (char)ch);
|
||||
} else if (ch < UTF16.SUPPLEMENTARY_MIN_VALUE) {
|
||||
// BMP codepoint
|
||||
return getBMPOffset((char)ch);
|
||||
}
|
||||
// for optimization
|
||||
if (ch >= UTF16.CODEPOINT_MIN_VALUE
|
||||
&& ch <= UCharacter.MAX_VALUE) {
|
||||
} else if (ch <= UCharacter.MAX_VALUE) {
|
||||
// look at the construction of supplementary characters
|
||||
// trail forms the ends of it.
|
||||
return getSurrogateOffset(UTF16.getLeadSurrogate(ch),
|
||||
(char)(ch & SURROGATE_MASK_));
|
||||
} else {
|
||||
// return -1 // if there is an error, in this case we return
|
||||
return -1;
|
||||
}
|
||||
// return -1 if there is an error, in this case we return
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -320,7 +329,6 @@ public abstract class Trie
|
||||
* <p>This is overwritten by the child classes.
|
||||
* @param inputStream input stream containing the trie information
|
||||
* @exception IOException thrown when data reading fails.
|
||||
* @draft 2.1
|
||||
*/
|
||||
protected void unserialize(InputStream inputStream) throws IOException
|
||||
{
|
||||
@ -335,7 +343,6 @@ public abstract class Trie
|
||||
/**
|
||||
* Determines if this is a 32 bit trie
|
||||
* @return true if options specifies this is a 32 bit trie
|
||||
* @draft 2.1
|
||||
*/
|
||||
protected final boolean isIntTrie()
|
||||
{
|
||||
@ -345,7 +352,6 @@ public abstract class Trie
|
||||
/**
|
||||
* Determines if this is a 16 bit trie
|
||||
* @return true if this is a 16 bit trie
|
||||
* @draft 2.1
|
||||
*/
|
||||
protected final boolean isCharTrie()
|
||||
{
|
||||
@ -354,40 +360,20 @@ public abstract class Trie
|
||||
|
||||
// private data members --------------------------------------------
|
||||
|
||||
/**
|
||||
* Signature index
|
||||
*/
|
||||
private static final int HEADER_SIGNATURE_INDEX_ = 0;
|
||||
/**
|
||||
* Options index
|
||||
*/
|
||||
private static final int HEADER_OPTIONS_INDEX_ = 1 << 1;
|
||||
/**
|
||||
* Index length index
|
||||
*/
|
||||
private static final int HEADER_INDEX_LENGTH_INDEX_ = 2 << 1;
|
||||
/**
|
||||
* Data length index
|
||||
*/
|
||||
private static final int HEADER_DATA_LENGTH_INDEX_ = 3 << 1;
|
||||
/**
|
||||
* Size of header
|
||||
*/
|
||||
private static final int HEADER_LENGTH_ = 4 << 1;
|
||||
/**
|
||||
* Latin 1 option mask
|
||||
*/
|
||||
private static final int HEADER_OPTIONS_LATIN1_IS_LINEAR_MASK_ = 0x200;
|
||||
protected static final int HEADER_OPTIONS_LATIN1_IS_LINEAR_MASK_ = 0x200;
|
||||
/**
|
||||
* Constant number to authenticate the byte block
|
||||
*/
|
||||
private static final int HEADER_SIGNATURE_ = 0x54726965;
|
||||
protected static final int HEADER_SIGNATURE_ = 0x54726965;
|
||||
/**
|
||||
* Header option formatting
|
||||
*/
|
||||
private static final int HEADER_OPTIONS_SHIFT_MASK_ = 0xF;
|
||||
private static final int HEADER_OPTIONS_INDEX_SHIFT_ = 4;
|
||||
private static final int HEADER_OPTIONS_DATA_IS_32_BIT_ = 0x100;
|
||||
protected static final int HEADER_OPTIONS_INDEX_SHIFT_ = 4;
|
||||
protected static final int HEADER_OPTIONS_DATA_IS_32_BIT_ = 0x100;
|
||||
|
||||
/**
|
||||
* Flag indicator for Latin quick access data block
|
||||
@ -409,9 +395,8 @@ public abstract class Trie
|
||||
/**
|
||||
* Authenticates raw data header.
|
||||
* Checking the header information, signature and options.
|
||||
* @param rawdata array of char data to be checked
|
||||
* @param signature This contains the options and type of a Trie
|
||||
* @return true if the header is authenticated valid
|
||||
* @draft 2.1
|
||||
*/
|
||||
private final boolean checkHeader(int signature)
|
||||
{
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Portions Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* Portions Copyright 2005-2009 Sun Microsystems, Inc. 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
|
||||
@ -22,10 +22,9 @@
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
*******************************************************************************
|
||||
* (C) Copyright IBM Corp. 1996-2005 - All Rights Reserved *
|
||||
* (C) Copyright IBM Corp. and others, 1996-2009 - All Rights Reserved *
|
||||
* *
|
||||
* The original version of this source code and documentation is copyrighted *
|
||||
* and owned by IBM, These materials are provided under terms of a License *
|
||||
@ -108,15 +107,14 @@ package sun.text.normalizer;
|
||||
* @since release 2.1, Jan 17 2002
|
||||
*/
|
||||
public class TrieIterator implements RangeValueIterator
|
||||
|
||||
{
|
||||
|
||||
// public constructor ---------------------------------------------
|
||||
|
||||
/**
|
||||
* TrieEnumeration constructor
|
||||
* @param trie to be used
|
||||
* @exception IllegalArgumentException throw when argument is null.
|
||||
* @draft 2.1
|
||||
*/
|
||||
public TrieIterator(Trie trie)
|
||||
{
|
||||
@ -141,7 +139,6 @@ public class TrieIterator implements RangeValueIterator
|
||||
* @return true if we are not at the end of the iteration, false otherwise.
|
||||
* @exception NoSuchElementException - if no more elements exist.
|
||||
* @see com.ibm.icu.util.RangeValueIterator.Element
|
||||
* @draft 2.1
|
||||
*/
|
||||
public final boolean next(Element element)
|
||||
{
|
||||
@ -158,7 +155,6 @@ public class TrieIterator implements RangeValueIterator
|
||||
|
||||
/**
|
||||
* Resets the iterator to the beginning of the iteration
|
||||
* @draft 2.1
|
||||
*/
|
||||
public final void reset()
|
||||
{
|
||||
@ -186,7 +182,6 @@ public class TrieIterator implements RangeValueIterator
|
||||
* The default function is to return the value as it is.
|
||||
* @param value a value from the trie
|
||||
* @return extracted value
|
||||
* @draft 2.1
|
||||
*/
|
||||
protected int extract(int value)
|
||||
{
|
||||
@ -278,7 +273,6 @@ public class TrieIterator implements RangeValueIterator
|
||||
* Note, if there are no more iterations, it will never get to here.
|
||||
* Blocked out by next().
|
||||
* @param element return result object
|
||||
* @draft 2.1
|
||||
*/
|
||||
private final void calculateNextSupplementaryElement(Element element)
|
||||
{
|
||||
@ -516,10 +510,6 @@ public class TrieIterator implements RangeValueIterator
|
||||
*/
|
||||
private static final int TRAIL_SURROGATE_MIN_VALUE_ = 0xDC00;
|
||||
/**
|
||||
* Trail surrogate maximum value
|
||||
*/
|
||||
private static final int TRAIL_SURROGATE_MAX_VALUE_ = 0xDFFF;
|
||||
/**
|
||||
* Number of trail surrogate
|
||||
*/
|
||||
private static final int TRAIL_SURROGATE_COUNT_ = 0x400;
|
||||
@ -538,11 +528,6 @@ public class TrieIterator implements RangeValueIterator
|
||||
private static final int DATA_BLOCK_LENGTH_ =
|
||||
1 << Trie.INDEX_STAGE_1_SHIFT_;
|
||||
/**
|
||||
* Number of codepoints in a stage 2 block
|
||||
*/
|
||||
private static final int DATA_BLOCK_SUPPLEMENTARY_LENGTH_ =
|
||||
DATA_BLOCK_LENGTH_ << 10;
|
||||
/**
|
||||
* Trie instance
|
||||
*/
|
||||
private Trie m_trie_;
|
||||
@ -560,10 +545,4 @@ public class TrieIterator implements RangeValueIterator
|
||||
private int m_nextBlock_;
|
||||
private int m_nextBlockIndex_;
|
||||
private int m_nextTrailIndexOffset_;
|
||||
/**
|
||||
* This is the return result element
|
||||
*/
|
||||
private int m_start_;
|
||||
private int m_limit_;
|
||||
private int m_value_;
|
||||
}
|
||||
|
179
jdk/src/share/classes/sun/text/normalizer/UBiDiProps.java
Normal file
179
jdk/src/share/classes/sun/text/normalizer/UBiDiProps.java
Normal file
@ -0,0 +1,179 @@
|
||||
/*
|
||||
* Portions Copyright 2005-2009 Sun Microsystems, Inc. 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. Sun designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
/*
|
||||
*******************************************************************************
|
||||
* (C) Copyright IBM Corp. and others, 1996-2009 - All Rights Reserved *
|
||||
* *
|
||||
* The original version of this source code and documentation is copyrighted *
|
||||
* and owned by IBM, These materials are provided under terms of a License *
|
||||
* Agreement between IBM and Sun. This technology is protected by multiple *
|
||||
* US and International patents. This notice and attribution to IBM may not *
|
||||
* to removed. *
|
||||
*******************************************************************************
|
||||
* file name: UBiDiProps.java
|
||||
* encoding: US-ASCII
|
||||
* tab size: 8 (not used)
|
||||
* indentation:4
|
||||
*
|
||||
* created on: 2005jan16
|
||||
* created by: Markus W. Scherer
|
||||
*
|
||||
* Low-level Unicode bidi/shaping properties access.
|
||||
* Java port of ubidi_props.h/.c.
|
||||
*/
|
||||
|
||||
package sun.text.normalizer;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public final class UBiDiProps {
|
||||
// constructors etc. --------------------------------------------------- ***
|
||||
|
||||
// port of ubidi_openProps()
|
||||
public UBiDiProps() throws IOException{
|
||||
InputStream is=ICUData.getStream(DATA_FILE_NAME);
|
||||
BufferedInputStream b=new BufferedInputStream(is, 4096 /* data buffer size */);
|
||||
readData(b);
|
||||
b.close();
|
||||
is.close();
|
||||
|
||||
}
|
||||
|
||||
private void readData(InputStream is) throws IOException {
|
||||
DataInputStream inputStream=new DataInputStream(is);
|
||||
|
||||
// read the header
|
||||
ICUBinary.readHeader(inputStream, FMT, new IsAcceptable());
|
||||
|
||||
// read indexes[]
|
||||
int i, count;
|
||||
count=inputStream.readInt();
|
||||
if(count<IX_INDEX_TOP) {
|
||||
throw new IOException("indexes[0] too small in "+DATA_FILE_NAME);
|
||||
}
|
||||
indexes=new int[count];
|
||||
|
||||
indexes[0]=count;
|
||||
for(i=1; i<count; ++i) {
|
||||
indexes[i]=inputStream.readInt();
|
||||
}
|
||||
|
||||
// read the trie
|
||||
trie=new CharTrie(inputStream, null);
|
||||
|
||||
// read mirrors[]
|
||||
count=indexes[IX_MIRROR_LENGTH];
|
||||
if(count>0) {
|
||||
mirrors=new int[count];
|
||||
for(i=0; i<count; ++i) {
|
||||
mirrors[i]=inputStream.readInt();
|
||||
}
|
||||
}
|
||||
|
||||
// read jgArray[]
|
||||
count=indexes[IX_JG_LIMIT]-indexes[IX_JG_START];
|
||||
jgArray=new byte[count];
|
||||
for(i=0; i<count; ++i) {
|
||||
jgArray[i]=inputStream.readByte();
|
||||
}
|
||||
}
|
||||
|
||||
// implement ICUBinary.Authenticate
|
||||
private final class IsAcceptable implements ICUBinary.Authenticate {
|
||||
public boolean isDataVersionAcceptable(byte version[]) {
|
||||
return version[0]==1 &&
|
||||
version[2]==Trie.INDEX_STAGE_1_SHIFT_ && version[3]==Trie.INDEX_STAGE_2_SHIFT_;
|
||||
}
|
||||
}
|
||||
|
||||
// UBiDiProps singleton
|
||||
private static UBiDiProps gBdp=null;
|
||||
|
||||
// port of ubidi_getSingleton()
|
||||
public static final synchronized UBiDiProps getSingleton() throws IOException {
|
||||
if(gBdp==null) {
|
||||
gBdp=new UBiDiProps();
|
||||
}
|
||||
return gBdp;
|
||||
}
|
||||
|
||||
// UBiDiProps dummy singleton
|
||||
private static UBiDiProps gBdpDummy=null;
|
||||
|
||||
private UBiDiProps(boolean makeDummy) { // ignore makeDummy, only creates a unique signature
|
||||
indexes=new int[IX_TOP];
|
||||
indexes[0]=IX_TOP;
|
||||
trie=new CharTrie(0, 0, null); // dummy trie, always returns 0
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a singleton dummy object, one that works with no real data.
|
||||
* This can be used when the real data is not available.
|
||||
* Using the dummy can reduce checks for available data after an initial failure.
|
||||
* Port of ucase_getDummy().
|
||||
*/
|
||||
public static final synchronized UBiDiProps getDummy() {
|
||||
if(gBdpDummy==null) {
|
||||
gBdpDummy=new UBiDiProps(true);
|
||||
}
|
||||
return gBdpDummy;
|
||||
}
|
||||
|
||||
public final int getClass(int c) {
|
||||
return getClassFromProps(trie.getCodePointValue(c));
|
||||
}
|
||||
|
||||
// data members -------------------------------------------------------- ***
|
||||
private int indexes[];
|
||||
private int mirrors[];
|
||||
private byte jgArray[];
|
||||
|
||||
private CharTrie trie;
|
||||
|
||||
// data format constants ----------------------------------------------- ***
|
||||
private static final String DATA_FILE_NAME = "/sun/text/resources/ubidi.icu";
|
||||
|
||||
/* format "BiDi" */
|
||||
private static final byte FMT[]={ 0x42, 0x69, 0x44, 0x69 };
|
||||
|
||||
/* indexes into indexes[] */
|
||||
private static final int IX_INDEX_TOP=0;
|
||||
private static final int IX_MIRROR_LENGTH=3;
|
||||
|
||||
private static final int IX_JG_START=4;
|
||||
private static final int IX_JG_LIMIT=5;
|
||||
|
||||
private static final int IX_TOP=16;
|
||||
|
||||
private static final int CLASS_MASK= 0x0000001f;
|
||||
|
||||
private static final int getClassFromProps(int props) {
|
||||
return props&CLASS_MASK;
|
||||
}
|
||||
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Portions Copyright 2005 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* Portions Copyright 2005-2009 Sun Microsystems, Inc. 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
|
||||
@ -24,7 +24,7 @@
|
||||
*/
|
||||
/*
|
||||
*******************************************************************************
|
||||
* (C) Copyright IBM Corp. 1996-2005 - All Rights Reserved *
|
||||
* (C) Copyright IBM Corp. and others, 1996-2009 - All Rights Reserved *
|
||||
* *
|
||||
* The original version of this source code and documentation is copyrighted *
|
||||
* and owned by IBM, These materials are provided under terms of a License *
|
||||
@ -36,19 +36,18 @@
|
||||
|
||||
package sun.text.normalizer;
|
||||
|
||||
import java.lang.ref.SoftReference;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.io.IOException;
|
||||
import java.util.MissingResourceException;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* The UCharacter class provides extensions to the
|
||||
* <a href=http://java.sun.com/j2se/1.3/docs/api/java/lang/Character.html>
|
||||
* <a href="http://java.sun.com/j2se/1.5/docs/api/java/lang/Character.html">
|
||||
* java.lang.Character</a> class. These extensions provide support for
|
||||
* Unicode 3.2 properties and together with the <a href=../text/UTF16.html>UTF16</a>
|
||||
* more Unicode properties and together with the <a href=../text/UTF16.html>UTF16</a>
|
||||
* class, provide support for supplementary characters (those with code
|
||||
* points above U+FFFF).
|
||||
* Each ICU release supports the latest version of Unicode available at that time.
|
||||
* </p>
|
||||
* <p>
|
||||
* Code points are represented in these API using ints. While it would be
|
||||
@ -67,7 +66,7 @@ import java.util.Map;
|
||||
* <i>$ICU4J_CLASS/com.ibm.icu.impl.data</i>.
|
||||
* </p>
|
||||
* <p>
|
||||
* Aside from the additions for UTF-16 support, and the updated Unicode 3.1
|
||||
* Aside from the additions for UTF-16 support, and the updated Unicode
|
||||
* properties, the main differences between UCharacter and Character are:
|
||||
* <ul>
|
||||
* <li> UCharacter is not designed to be a char wrapper and does not have
|
||||
@ -77,7 +76,7 @@ import java.util.Map;
|
||||
* <li> char charValue(),
|
||||
* <li> int compareTo(java.lang.Character, java.lang.Character), etc.
|
||||
* </ul>
|
||||
* <li> UCharacter does not include Character APIs that are deprecated, not
|
||||
* <li> UCharacter does not include Character APIs that are deprecated, nor
|
||||
* does it include the Java-specific character information, such as
|
||||
* boolean isJavaIdentifierPart(char ch).
|
||||
* <li> Character maps characters 'A' - 'Z' and 'a' - 'z' to the numeric
|
||||
@ -89,10 +88,75 @@ import java.util.Map;
|
||||
* </ul>
|
||||
* <p>
|
||||
* Further detail differences can be determined from the program
|
||||
* <a href = http://oss.software.ibm.com/developerworks/opensource/cvs/icu4j/~checkout~/icu4j/src/com/ibm/icu/dev/test/lang/UCharacterCompare.java>
|
||||
* <a href="http://source.icu-project.org/repos/icu/icu4j/trunk/src/com/ibm/icu/dev/test/lang/UCharacterCompare.java">
|
||||
* com.ibm.icu.dev.test.lang.UCharacterCompare</a>
|
||||
* </p>
|
||||
* <p>
|
||||
* In addition to Java compatibility functions, which calculate derived properties,
|
||||
* this API provides low-level access to the Unicode Character Database.
|
||||
* </p>
|
||||
* <p>
|
||||
* Unicode assigns each code point (not just assigned character) values for
|
||||
* many properties.
|
||||
* Most of them are simple boolean flags, or constants from a small enumerated list.
|
||||
* For some properties, values are strings or other relatively more complex types.
|
||||
* </p>
|
||||
* <p>
|
||||
* For more information see
|
||||
* "About the Unicode Character Database" (http://www.unicode.org/ucd/)
|
||||
* and the ICU User Guide chapter on Properties (http://www.icu-project.org/userguide/properties.html).
|
||||
* </p>
|
||||
* <p>
|
||||
* There are also functions that provide easy migration from C/POSIX functions
|
||||
* like isblank(). Their use is generally discouraged because the C/POSIX
|
||||
* standards do not define their semantics beyond the ASCII range, which means
|
||||
* that different implementations exhibit very different behavior.
|
||||
* Instead, Unicode properties should be used directly.
|
||||
* </p>
|
||||
* <p>
|
||||
* There are also only a few, broad C/POSIX character classes, and they tend
|
||||
* to be used for conflicting purposes. For example, the "isalpha()" class
|
||||
* is sometimes used to determine word boundaries, while a more sophisticated
|
||||
* approach would at least distinguish initial letters from continuation
|
||||
* characters (the latter including combining marks).
|
||||
* (In ICU, BreakIterator is the most sophisticated API for word boundaries.)
|
||||
* Another example: There is no "istitle()" class for titlecase characters.
|
||||
* </p>
|
||||
* <p>
|
||||
* ICU 3.4 and later provides API access for all twelve C/POSIX character classes.
|
||||
* ICU implements them according to the Standard Recommendations in
|
||||
* Annex C: Compatibility Properties of UTS #18 Unicode Regular Expressions
|
||||
* (http://www.unicode.org/reports/tr18/#Compatibility_Properties).
|
||||
* </p>
|
||||
* <p>
|
||||
* API access for C/POSIX character classes is as follows:
|
||||
* - alpha: isUAlphabetic(c) or hasBinaryProperty(c, UProperty.ALPHABETIC)
|
||||
* - lower: isULowercase(c) or hasBinaryProperty(c, UProperty.LOWERCASE)
|
||||
* - upper: isUUppercase(c) or hasBinaryProperty(c, UProperty.UPPERCASE)
|
||||
* - punct: ((1<<getType(c)) & ((1<<DASH_PUNCTUATION)|(1<<START_PUNCTUATION)|(1<<END_PUNCTUATION)|(1<<CONNECTOR_PUNCTUATION)|(1<<OTHER_PUNCTUATION)|(1<<INITIAL_PUNCTUATION)|(1<<FINAL_PUNCTUATION)))!=0
|
||||
* - digit: isDigit(c) or getType(c)==DECIMAL_DIGIT_NUMBER
|
||||
* - xdigit: hasBinaryProperty(c, UProperty.POSIX_XDIGIT)
|
||||
* - alnum: hasBinaryProperty(c, UProperty.POSIX_ALNUM)
|
||||
* - space: isUWhiteSpace(c) or hasBinaryProperty(c, UProperty.WHITE_SPACE)
|
||||
* - blank: hasBinaryProperty(c, UProperty.POSIX_BLANK)
|
||||
* - cntrl: getType(c)==CONTROL
|
||||
* - graph: hasBinaryProperty(c, UProperty.POSIX_GRAPH)
|
||||
* - print: hasBinaryProperty(c, UProperty.POSIX_PRINT)
|
||||
* </p>
|
||||
* <p>
|
||||
* The C/POSIX character classes are also available in UnicodeSet patterns,
|
||||
* using patterns like [:graph:] or \p{graph}.
|
||||
* </p>
|
||||
* <p>
|
||||
* Note: There are several ICU (and Java) whitespace functions.
|
||||
* Comparison:
|
||||
* - isUWhiteSpace=UCHAR_WHITE_SPACE: Unicode White_Space property;
|
||||
* most of general categories "Z" (separators) + most whitespace ISO controls
|
||||
* (including no-break spaces, but excluding IS1..IS4 and ZWSP)
|
||||
* - isWhitespace: Java isWhitespace; Z + whitespace ISO controls but excluding no-break spaces
|
||||
* - isSpaceChar: just Z (including no-break spaces)
|
||||
* </p>
|
||||
* <p>
|
||||
* This class is not subclassable
|
||||
* </p>
|
||||
* @author Syn Wee Quek
|
||||
@ -110,95 +174,10 @@ public final class UCharacter
|
||||
*/
|
||||
public static interface NumericType
|
||||
{
|
||||
/**
|
||||
* @stable ICU 2.4
|
||||
*/
|
||||
public static final int NONE = 0;
|
||||
/**
|
||||
* @stable ICU 2.4
|
||||
*/
|
||||
public static final int DECIMAL = 1;
|
||||
/**
|
||||
* @stable ICU 2.4
|
||||
*/
|
||||
public static final int DIGIT = 2;
|
||||
/**
|
||||
* @stable ICU 2.4
|
||||
*/
|
||||
public static final int NUMERIC = 3;
|
||||
/**
|
||||
* @stable ICU 2.4
|
||||
*/
|
||||
public static final int COUNT = 4;
|
||||
}
|
||||
|
||||
/**
|
||||
* Hangul Syllable Type constants.
|
||||
*
|
||||
* @see UProperty#HANGUL_SYLLABLE_TYPE
|
||||
* @stable ICU 2.6
|
||||
*/
|
||||
public static interface HangulSyllableType
|
||||
{
|
||||
/**
|
||||
* @stable ICU 2.6
|
||||
*/
|
||||
public static final int NOT_APPLICABLE = 0; /*[NA]*/ /*See note !!*/
|
||||
/**
|
||||
* @stable ICU 2.6
|
||||
*/
|
||||
public static final int LEADING_JAMO = 1; /*[L]*/
|
||||
/**
|
||||
* @stable ICU 2.6
|
||||
*/
|
||||
public static final int VOWEL_JAMO = 2; /*[V]*/
|
||||
/**
|
||||
* @stable ICU 2.6
|
||||
*/
|
||||
public static final int TRAILING_JAMO = 3; /*[T]*/
|
||||
/**
|
||||
* @stable ICU 2.6
|
||||
*/
|
||||
public static final int LV_SYLLABLE = 4; /*[LV]*/
|
||||
/**
|
||||
* @stable ICU 2.6
|
||||
*/
|
||||
public static final int LVT_SYLLABLE = 5; /*[LVT]*/
|
||||
/**
|
||||
* @stable ICU 2.6
|
||||
*/
|
||||
public static final int COUNT = 6;
|
||||
}
|
||||
|
||||
/**
|
||||
* [Sun] This interface moved from UCharacterEnums.java.
|
||||
*
|
||||
* 'Enum' for the CharacterCategory constants. These constants are
|
||||
* compatible in name <b>but not in value</b> with those defined in
|
||||
* <code>java.lang.Character</code>.
|
||||
* @see UCharacterCategory
|
||||
* @draft ICU 3.0
|
||||
* @deprecated This is a draft API and might change in a future release of ICU.
|
||||
*/
|
||||
public static interface ECharacterCategory
|
||||
{
|
||||
/**
|
||||
* Character type Lu
|
||||
* @stable ICU 2.1
|
||||
*/
|
||||
public static final int UPPERCASE_LETTER = 1;
|
||||
|
||||
/**
|
||||
* Character type Lt
|
||||
* @stable ICU 2.1
|
||||
*/
|
||||
public static final int TITLECASE_LETTER = 3;
|
||||
|
||||
/**
|
||||
* Character type Lo
|
||||
* @stable ICU 2.1
|
||||
*/
|
||||
public static final int OTHER_LETTER = 5;
|
||||
}
|
||||
|
||||
// public data members -----------------------------------------------
|
||||
@ -225,14 +204,6 @@ public final class UCharacter
|
||||
public static final int SUPPLEMENTARY_MIN_VALUE =
|
||||
UTF16.SUPPLEMENTARY_MIN_VALUE;
|
||||
|
||||
/**
|
||||
* Special value that is returned by getUnicodeNumericValue(int) when no
|
||||
* numeric value is defined for a code point.
|
||||
* @stable ICU 2.4
|
||||
* @see #getUnicodeNumericValue
|
||||
*/
|
||||
public static final double NO_NUMERIC_VALUE = -123456789;
|
||||
|
||||
// public methods ----------------------------------------------------
|
||||
|
||||
/**
|
||||
@ -262,160 +233,15 @@ public final class UCharacter
|
||||
{
|
||||
// when ch is out of bounds getProperty == 0
|
||||
int props = getProperty(ch);
|
||||
if (getNumericType(props) != NumericType.DECIMAL) {
|
||||
return (radix <= 10) ? -1 : getEuropeanDigit(ch);
|
||||
int value;
|
||||
if (getNumericType(props) == NumericType.DECIMAL) {
|
||||
value = UCharacterProperty.getUnsignedValue(props);
|
||||
} else {
|
||||
value = getEuropeanDigit(ch);
|
||||
}
|
||||
// if props == 0, it will just fall through and return -1
|
||||
if (isNotExceptionIndicator(props)) {
|
||||
// not contained in exception data
|
||||
// getSignedValue is just shifting so we can check for the sign
|
||||
// first
|
||||
// Optimization
|
||||
// int result = UCharacterProperty.getSignedValue(props);
|
||||
// if (result >= 0) {
|
||||
// return result;
|
||||
// }
|
||||
if (props >= 0) {
|
||||
return UCharacterProperty.getSignedValue(props);
|
||||
}
|
||||
}
|
||||
else {
|
||||
int index = UCharacterProperty.getExceptionIndex(props);
|
||||
if (PROPERTY_.hasExceptionValue(index,
|
||||
UCharacterProperty.EXC_NUMERIC_VALUE_)) {
|
||||
int result = PROPERTY_.getException(index,
|
||||
UCharacterProperty.EXC_NUMERIC_VALUE_);
|
||||
if (result >= 0) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (radix > 10) {
|
||||
int result = getEuropeanDigit(ch);
|
||||
if (result >= 0 && result < radix) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
return (0 <= value && value < radix) ? value : -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Get the numeric value for a Unicode code point as defined in the
|
||||
* Unicode Character Database.</p>
|
||||
* <p>A "double" return type is necessary because some numeric values are
|
||||
* fractions, negative, or too large for int.</p>
|
||||
* <p>For characters without any numeric values in the Unicode Character
|
||||
* Database, this function will return NO_NUMERIC_VALUE.</p>
|
||||
* <p><em>API Change:</em> In release 2.2 and prior, this API has a
|
||||
* return type int and returns -1 when the argument ch does not have a
|
||||
* corresponding numeric value. This has been changed to synch with ICU4C
|
||||
* </p>
|
||||
* This corresponds to the ICU4C function u_getNumericValue.
|
||||
* @param ch Code point to get the numeric value for.
|
||||
* @return numeric value of ch, or NO_NUMERIC_VALUE if none is defined.
|
||||
* @stable ICU 2.4
|
||||
*/
|
||||
public static double getUnicodeNumericValue(int ch)
|
||||
{
|
||||
// equivalent to c version double u_getNumericValue(UChar32 c)
|
||||
int props = PROPERTY_.getProperty(ch);
|
||||
int numericType = getNumericType(props);
|
||||
if (numericType > NumericType.NONE && numericType < NumericType.COUNT) {
|
||||
if (isNotExceptionIndicator(props)) {
|
||||
return UCharacterProperty.getSignedValue(props);
|
||||
}
|
||||
else {
|
||||
int index = UCharacterProperty.getExceptionIndex(props);
|
||||
boolean nex = false;
|
||||
boolean dex = false;
|
||||
double numerator = 0;
|
||||
if (PROPERTY_.hasExceptionValue(index,
|
||||
UCharacterProperty.EXC_NUMERIC_VALUE_)) {
|
||||
int num = PROPERTY_.getException(index,
|
||||
UCharacterProperty.EXC_NUMERIC_VALUE_);
|
||||
// There are special values for huge numbers that are
|
||||
// powers of ten. genprops/store.c documents:
|
||||
// if numericValue = 0x7fffff00 + x then
|
||||
// numericValue = 10 ^ x
|
||||
if (num >= NUMERATOR_POWER_LIMIT_) {
|
||||
num &= 0xff;
|
||||
// 10^x without math.h
|
||||
numerator = Math.pow(10, num);
|
||||
}
|
||||
else {
|
||||
numerator = num;
|
||||
}
|
||||
nex = true;
|
||||
}
|
||||
double denominator = 0;
|
||||
if (PROPERTY_.hasExceptionValue(index,
|
||||
UCharacterProperty.EXC_DENOMINATOR_VALUE_)) {
|
||||
denominator = PROPERTY_.getException(index,
|
||||
UCharacterProperty.EXC_DENOMINATOR_VALUE_);
|
||||
// faster path not in c
|
||||
if (numerator != 0) {
|
||||
return numerator / denominator;
|
||||
}
|
||||
dex = true;
|
||||
}
|
||||
|
||||
if (nex) {
|
||||
if (dex) {
|
||||
return numerator / denominator;
|
||||
}
|
||||
return numerator;
|
||||
}
|
||||
if (dex) {
|
||||
return 1 / denominator;
|
||||
}
|
||||
}
|
||||
}
|
||||
return NO_NUMERIC_VALUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a value indicating a code point's Unicode category.
|
||||
* Up-to-date Unicode implementation of java.lang.Character.getType()
|
||||
* except for the above mentioned code points that had their category
|
||||
* changed.<br>
|
||||
* Return results are constants from the interface
|
||||
* <a href=UCharacterCategory.html>UCharacterCategory</a><br>
|
||||
* <em>NOTE:</em> the UCharacterCategory values are <em>not</em> compatible with
|
||||
* those returned by java.lang.Character.getType. UCharacterCategory values
|
||||
* match the ones used in ICU4C, while java.lang.Character type
|
||||
* values, though similar, skip the value 17.</p>
|
||||
* @param ch code point whose type is to be determined
|
||||
* @return category which is a value of UCharacterCategory
|
||||
* @stable ICU 2.1
|
||||
*/
|
||||
public static int getType(int ch)
|
||||
{
|
||||
return getProperty(ch) & UCharacterProperty.TYPE_MASK;
|
||||
}
|
||||
|
||||
//// for StringPrep
|
||||
/**
|
||||
* Returns a code point corresponding to the two UTF16 characters.
|
||||
* @param lead the lead char
|
||||
* @param trail the trail char
|
||||
* @return code point if surrogate characters are valid.
|
||||
* @exception IllegalArgumentException thrown when argument characters do
|
||||
* not form a valid codepoint
|
||||
* @stable ICU 2.1
|
||||
*/
|
||||
public static int getCodePoint(char lead, char trail)
|
||||
{
|
||||
if (lead >= UTF16.LEAD_SURROGATE_MIN_VALUE &&
|
||||
lead <= UTF16.LEAD_SURROGATE_MAX_VALUE &&
|
||||
trail >= UTF16.TRAIL_SURROGATE_MIN_VALUE &&
|
||||
trail <= UTF16.TRAIL_SURROGATE_MAX_VALUE) {
|
||||
return UCharacterProperty.getRawSupplementary(lead, trail);
|
||||
}
|
||||
throw new IllegalArgumentException("Illegal surrogate characters");
|
||||
}
|
||||
|
||||
//// for StringPrep
|
||||
/**
|
||||
* Returns the Bidirection property of a code point.
|
||||
* For example, 0x0041 (letter A) has the LEFT_TO_RIGHT directional
|
||||
@ -428,111 +254,24 @@ public final class UCharacter
|
||||
*/
|
||||
public static int getDirection(int ch)
|
||||
{
|
||||
// when ch is out of bounds getProperty == 0
|
||||
return (getProperty(ch) >> BIDI_SHIFT_) & BIDI_MASK_AFTER_SHIFT_;
|
||||
return gBdp.getClass(ch);
|
||||
}
|
||||
|
||||
/**
|
||||
* The given string is mapped to its case folding equivalent according to
|
||||
* UnicodeData.txt and CaseFolding.txt; if any character has no case
|
||||
* folding equivalent, the character itself is returned.
|
||||
* "Full", multiple-code point case folding mappings are returned here.
|
||||
* For "simple" single-code point mappings use the API
|
||||
* foldCase(int ch, boolean defaultmapping).
|
||||
* @param str the String to be converted
|
||||
* @param defaultmapping Indicates if all mappings defined in
|
||||
* CaseFolding.txt is to be used, otherwise the
|
||||
* mappings for dotted I and dotless i marked with
|
||||
* 'I' in CaseFolding.txt will be skipped.
|
||||
* @return the case folding equivalent of the character, if
|
||||
* any; otherwise the character itself.
|
||||
* @see #foldCase(int, boolean)
|
||||
* Returns a code point corresponding to the two UTF16 characters.
|
||||
* @param lead the lead char
|
||||
* @param trail the trail char
|
||||
* @return code point if surrogate characters are valid.
|
||||
* @exception IllegalArgumentException thrown when argument characters do
|
||||
* not form a valid codepoint
|
||||
* @stable ICU 2.1
|
||||
*/
|
||||
public static String foldCase(String str, boolean defaultmapping)
|
||||
public static int getCodePoint(char lead, char trail)
|
||||
{
|
||||
int size = str.length();
|
||||
StringBuffer result = new StringBuffer(size);
|
||||
int offset = 0;
|
||||
int ch;
|
||||
|
||||
// case mapping loop
|
||||
while (offset < size) {
|
||||
ch = UTF16.charAt(str, offset);
|
||||
offset += UTF16.getCharCount(ch);
|
||||
int props = PROPERTY_.getProperty(ch);
|
||||
if (isNotExceptionIndicator(props)) {
|
||||
int type = UCharacterProperty.TYPE_MASK & props;
|
||||
if (type == ECharacterCategory.UPPERCASE_LETTER ||
|
||||
type == ECharacterCategory.TITLECASE_LETTER) {
|
||||
ch += UCharacterProperty.getSignedValue(props);
|
||||
}
|
||||
}
|
||||
else {
|
||||
int index = UCharacterProperty.getExceptionIndex(props);
|
||||
if (PROPERTY_.hasExceptionValue(index,
|
||||
UCharacterProperty.EXC_CASE_FOLDING_)) {
|
||||
int exception = PROPERTY_.getException(index,
|
||||
UCharacterProperty.EXC_CASE_FOLDING_);
|
||||
if (exception != 0) {
|
||||
PROPERTY_.getFoldCase(exception & LAST_CHAR_MASK_,
|
||||
exception >> SHIFT_24_, result);
|
||||
}
|
||||
else {
|
||||
// special case folding mappings, hardcoded
|
||||
if (ch != 0x49 && ch != 0x130) {
|
||||
// return ch itself because there is no special
|
||||
// mapping for it
|
||||
UTF16.append(result, ch);
|
||||
continue;
|
||||
}
|
||||
if (defaultmapping) {
|
||||
// default mappings
|
||||
if (ch == 0x49) {
|
||||
// 0049; C; 0069; # LATIN CAPITAL LETTER I
|
||||
result.append(
|
||||
UCharacterProperty.LATIN_SMALL_LETTER_I_);
|
||||
}
|
||||
else if (ch == 0x130) {
|
||||
// 0130; F; 0069 0307;
|
||||
// # LATIN CAPITAL LETTER I WITH DOT ABOVE
|
||||
result.append(
|
||||
UCharacterProperty.LATIN_SMALL_LETTER_I_);
|
||||
result.append((char)0x307);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Turkic mappings
|
||||
if (ch == 0x49) {
|
||||
// 0049; T; 0131; # LATIN CAPITAL LETTER I
|
||||
result.append((char)0x131);
|
||||
}
|
||||
else if (ch == 0x130) {
|
||||
// 0130; T; 0069;
|
||||
// # LATIN CAPITAL LETTER I WITH DOT ABOVE
|
||||
result.append(
|
||||
UCharacterProperty.LATIN_SMALL_LETTER_I_);
|
||||
}
|
||||
}
|
||||
}
|
||||
// do not fall through to the output of c
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
if (PROPERTY_.hasExceptionValue(index,
|
||||
UCharacterProperty.EXC_LOWERCASE_)) {
|
||||
ch = PROPERTY_.getException(index,
|
||||
UCharacterProperty.EXC_LOWERCASE_);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// handle 1:1 code point mappings from UnicodeData.txt
|
||||
UTF16.append(result, ch);
|
||||
if (UTF16.isLeadSurrogate(lead) && UTF16.isTrailSurrogate(trail)) {
|
||||
return UCharacterProperty.getRawSupplementary(lead, trail);
|
||||
}
|
||||
|
||||
return result.toString();
|
||||
throw new IllegalArgumentException("Illegal surrogate characters");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -555,83 +294,6 @@ public final class UCharacter
|
||||
return PROPERTY_.getAge(ch);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Gets the property value for an Unicode property type of a code point.
|
||||
* Also returns binary and mask property values.</p>
|
||||
* <p>Unicode, especially in version 3.2, defines many more properties than
|
||||
* the original set in UnicodeData.txt.</p>
|
||||
* <p>The properties APIs are intended to reflect Unicode properties as
|
||||
* defined in the Unicode Character Database (UCD) and Unicode Technical
|
||||
* Reports (UTR). For details about the properties see
|
||||
* http://www.unicode.org/.</p>
|
||||
* <p>For names of Unicode properties see the UCD file PropertyAliases.txt.
|
||||
* </p>
|
||||
* <pre>
|
||||
* Sample usage:
|
||||
* int ea = UCharacter.getIntPropertyValue(c, UProperty.EAST_ASIAN_WIDTH);
|
||||
* int ideo = UCharacter.getIntPropertyValue(c, UProperty.IDEOGRAPHIC);
|
||||
* boolean b = (ideo == 1) ? true : false;
|
||||
* </pre>
|
||||
* @param ch code point to test.
|
||||
* @param type UProperty selector constant, identifies which binary
|
||||
* property to check. Must be
|
||||
* UProperty.BINARY_START <= type < UProperty.BINARY_LIMIT or
|
||||
* UProperty.INT_START <= type < UProperty.INT_LIMIT or
|
||||
* UProperty.MASK_START <= type < UProperty.MASK_LIMIT.
|
||||
* @return numeric value that is directly the property value or,
|
||||
* for enumerated properties, corresponds to the numeric value of
|
||||
* the enumerated constant of the respective property value
|
||||
* enumeration type (cast to enum type if necessary).
|
||||
* Returns 0 or 1 (for false / true) for binary Unicode properties.
|
||||
* Returns a bit-mask for mask properties.
|
||||
* Returns 0 if 'type' is out of bounds or if the Unicode version
|
||||
* does not have data for the property at all, or not for this code
|
||||
* point.
|
||||
* @see UProperty
|
||||
* @see #hasBinaryProperty
|
||||
* @see #getIntPropertyMinValue
|
||||
* @see #getIntPropertyMaxValue
|
||||
* @see #getUnicodeVersion
|
||||
* @stable ICU 2.4
|
||||
*/
|
||||
public static int getIntPropertyValue(int ch, int type)
|
||||
{
|
||||
/*
|
||||
* For Normalizer with Unicode 3.2, this method is called only for
|
||||
* HANGUL_SYLLABLE_TYPE in UnicodeSet.addPropertyStarts().
|
||||
*/
|
||||
if (type == UProperty.HANGUL_SYLLABLE_TYPE) {
|
||||
/* purely algorithmic; hardcode known characters, check for assigned new ones */
|
||||
if(ch<NormalizerImpl.JAMO_L_BASE) {
|
||||
/* NA */
|
||||
} else if(ch<=0x11ff) {
|
||||
/* Jamo range */
|
||||
if(ch<=0x115f) {
|
||||
/* Jamo L range, HANGUL CHOSEONG ... */
|
||||
if(ch==0x115f || ch<=0x1159 || getType(ch)==ECharacterCategory.OTHER_LETTER) {
|
||||
return HangulSyllableType.LEADING_JAMO;
|
||||
}
|
||||
} else if(ch<=0x11a7) {
|
||||
/* Jamo V range, HANGUL JUNGSEONG ... */
|
||||
if(ch<=0x11a2 || getType(ch)==ECharacterCategory.OTHER_LETTER) {
|
||||
return HangulSyllableType.VOWEL_JAMO;
|
||||
}
|
||||
} else {
|
||||
/* Jamo T range */
|
||||
if(ch<=0x11f9 || getType(ch)==ECharacterCategory.OTHER_LETTER) {
|
||||
return HangulSyllableType.TRAILING_JAMO;
|
||||
}
|
||||
}
|
||||
} else if((ch-=NormalizerImpl.HANGUL_BASE)<0) {
|
||||
/* NA */
|
||||
} else if(ch<NormalizerImpl.HANGUL_COUNT) {
|
||||
/* Hangul syllable */
|
||||
return ch%NormalizerImpl.JAMO_T_COUNT==0 ? HangulSyllableType.LV_SYLLABLE : HangulSyllableType.LVT_SYLLABLE;
|
||||
}
|
||||
}
|
||||
return 0; /* NA */
|
||||
}
|
||||
|
||||
// private variables -------------------------------------------------
|
||||
|
||||
/**
|
||||
@ -643,143 +305,43 @@ public final class UCharacter
|
||||
*/
|
||||
private static final char[] PROPERTY_TRIE_INDEX_;
|
||||
private static final char[] PROPERTY_TRIE_DATA_;
|
||||
private static final int[] PROPERTY_DATA_;
|
||||
private static final int PROPERTY_INITIAL_VALUE_;
|
||||
|
||||
private static final UBiDiProps gBdp;
|
||||
|
||||
// block to initialise character property database
|
||||
static
|
||||
{
|
||||
try
|
||||
{
|
||||
PROPERTY_ = UCharacterProperty.getInstance();
|
||||
PROPERTY_TRIE_INDEX_ = PROPERTY_.m_trieIndex_;
|
||||
PROPERTY_TRIE_DATA_ = PROPERTY_.m_trieData_;
|
||||
PROPERTY_DATA_ = PROPERTY_.m_property_;
|
||||
PROPERTY_INITIAL_VALUE_
|
||||
= PROPERTY_DATA_[PROPERTY_.m_trieInitialValue_];
|
||||
PROPERTY_ = UCharacterProperty.getInstance();
|
||||
PROPERTY_TRIE_INDEX_ = PROPERTY_.m_trieIndex_;
|
||||
PROPERTY_TRIE_DATA_ = PROPERTY_.m_trieData_;
|
||||
PROPERTY_INITIAL_VALUE_ = PROPERTY_.m_trieInitialValue_;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new RuntimeException(e.getMessage());
|
||||
throw new MissingResourceException(e.getMessage(),"","");
|
||||
}
|
||||
|
||||
UBiDiProps bdp;
|
||||
try {
|
||||
bdp=UBiDiProps.getSingleton();
|
||||
} catch(IOException e) {
|
||||
bdp=UBiDiProps.getDummy();
|
||||
}
|
||||
gBdp=bdp;
|
||||
}
|
||||
|
||||
/**
|
||||
* To get the last character out from a data type
|
||||
*/
|
||||
private static final int LAST_CHAR_MASK_ = 0xFFFF;
|
||||
|
||||
/**
|
||||
* To get the last byte out from a data type
|
||||
*/
|
||||
// private static final int LAST_BYTE_MASK_ = 0xFF;
|
||||
|
||||
/**
|
||||
* Shift 16 bits
|
||||
*/
|
||||
// private static final int SHIFT_16_ = 16;
|
||||
|
||||
/**
|
||||
* Shift 24 bits
|
||||
*/
|
||||
private static final int SHIFT_24_ = 24;
|
||||
|
||||
/**
|
||||
* Shift to get numeric type
|
||||
*/
|
||||
private static final int NUMERIC_TYPE_SHIFT_ = 12;
|
||||
private static final int NUMERIC_TYPE_SHIFT_ = 5;
|
||||
/**
|
||||
* Mask to get numeric type
|
||||
*/
|
||||
private static final int NUMERIC_TYPE_MASK_ = 0x7 << NUMERIC_TYPE_SHIFT_;
|
||||
/**
|
||||
* Shift to get bidi bits
|
||||
*/
|
||||
private static final int BIDI_SHIFT_ = 6;
|
||||
|
||||
/**
|
||||
* Mask to be applied after shifting to get bidi bits
|
||||
*/
|
||||
private static final int BIDI_MASK_AFTER_SHIFT_ = 0x1F;
|
||||
|
||||
/**
|
||||
* <p>Numerator power limit.
|
||||
* There are special values for huge numbers that are powers of ten.</p>
|
||||
* <p>c version genprops/store.c documents:
|
||||
* if numericValue = 0x7fffff00 + x then numericValue = 10 ^ x</p>
|
||||
*/
|
||||
private static final int NUMERATOR_POWER_LIMIT_ = 0x7fffff00;
|
||||
/**
|
||||
* Integer properties mask and shift values for joining type.
|
||||
* Equivalent to icu4c UPROPS_JT_MASK.
|
||||
*/
|
||||
private static final int JOINING_TYPE_MASK_ = 0x00003800;
|
||||
/**
|
||||
* Integer properties mask and shift values for joining type.
|
||||
* Equivalent to icu4c UPROPS_JT_SHIFT.
|
||||
*/
|
||||
private static final int JOINING_TYPE_SHIFT_ = 11;
|
||||
/**
|
||||
* Integer properties mask and shift values for joining group.
|
||||
* Equivalent to icu4c UPROPS_JG_MASK.
|
||||
*/
|
||||
private static final int JOINING_GROUP_MASK_ = 0x000007e0;
|
||||
/**
|
||||
* Integer properties mask and shift values for joining group.
|
||||
* Equivalent to icu4c UPROPS_JG_SHIFT.
|
||||
*/
|
||||
private static final int JOINING_GROUP_SHIFT_ = 5;
|
||||
/**
|
||||
* Integer properties mask for decomposition type.
|
||||
* Equivalent to icu4c UPROPS_DT_MASK.
|
||||
*/
|
||||
private static final int DECOMPOSITION_TYPE_MASK_ = 0x0000001f;
|
||||
/**
|
||||
* Integer properties mask and shift values for East Asian cell width.
|
||||
* Equivalent to icu4c UPROPS_EA_MASK
|
||||
*/
|
||||
private static final int EAST_ASIAN_MASK_ = 0x00038000;
|
||||
/**
|
||||
* Integer properties mask and shift values for East Asian cell width.
|
||||
* Equivalent to icu4c UPROPS_EA_SHIFT
|
||||
*/
|
||||
private static final int EAST_ASIAN_SHIFT_ = 15;
|
||||
|
||||
/**
|
||||
* Integer properties mask and shift values for line breaks.
|
||||
* Equivalent to icu4c UPROPS_LB_MASK
|
||||
*/
|
||||
private static final int LINE_BREAK_MASK_ = 0x007C0000;
|
||||
/**
|
||||
* Integer properties mask and shift values for line breaks.
|
||||
* Equivalent to icu4c UPROPS_LB_SHIFT
|
||||
*/
|
||||
private static final int LINE_BREAK_SHIFT_ = 18;
|
||||
/**
|
||||
* Integer properties mask and shift values for blocks.
|
||||
* Equivalent to icu4c UPROPS_BLOCK_MASK
|
||||
*/
|
||||
private static final int BLOCK_MASK_ = 0x00007f80;
|
||||
/**
|
||||
* Integer properties mask and shift values for blocks.
|
||||
* Equivalent to icu4c UPROPS_BLOCK_SHIFT
|
||||
*/
|
||||
private static final int BLOCK_SHIFT_ = 7;
|
||||
/**
|
||||
* Integer properties mask and shift values for scripts.
|
||||
* Equivalent to icu4c UPROPS_SHIFT_MASK
|
||||
*/
|
||||
private static final int SCRIPT_MASK_ = 0x0000007f;
|
||||
|
||||
// private constructor -----------------------------------------------
|
||||
///CLOVER:OFF
|
||||
/**
|
||||
* Private constructor to prevent instantiation
|
||||
*/
|
||||
private UCharacter()
|
||||
{
|
||||
}
|
||||
///CLOVER:ON
|
||||
// private methods ---------------------------------------------------
|
||||
|
||||
/**
|
||||
@ -818,17 +380,6 @@ public final class UCharacter
|
||||
return (props & NUMERIC_TYPE_MASK_) >> NUMERIC_TYPE_SHIFT_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the property value has a exception indicator
|
||||
* @param props 32 bit property value
|
||||
* @return true if property does not have a exception indicator, false
|
||||
* otherwise
|
||||
*/
|
||||
private static boolean isNotExceptionIndicator(int props)
|
||||
{
|
||||
return (props & UCharacterProperty.EXCEPTION_MASK) == 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the property value at the index.
|
||||
* This is optimized.
|
||||
@ -841,35 +392,34 @@ public final class UCharacter
|
||||
* @return property value of code point
|
||||
* @stable ICU 2.6
|
||||
*/
|
||||
private static int getProperty(int ch)
|
||||
private static final int getProperty(int ch)
|
||||
{
|
||||
if (ch < UTF16.LEAD_SURROGATE_MIN_VALUE
|
||||
|| (ch > UTF16.LEAD_SURROGATE_MAX_VALUE
|
||||
&& ch < UTF16.SUPPLEMENTARY_MIN_VALUE)) {
|
||||
// BMP codepoint
|
||||
try { // using try for < 0 ch is faster than using an if statement
|
||||
return PROPERTY_DATA_[
|
||||
PROPERTY_TRIE_DATA_[
|
||||
// BMP codepoint 0000..D7FF or DC00..FFFF
|
||||
try { // using try for ch < 0 is faster than using an if statement
|
||||
return PROPERTY_TRIE_DATA_[
|
||||
(PROPERTY_TRIE_INDEX_[ch >> 5] << 2)
|
||||
+ (ch & 0x1f)]];
|
||||
+ (ch & 0x1f)];
|
||||
} catch (ArrayIndexOutOfBoundsException e) {
|
||||
return PROPERTY_INITIAL_VALUE_;
|
||||
}
|
||||
}
|
||||
if (ch <= UTF16.LEAD_SURROGATE_MAX_VALUE) {
|
||||
// surrogate
|
||||
return PROPERTY_DATA_[
|
||||
PROPERTY_TRIE_DATA_[
|
||||
// lead surrogate D800..DBFF
|
||||
return PROPERTY_TRIE_DATA_[
|
||||
(PROPERTY_TRIE_INDEX_[(0x2800 >> 5) + (ch >> 5)] << 2)
|
||||
+ (ch & 0x1f)]];
|
||||
+ (ch & 0x1f)];
|
||||
}
|
||||
// for optimization
|
||||
if (ch <= UTF16.CODEPOINT_MAX_VALUE) {
|
||||
// supplementary code point 10000..10FFFF
|
||||
// look at the construction of supplementary characters
|
||||
// trail forms the ends of it.
|
||||
return PROPERTY_DATA_[PROPERTY_.m_trie_.getSurrogateValue(
|
||||
return PROPERTY_.m_trie_.getSurrogateValue(
|
||||
UTF16.getLeadSurrogate(ch),
|
||||
(char)(ch & 0x3ff))];
|
||||
(char)(ch & 0x3ff));
|
||||
}
|
||||
// return m_dataOffset_ if there is an error, in this case we return
|
||||
// the default value: m_initialValue_
|
||||
@ -877,4 +427,5 @@ public final class UCharacter
|
||||
// this is for optimization.
|
||||
return PROPERTY_INITIAL_VALUE_;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Portions Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* Portions Copyright 2005-2009 Sun Microsystems, Inc. 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
|
||||
@ -22,10 +22,9 @@
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
*******************************************************************************
|
||||
* (C) Copyright IBM Corp. 1996-2005 - All Rights Reserved *
|
||||
* (C) Copyright IBM Corp. and others, 1996-2009 - All Rights Reserved *
|
||||
* *
|
||||
* The original version of this source code and documentation is copyrighted *
|
||||
* and owned by IBM, These materials are provided under terms of a License *
|
||||
@ -40,8 +39,7 @@ package sun.text.normalizer;
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.IOException;
|
||||
import java.text.BreakIterator;
|
||||
import java.util.Locale;
|
||||
import java.util.MissingResourceException;
|
||||
|
||||
/**
|
||||
* <p>Internal class used for Unicode character property database.</p>
|
||||
@ -56,10 +54,9 @@ import java.util.Locale;
|
||||
* <a href=UCharacter.html>UCharacter</a>.</p>
|
||||
* @author Syn Wee Quek
|
||||
* @since release 2.1, february 1st 2002
|
||||
* @draft 2.1
|
||||
*/
|
||||
|
||||
public final class UCharacterProperty implements Trie.DataManipulate
|
||||
public final class UCharacterProperty
|
||||
{
|
||||
// public data members -----------------------------------------------
|
||||
|
||||
@ -83,68 +80,16 @@ public final class UCharacterProperty implements Trie.DataManipulate
|
||||
*/
|
||||
public int m_trieInitialValue_;
|
||||
/**
|
||||
* Character property table
|
||||
*/
|
||||
public int m_property_[];
|
||||
/**
|
||||
* Unicode version
|
||||
*/
|
||||
public VersionInfo m_unicodeVersion_;
|
||||
/**
|
||||
* Exception indicator for uppercase type
|
||||
*/
|
||||
public static final int EXC_UPPERCASE_ = 0;
|
||||
/**
|
||||
* Exception indicator for lowercase type
|
||||
*/
|
||||
public static final int EXC_LOWERCASE_ = 1;
|
||||
/**
|
||||
* Exception indicator for titlecase type
|
||||
*/
|
||||
public static final int EXC_TITLECASE_ = 2;
|
||||
/**
|
||||
* Exception indicator for digit type
|
||||
*/
|
||||
public static final int EXC_UNUSED_ = 3;
|
||||
/**
|
||||
* Exception indicator for numeric type
|
||||
*/
|
||||
public static final int EXC_NUMERIC_VALUE_ = 4;
|
||||
/**
|
||||
* Exception indicator for denominator type
|
||||
*/
|
||||
public static final int EXC_DENOMINATOR_VALUE_ = 5;
|
||||
/**
|
||||
* Exception indicator for mirror type
|
||||
*/
|
||||
public static final int EXC_MIRROR_MAPPING_ = 6;
|
||||
/**
|
||||
* Exception indicator for special casing type
|
||||
*/
|
||||
public static final int EXC_SPECIAL_CASING_ = 7;
|
||||
/**
|
||||
* Exception indicator for case folding type
|
||||
*/
|
||||
public static final int EXC_CASE_FOLDING_ = 8;
|
||||
/**
|
||||
* EXC_COMBINING_CLASS_ is not found in ICU.
|
||||
* Used to retrieve the combining class of the character in the exception
|
||||
* value
|
||||
*/
|
||||
public static final int EXC_COMBINING_CLASS_ = 9;
|
||||
|
||||
/**
|
||||
* Latin lowercase i
|
||||
*/
|
||||
public static final char LATIN_SMALL_LETTER_I_ = 0x69;
|
||||
/**
|
||||
* Character type mask
|
||||
*/
|
||||
public static final int TYPE_MASK = 0x1F;
|
||||
/**
|
||||
* Exception test mask
|
||||
*/
|
||||
public static final int EXCEPTION_MASK = 0x20;
|
||||
// uprops.h enum UPropertySource --------------------------------------- ***
|
||||
|
||||
/** From uchar.c/uprops.icu properties vectors trie */
|
||||
public static final int SRC_PROPSVEC=2;
|
||||
/** One more than the highest UPropertySource (SRC_) constant. */
|
||||
public static final int SRC_COUNT=9;
|
||||
|
||||
// public methods ----------------------------------------------------
|
||||
|
||||
@ -158,23 +103,6 @@ public final class UCharacterProperty implements Trie.DataManipulate
|
||||
m_trieInitialValue_ = friendagent.getPrivateInitialValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Called by com.ibm.icu.util.Trie to extract from a lead surrogate's
|
||||
* data the index array offset of the indexes for that lead surrogate.
|
||||
* @param value data value for a surrogate from the trie, including the
|
||||
* folding offset
|
||||
* @return data offset or 0 if there is no data for the lead surrogate
|
||||
*/
|
||||
public int getFoldingOffset(int value)
|
||||
{
|
||||
if ((value & SUPPLEMENTARY_FOLD_INDICATOR_MASK_) != 0) {
|
||||
return (value & SUPPLEMENTARY_FOLD_OFFSET_MASK_);
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the property value at the index.
|
||||
* This is optimized.
|
||||
@ -183,129 +111,79 @@ public final class UCharacterProperty implements Trie.DataManipulate
|
||||
* @param ch code point whose property value is to be retrieved
|
||||
* @return property value of code point
|
||||
*/
|
||||
public int getProperty(int ch)
|
||||
public final int getProperty(int ch)
|
||||
{
|
||||
if (ch < UTF16.LEAD_SURROGATE_MIN_VALUE
|
||||
|| (ch > UTF16.LEAD_SURROGATE_MAX_VALUE
|
||||
&& ch < UTF16.SUPPLEMENTARY_MIN_VALUE)) {
|
||||
// BMP codepoint
|
||||
// BMP codepoint 0000..D7FF or DC00..FFFF
|
||||
// optimized
|
||||
try {
|
||||
return m_property_[
|
||||
m_trieData_[
|
||||
try { // using try for ch < 0 is faster than using an if statement
|
||||
return m_trieData_[
|
||||
(m_trieIndex_[ch >> Trie.INDEX_STAGE_1_SHIFT_]
|
||||
<< Trie.INDEX_STAGE_2_SHIFT_)
|
||||
+ (ch & Trie.INDEX_STAGE_3_MASK_)]];
|
||||
+ (ch & Trie.INDEX_STAGE_3_MASK_)];
|
||||
} catch (ArrayIndexOutOfBoundsException e) {
|
||||
return m_property_[m_trieInitialValue_];
|
||||
return m_trieInitialValue_;
|
||||
}
|
||||
}
|
||||
if (ch <= UTF16.LEAD_SURROGATE_MAX_VALUE) {
|
||||
return m_property_[
|
||||
m_trieData_[
|
||||
// lead surrogate D800..DBFF
|
||||
return m_trieData_[
|
||||
(m_trieIndex_[Trie.LEAD_INDEX_OFFSET_
|
||||
+ (ch >> Trie.INDEX_STAGE_1_SHIFT_)]
|
||||
<< Trie.INDEX_STAGE_2_SHIFT_)
|
||||
+ (ch & Trie.INDEX_STAGE_3_MASK_)]];
|
||||
+ (ch & Trie.INDEX_STAGE_3_MASK_)];
|
||||
}
|
||||
// for optimization
|
||||
if (ch <= UTF16.CODEPOINT_MAX_VALUE) {
|
||||
// supplementary code point 10000..10FFFF
|
||||
// look at the construction of supplementary characters
|
||||
// trail forms the ends of it.
|
||||
return m_property_[m_trie_.getSurrogateValue(
|
||||
return m_trie_.getSurrogateValue(
|
||||
UTF16.getLeadSurrogate(ch),
|
||||
(char)(ch & Trie.SURROGATE_MASK_))];
|
||||
(char)(ch & Trie.SURROGATE_MASK_));
|
||||
}
|
||||
// ch is out of bounds
|
||||
// return m_dataOffset_ if there is an error, in this case we return
|
||||
// the default value: m_initialValue_
|
||||
// we cannot assume that m_initialValue_ is at offset 0
|
||||
// this is for optimization.
|
||||
return m_property_[m_trieInitialValue_];
|
||||
// return m_property_[m_trie_.getCodePointValue(ch)];
|
||||
return m_trieInitialValue_;
|
||||
|
||||
// this all is an inlined form of return m_trie_.getCodePointValue(ch);
|
||||
}
|
||||
|
||||
/**
|
||||
* Getting the signed numeric value of a character embedded in the property
|
||||
* Getting the unsigned numeric value of a character embedded in the property
|
||||
* argument
|
||||
* @param prop the character
|
||||
* @return signed numberic value
|
||||
* @return unsigned numberic value
|
||||
*/
|
||||
public static int getSignedValue(int prop)
|
||||
{
|
||||
return (prop >> VALUE_SHIFT_);
|
||||
}
|
||||
|
||||
/**
|
||||
* Getting the exception index for argument property
|
||||
* @param prop character property
|
||||
* @return exception index
|
||||
*/
|
||||
public static int getExceptionIndex(int prop)
|
||||
public static int getUnsignedValue(int prop)
|
||||
{
|
||||
return (prop >> VALUE_SHIFT_) & UNSIGNED_VALUE_MASK_AFTER_SHIFT_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if the exception value passed in has the kind of information
|
||||
* which the indicator wants, e.g if the exception value contains the digit
|
||||
* value of the character
|
||||
* @param index exception index
|
||||
* @param indicator type indicator
|
||||
* @return true if type value exist
|
||||
*/
|
||||
public boolean hasExceptionValue(int index, int indicator)
|
||||
{
|
||||
return (m_exception_[index] & (1 << indicator)) != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the exception value at the index, assuming that data type is
|
||||
* available. Result is undefined if data is not available. Use
|
||||
* hasExceptionValue() to determine data's availability.
|
||||
* @param index
|
||||
* @param etype exception data type
|
||||
* @return exception data type value at index
|
||||
*/
|
||||
public int getException(int index, int etype)
|
||||
{
|
||||
// contained in exception data
|
||||
if (etype == EXC_COMBINING_CLASS_) {
|
||||
return m_exception_[index];
|
||||
}
|
||||
// contained in the exception digit address
|
||||
index = addExceptionOffset(m_exception_[index], etype, ++ index);
|
||||
return m_exception_[index];
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the folded case value at the index
|
||||
* @param index of the case value to be retrieved
|
||||
* @param count number of characters to retrieve
|
||||
* @param str string buffer to which to append the result
|
||||
*/
|
||||
public void getFoldCase(int index, int count, StringBuffer str)
|
||||
{
|
||||
// first 2 chars are for the simple mappings
|
||||
index += 2;
|
||||
while (count > 0) {
|
||||
str.append(m_case_[index]);
|
||||
index ++;
|
||||
count --;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the unicode additional properties.
|
||||
* C version getUnicodeProperties.
|
||||
* @param codepoint codepoint whose additional properties is to be
|
||||
* retrieved
|
||||
* @param column
|
||||
* @return unicode properties
|
||||
*/
|
||||
public int getAdditional(int codepoint) {
|
||||
return m_additionalVectors_[m_additionalTrie_.getCodePointValue(codepoint)];
|
||||
public int getAdditional(int codepoint, int column) {
|
||||
if (column == -1) {
|
||||
return getProperty(codepoint);
|
||||
}
|
||||
if (column < 0 || column >= m_additionalColumnsCount_) {
|
||||
return 0;
|
||||
}
|
||||
return m_additionalVectors_[
|
||||
m_additionalTrie_.getCodePointValue(codepoint) + column];
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* <p>Get the "age" of the code point.</p>
|
||||
* <p>The "age" is the Unicode version when the code point was first
|
||||
* designated (as a non-character or for Private Use) or assigned a
|
||||
@ -316,11 +194,10 @@ public final class UCharacterProperty implements Trie.DataManipulate
|
||||
* <p>This API does not check the validity of the codepoint.</p>
|
||||
* @param codepoint The code point.
|
||||
* @return the Unicode version number
|
||||
* @draft ICU 2.1
|
||||
*/
|
||||
public VersionInfo getAge(int codepoint)
|
||||
{
|
||||
int version = getAdditional(codepoint) >> AGE_SHIFT_;
|
||||
int version = getAdditional(codepoint, 0) >> AGE_SHIFT_;
|
||||
return VersionInfo.getInstance(
|
||||
(version >> FIRST_NIBBLE_SHIFT_) & LAST_NIBBLE_MASK_,
|
||||
version & LAST_NIBBLE_MASK_, 0, 0);
|
||||
@ -341,16 +218,16 @@ public final class UCharacterProperty implements Trie.DataManipulate
|
||||
|
||||
/**
|
||||
* Loads the property data and initialize the UCharacterProperty instance.
|
||||
* @throws RuntimeException when data is missing or data has been corrupted
|
||||
* @throws MissingResourceException when data is missing or data has been corrupted
|
||||
*/
|
||||
public static UCharacterProperty getInstance() throws RuntimeException
|
||||
public static UCharacterProperty getInstance()
|
||||
{
|
||||
if (INSTANCE_ == null) {
|
||||
if(INSTANCE_ == null) {
|
||||
try {
|
||||
INSTANCE_ = new UCharacterProperty();
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new RuntimeException(e.getMessage());
|
||||
throw new MissingResourceException(e.getMessage(),"","");
|
||||
}
|
||||
}
|
||||
return INSTANCE_;
|
||||
@ -359,6 +236,9 @@ public final class UCharacterProperty implements Trie.DataManipulate
|
||||
/**
|
||||
* Checks if the argument c is to be treated as a white space in ICU
|
||||
* rules. Usually ICU rule white spaces are ignored unless quoted.
|
||||
* Equivalent to test for Pattern_White_Space Unicode property.
|
||||
* Stable set of characters, won't change.
|
||||
* See UAX #31 Identifier and Pattern Syntax: http://www.unicode.org/reports/tr31/
|
||||
* @param c codepoint to check
|
||||
* @return true if c is a ICU white space
|
||||
*/
|
||||
@ -366,8 +246,9 @@ public final class UCharacterProperty implements Trie.DataManipulate
|
||||
{
|
||||
/* "white space" in the sense of ICU rule parsers
|
||||
This is a FIXED LIST that is NOT DEPENDENT ON UNICODE PROPERTIES.
|
||||
See UTR #31: http://www.unicode.org/reports/tr31/.
|
||||
See UAX #31 Identifier and Pattern Syntax: http://www.unicode.org/reports/tr31/
|
||||
U+0009..U+000D, U+0020, U+0085, U+200E..U+200F, and U+2028..U+2029
|
||||
Equivalent to test for Pattern_White_Space Unicode property.
|
||||
*/
|
||||
return (c >= 0x0009 && c <= 0x2029 &&
|
||||
(c <= 0x000D || c == 0x0020 || c == 0x0085 ||
|
||||
@ -376,15 +257,6 @@ public final class UCharacterProperty implements Trie.DataManipulate
|
||||
|
||||
// protected variables -----------------------------------------------
|
||||
|
||||
/**
|
||||
* Case table
|
||||
*/
|
||||
char m_case_[];
|
||||
|
||||
/**
|
||||
* Exception property table
|
||||
*/
|
||||
int m_exception_[];
|
||||
/**
|
||||
* Extra property trie
|
||||
*/
|
||||
@ -426,78 +298,20 @@ public final class UCharacterProperty implements Trie.DataManipulate
|
||||
*/
|
||||
private static final int DATA_BUFFER_SIZE_ = 25000;
|
||||
|
||||
/**
|
||||
* This, from what i infer is the max size of the indicators used for the
|
||||
* exception values.
|
||||
* Number of bits in an 8-bit integer value
|
||||
*/
|
||||
private static final int EXC_GROUP_ = 8;
|
||||
|
||||
/**
|
||||
* Mask to get the group
|
||||
*/
|
||||
private static final int EXC_GROUP_MASK_ = 255;
|
||||
|
||||
/**
|
||||
* Mask to get the digit value in the exception result
|
||||
*/
|
||||
private static final int EXC_DIGIT_MASK_ = 0xFFFF;
|
||||
|
||||
/**
|
||||
* Offset table for data in exception block.<br>
|
||||
* Table formed by the number of bits used for the index, e.g. 0 = 0 bits,
|
||||
* 1 = 1 bits.
|
||||
*/
|
||||
private static final byte FLAGS_OFFSET_[] =
|
||||
{
|
||||
0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4,
|
||||
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
|
||||
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
|
||||
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
|
||||
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
|
||||
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
|
||||
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
|
||||
3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
|
||||
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
|
||||
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
|
||||
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
|
||||
3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
|
||||
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
|
||||
3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
|
||||
3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
|
||||
4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8
|
||||
};
|
||||
|
||||
/**
|
||||
* Numeric value shift
|
||||
*/
|
||||
private static final int VALUE_SHIFT_ = 20;
|
||||
private static final int VALUE_SHIFT_ = 8;
|
||||
|
||||
/**
|
||||
* Mask to be applied after shifting to obtain an unsigned numeric value
|
||||
*/
|
||||
private static final int UNSIGNED_VALUE_MASK_AFTER_SHIFT_ = 0x7FF;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final int NUMERIC_TYPE_SHIFT = 12;
|
||||
|
||||
/**
|
||||
* Folding indicator mask
|
||||
*/
|
||||
private static final int SUPPLEMENTARY_FOLD_INDICATOR_MASK_ = 0x8000;
|
||||
|
||||
/**
|
||||
* Folding offset mask
|
||||
*/
|
||||
private static final int SUPPLEMENTARY_FOLD_OFFSET_MASK_ = 0x7FFF;
|
||||
private static final int UNSIGNED_VALUE_MASK_AFTER_SHIFT_ = 0xFF;
|
||||
|
||||
/**
|
||||
* Shift value for lead surrogate to form a supplementary character.
|
||||
*/
|
||||
private static final int LEAD_SURROGATE_SHIFT_ = 10;
|
||||
|
||||
/**
|
||||
* Offset to add to combined surrogate pair to avoid msking.
|
||||
*/
|
||||
@ -507,16 +321,12 @@ public final class UCharacterProperty implements Trie.DataManipulate
|
||||
LEAD_SURROGATE_SHIFT_) -
|
||||
UTF16.TRAIL_SURROGATE_MIN_VALUE;
|
||||
|
||||
/**
|
||||
* To get the last character out from a data type
|
||||
*/
|
||||
private static final int LAST_CHAR_MASK_ = 0xFFFF;
|
||||
// additional properties ----------------------------------------------
|
||||
|
||||
/**
|
||||
* First nibble shift
|
||||
*/
|
||||
private static final int FIRST_NIBBLE_SHIFT_ = 0x4;
|
||||
|
||||
/**
|
||||
* Second nibble mask
|
||||
*/
|
||||
@ -530,7 +340,7 @@ public final class UCharacterProperty implements Trie.DataManipulate
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @exception thrown when data reading fails or data corrupted
|
||||
* @exception IOException thrown when data reading fails or data corrupted
|
||||
*/
|
||||
private UCharacterProperty() throws IOException
|
||||
{
|
||||
@ -544,275 +354,16 @@ public final class UCharacterProperty implements Trie.DataManipulate
|
||||
m_trie_.putIndexData(this);
|
||||
}
|
||||
|
||||
/* Is followed by {case-ignorable}* cased ? */
|
||||
/**
|
||||
* Getting the correct address for data in the exception value
|
||||
* @param evalue exception value
|
||||
* @param indicator type of data to retrieve
|
||||
* @param address current address to move from
|
||||
* @return the correct address
|
||||
*/
|
||||
private int addExceptionOffset(int evalue, int indicator, int address)
|
||||
{
|
||||
int result = address;
|
||||
if (indicator >= EXC_GROUP_) {
|
||||
result += FLAGS_OFFSET_[evalue & EXC_GROUP_MASK_];
|
||||
evalue >>= EXC_GROUP_;
|
||||
indicator -= EXC_GROUP_;
|
||||
}
|
||||
int mask = (1 << indicator) - 1;
|
||||
result += FLAGS_OFFSET_[evalue & mask];
|
||||
return result;
|
||||
}
|
||||
|
||||
private static final int TAB = 0x0009;
|
||||
private static final int LF = 0x000a;
|
||||
private static final int FF = 0x000c;
|
||||
private static final int CR = 0x000d;
|
||||
private static final int U_A = 0x0041;
|
||||
private static final int U_Z = 0x005a;
|
||||
private static final int U_a = 0x0061;
|
||||
private static final int U_z = 0x007a;
|
||||
private static final int DEL = 0x007f;
|
||||
private static final int NL = 0x0085;
|
||||
private static final int NBSP = 0x00a0;
|
||||
private static final int CGJ = 0x034f;
|
||||
private static final int FIGURESP= 0x2007;
|
||||
private static final int HAIRSP = 0x200a;
|
||||
private static final int ZWNJ = 0x200c;
|
||||
private static final int ZWJ = 0x200d;
|
||||
private static final int RLM = 0x200f;
|
||||
private static final int NNBSP = 0x202f;
|
||||
private static final int WJ = 0x2060;
|
||||
private static final int INHSWAP = 0x206a;
|
||||
private static final int NOMDIG = 0x206f;
|
||||
private static final int ZWNBSP = 0xfeff;
|
||||
|
||||
public UnicodeSet addPropertyStarts(UnicodeSet set) {
|
||||
int c;
|
||||
|
||||
/* add the start code point of each same-value range of each trie */
|
||||
//utrie_enum(&normTrie, NULL, _enumPropertyStartsRange, set);
|
||||
TrieIterator propsIter = new TrieIterator(m_trie_);
|
||||
RangeValueIterator.Element propsResult = new RangeValueIterator.Element();
|
||||
while(propsIter.next(propsResult)){
|
||||
set.add(propsResult.start);
|
||||
}
|
||||
//utrie_enum(&propsVectorsTrie, NULL, _enumPropertyStartsRange, set);
|
||||
TrieIterator propsVectorsIter = new TrieIterator(m_additionalTrie_);
|
||||
RangeValueIterator.Element propsVectorsResult = new RangeValueIterator.Element();
|
||||
while(propsVectorsIter.next(propsVectorsResult)){
|
||||
set.add(propsVectorsResult.start);
|
||||
}
|
||||
|
||||
|
||||
/* add code points with hardcoded properties, plus the ones following them */
|
||||
|
||||
/* add for IS_THAT_CONTROL_SPACE() */
|
||||
set.add(TAB); /* range TAB..CR */
|
||||
set.add(CR+1);
|
||||
set.add(0x1c);
|
||||
set.add(0x1f+1);
|
||||
set.add(NL);
|
||||
set.add(NL+1);
|
||||
|
||||
/* add for u_isIDIgnorable() what was not added above */
|
||||
set.add(DEL); /* range DEL..NBSP-1, NBSP added below */
|
||||
set.add(HAIRSP);
|
||||
set.add(RLM+1);
|
||||
set.add(INHSWAP);
|
||||
set.add(NOMDIG+1);
|
||||
set.add(ZWNBSP);
|
||||
set.add(ZWNBSP+1);
|
||||
|
||||
/* add no-break spaces for u_isWhitespace() what was not added above */
|
||||
set.add(NBSP);
|
||||
set.add(NBSP+1);
|
||||
set.add(FIGURESP);
|
||||
set.add(FIGURESP+1);
|
||||
set.add(NNBSP);
|
||||
set.add(NNBSP+1);
|
||||
|
||||
/* add for u_charDigitValue() */
|
||||
set.add(0x3007);
|
||||
set.add(0x3008);
|
||||
set.add(0x4e00);
|
||||
set.add(0x4e01);
|
||||
set.add(0x4e8c);
|
||||
set.add(0x4e8d);
|
||||
set.add(0x4e09);
|
||||
set.add(0x4e0a);
|
||||
set.add(0x56db);
|
||||
set.add(0x56dc);
|
||||
set.add(0x4e94);
|
||||
set.add(0x4e95);
|
||||
set.add(0x516d);
|
||||
set.add(0x516e);
|
||||
set.add(0x4e03);
|
||||
set.add(0x4e04);
|
||||
set.add(0x516b);
|
||||
set.add(0x516c);
|
||||
set.add(0x4e5d);
|
||||
set.add(0x4e5e);
|
||||
|
||||
/* add for u_digit() */
|
||||
set.add(U_a);
|
||||
set.add(U_z+1);
|
||||
set.add(U_A);
|
||||
set.add(U_Z+1);
|
||||
|
||||
/* add for UCHAR_DEFAULT_IGNORABLE_CODE_POINT what was not added above */
|
||||
set.add(WJ); /* range WJ..NOMDIG */
|
||||
set.add(0xfff0);
|
||||
set.add(0xfffb+1);
|
||||
set.add(0xe0000);
|
||||
set.add(0xe0fff+1);
|
||||
|
||||
/* add for UCHAR_GRAPHEME_BASE and others */
|
||||
set.add(CGJ);
|
||||
set.add(CGJ+1);
|
||||
|
||||
/* add for UCHAR_JOINING_TYPE */
|
||||
set.add(ZWNJ); /* range ZWNJ..ZWJ */
|
||||
set.add(ZWJ+1);
|
||||
|
||||
/* add Jamo type boundaries for UCHAR_HANGUL_SYLLABLE_TYPE */
|
||||
set.add(0x1100);
|
||||
int value= UCharacter.HangulSyllableType.LEADING_JAMO;
|
||||
int value2;
|
||||
for(c=0x115a; c<=0x115f; ++c) {
|
||||
value2= UCharacter.getIntPropertyValue(c, UProperty.HANGUL_SYLLABLE_TYPE);
|
||||
if(value!=value2) {
|
||||
value=value2;
|
||||
set.add(c);
|
||||
public void upropsvec_addPropertyStarts(UnicodeSet set) {
|
||||
/* add the start code point of each same-value range of the properties vectors trie */
|
||||
if(m_additionalColumnsCount_>0) {
|
||||
/* if m_additionalColumnsCount_==0 then the properties vectors trie may not be there at all */
|
||||
TrieIterator propsVectorsIter = new TrieIterator(m_additionalTrie_);
|
||||
RangeValueIterator.Element propsVectorsResult = new RangeValueIterator.Element();
|
||||
while(propsVectorsIter.next(propsVectorsResult)){
|
||||
set.add(propsVectorsResult.start);
|
||||
}
|
||||
}
|
||||
|
||||
set.add(0x1160);
|
||||
value=UCharacter.HangulSyllableType.VOWEL_JAMO;
|
||||
for(c=0x11a3; c<=0x11a7; ++c) {
|
||||
value2=UCharacter.getIntPropertyValue(c, UProperty.HANGUL_SYLLABLE_TYPE);
|
||||
if(value!=value2) {
|
||||
value=value2;
|
||||
set.add(c);
|
||||
}
|
||||
}
|
||||
|
||||
set.add(0x11a8);
|
||||
value=UCharacter.HangulSyllableType.TRAILING_JAMO;
|
||||
for(c=0x11fa; c<=0x11ff; ++c) {
|
||||
value2=UCharacter.getIntPropertyValue(c, UProperty.HANGUL_SYLLABLE_TYPE);
|
||||
if(value!=value2) {
|
||||
value=value2;
|
||||
set.add(c);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Omit code points for u_charCellWidth() because
|
||||
* - it is deprecated and not a real Unicode property
|
||||
* - they are probably already set from the trie enumeration
|
||||
*/
|
||||
|
||||
/*
|
||||
* Omit code points with hardcoded specialcasing properties
|
||||
* because we do not build property UnicodeSets for them right now.
|
||||
*/
|
||||
return set; // for chaining
|
||||
}
|
||||
/*----------------------------------------------------------------
|
||||
* Inclusions list
|
||||
*----------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* Return a set of characters for property enumeration.
|
||||
* The set implicitly contains 0x110000 as well, which is one more than the highest
|
||||
* Unicode code point.
|
||||
*
|
||||
* This set is used as an ordered list - its code points are ordered, and
|
||||
* consecutive code points (in Unicode code point order) in the set define a range.
|
||||
* For each two consecutive characters (start, limit) in the set,
|
||||
* all of the UCD/normalization and related properties for
|
||||
* all code points start..limit-1 are all the same,
|
||||
* except for character names and ISO comments.
|
||||
*
|
||||
* All Unicode code points U+0000..U+10ffff are covered by these ranges.
|
||||
* The ranges define a partition of the Unicode code space.
|
||||
* ICU uses the inclusions set to enumerate properties for generating
|
||||
* UnicodeSets containing all code points that have a certain property value.
|
||||
*
|
||||
* The Inclusion List is generated from the UCD. It is generated
|
||||
* by enumerating the data tries, and code points for hardcoded properties
|
||||
* are added as well.
|
||||
*
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* The following are ideas for getting properties-unique code point ranges,
|
||||
* with possible optimizations beyond the current implementation.
|
||||
* These optimizations would require more code and be more fragile.
|
||||
* The current implementation generates one single list (set) for all properties.
|
||||
*
|
||||
* To enumerate properties efficiently, one needs to know ranges of
|
||||
* repetitive values, so that the value of only each start code point
|
||||
* can be applied to the whole range.
|
||||
* This information is in principle available in the uprops.icu/unorm.icu data.
|
||||
*
|
||||
* There are two obstacles:
|
||||
*
|
||||
* 1. Some properties are computed from multiple data structures,
|
||||
* making it necessary to get repetitive ranges by intersecting
|
||||
* ranges from multiple tries.
|
||||
*
|
||||
* 2. It is not economical to write code for getting repetitive ranges
|
||||
* that are precise for each of some 50 properties.
|
||||
*
|
||||
* Compromise ideas:
|
||||
*
|
||||
* - Get ranges per trie, not per individual property.
|
||||
* Each range contains the same values for a whole group of properties.
|
||||
* This would generate currently five range sets, two for uprops.icu tries
|
||||
* and three for unorm.icu tries.
|
||||
*
|
||||
* - Combine sets of ranges for multiple tries to get sufficient sets
|
||||
* for properties, e.g., the uprops.icu main and auxiliary tries
|
||||
* for all non-normalization properties.
|
||||
*
|
||||
* Ideas for representing ranges and combining them:
|
||||
*
|
||||
* - A UnicodeSet could hold just the start code points of ranges.
|
||||
* Multiple sets are easily combined by or-ing them together.
|
||||
*
|
||||
* - Alternatively, a UnicodeSet could hold each even-numbered range.
|
||||
* All ranges could be enumerated by using each start code point
|
||||
* (for the even-numbered ranges) as well as each limit (end+1) code point
|
||||
* (for the odd-numbered ranges).
|
||||
* It should be possible to combine two such sets by xor-ing them,
|
||||
* but no more than two.
|
||||
*
|
||||
* The second way to represent ranges may(?!) yield smaller UnicodeSet arrays,
|
||||
* but the first one is certainly simpler and applicable for combining more than
|
||||
* two range sets.
|
||||
*
|
||||
* It is possible to combine all range sets for all uprops/unorm tries into one
|
||||
* set that can be used for all properties.
|
||||
* As an optimization, there could be less-combined range sets for certain
|
||||
* groups of properties.
|
||||
* The relationship of which less-combined range set to use for which property
|
||||
* depends on the implementation of the properties and must be hardcoded
|
||||
* - somewhat error-prone and higher maintenance but can be tested easily
|
||||
* by building property sets "the simple way" in test code.
|
||||
*
|
||||
* ---
|
||||
*
|
||||
* Do not use a UnicodeSet pattern because that causes infinite recursion;
|
||||
* UnicodeSet depends on the inclusions set.
|
||||
*/
|
||||
public UnicodeSet getInclusions() {
|
||||
UnicodeSet set = new UnicodeSet();
|
||||
NormalizerImpl.addPropertyStarts(set);
|
||||
addPropertyStarts(set);
|
||||
return set;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Portions Copyright 2005 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* Portions Copyright 2005-2009 Sun Microsystems, Inc. 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
|
||||
@ -22,10 +22,9 @@
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
*******************************************************************************
|
||||
* (C) Copyright IBM Corp. 1996-2005 - All Rights Reserved *
|
||||
* (C) Copyright IBM Corp. and others, 1996-2009 - All Rights Reserved *
|
||||
* *
|
||||
* The original version of this source code and documentation is copyrighted *
|
||||
* and owned by IBM, These materials are provided under terms of a License *
|
||||
@ -37,8 +36,8 @@
|
||||
|
||||
package sun.text.normalizer;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
@ -50,254 +49,13 @@ import java.io.IOException;
|
||||
* </p>
|
||||
* <p>uprops.icu which is in big-endian format is jared together with this
|
||||
* package.</p>
|
||||
*
|
||||
* Unicode character properties file format see
|
||||
* (ICU4C)/source/tools/genprops/store.c
|
||||
*
|
||||
* @author Syn Wee Quek
|
||||
* @since release 2.1, February 1st 2002
|
||||
* @draft 2.1
|
||||
*/
|
||||
/* Unicode character properties file format ------------------------------------
|
||||
|
||||
The file format prepared and written here contains several data
|
||||
structures that store indexes or data.
|
||||
|
||||
|
||||
|
||||
The following is a description of format version 3 .
|
||||
|
||||
Data contents:
|
||||
|
||||
The contents is a parsed, binary form of several Unicode character
|
||||
database files, most prominently UnicodeData.txt.
|
||||
|
||||
Any Unicode code point from 0 to 0x10ffff can be looked up to get
|
||||
the properties, if any, for that code point. This means that the input
|
||||
to the lookup are 21-bit unsigned integers, with not all of the
|
||||
21-bit range used.
|
||||
|
||||
It is assumed that client code keeps a uint32_t pointer
|
||||
to the beginning of the data:
|
||||
|
||||
const uint32_t *p32;
|
||||
|
||||
Formally, the file contains the following structures:
|
||||
|
||||
const int32_t indexes[16] with values i0..i15:
|
||||
|
||||
i0 propsIndex; -- 32-bit unit index to the table of 32-bit properties words
|
||||
i1 exceptionsIndex; -- 32-bit unit index to the table of 32-bit exception words
|
||||
i2 exceptionsTopIndex; -- 32-bit unit index to the array of UChars for special mappings
|
||||
|
||||
i3 additionalTrieIndex; -- 32-bit unit index to the additional trie for more properties
|
||||
i4 additionalVectorsIndex; -- 32-bit unit index to the table of properties vectors
|
||||
i5 additionalVectorsColumns; -- number of 32-bit words per properties vector
|
||||
|
||||
i6 reservedItemIndex; -- 32-bit unit index to the top of the properties vectors table
|
||||
i7..i9 reservedIndexes; -- reserved values; 0 for now
|
||||
|
||||
i10 maxValues; -- maximum code values for vector word 0, see uprops.h (format version 3.1+)
|
||||
i11 maxValues2; -- maximum code values for vector word 2, see uprops.h (format version 3.2)
|
||||
i12..i15 reservedIndexes; -- reserved values; 0 for now
|
||||
|
||||
PT serialized properties trie, see utrie.h (byte size: 4*(i0-16))
|
||||
|
||||
P const uint32_t props32[i1-i0];
|
||||
E const uint32_t exceptions[i2-i1];
|
||||
U const UChar uchars[2*(i3-i2)];
|
||||
|
||||
AT serialized trie for additional properties (byte size: 4*(i4-i3))
|
||||
PV const uint32_t propsVectors[(i6-i4)/i5][i5]==uint32_t propsVectors[i6-i4];
|
||||
|
||||
Trie lookup and properties:
|
||||
|
||||
In order to condense the data for the 21-bit code space, several properties of
|
||||
the Unicode code assignment are exploited:
|
||||
- The code space is sparse.
|
||||
- There are several 10k of consecutive codes with the same properties.
|
||||
- Characters and scripts are allocated in groups of 16 code points.
|
||||
- Inside blocks for scripts the properties are often repetitive.
|
||||
- The 21-bit space is not fully used for Unicode.
|
||||
|
||||
The lookup of properties for a given code point is done with a trie lookup,
|
||||
using the UTrie implementation.
|
||||
The trie lookup result is a 16-bit index in the props32[] table where the
|
||||
actual 32-bit properties word is stored. This is done to save space.
|
||||
|
||||
(There are thousands of 16-bit entries in the trie data table, but
|
||||
only a few hundred unique 32-bit properties words.
|
||||
If the trie data table contained 32-bit words directly, then that would be
|
||||
larger because the length of the table would be the same as now but the
|
||||
width would be 32 bits instead of 16. This saves more than 10kB.)
|
||||
|
||||
With a given Unicode code point
|
||||
|
||||
UChar32 c;
|
||||
|
||||
and 0<=c<0x110000, the lookup is done like this:
|
||||
|
||||
uint16_t i;
|
||||
UTRIE_GET16(c, i);
|
||||
uint32_t props=p32[i];
|
||||
|
||||
For some characters, not all of the properties can be efficiently encoded
|
||||
using 32 bits. For them, the 32-bit word contains an index into the exceptions[]
|
||||
array:
|
||||
|
||||
if(props&EXCEPTION_BIT)) {
|
||||
uint16_t e=(uint16_t)(props>>VALUE_SHIFT);
|
||||
...
|
||||
}
|
||||
|
||||
The exception values are a variable number of uint32_t starting at
|
||||
|
||||
const uint32_t *pe=p32+exceptionsIndex+e;
|
||||
|
||||
The first uint32_t there contains flags about what values actually follow it.
|
||||
Some of the exception values are UChar32 code points for the case mappings,
|
||||
others are numeric values etc.
|
||||
|
||||
32-bit properties sets:
|
||||
|
||||
Each 32-bit properties word contains:
|
||||
|
||||
0.. 4 general category
|
||||
5 has exception values
|
||||
6..10 BiDi category
|
||||
11 is mirrored
|
||||
12..14 numericType:
|
||||
0 no numeric value
|
||||
1 decimal digit value
|
||||
2 digit value
|
||||
3 numeric value
|
||||
### TODO: type 4 for Han digits & numbers?!
|
||||
15..19 reserved
|
||||
20..31 value according to bits 0..5:
|
||||
if(has exception) {
|
||||
exception index;
|
||||
} else switch(general category) {
|
||||
case Ll: delta to uppercase; -- same as titlecase
|
||||
case Lu: -delta to lowercase; -- titlecase is same as c
|
||||
case Lt: -delta to lowercase; -- uppercase is same as c
|
||||
default:
|
||||
if(is mirrored) {
|
||||
delta to mirror;
|
||||
} else if(numericType!=0) {
|
||||
numericValue;
|
||||
} else {
|
||||
0;
|
||||
};
|
||||
}
|
||||
|
||||
Exception values:
|
||||
|
||||
In the first uint32_t exception word for a code point,
|
||||
bits
|
||||
31..16 reserved
|
||||
15..0 flags that indicate which values follow:
|
||||
|
||||
bit
|
||||
0 has uppercase mapping
|
||||
1 has lowercase mapping
|
||||
2 has titlecase mapping
|
||||
3 unused
|
||||
4 has numeric value (numerator)
|
||||
if numericValue=0x7fffff00+x then numericValue=10^x
|
||||
5 has denominator value
|
||||
6 has a mirror-image Unicode code point
|
||||
7 has SpecialCasing.txt entries
|
||||
8 has CaseFolding.txt entries
|
||||
|
||||
According to the flags in this word, one or more uint32_t words follow it
|
||||
in the sequence of the bit flags in the flags word; if a flag is not set,
|
||||
then the value is missing or 0:
|
||||
|
||||
For the case mappings and the mirror-image Unicode code point,
|
||||
one uint32_t or UChar32 each is the code point.
|
||||
If the titlecase mapping is missing, then it is the same as the uppercase mapping.
|
||||
|
||||
For the digit values, bits 31..16 contain the decimal digit value, and
|
||||
bits 15..0 contain the digit value. A value of -1 indicates that
|
||||
this value is missing.
|
||||
|
||||
For the numeric/numerator value, an int32_t word contains the value directly,
|
||||
except for when there is no numerator but a denominator, then the numerator
|
||||
is implicitly 1. This means:
|
||||
numerator denominator result
|
||||
none none none
|
||||
x none x
|
||||
none y 1/y
|
||||
x y x/y
|
||||
|
||||
If the numerator value is 0x7fffff00+x then it is replaced with 10^x.
|
||||
|
||||
For the denominator value, a uint32_t word contains the value directly.
|
||||
|
||||
For special casing mappings, the 32-bit exception word contains:
|
||||
31 if set, this character has complex, conditional mappings
|
||||
that are not stored;
|
||||
otherwise, the mappings are stored according to the following bits
|
||||
30..24 number of UChars used for mappings
|
||||
23..16 reserved
|
||||
15.. 0 UChar offset from the beginning of the UChars array where the
|
||||
UChars for the special case mappings are stored in the following format:
|
||||
|
||||
Format of special casing UChars:
|
||||
One UChar value with lengths as follows:
|
||||
14..10 number of UChars for titlecase mapping
|
||||
9.. 5 number of UChars for uppercase mapping
|
||||
4.. 0 number of UChars for lowercase mapping
|
||||
|
||||
Followed by the UChars for lowercase, uppercase, titlecase mappings in this order.
|
||||
|
||||
For case folding mappings, the 32-bit exception word contains:
|
||||
31..24 number of UChars used for the full mapping
|
||||
23..16 reserved
|
||||
15.. 0 UChar offset from the beginning of the UChars array where the
|
||||
UChars for the special case mappings are stored in the following format:
|
||||
|
||||
Format of case folding UChars:
|
||||
Two UChars contain the simple mapping as follows:
|
||||
0, 0 no simple mapping
|
||||
BMP,0 a simple mapping to a BMP code point
|
||||
s1, s2 a simple mapping to a supplementary code point stored as two surrogates
|
||||
This is followed by the UChars for the full case folding mappings.
|
||||
|
||||
Example:
|
||||
U+2160, ROMAN NUMERAL ONE, needs an exception because it has a lowercase
|
||||
mapping and a numeric value.
|
||||
Its exception values would be stored as 3 uint32_t words:
|
||||
|
||||
- flags=0x0a (see above) with combining class 0
|
||||
- lowercase mapping 0x2170
|
||||
- numeric value=1
|
||||
|
||||
--- Additional properties (new in format version 2.1) ---
|
||||
|
||||
The second trie for additional properties (AT) is also a UTrie with 16-bit data.
|
||||
The data words consist of 32-bit unit indexes (not row indexes!) into the
|
||||
table of unique properties vectors (PV).
|
||||
Each vector contains a set of properties.
|
||||
The width of a vector (number of uint32_t per row) may change
|
||||
with the formatVersion, it is stored in i5.
|
||||
|
||||
Current properties: see icu/source/common/uprops.h
|
||||
|
||||
--- Changes in format version 3.1 ---
|
||||
|
||||
See i10 maxValues above, contains only UBLOCK_COUNT and USCRIPT_CODE_LIMIT.
|
||||
|
||||
--- Changes in format version 3.2 ---
|
||||
|
||||
- The tries use linear Latin-1 ranges.
|
||||
- The additional properties bits store full properties XYZ instead
|
||||
of partial Other_XYZ, so that changes in the derivation formulas
|
||||
need not be tracked in runtime library code.
|
||||
- Joining Type and Line Break are also stored completely, so that uprops.c
|
||||
needs no runtime formulas for enumerated properties either.
|
||||
- Store the case-sensitive flag in the main properties word.
|
||||
- i10 also contains U_LB_COUNT and U_EA_COUNT.
|
||||
- i11 contains maxValues2 for vector word 2.
|
||||
|
||||
----------------------------------------------------------------------------- */
|
||||
|
||||
final class UCharacterPropertyReader implements ICUBinary.Authenticate
|
||||
{
|
||||
// public methods ----------------------------------------------------
|
||||
@ -315,7 +73,6 @@ final class UCharacterPropertyReader implements ICUBinary.Authenticate
|
||||
* <p>Protected constructor.</p>
|
||||
* @param inputStream ICU uprop.dat file input stream
|
||||
* @exception IOException throw if data file fails authentication
|
||||
* @draft 2.1
|
||||
*/
|
||||
protected UCharacterPropertyReader(InputStream inputStream)
|
||||
throws IOException
|
||||
@ -331,8 +88,7 @@ final class UCharacterPropertyReader implements ICUBinary.Authenticate
|
||||
* <p>Reads uprops.icu, parse it into blocks of data to be stored in
|
||||
* UCharacterProperty.</P
|
||||
* @param ucharppty UCharacterProperty instance
|
||||
* @exception thrown when data reading fails
|
||||
* @draft 2.1
|
||||
* @exception IOException thrown when data reading fails
|
||||
*/
|
||||
protected void read(UCharacterProperty ucharppty) throws IOException
|
||||
{
|
||||
@ -362,38 +118,30 @@ final class UCharacterPropertyReader implements ICUBinary.Authenticate
|
||||
|
||||
// read the trie index block
|
||||
// m_props_index_ in terms of ints
|
||||
ucharppty.m_trie_ = new CharTrie(m_dataInputStream_, ucharppty);
|
||||
ucharppty.m_trie_ = new CharTrie(m_dataInputStream_, null);
|
||||
|
||||
// reads the 32 bit properties block
|
||||
// skip the 32 bit properties block
|
||||
int size = m_exceptionOffset_ - m_propertyOffset_;
|
||||
ucharppty.m_property_ = new int[size];
|
||||
for (int i = 0; i < size; i ++) {
|
||||
ucharppty.m_property_[i] = m_dataInputStream_.readInt();
|
||||
}
|
||||
m_dataInputStream_.skipBytes(size * 4);
|
||||
|
||||
// reads the 32 bit exceptions block
|
||||
size = m_caseOffset_ - m_exceptionOffset_;
|
||||
ucharppty.m_exception_ = new int[size];
|
||||
for (int i = 0; i < size; i ++) {
|
||||
ucharppty.m_exception_[i] = m_dataInputStream_.readInt();
|
||||
}
|
||||
m_dataInputStream_.skipBytes(size * 4);
|
||||
|
||||
// reads the 32 bit case block
|
||||
size = (m_additionalOffset_ - m_caseOffset_) << 1;
|
||||
ucharppty.m_case_ = new char[size];
|
||||
for (int i = 0; i < size; i ++) {
|
||||
ucharppty.m_case_[i] = m_dataInputStream_.readChar();
|
||||
}
|
||||
m_dataInputStream_.skipBytes(size * 2);
|
||||
|
||||
// reads the additional property block
|
||||
ucharppty.m_additionalTrie_ = new CharTrie(m_dataInputStream_,
|
||||
ucharppty);
|
||||
if(m_additionalColumnsCount_ > 0) {
|
||||
// reads the additional property block
|
||||
ucharppty.m_additionalTrie_ = new CharTrie(m_dataInputStream_, null);
|
||||
|
||||
// additional properties
|
||||
size = m_reservedOffset_ - m_additionalVectorsOffset_;
|
||||
ucharppty.m_additionalVectors_ = new int[size];
|
||||
for (int i = 0; i < size; i ++) {
|
||||
ucharppty.m_additionalVectors_[i] = m_dataInputStream_.readInt();
|
||||
// additional properties
|
||||
size = m_reservedOffset_ - m_additionalVectorsOffset_;
|
||||
ucharppty.m_additionalVectors_ = new int[size];
|
||||
for (int i = 0; i < size; i ++) {
|
||||
ucharppty.m_additionalVectors_[i] = m_dataInputStream_.readInt();
|
||||
}
|
||||
}
|
||||
|
||||
m_dataInputStream_.close();
|
||||
@ -428,12 +176,15 @@ final class UCharacterPropertyReader implements ICUBinary.Authenticate
|
||||
private byte m_unicodeVersion_[];
|
||||
|
||||
/**
|
||||
* File format version that this class understands.
|
||||
* No guarantees are made if a older version is used
|
||||
* Data format "UPro".
|
||||
*/
|
||||
private static final byte DATA_FORMAT_ID_[] = {(byte)0x55, (byte)0x50,
|
||||
(byte)0x72, (byte)0x6F};
|
||||
private static final byte DATA_FORMAT_VERSION_[] = {(byte)0x3, (byte)0x1,
|
||||
/**
|
||||
* Format version; this code works with all versions with the same major
|
||||
* version number and the same Trie bit distribution.
|
||||
*/
|
||||
private static final byte DATA_FORMAT_VERSION_[] = {(byte)0x5, (byte)0,
|
||||
(byte)Trie.INDEX_STAGE_1_SHIFT_,
|
||||
(byte)Trie.INDEX_STAGE_2_SHIFT_};
|
||||
}
|
||||
|
@ -1,80 +0,0 @@
|
||||
/*
|
||||
* Portions Copyright 2005 Sun Microsystems, Inc. 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. Sun designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
*******************************************************************************
|
||||
* (C) Copyright IBM Corp. 1996-2005 - All Rights Reserved *
|
||||
* *
|
||||
* The original version of this source code and documentation is copyrighted *
|
||||
* and owned by IBM, These materials are provided under terms of a License *
|
||||
* Agreement between IBM and Sun. This technology is protected by multiple *
|
||||
* US and International patents. This notice and attribution to IBM may not *
|
||||
* to removed. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
package sun.text.normalizer;
|
||||
|
||||
/**
|
||||
* <p>Selection constants for Unicode properties. </p>
|
||||
* <p>These constants are used in functions like
|
||||
* UCharacter.hasBinaryProperty(int) to select one of the Unicode properties.
|
||||
* </p>
|
||||
* <p>The properties APIs are intended to reflect Unicode properties as
|
||||
* defined in the Unicode Character Database (UCD) and Unicode Technical
|
||||
* Reports (UTR).</p>
|
||||
* <p>For details about the properties see <a href=http://www.unicode.org>
|
||||
* http://www.unicode.org</a>.</p>
|
||||
* <p>For names of Unicode properties see the UCD file PropertyAliases.txt.
|
||||
* </p>
|
||||
* <p>Important: If ICU is built with UCD files from Unicode versions below
|
||||
* 3.2, then properties marked with "new" are not or not fully
|
||||
* available. Check UCharacter.getUnicodeVersion() to be sure.</p>
|
||||
* @author Syn Wee Quek
|
||||
* @stable ICU 2.6
|
||||
* @see com.ibm.icu.lang.UCharacter
|
||||
*/
|
||||
public interface UProperty
|
||||
{
|
||||
// public data member --------------------------------------------------
|
||||
|
||||
/**
|
||||
* Enumerated property Hangul_Syllable_Type, new in Unicode 4.
|
||||
* Returns HangulSyllableType values.
|
||||
* @stable ICU 2.6
|
||||
*/
|
||||
public static final int HANGUL_SYLLABLE_TYPE = 0x100B;
|
||||
|
||||
/**
|
||||
* Bitmask property General_Category_Mask.
|
||||
* This is the General_Category property returned as a bit mask.
|
||||
* When used in UCharacter.getIntPropertyValue(c),
|
||||
* returns bit masks for UCharacterCategory values where exactly one bit is set.
|
||||
* When used with UCharacter.getPropertyValueName() and UCharacter.getPropertyValueEnum(),
|
||||
* a multi-bit mask is used for sets of categories like "Letters".
|
||||
* @stable ICU 2.4
|
||||
*/
|
||||
public static final int GENERAL_CATEGORY_MASK = 0x2000;
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Portions Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* Portions Copyright 2005-2009 Sun Microsystems, Inc. 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
|
||||
@ -22,10 +22,9 @@
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
*******************************************************************************
|
||||
* (C) Copyright IBM Corp. 1996-2005 - All Rights Reserved *
|
||||
* (C) Copyright IBM Corp. and others, 1996-2009 - All Rights Reserved *
|
||||
* *
|
||||
* The original version of this source code and documentation is copyrighted *
|
||||
* and owned by IBM, These materials are provided under terms of a License *
|
||||
@ -184,15 +183,16 @@ public final class UTF16
|
||||
* bounds.
|
||||
* @stable ICU 2.1
|
||||
*/
|
||||
public static int charAt(String source, int offset16)
|
||||
{
|
||||
if (offset16 < 0 || offset16 >= source.length()) {
|
||||
throw new StringIndexOutOfBoundsException(offset16);
|
||||
}
|
||||
|
||||
public static int charAt(String source, int offset16) {
|
||||
char single = source.charAt(offset16);
|
||||
if (single < LEAD_SURROGATE_MIN_VALUE ||
|
||||
single > TRAIL_SURROGATE_MAX_VALUE) {
|
||||
if (single < LEAD_SURROGATE_MIN_VALUE) {
|
||||
return single;
|
||||
}
|
||||
return _charAt(source, offset16, single);
|
||||
}
|
||||
|
||||
private static int _charAt(String source, int offset16, char single) {
|
||||
if (single > TRAIL_SURROGATE_MAX_VALUE) {
|
||||
return single;
|
||||
}
|
||||
|
||||
@ -201,29 +201,23 @@ public final class UTF16
|
||||
// low, look both directions.
|
||||
|
||||
if (single <= LEAD_SURROGATE_MAX_VALUE) {
|
||||
++ offset16;
|
||||
++offset16;
|
||||
if (source.length() != offset16) {
|
||||
char trail = source.charAt(offset16);
|
||||
if (trail >= TRAIL_SURROGATE_MIN_VALUE &&
|
||||
trail <= TRAIL_SURROGATE_MAX_VALUE) {
|
||||
return UCharacterProperty.getRawSupplementary(single,
|
||||
trail);
|
||||
if (trail >= TRAIL_SURROGATE_MIN_VALUE && trail <= TRAIL_SURROGATE_MAX_VALUE) {
|
||||
return UCharacterProperty.getRawSupplementary(single, trail);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
--offset16;
|
||||
if (offset16 >= 0) {
|
||||
// single is a trail surrogate so
|
||||
char lead = source.charAt(offset16);
|
||||
if (lead >= LEAD_SURROGATE_MIN_VALUE && lead <= LEAD_SURROGATE_MAX_VALUE) {
|
||||
return UCharacterProperty.getRawSupplementary(lead, single);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
-- offset16;
|
||||
if (offset16 >= 0) {
|
||||
// single is a trail surrogate so
|
||||
char lead = source.charAt(offset16);
|
||||
if (lead >= LEAD_SURROGATE_MIN_VALUE &&
|
||||
lead <= LEAD_SURROGATE_MAX_VALUE) {
|
||||
return UCharacterProperty.getRawSupplementary(lead,
|
||||
single);
|
||||
}
|
||||
}
|
||||
}
|
||||
return single; // return unmatched surrogate
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Portions Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* Portions Copyright 2005-2009 Sun Microsystems, Inc. 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
|
||||
@ -22,10 +22,9 @@
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
*******************************************************************************
|
||||
* (C) Copyright IBM Corp. 1996-2005 - All Rights Reserved *
|
||||
* (C) Copyright IBM Corp. and others, 1996-2009 - All Rights Reserved *
|
||||
* *
|
||||
* The original version of this source code and documentation is copyrighted *
|
||||
* and owned by IBM, These materials are provided under terms of a License *
|
||||
@ -38,11 +37,8 @@
|
||||
package sun.text.normalizer;
|
||||
|
||||
import java.text.ParsePosition;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import java.util.TreeSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Collection;
|
||||
import java.util.TreeSet;
|
||||
|
||||
/**
|
||||
* A mutable set of Unicode characters and multicharacter strings. Objects of this class
|
||||
@ -130,8 +126,8 @@ import java.util.Collection;
|
||||
* "[:Lu:]" and the Perl-like syntax "\p{Lu}" are recognized. For a
|
||||
* complete list of supported property patterns, see the User's Guide
|
||||
* for UnicodeSet at
|
||||
* <a href="http://oss.software.ibm.com/icu/userguide/unicodeSet.html">
|
||||
* http://oss.software.ibm.com/icu/userguide/unicodeSet.html</a>.
|
||||
* <a href="http://www.icu-project.org/userguide/unicodeSet.html">
|
||||
* http://www.icu-project.org/userguide/unicodeSet.html</a>.
|
||||
* Actual determination of property data is defined by the underlying
|
||||
* Unicode database as implemented by UCharacter.
|
||||
*
|
||||
@ -271,9 +267,11 @@ import java.util.Collection;
|
||||
* </tr>
|
||||
* </table>
|
||||
* </blockquote>
|
||||
* <p>To iterate over contents of UnicodeSet, use UnicodeSetIterator class.
|
||||
*
|
||||
* @author Alan Liu
|
||||
* @stable ICU 2.0
|
||||
* @see UnicodeSetIterator
|
||||
*/
|
||||
public class UnicodeSet implements UnicodeMatcher {
|
||||
|
||||
@ -322,7 +320,7 @@ public class UnicodeSet implements UnicodeMatcher {
|
||||
* properties are all exactly alike, e.g. CJK Ideographs from
|
||||
* U+4E00 to U+9FA5.
|
||||
*/
|
||||
private static UnicodeSet INCLUSIONS = null;
|
||||
private static UnicodeSet INCLUSIONS[] = null;
|
||||
|
||||
//----------------------------------------------------------------
|
||||
// Public API
|
||||
@ -471,17 +469,18 @@ public class UnicodeSet implements UnicodeMatcher {
|
||||
return result;
|
||||
}
|
||||
|
||||
return _generatePattern(result, escapeUnprintable);
|
||||
return _generatePattern(result, escapeUnprintable, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate and append a string representation of this set to result.
|
||||
* This does not use this.pat, the cleaned up copy of the string
|
||||
* passed to applyPattern().
|
||||
* @stable ICU 2.0
|
||||
* @param includeStrings if false, doesn't include the strings.
|
||||
* @stable ICU 3.8
|
||||
*/
|
||||
public StringBuffer _generatePattern(StringBuffer result,
|
||||
boolean escapeUnprintable) {
|
||||
boolean escapeUnprintable, boolean includeStrings) {
|
||||
result.append('[');
|
||||
|
||||
int count = getRangeCount();
|
||||
@ -524,7 +523,7 @@ public class UnicodeSet implements UnicodeMatcher {
|
||||
}
|
||||
}
|
||||
|
||||
if (strings.size() > 0) {
|
||||
if (includeStrings && strings.size() > 0) {
|
||||
Iterator it = strings.iterator();
|
||||
while (it.hasNext()) {
|
||||
result.append('{');
|
||||
@ -535,19 +534,8 @@ public class UnicodeSet implements UnicodeMatcher {
|
||||
return result.append(']');
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the specified range to this set if it is not already
|
||||
* present. If this set already contains the specified range,
|
||||
* the call leaves this set unchanged. If <code>end > start</code>
|
||||
* then an empty range is added, leaving the set unchanged.
|
||||
*
|
||||
* @param start first character, inclusive, of range to be added
|
||||
* to this set.
|
||||
* @param end last character, inclusive, of range to be added
|
||||
* to this set.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
public UnicodeSet add(int start, int end) {
|
||||
// for internal use, after checkFrozen has been called
|
||||
private UnicodeSet add_unchecked(int start, int end) {
|
||||
if (start < MIN_VALUE || start > MAX_VALUE) {
|
||||
throw new IllegalArgumentException("Invalid code point U+" + Utility.hex(start, 6));
|
||||
}
|
||||
@ -569,6 +557,11 @@ public class UnicodeSet implements UnicodeMatcher {
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
public final UnicodeSet add(int c) {
|
||||
return add_unchecked(c);
|
||||
}
|
||||
|
||||
// for internal use only, after checkFrozen has been called
|
||||
private final UnicodeSet add_unchecked(int c) {
|
||||
if (c < MIN_VALUE || c > MAX_VALUE) {
|
||||
throw new IllegalArgumentException("Invalid code point U+" + Utility.hex(c, 6));
|
||||
}
|
||||
@ -663,13 +656,12 @@ public class UnicodeSet implements UnicodeMatcher {
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
public final UnicodeSet add(String s) {
|
||||
|
||||
int cp = getSingleCP(s);
|
||||
if (cp < 0) {
|
||||
strings.add(s);
|
||||
pat = null;
|
||||
} else {
|
||||
add(cp, cp);
|
||||
add_unchecked(cp, cp);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
@ -981,7 +973,6 @@ public class UnicodeSet implements UnicodeMatcher {
|
||||
*/
|
||||
void applyPattern(RuleCharacterIterator chars, SymbolTable symbols,
|
||||
StringBuffer rebuiltPat, int options) {
|
||||
|
||||
// Syntax characters: [ ] ^ - & { }
|
||||
|
||||
// Recognized special forms for chars, sets: c-c s-s s&s
|
||||
@ -992,7 +983,7 @@ public class UnicodeSet implements UnicodeMatcher {
|
||||
opts |= RuleCharacterIterator.SKIP_WHITESPACE;
|
||||
}
|
||||
|
||||
StringBuffer pat = new StringBuffer(), buf = null;
|
||||
StringBuffer patBuf = new StringBuffer(), buf = null;
|
||||
boolean usePat = false;
|
||||
UnicodeSet scratch = null;
|
||||
Object backup = null;
|
||||
@ -1049,13 +1040,13 @@ public class UnicodeSet implements UnicodeMatcher {
|
||||
} else {
|
||||
// Handle opening '[' delimiter
|
||||
mode = 1;
|
||||
pat.append('[');
|
||||
patBuf.append('[');
|
||||
backup = chars.getPos(backup); // prepare to backup
|
||||
c = chars.next(opts);
|
||||
literal = chars.isEscaped();
|
||||
if (c == '^' && !literal) {
|
||||
invert = true;
|
||||
pat.append('^');
|
||||
patBuf.append('^');
|
||||
backup = chars.getPos(backup); // prepare to backup
|
||||
c = chars.next(opts);
|
||||
literal = chars.isEscaped();
|
||||
@ -1093,13 +1084,13 @@ public class UnicodeSet implements UnicodeMatcher {
|
||||
if (op != 0) {
|
||||
syntaxError(chars, "Char expected after operator");
|
||||
}
|
||||
add(lastChar, lastChar);
|
||||
_appendToPat(pat, lastChar, false);
|
||||
add_unchecked(lastChar, lastChar);
|
||||
_appendToPat(patBuf, lastChar, false);
|
||||
lastItem = op = 0;
|
||||
}
|
||||
|
||||
if (op == '-' || op == '&') {
|
||||
pat.append(op);
|
||||
patBuf.append(op);
|
||||
}
|
||||
|
||||
if (nested == null) {
|
||||
@ -1108,14 +1099,14 @@ public class UnicodeSet implements UnicodeMatcher {
|
||||
}
|
||||
switch (setMode) {
|
||||
case 1:
|
||||
nested.applyPattern(chars, symbols, pat, options);
|
||||
nested.applyPattern(chars, symbols, patBuf, options);
|
||||
break;
|
||||
case 2:
|
||||
chars.skipIgnored(opts);
|
||||
nested.applyPropertyPattern(chars, pat, symbols);
|
||||
nested.applyPropertyPattern(chars, patBuf, symbols);
|
||||
break;
|
||||
case 3: // `nested' already parsed
|
||||
nested._toPattern(pat, false);
|
||||
nested._toPattern(patBuf, false);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -1158,17 +1149,17 @@ public class UnicodeSet implements UnicodeMatcher {
|
||||
switch (c) {
|
||||
case ']':
|
||||
if (lastItem == 1) {
|
||||
add(lastChar, lastChar);
|
||||
_appendToPat(pat, lastChar, false);
|
||||
add_unchecked(lastChar, lastChar);
|
||||
_appendToPat(patBuf, lastChar, false);
|
||||
}
|
||||
// Treat final trailing '-' as a literal
|
||||
if (op == '-') {
|
||||
add(op, op);
|
||||
pat.append(op);
|
||||
add_unchecked(op, op);
|
||||
patBuf.append(op);
|
||||
} else if (op == '&') {
|
||||
syntaxError(chars, "Trailing '&'");
|
||||
}
|
||||
pat.append(']');
|
||||
patBuf.append(']');
|
||||
mode = 2;
|
||||
continue;
|
||||
case '-':
|
||||
@ -1178,11 +1169,11 @@ public class UnicodeSet implements UnicodeMatcher {
|
||||
continue;
|
||||
} else {
|
||||
// Treat final trailing '-' as a literal
|
||||
add(c, c);
|
||||
add_unchecked(c, c);
|
||||
c = chars.next(opts);
|
||||
literal = chars.isEscaped();
|
||||
if (c == ']' && !literal) {
|
||||
pat.append("-]");
|
||||
patBuf.append("-]");
|
||||
mode = 2;
|
||||
continue;
|
||||
}
|
||||
@ -1202,8 +1193,8 @@ public class UnicodeSet implements UnicodeMatcher {
|
||||
syntaxError(chars, "Missing operand after operator");
|
||||
}
|
||||
if (lastItem == 1) {
|
||||
add(lastChar, lastChar);
|
||||
_appendToPat(pat, lastChar, false);
|
||||
add_unchecked(lastChar, lastChar);
|
||||
_appendToPat(patBuf, lastChar, false);
|
||||
}
|
||||
lastItem = 0;
|
||||
if (buf == null) {
|
||||
@ -1228,9 +1219,9 @@ public class UnicodeSet implements UnicodeMatcher {
|
||||
// we don't need to drop through to the further
|
||||
// processing
|
||||
add(buf.toString());
|
||||
pat.append('{');
|
||||
_appendToPat(pat, buf.toString(), false);
|
||||
pat.append('}');
|
||||
patBuf.append('{');
|
||||
_appendToPat(patBuf, buf.toString(), false);
|
||||
patBuf.append('}');
|
||||
continue;
|
||||
case SymbolTable.SYMBOL_REF:
|
||||
// symbols nosymbols
|
||||
@ -1250,12 +1241,12 @@ public class UnicodeSet implements UnicodeMatcher {
|
||||
}
|
||||
if (anchor && op == 0) {
|
||||
if (lastItem == 1) {
|
||||
add(lastChar, lastChar);
|
||||
_appendToPat(pat, lastChar, false);
|
||||
add_unchecked(lastChar, lastChar);
|
||||
_appendToPat(patBuf, lastChar, false);
|
||||
}
|
||||
add(UnicodeMatcher.ETHER);
|
||||
add_unchecked(UnicodeMatcher.ETHER);
|
||||
usePat = true;
|
||||
pat.append(SymbolTable.SYMBOL_REF).append(']');
|
||||
patBuf.append(SymbolTable.SYMBOL_REF).append(']');
|
||||
mode = 2;
|
||||
continue;
|
||||
}
|
||||
@ -1281,14 +1272,14 @@ public class UnicodeSet implements UnicodeMatcher {
|
||||
// these are most likely typos.
|
||||
syntaxError(chars, "Invalid range");
|
||||
}
|
||||
add(lastChar, c);
|
||||
_appendToPat(pat, lastChar, false);
|
||||
pat.append(op);
|
||||
_appendToPat(pat, c, false);
|
||||
add_unchecked(lastChar, c);
|
||||
_appendToPat(patBuf, lastChar, false);
|
||||
patBuf.append(op);
|
||||
_appendToPat(patBuf, c, false);
|
||||
lastItem = op = 0;
|
||||
} else {
|
||||
add(lastChar, lastChar);
|
||||
_appendToPat(pat, lastChar, false);
|
||||
add_unchecked(lastChar, lastChar);
|
||||
_appendToPat(patBuf, lastChar, false);
|
||||
lastChar = c;
|
||||
}
|
||||
break;
|
||||
@ -1315,9 +1306,9 @@ public class UnicodeSet implements UnicodeMatcher {
|
||||
// Use the rebuilt pattern (pat) only if necessary. Prefer the
|
||||
// generated pattern.
|
||||
if (usePat) {
|
||||
rebuiltPat.append(pat.toString());
|
||||
rebuiltPat.append(patBuf.toString());
|
||||
} else {
|
||||
_generatePattern(rebuiltPat, false);
|
||||
_generatePattern(rebuiltPat, false, true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1590,7 +1581,9 @@ public class UnicodeSet implements UnicodeMatcher {
|
||||
|
||||
private static class VersionFilter implements Filter {
|
||||
VersionInfo version;
|
||||
|
||||
VersionFilter(VersionInfo version) { this.version = version; }
|
||||
|
||||
public boolean contains(int ch) {
|
||||
VersionInfo v = UCharacter.getAge(ch);
|
||||
// Reference comparison ok; VersionInfo caches and reuses
|
||||
@ -1600,18 +1593,28 @@ public class UnicodeSet implements UnicodeMatcher {
|
||||
}
|
||||
}
|
||||
|
||||
private static synchronized UnicodeSet getInclusions() {
|
||||
private static synchronized UnicodeSet getInclusions(int src) {
|
||||
if (INCLUSIONS == null) {
|
||||
UCharacterProperty property = UCharacterProperty.getInstance();
|
||||
INCLUSIONS = property.getInclusions();
|
||||
INCLUSIONS = new UnicodeSet[UCharacterProperty.SRC_COUNT];
|
||||
}
|
||||
return INCLUSIONS;
|
||||
if(INCLUSIONS[src] == null) {
|
||||
UnicodeSet incl = new UnicodeSet();
|
||||
switch(src) {
|
||||
case UCharacterProperty.SRC_PROPSVEC:
|
||||
UCharacterProperty.getInstance().upropsvec_addPropertyStarts(incl);
|
||||
break;
|
||||
default:
|
||||
throw new IllegalStateException("UnicodeSet.getInclusions(unknown src "+src+")");
|
||||
}
|
||||
INCLUSIONS[src] = incl;
|
||||
}
|
||||
return INCLUSIONS[src];
|
||||
}
|
||||
|
||||
/**
|
||||
* Generic filter-based scanning code for UCD property UnicodeSets.
|
||||
*/
|
||||
private UnicodeSet applyFilter(Filter filter) {
|
||||
private UnicodeSet applyFilter(Filter filter, int src) {
|
||||
// Walk through all Unicode characters, noting the start
|
||||
// and end of each range for which filter.contain(c) is
|
||||
// true. Add each range to a set.
|
||||
@ -1629,7 +1632,7 @@ public class UnicodeSet implements UnicodeMatcher {
|
||||
clear();
|
||||
|
||||
int startHasProperty = -1;
|
||||
UnicodeSet inclusions = getInclusions();
|
||||
UnicodeSet inclusions = getInclusions(src);
|
||||
int limitRange = inclusions.getRangeCount();
|
||||
|
||||
for (int j=0; j<limitRange; ++j) {
|
||||
@ -1646,19 +1649,18 @@ public class UnicodeSet implements UnicodeMatcher {
|
||||
startHasProperty = ch;
|
||||
}
|
||||
} else if (startHasProperty >= 0) {
|
||||
add(startHasProperty, ch-1);
|
||||
add_unchecked(startHasProperty, ch-1);
|
||||
startHasProperty = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (startHasProperty >= 0) {
|
||||
add(startHasProperty, 0x10FFFF);
|
||||
add_unchecked(startHasProperty, 0x10FFFF);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Remove leading and trailing rule white space and compress
|
||||
* internal rule white space to a single space character.
|
||||
@ -1686,10 +1688,6 @@ public class UnicodeSet implements UnicodeMatcher {
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------
|
||||
// Property set API
|
||||
//----------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Modifies this set to contain those code points which have the
|
||||
* given value for the given property. Prior contents of this
|
||||
@ -1699,22 +1697,21 @@ public class UnicodeSet implements UnicodeMatcher {
|
||||
* @param symbols if not null, then symbols are first called to see if a property
|
||||
* is available. If true, then everything else is skipped.
|
||||
* @return this set
|
||||
* @draft ICU 3.2
|
||||
* @deprecated This is a draft API and might change in a future release of ICU.
|
||||
* @stable ICU 3.2
|
||||
*/
|
||||
public UnicodeSet applyPropertyAlias(String propertyAlias,
|
||||
String valueAlias, SymbolTable symbols) {
|
||||
if (propertyAlias.equals("Age"))
|
||||
{
|
||||
// Must munge name, since
|
||||
// VersionInfo.getInstance() does not do
|
||||
// 'loose' matching.
|
||||
VersionInfo version = VersionInfo.getInstance(mungeCharName(valueAlias));
|
||||
applyFilter(new VersionFilter(version));
|
||||
return this;
|
||||
}
|
||||
else
|
||||
throw new IllegalArgumentException("Unsupported property");
|
||||
if (valueAlias.length() > 0) {
|
||||
if (propertyAlias.equals("Age")) {
|
||||
// Must munge name, since
|
||||
// VersionInfo.getInstance() does not do
|
||||
// 'loose' matching.
|
||||
VersionInfo version = VersionInfo.getInstance(mungeCharName(valueAlias));
|
||||
applyFilter(new VersionFilter(version), UCharacterProperty.SRC_PROPSVEC);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
throw new IllegalArgumentException("Unsupported property: " + propertyAlias);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1840,14 +1837,14 @@ public class UnicodeSet implements UnicodeMatcher {
|
||||
*/
|
||||
private void applyPropertyPattern(RuleCharacterIterator chars,
|
||||
StringBuffer rebuiltPat, SymbolTable symbols) {
|
||||
String pat = chars.lookahead();
|
||||
String patStr = chars.lookahead();
|
||||
ParsePosition pos = new ParsePosition(0);
|
||||
applyPropertyPattern(pat, pos, symbols);
|
||||
applyPropertyPattern(patStr, pos, symbols);
|
||||
if (pos.getIndex() == 0) {
|
||||
syntaxError(chars, "Invalid property pattern");
|
||||
}
|
||||
chars.jumpahead(pos.getIndex());
|
||||
rebuiltPat.append(pat.substring(0, pos.getIndex()));
|
||||
rebuiltPat.append(patStr.substring(0, pos.getIndex()));
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------
|
||||
@ -1860,8 +1857,9 @@ public class UnicodeSet implements UnicodeMatcher {
|
||||
* which UCharacterProperty.isRuleWhiteSpace() returns true,
|
||||
* unless they are quoted or escaped. This may be ORed together
|
||||
* with other selectors.
|
||||
* @internal
|
||||
* @stable ICU 3.8
|
||||
*/
|
||||
public static final int IGNORE_SPACE = 1;
|
||||
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Portions Copyright 2005 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* Portions Copyright 2005-2009 Sun Microsystems, Inc. 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
|
||||
@ -22,10 +22,9 @@
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
*******************************************************************************
|
||||
* (C) Copyright IBM Corp. 1996-2005 - All Rights Reserved *
|
||||
* (C) Copyright IBM Corp. and others, 1996-2009 - All Rights Reserved *
|
||||
* *
|
||||
* The original version of this source code and documentation is copyrighted *
|
||||
* and owned by IBM, These materials are provided under terms of a License *
|
||||
@ -167,8 +166,8 @@ public class UnicodeSetIterator {
|
||||
* @param set the set to iterate over.
|
||||
* @stable ICU 2.0
|
||||
*/
|
||||
public void reset(UnicodeSet set) {
|
||||
this.set = set;
|
||||
public void reset(UnicodeSet uset) {
|
||||
set = uset;
|
||||
reset();
|
||||
}
|
||||
|
||||
@ -213,8 +212,8 @@ public class UnicodeSetIterator {
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
protected void loadRange(int range) {
|
||||
nextElement = set.getRangeStart(range);
|
||||
endElement = set.getRangeEnd(range);
|
||||
protected void loadRange(int aRange) {
|
||||
nextElement = set.getRangeStart(aRange);
|
||||
endElement = set.getRangeEnd(aRange);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Portions Copyright 2005 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* Portions Copyright 2005-2009 Sun Microsystems, Inc. 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
|
||||
@ -24,7 +24,7 @@
|
||||
*/
|
||||
/*
|
||||
*******************************************************************************
|
||||
* (C) Copyright IBM Corp. 1996-2005 - All Rights Reserved *
|
||||
* (C) Copyright IBM Corp. and others, 1996-2009 - All Rights Reserved *
|
||||
* *
|
||||
* The original version of this source code and documentation is copyrighted *
|
||||
* and owned by IBM, These materials are provided under terms of a License *
|
||||
@ -36,10 +36,27 @@
|
||||
|
||||
package sun.text.normalizer;
|
||||
|
||||
// This class contains utility functions so testing not needed
|
||||
///CLOVER:OFF
|
||||
public final class Utility {
|
||||
|
||||
/**
|
||||
* Convenience utility to compare two Object[]s
|
||||
* Ought to be in System.
|
||||
* @param len the length to compare.
|
||||
* The start indices and start+len must be valid.
|
||||
*/
|
||||
public final static boolean arrayRegionMatches(char[] source, int sourceStart,
|
||||
char[] target, int targetStart,
|
||||
int len)
|
||||
{
|
||||
int sourceEnd = sourceStart + len;
|
||||
int delta = targetStart - sourceStart;
|
||||
for (int i = sourceStart; i < sourceEnd; i++) {
|
||||
if (source[i]!=target[i + delta])
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert characters outside the range U+0020 to U+007F to
|
||||
* Unicode escapes, and convert backslash to a double backslash.
|
||||
@ -344,7 +361,6 @@ public final class Utility {
|
||||
return false;
|
||||
}
|
||||
|
||||
//// for StringPrep
|
||||
/**
|
||||
* Similar to StringBuffer.getChars, version 1.3.
|
||||
* Since JDK 1.2 implements StringBuffer.getChars differently, this method
|
||||
@ -356,7 +372,6 @@ public final class Utility {
|
||||
* @param dst char array to store the retrieved chars
|
||||
* @param dstBegin offset to the start of the destination char array to
|
||||
* store the retrieved chars
|
||||
* @draft since ICU4J 2.0
|
||||
*/
|
||||
public static void getChars(StringBuffer src, int srcBegin, int srcEnd,
|
||||
char dst[], int dstBegin)
|
||||
@ -367,23 +382,4 @@ public final class Utility {
|
||||
src.getChars(srcBegin, srcEnd, dst, dstBegin);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience utility to compare two char[]s.
|
||||
* @param len the length to compare.
|
||||
* The start indices and start+len must be valid.
|
||||
*/
|
||||
public final static boolean arrayRegionMatches(char[] source, int sourceStart,
|
||||
char[] target, int targetStart,
|
||||
int len)
|
||||
{
|
||||
int sourceEnd = sourceStart + len;
|
||||
int delta = targetStart - sourceStart;
|
||||
for (int i = sourceStart; i < sourceEnd; i++) {
|
||||
if (source[i] != target[i + delta])
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
///CLOVER:ON
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Portions Copyright 2005-2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* Portions Copyright 2005-2009 Sun Microsystems, Inc. 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
|
||||
@ -24,7 +24,7 @@
|
||||
*/
|
||||
/*
|
||||
*******************************************************************************
|
||||
* (C) Copyright IBM Corp. 1996-2005 - All Rights Reserved *
|
||||
* (C) Copyright IBM Corp. and others, 1996-2009 - All Rights Reserved *
|
||||
* *
|
||||
* The original version of this source code and documentation is copyrighted *
|
||||
* and owned by IBM, These materials are provided under terms of a License *
|
||||
|
BIN
jdk/src/share/classes/sun/text/resources/ubidi.icu
Normal file
BIN
jdk/src/share/classes/sun/text/resources/ubidi.icu
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -93,6 +93,7 @@ static int gtk2_pixbuf_height = 0;
|
||||
/* Static buffer for conversion from java.lang.String to UTF-8 */
|
||||
static char convertionBuffer[CONV_BUFFER_SIZE];
|
||||
|
||||
static gboolean new_combo = TRUE;
|
||||
const char ENV_PREFIX[] = "GTK_MODULES=";
|
||||
|
||||
/*******************/
|
||||
@ -608,6 +609,7 @@ gboolean gtk2_load()
|
||||
dlsym(gtk2_libhandle, "gtk_combo_box_entry_new");
|
||||
if (fp_gtk_combo_box_entry_new == NULL) {
|
||||
fp_gtk_combo_box_entry_new = dl_symbol("gtk_combo_new");
|
||||
new_combo = FALSE;
|
||||
}
|
||||
|
||||
fp_gtk_separator_tool_item_new =
|
||||
@ -1423,17 +1425,13 @@ static GtkWidget *gtk2_get_widget(WidgetType widget_type)
|
||||
*/
|
||||
GtkWidget *combo = (*fp_gtk_combo_box_entry_new)();
|
||||
|
||||
if (widget_type == COMBO_BOX_TEXT_FIELD)
|
||||
(*fp_gtk_container_add)((GtkContainer *)combo, result);
|
||||
else
|
||||
{
|
||||
if (new_combo && widget_type == COMBO_BOX_ARROW_BUTTON) {
|
||||
(*fp_gtk_widget_set_parent)(result, combo);
|
||||
((GtkBin*)combo)->child = result;
|
||||
} else {
|
||||
(*fp_gtk_container_add)((GtkContainer *)combo, result);
|
||||
}
|
||||
|
||||
(*fp_gtk_container_add)((GtkContainer *)gtk2_fixed, combo);
|
||||
(*fp_gtk_widget_realize)(result);
|
||||
return result;
|
||||
}
|
||||
else if (widget_type != TOOL_TIP &&
|
||||
widget_type != INTERNAL_FRAME &&
|
||||
|
@ -32,6 +32,7 @@ import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.*;
|
||||
import javax.swing.SwingConstants;
|
||||
|
||||
// NOTE: This class supersedes Win32ShellFolder, which was removed from
|
||||
@ -184,15 +185,20 @@ final class Win32ShellFolder2 extends ShellFolder {
|
||||
boolean disposed;
|
||||
public void dispose() {
|
||||
if (disposed) return;
|
||||
if (relativePIDL != 0) {
|
||||
releasePIDL(relativePIDL);
|
||||
}
|
||||
if (absolutePIDL != 0) {
|
||||
releasePIDL(absolutePIDL);
|
||||
}
|
||||
if (pIShellFolder != 0) {
|
||||
releaseIShellFolder(pIShellFolder);
|
||||
}
|
||||
ShellFolder.getInvoker().invoke(new Callable<Void>() {
|
||||
public Void call() throws Exception {
|
||||
if (relativePIDL != 0) {
|
||||
releasePIDL(relativePIDL);
|
||||
}
|
||||
if (absolutePIDL != 0) {
|
||||
releasePIDL(absolutePIDL);
|
||||
}
|
||||
if (pIShellFolder != 0) {
|
||||
releaseIShellFolder(pIShellFolder);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
});
|
||||
disposed = true;
|
||||
}
|
||||
}
|
||||
@ -218,50 +224,59 @@ final class Win32ShellFolder2 extends ShellFolder {
|
||||
*/
|
||||
private boolean isPersonal;
|
||||
|
||||
private static String composePathForCsidl(int csidl) throws IOException {
|
||||
String path = getFileSystemPath(csidl);
|
||||
return path == null
|
||||
? ("ShellFolder: 0x" + Integer.toHexString(csidl))
|
||||
: path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a system special shell folder, such as the
|
||||
* desktop or Network Neighborhood.
|
||||
*/
|
||||
Win32ShellFolder2(int csidl) throws IOException {
|
||||
Win32ShellFolder2(final int csidl) throws IOException {
|
||||
// Desktop is parent of DRIVES and NETWORK, not necessarily
|
||||
// other special shell folders.
|
||||
super(null,
|
||||
(getFileSystemPath(csidl) == null)
|
||||
? ("ShellFolder: 0x"+Integer.toHexString(csidl)) : getFileSystemPath(csidl));
|
||||
if (csidl == DESKTOP) {
|
||||
initDesktop();
|
||||
} else {
|
||||
initSpecial(getDesktop().getIShellFolder(), csidl);
|
||||
// At this point, the native method initSpecial() has set our relativePIDL
|
||||
// relative to the Desktop, which may not be our immediate parent. We need
|
||||
// to traverse this ID list and break it into a chain of shell folders from
|
||||
// the top, with each one having an immediate parent and a relativePIDL
|
||||
// relative to that parent.
|
||||
long pIDL = disposer.relativePIDL;
|
||||
parent = getDesktop();
|
||||
while (pIDL != 0) {
|
||||
// Get a child pidl relative to 'parent'
|
||||
long childPIDL = copyFirstPIDLEntry(pIDL);
|
||||
if (childPIDL != 0) {
|
||||
// Get a handle to the the rest of the ID list
|
||||
// i,e, parent's grandchilren and down
|
||||
pIDL = getNextPIDLEntry(pIDL);
|
||||
if (pIDL != 0) {
|
||||
// Now we know that parent isn't immediate to 'this' because it
|
||||
// has a continued ID list. Create a shell folder for this child
|
||||
// pidl and make it the new 'parent'.
|
||||
parent = new Win32ShellFolder2((Win32ShellFolder2)parent, childPIDL);
|
||||
} else {
|
||||
// No grandchildren means we have arrived at the parent of 'this',
|
||||
// and childPIDL is directly relative to parent.
|
||||
disposer.relativePIDL = childPIDL;
|
||||
}
|
||||
super(null, composePathForCsidl(csidl));
|
||||
ShellFolder.getInvoker().invoke(new Callable<Void>() {
|
||||
public Void call() throws Exception {
|
||||
if (csidl == DESKTOP) {
|
||||
initDesktop();
|
||||
} else {
|
||||
break;
|
||||
initSpecial(getDesktop().getIShellFolder(), csidl);
|
||||
// At this point, the native method initSpecial() has set our relativePIDL
|
||||
// relative to the Desktop, which may not be our immediate parent. We need
|
||||
// to traverse this ID list and break it into a chain of shell folders from
|
||||
// the top, with each one having an immediate parent and a relativePIDL
|
||||
// relative to that parent.
|
||||
long pIDL = disposer.relativePIDL;
|
||||
parent = getDesktop();
|
||||
while (pIDL != 0) {
|
||||
// Get a child pidl relative to 'parent'
|
||||
long childPIDL = copyFirstPIDLEntry(pIDL);
|
||||
if (childPIDL != 0) {
|
||||
// Get a handle to the the rest of the ID list
|
||||
// i,e, parent's grandchilren and down
|
||||
pIDL = getNextPIDLEntry(pIDL);
|
||||
if (pIDL != 0) {
|
||||
// Now we know that parent isn't immediate to 'this' because it
|
||||
// has a continued ID list. Create a shell folder for this child
|
||||
// pidl and make it the new 'parent'.
|
||||
parent = new Win32ShellFolder2((Win32ShellFolder2) parent, childPIDL);
|
||||
} else {
|
||||
// No grandchildren means we have arrived at the parent of 'this',
|
||||
// and childPIDL is directly relative to parent.
|
||||
disposer.relativePIDL = childPIDL;
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
sun.java2d.Disposer.addRecord(this, disposer);
|
||||
}
|
||||
@ -281,17 +296,26 @@ final class Win32ShellFolder2 extends ShellFolder {
|
||||
/**
|
||||
* Creates a shell folder with a parent and relative PIDL
|
||||
*/
|
||||
Win32ShellFolder2(Win32ShellFolder2 parent, long relativePIDL) {
|
||||
super(parent, getFileSystemPath(parent.getIShellFolder(), relativePIDL));
|
||||
Win32ShellFolder2(final Win32ShellFolder2 parent, final long relativePIDL) {
|
||||
super(parent,
|
||||
ShellFolder.getInvoker().invoke(new Callable<String>() {
|
||||
public String call() throws Exception {
|
||||
return getFileSystemPath(parent.getIShellFolder(), relativePIDL);
|
||||
}
|
||||
})
|
||||
);
|
||||
this.disposer.relativePIDL = relativePIDL;
|
||||
getAbsolutePath();
|
||||
sun.java2d.Disposer.addRecord(this, disposer);
|
||||
}
|
||||
|
||||
// Initializes the desktop shell folder
|
||||
// NOTE: this method uses COM and must be called on the 'COM thread'. See ComInvoker for the details
|
||||
private native void initDesktop();
|
||||
|
||||
// Initializes a special, non-file system shell folder
|
||||
// from one of the above constants
|
||||
// NOTE: this method uses COM and must be called on the 'COM thread'. See ComInvoker for the details
|
||||
private native void initSpecial(long desktopIShellFolder, int csidl);
|
||||
|
||||
/** Marks this folder as being the My Documents (Personal) folder */
|
||||
@ -311,26 +335,30 @@ final class Win32ShellFolder2 extends ShellFolder {
|
||||
* drive (normally "C:\").
|
||||
*/
|
||||
protected Object writeReplace() throws java.io.ObjectStreamException {
|
||||
if (isFileSystem()) {
|
||||
return new File(getPath());
|
||||
} else {
|
||||
Win32ShellFolder2 drives = Win32ShellFolderManager2.getDrives();
|
||||
if (drives != null) {
|
||||
File[] driveRoots = drives.listFiles();
|
||||
if (driveRoots != null) {
|
||||
for (int i = 0; i < driveRoots.length; i++) {
|
||||
if (driveRoots[i] instanceof Win32ShellFolder2) {
|
||||
Win32ShellFolder2 sf = (Win32ShellFolder2)driveRoots[i];
|
||||
if (sf.isFileSystem() && !sf.hasAttribute(ATTRIB_REMOVABLE)) {
|
||||
return new File(sf.getPath());
|
||||
return ShellFolder.getInvoker().invoke(new Callable<File>() {
|
||||
public File call() throws Exception {
|
||||
if (isFileSystem()) {
|
||||
return new File(getPath());
|
||||
} else {
|
||||
Win32ShellFolder2 drives = Win32ShellFolderManager2.getDrives();
|
||||
if (drives != null) {
|
||||
File[] driveRoots = drives.listFiles();
|
||||
if (driveRoots != null) {
|
||||
for (int i = 0; i < driveRoots.length; i++) {
|
||||
if (driveRoots[i] instanceof Win32ShellFolder2) {
|
||||
Win32ShellFolder2 sf = (Win32ShellFolder2) driveRoots[i];
|
||||
if (sf.isFileSystem() && !sf.hasAttribute(ATTRIB_REMOVABLE)) {
|
||||
return new File(sf.getPath());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Ouch, we have no hard drives. Return something "valid" anyway.
|
||||
return new File("C:\\");
|
||||
}
|
||||
}
|
||||
// Ouch, we have no hard drives. Return something "valid" anyway.
|
||||
return new File("C:\\");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -364,6 +392,7 @@ final class Win32ShellFolder2 extends ShellFolder {
|
||||
static native void releasePIDL(long pIDL);
|
||||
|
||||
// Release an IShellFolder object
|
||||
// NOTE: this method uses COM and must be called on the 'COM thread'. See ComInvoker for the details
|
||||
private static native void releaseIShellFolder(long pIShellFolder);
|
||||
|
||||
/**
|
||||
@ -371,18 +400,28 @@ final class Win32ShellFolder2 extends ShellFolder {
|
||||
*/
|
||||
public long getIShellFolder() {
|
||||
if (disposer.pIShellFolder == 0) {
|
||||
assert(isDirectory());
|
||||
assert(parent != null);
|
||||
long parentIShellFolder = getParentIShellFolder();
|
||||
if (parentIShellFolder == 0) {
|
||||
throw new InternalError("Parent IShellFolder was null for " + getAbsolutePath());
|
||||
}
|
||||
// We are a directory with a parent and a relative PIDL.
|
||||
// We want to bind to the parent so we get an IShellFolder instance associated with us.
|
||||
disposer.pIShellFolder = bindToObject(parentIShellFolder, disposer.relativePIDL);
|
||||
if (disposer.pIShellFolder == 0) {
|
||||
throw new InternalError("Unable to bind " + getAbsolutePath() + " to parent");
|
||||
}
|
||||
disposer.pIShellFolder =
|
||||
ShellFolder.getInvoker().invoke(new Callable<Long>() {
|
||||
public Long call() throws Exception {
|
||||
assert(isDirectory());
|
||||
assert(parent != null);
|
||||
long parentIShellFolder = getParentIShellFolder();
|
||||
if (parentIShellFolder == 0) {
|
||||
throw new InternalError("Parent IShellFolder was null for "
|
||||
+ getAbsolutePath());
|
||||
}
|
||||
// We are a directory with a parent and a relative PIDL.
|
||||
// We want to bind to the parent so we get an
|
||||
// IShellFolder instance associated with us.
|
||||
long pIShellFolder = bindToObject(parentIShellFolder,
|
||||
disposer.relativePIDL);
|
||||
if (pIShellFolder == 0) {
|
||||
throw new InternalError("Unable to bind "
|
||||
+ getAbsolutePath() + " to parent");
|
||||
}
|
||||
return pIShellFolder;
|
||||
}
|
||||
});
|
||||
}
|
||||
return disposer.pIShellFolder;
|
||||
}
|
||||
@ -472,24 +511,42 @@ final class Win32ShellFolder2 extends ShellFolder {
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean pidlsEqual(long pIShellFolder, long pidl1, long pidl2) {
|
||||
return (compareIDs(pIShellFolder, pidl1, pidl2) == 0);
|
||||
private static boolean pidlsEqual(final long pIShellFolder, final long pidl1, final long pidl2) {
|
||||
return ShellFolder.getInvoker().invoke(new Callable<Boolean>() {
|
||||
public Boolean call() throws Exception {
|
||||
return (compareIDs(pIShellFolder, pidl1, pidl2) == 0);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// NOTE: this method uses COM and must be called on the 'COM thread'. See ComInvoker for the details
|
||||
private static native int compareIDs(long pParentIShellFolder, long pidl1, long pidl2);
|
||||
|
||||
private Boolean cachedIsFileSystem;
|
||||
|
||||
/**
|
||||
* @return Whether this is a file system shell folder
|
||||
*/
|
||||
public boolean isFileSystem() {
|
||||
return hasAttribute(ATTRIB_FILESYSTEM);
|
||||
public synchronized boolean isFileSystem() {
|
||||
if (cachedIsFileSystem == null) {
|
||||
cachedIsFileSystem = hasAttribute(ATTRIB_FILESYSTEM);
|
||||
}
|
||||
|
||||
return cachedIsFileSystem;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether the given attribute flag is set for this object
|
||||
*/
|
||||
public boolean hasAttribute(int attribute) {
|
||||
// Caching at this point doesn't seem to be cost efficient
|
||||
return (getAttributes0(getParentIShellFolder(), getRelativePIDL(), attribute) & attribute) != 0;
|
||||
public boolean hasAttribute(final int attribute) {
|
||||
return ShellFolder.getInvoker().invoke(new Callable<Boolean>() {
|
||||
public Boolean call() throws Exception {
|
||||
// Caching at this point doesn't seem to be cost efficient
|
||||
return (getAttributes0(getParentIShellFolder(),
|
||||
getRelativePIDL(), attribute)
|
||||
& attribute) != 0;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@ -498,26 +555,42 @@ final class Win32ShellFolder2 extends ShellFolder {
|
||||
* Could plausibly be used for attribute caching but have to be
|
||||
* very careful not to touch network drives and file system roots
|
||||
* with a full attrsMask
|
||||
* NOTE: this method uses COM and must be called on the 'COM thread'. See ComInvoker for the details
|
||||
*/
|
||||
|
||||
private static native int getAttributes0(long pParentIShellFolder, long pIDL, int attrsMask);
|
||||
|
||||
// Return the path to the underlying file system object
|
||||
private static String getFileSystemPath(long parentIShellFolder, long relativePIDL) {
|
||||
int linkedFolder = ATTRIB_LINK | ATTRIB_FOLDER;
|
||||
if (parentIShellFolder == Win32ShellFolderManager2.getNetwork().getIShellFolder() &&
|
||||
getAttributes0(parentIShellFolder, relativePIDL, linkedFolder) == linkedFolder) {
|
||||
private static String getFileSystemPath(final long parentIShellFolder, final long relativePIDL) {
|
||||
return ShellFolder.getInvoker().invoke(new Callable<String>() {
|
||||
public String call() throws Exception {
|
||||
int linkedFolder = ATTRIB_LINK | ATTRIB_FOLDER;
|
||||
if (parentIShellFolder == Win32ShellFolderManager2.getNetwork().getIShellFolder() &&
|
||||
getAttributes0(parentIShellFolder, relativePIDL, linkedFolder) == linkedFolder) {
|
||||
|
||||
String s =
|
||||
getFileSystemPath(Win32ShellFolderManager2.getDesktop().getIShellFolder(),
|
||||
getLinkLocation(parentIShellFolder, relativePIDL, false));
|
||||
if (s != null && s.startsWith("\\\\")) {
|
||||
return s;
|
||||
String s =
|
||||
getFileSystemPath(Win32ShellFolderManager2.getDesktop().getIShellFolder(),
|
||||
getLinkLocation(parentIShellFolder, relativePIDL, false));
|
||||
if (s != null && s.startsWith("\\\\")) {
|
||||
return s;
|
||||
}
|
||||
}
|
||||
return getDisplayNameOf(parentIShellFolder, relativePIDL, SHGDN_FORPARSING);
|
||||
}
|
||||
}
|
||||
return getDisplayNameOf(parentIShellFolder, relativePIDL, SHGDN_NORMAL | SHGDN_FORPARSING);
|
||||
});
|
||||
}
|
||||
|
||||
// Needs to be accessible to Win32ShellFolderManager2
|
||||
static native String getFileSystemPath(int csidl) throws IOException;
|
||||
static String getFileSystemPath(final int csidl) throws IOException {
|
||||
return ShellFolder.getInvoker().invoke(new Callable<String>() {
|
||||
public String call() throws Exception {
|
||||
return getFileSystemPath0(csidl);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// NOTE: this method uses COM and must be called on the 'COM thread'. See ComInvoker for the details
|
||||
private static native String getFileSystemPath0(int csidl) throws IOException;
|
||||
|
||||
// Return whether the path is a network root.
|
||||
// Path is assumed to be non-null
|
||||
@ -557,24 +630,33 @@ final class Win32ShellFolder2 extends ShellFolder {
|
||||
*/
|
||||
// Returns an IEnumIDList interface for an IShellFolder. The value
|
||||
// returned must be released using releaseEnumObjects().
|
||||
private long getEnumObjects(long pIShellFolder, boolean includeHiddenFiles) {
|
||||
boolean isDesktop = (disposer.pIShellFolder == getDesktopIShellFolder());
|
||||
return getEnumObjects(disposer.pIShellFolder, isDesktop, includeHiddenFiles);
|
||||
private long getEnumObjects(long pIShellFolder, final boolean includeHiddenFiles) {
|
||||
final boolean isDesktop = (disposer.pIShellFolder == getDesktopIShellFolder());
|
||||
return ShellFolder.getInvoker().invoke(new Callable<Long>() {
|
||||
public Long call() throws Exception {
|
||||
return getEnumObjects(disposer.pIShellFolder, isDesktop, includeHiddenFiles);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Returns an IEnumIDList interface for an IShellFolder. The value
|
||||
// returned must be released using releaseEnumObjects().
|
||||
// NOTE: this method uses COM and must be called on the 'COM thread'. See ComInvoker for the details
|
||||
private native long getEnumObjects(long pIShellFolder, boolean isDesktop,
|
||||
boolean includeHiddenFiles);
|
||||
// Returns the next sequential child as a relative PIDL
|
||||
// from an IEnumIDList interface. The value returned must
|
||||
// be released using releasePIDL().
|
||||
// NOTE: this method uses COM and must be called on the 'COM thread'. See ComInvoker for the details
|
||||
private native long getNextChild(long pEnumObjects);
|
||||
// Releases the IEnumIDList interface
|
||||
// NOTE: this method uses COM and must be called on the 'COM thread'. See ComInvoker for the details
|
||||
private native void releaseEnumObjects(long pEnumObjects);
|
||||
|
||||
// Returns the IShellFolder of a child from a parent IShellFolder
|
||||
// and a relative PIDL. The value returned must be released
|
||||
// using releaseIShellFolder().
|
||||
// NOTE: this method uses COM and must be called on the 'COM thread'. See ComInvoker for the details
|
||||
private static native long bindToObject(long parentIShellFolder, long pIDL);
|
||||
|
||||
/**
|
||||
@ -582,60 +664,64 @@ final class Win32ShellFolder2 extends ShellFolder {
|
||||
* object. The array will be empty if the folder is empty. Returns
|
||||
* <code>null</code> if this shellfolder does not denote a directory.
|
||||
*/
|
||||
public File[] listFiles(boolean includeHiddenFiles) {
|
||||
public File[] listFiles(final boolean includeHiddenFiles) {
|
||||
SecurityManager security = System.getSecurityManager();
|
||||
if (security != null) {
|
||||
security.checkRead(getPath());
|
||||
}
|
||||
if (!isDirectory()) {
|
||||
return null;
|
||||
}
|
||||
// Links to directories are not directories and cannot be parents.
|
||||
// This does not apply to folders in My Network Places (NetHood)
|
||||
// because they are both links and real directories!
|
||||
if (isLink() && !hasAttribute(ATTRIB_FOLDER)) {
|
||||
return new File[0];
|
||||
}
|
||||
|
||||
Win32ShellFolder2 desktop = Win32ShellFolderManager2.getDesktop();
|
||||
Win32ShellFolder2 personal = Win32ShellFolderManager2.getPersonal();
|
||||
|
||||
// If we are a directory, we have a parent and (at least) a
|
||||
// relative PIDL. We must first ensure we are bound to the
|
||||
// parent so we have an IShellFolder to query.
|
||||
long pIShellFolder = getIShellFolder();
|
||||
// Now we can enumerate the objects in this folder.
|
||||
ArrayList<Win32ShellFolder2> list = new ArrayList<Win32ShellFolder2>();
|
||||
long pEnumObjects = getEnumObjects(pIShellFolder, includeHiddenFiles);
|
||||
if (pEnumObjects != 0) {
|
||||
long childPIDL;
|
||||
int testedAttrs = ATTRIB_FILESYSTEM | ATTRIB_FILESYSANCESTOR;
|
||||
do {
|
||||
if (Thread.currentThread().isInterrupted()) {
|
||||
return ShellFolder.getInvoker().invoke(new Callable<File[]>() {
|
||||
public File[] call() throws Exception {
|
||||
if (!isDirectory()) {
|
||||
return null;
|
||||
}
|
||||
// Links to directories are not directories and cannot be parents.
|
||||
// This does not apply to folders in My Network Places (NetHood)
|
||||
// because they are both links and real directories!
|
||||
if (isLink() && !hasAttribute(ATTRIB_FOLDER)) {
|
||||
return new File[0];
|
||||
}
|
||||
childPIDL = getNextChild(pEnumObjects);
|
||||
boolean releasePIDL = true;
|
||||
if (childPIDL != 0 &&
|
||||
(getAttributes0(pIShellFolder, childPIDL, testedAttrs) & testedAttrs) != 0) {
|
||||
Win32ShellFolder2 childFolder = null;
|
||||
if (this.equals(desktop)
|
||||
&& personal != null
|
||||
&& pidlsEqual(pIShellFolder, childPIDL, personal.disposer.relativePIDL)) {
|
||||
childFolder = personal;
|
||||
} else {
|
||||
childFolder = new Win32ShellFolder2(this, childPIDL);
|
||||
releasePIDL = false;
|
||||
}
|
||||
list.add(childFolder);
|
||||
|
||||
Win32ShellFolder2 desktop = Win32ShellFolderManager2.getDesktop();
|
||||
Win32ShellFolder2 personal = Win32ShellFolderManager2.getPersonal();
|
||||
|
||||
// If we are a directory, we have a parent and (at least) a
|
||||
// relative PIDL. We must first ensure we are bound to the
|
||||
// parent so we have an IShellFolder to query.
|
||||
long pIShellFolder = getIShellFolder();
|
||||
// Now we can enumerate the objects in this folder.
|
||||
ArrayList<Win32ShellFolder2> list = new ArrayList<Win32ShellFolder2>();
|
||||
long pEnumObjects = getEnumObjects(pIShellFolder, includeHiddenFiles);
|
||||
if (pEnumObjects != 0) {
|
||||
long childPIDL;
|
||||
int testedAttrs = ATTRIB_FILESYSTEM | ATTRIB_FILESYSANCESTOR;
|
||||
do {
|
||||
childPIDL = getNextChild(pEnumObjects);
|
||||
boolean releasePIDL = true;
|
||||
if (childPIDL != 0 &&
|
||||
(getAttributes0(pIShellFolder, childPIDL, testedAttrs) & testedAttrs) != 0) {
|
||||
Win32ShellFolder2 childFolder;
|
||||
if (Win32ShellFolder2.this.equals(desktop)
|
||||
&& personal != null
|
||||
&& pidlsEqual(pIShellFolder, childPIDL, personal.disposer.relativePIDL)) {
|
||||
childFolder = personal;
|
||||
} else {
|
||||
childFolder = new Win32ShellFolder2(Win32ShellFolder2.this, childPIDL);
|
||||
releasePIDL = false;
|
||||
}
|
||||
list.add(childFolder);
|
||||
}
|
||||
if (releasePIDL) {
|
||||
releasePIDL(childPIDL);
|
||||
}
|
||||
} while (childPIDL != 0 && !Thread.currentThread().isInterrupted());
|
||||
releaseEnumObjects(pEnumObjects);
|
||||
}
|
||||
if (releasePIDL) {
|
||||
releasePIDL(childPIDL);
|
||||
}
|
||||
} while (childPIDL != 0);
|
||||
releaseEnumObjects(pEnumObjects);
|
||||
}
|
||||
return list.toArray(new ShellFolder[list.size()]);
|
||||
return Thread.currentThread().isInterrupted()
|
||||
? new File[0]
|
||||
: list.toArray(new ShellFolder[list.size()]);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -644,33 +730,43 @@ final class Win32ShellFolder2 extends ShellFolder {
|
||||
*
|
||||
* @return The child shellfolder, or null if not found.
|
||||
*/
|
||||
Win32ShellFolder2 getChildByPath(String filePath) {
|
||||
long pIShellFolder = getIShellFolder();
|
||||
long pEnumObjects = getEnumObjects(pIShellFolder, true);
|
||||
Win32ShellFolder2 child = null;
|
||||
long childPIDL;
|
||||
Win32ShellFolder2 getChildByPath(final String filePath) {
|
||||
return ShellFolder.getInvoker().invoke(new Callable<Win32ShellFolder2>() {
|
||||
public Win32ShellFolder2 call() throws Exception {
|
||||
long pIShellFolder = getIShellFolder();
|
||||
long pEnumObjects = getEnumObjects(pIShellFolder, true);
|
||||
Win32ShellFolder2 child = null;
|
||||
long childPIDL = 0;
|
||||
|
||||
while ((childPIDL = getNextChild(pEnumObjects)) != 0) {
|
||||
if (getAttributes0(pIShellFolder, childPIDL, ATTRIB_FILESYSTEM) != 0) {
|
||||
String path = getFileSystemPath(pIShellFolder, childPIDL);
|
||||
if (path != null && path.equalsIgnoreCase(filePath)) {
|
||||
long childIShellFolder = bindToObject(pIShellFolder, childPIDL);
|
||||
child = new Win32ShellFolder2(this, childIShellFolder, childPIDL, path);
|
||||
break;
|
||||
while ((childPIDL = getNextChild(pEnumObjects)) != 0) {
|
||||
if (getAttributes0(pIShellFolder, childPIDL, ATTRIB_FILESYSTEM) != 0) {
|
||||
String path = getFileSystemPath(pIShellFolder, childPIDL);
|
||||
if (path != null && path.equalsIgnoreCase(filePath)) {
|
||||
long childIShellFolder = bindToObject(pIShellFolder, childPIDL);
|
||||
child = new Win32ShellFolder2(Win32ShellFolder2.this,
|
||||
childIShellFolder, childPIDL, path);
|
||||
break;
|
||||
}
|
||||
}
|
||||
releasePIDL(childPIDL);
|
||||
}
|
||||
releaseEnumObjects(pEnumObjects);
|
||||
return child;
|
||||
}
|
||||
releasePIDL(childPIDL);
|
||||
}
|
||||
releaseEnumObjects(pEnumObjects);
|
||||
return child;
|
||||
});
|
||||
}
|
||||
|
||||
private Boolean cachedIsLink;
|
||||
|
||||
/**
|
||||
* @return Whether this shell folder is a link
|
||||
*/
|
||||
public boolean isLink() {
|
||||
return hasAttribute(ATTRIB_LINK);
|
||||
public synchronized boolean isLink() {
|
||||
if (cachedIsLink == null) {
|
||||
cachedIsLink = hasAttribute(ATTRIB_LINK);
|
||||
}
|
||||
|
||||
return cachedIsLink;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -682,6 +778,7 @@ final class Win32ShellFolder2 extends ShellFolder {
|
||||
|
||||
|
||||
// Return the link location of a shell folder
|
||||
// NOTE: this method uses COM and must be called on the 'COM thread'. See ComInvoker for the details
|
||||
private static native long getLinkLocation(long parentIShellFolder,
|
||||
long relativePIDL, boolean resolve);
|
||||
|
||||
@ -693,38 +790,52 @@ final class Win32ShellFolder2 extends ShellFolder {
|
||||
return getLinkLocation(true);
|
||||
}
|
||||
|
||||
private ShellFolder getLinkLocation(boolean resolve) {
|
||||
if (!isLink()) {
|
||||
return null;
|
||||
}
|
||||
private ShellFolder getLinkLocation(final boolean resolve) {
|
||||
return ShellFolder.getInvoker().invoke(new Callable<ShellFolder>() {
|
||||
public ShellFolder call() throws Exception {
|
||||
if (!isLink()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
ShellFolder location = null;
|
||||
long linkLocationPIDL = getLinkLocation(getParentIShellFolder(),
|
||||
getRelativePIDL(), resolve);
|
||||
if (linkLocationPIDL != 0) {
|
||||
try {
|
||||
location =
|
||||
Win32ShellFolderManager2.createShellFolderFromRelativePIDL(getDesktop(),
|
||||
linkLocationPIDL);
|
||||
} catch (InternalError e) {
|
||||
// Could be a link to a non-bindable object, such as a network connection
|
||||
// TODO: getIShellFolder() should throw FileNotFoundException instead
|
||||
ShellFolder location = null;
|
||||
long linkLocationPIDL = getLinkLocation(getParentIShellFolder(),
|
||||
getRelativePIDL(), resolve);
|
||||
if (linkLocationPIDL != 0) {
|
||||
try {
|
||||
location =
|
||||
Win32ShellFolderManager2.createShellFolderFromRelativePIDL(getDesktop(),
|
||||
linkLocationPIDL);
|
||||
} catch (InternalError e) {
|
||||
// Could be a link to a non-bindable object, such as a network connection
|
||||
// TODO: getIShellFolder() should throw FileNotFoundException instead
|
||||
}
|
||||
}
|
||||
return location;
|
||||
}
|
||||
}
|
||||
return location;
|
||||
});
|
||||
}
|
||||
|
||||
// Parse a display name into a PIDL relative to the current IShellFolder.
|
||||
long parseDisplayName(String name) throws FileNotFoundException {
|
||||
long parseDisplayName(final String name) throws FileNotFoundException {
|
||||
try {
|
||||
return parseDisplayName0(getIShellFolder(), name);
|
||||
} catch (IOException e) {
|
||||
throw new FileNotFoundException("Could not find file " + name);
|
||||
return ShellFolder.getInvoker().invoke(new Callable<Long>() {
|
||||
public Long call() throws Exception {
|
||||
return parseDisplayName0(getIShellFolder(), name);
|
||||
}
|
||||
});
|
||||
} catch (RuntimeException e) {
|
||||
if (e.getCause() instanceof IOException) {
|
||||
throw new FileNotFoundException("Could not find file " + name);
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
// NOTE: this method uses COM and must be called on the 'COM thread'. See ComInvoker for the details
|
||||
private static native long parseDisplayName0(long pIShellFolder, String name) throws IOException;
|
||||
|
||||
// Return the display name of a shell folder
|
||||
// NOTE: this method uses COM and must be called on the 'COM thread'. See ComInvoker for the details
|
||||
private static native String getDisplayNameOf(long parentIShellFolder,
|
||||
long relativePIDL,
|
||||
int attrs);
|
||||
@ -734,12 +845,19 @@ final class Win32ShellFolder2 extends ShellFolder {
|
||||
*/
|
||||
public String getDisplayName() {
|
||||
if (displayName == null) {
|
||||
displayName = getDisplayNameOf(getParentIShellFolder(), getRelativePIDL(), SHGDN_NORMAL);
|
||||
displayName =
|
||||
ShellFolder.getInvoker().invoke(new Callable<String>() {
|
||||
public String call() throws Exception {
|
||||
return getDisplayNameOf(getParentIShellFolder(),
|
||||
getRelativePIDL(), SHGDN_NORMAL);
|
||||
}
|
||||
});
|
||||
}
|
||||
return displayName;
|
||||
}
|
||||
|
||||
// Return the folder type of a shell folder
|
||||
// NOTE: this method uses COM and must be called on the 'COM thread'. See ComInvoker for the details
|
||||
private static native String getFolderType(long pIDL);
|
||||
|
||||
/**
|
||||
@ -747,7 +865,13 @@ final class Win32ShellFolder2 extends ShellFolder {
|
||||
*/
|
||||
public String getFolderType() {
|
||||
if (folderType == null) {
|
||||
folderType = getFolderType(getAbsolutePIDL());
|
||||
final long absolutePIDL = getAbsolutePIDL();
|
||||
folderType =
|
||||
ShellFolder.getInvoker().invoke(new Callable<String>() {
|
||||
public String call() throws Exception {
|
||||
return getFolderType(absolutePIDL);
|
||||
}
|
||||
});
|
||||
}
|
||||
return folderType;
|
||||
}
|
||||
@ -774,11 +898,16 @@ final class Win32ShellFolder2 extends ShellFolder {
|
||||
private static Map smallLinkedSystemImages = new HashMap();
|
||||
private static Map largeLinkedSystemImages = new HashMap();
|
||||
|
||||
// NOTE: this method uses COM and must be called on the 'COM thread'. See ComInvoker for the details
|
||||
private static native long getIShellIcon(long pIShellFolder);
|
||||
|
||||
// NOTE: this method uses COM and must be called on the 'COM thread'. See ComInvoker for the details
|
||||
private static native int getIconIndex(long parentIShellIcon, long relativePIDL);
|
||||
|
||||
// Return the icon of a file system shell folder in the form of an HICON
|
||||
private static native long getIcon(String absolutePath, boolean getLargeIcon);
|
||||
|
||||
// NOTE: this method uses COM and must be called on the 'COM thread'. See ComInvoker for the details
|
||||
private static native long extractIcon(long parentIShellFolder, long relativePIDL,
|
||||
boolean getLargeIcon);
|
||||
|
||||
@ -799,7 +928,12 @@ final class Win32ShellFolder2 extends ShellFolder {
|
||||
|
||||
private long getIShellIcon() {
|
||||
if (pIShellIcon == -1L) {
|
||||
pIShellIcon = getIShellIcon(getIShellFolder());
|
||||
pIShellIcon =
|
||||
ShellFolder.getInvoker().invoke(new Callable<Long>() {
|
||||
public Long call() throws Exception {
|
||||
return getIShellIcon(getIShellFolder());
|
||||
}
|
||||
});
|
||||
}
|
||||
return pIShellIcon;
|
||||
}
|
||||
@ -850,50 +984,60 @@ final class Win32ShellFolder2 extends ShellFolder {
|
||||
/**
|
||||
* @return The icon image used to display this shell folder
|
||||
*/
|
||||
public Image getIcon(boolean getLargeIcon) {
|
||||
public Image getIcon(final boolean getLargeIcon) {
|
||||
Image icon = getLargeIcon ? largeIcon : smallIcon;
|
||||
if (icon == null) {
|
||||
long parentIShellIcon = (parent != null) ? ((Win32ShellFolder2)parent).getIShellIcon() : 0L;
|
||||
long relativePIDL = getRelativePIDL();
|
||||
icon =
|
||||
ShellFolder.getInvoker().invoke(new Callable<Image>() {
|
||||
public Image call() throws Exception {
|
||||
Image newIcon = null;
|
||||
if (isFileSystem()) {
|
||||
long parentIShellIcon = (parent != null)
|
||||
? ((Win32ShellFolder2) parent).getIShellIcon()
|
||||
: 0L;
|
||||
long relativePIDL = getRelativePIDL();
|
||||
|
||||
if (isFileSystem()) {
|
||||
// These are cached per type (using the index in the system image list)
|
||||
int index = getIconIndex(parentIShellIcon, relativePIDL);
|
||||
if (index > 0) {
|
||||
Map imageCache;
|
||||
if (isLink()) {
|
||||
imageCache = getLargeIcon ? largeLinkedSystemImages : smallLinkedSystemImages;
|
||||
} else {
|
||||
imageCache = getLargeIcon ? largeSystemImages : smallSystemImages;
|
||||
}
|
||||
icon = (Image)imageCache.get(Integer.valueOf(index));
|
||||
if (icon == null) {
|
||||
long hIcon = getIcon(getAbsolutePath(), getLargeIcon);
|
||||
icon = makeIcon(hIcon, getLargeIcon);
|
||||
disposeIcon(hIcon);
|
||||
if (icon != null) {
|
||||
imageCache.put(Integer.valueOf(index), icon);
|
||||
// These are cached per type (using the index in the system image list)
|
||||
int index = getIconIndex(parentIShellIcon, relativePIDL);
|
||||
if (index > 0) {
|
||||
Map imageCache;
|
||||
if (isLink()) {
|
||||
imageCache = getLargeIcon ? largeLinkedSystemImages : smallLinkedSystemImages;
|
||||
} else {
|
||||
imageCache = getLargeIcon ? largeSystemImages : smallSystemImages;
|
||||
}
|
||||
newIcon = (Image) imageCache.get(Integer.valueOf(index));
|
||||
if (newIcon == null) {
|
||||
long hIcon = getIcon(getAbsolutePath(), getLargeIcon);
|
||||
newIcon = makeIcon(hIcon, getLargeIcon);
|
||||
disposeIcon(hIcon);
|
||||
if (newIcon != null) {
|
||||
imageCache.put(Integer.valueOf(index), newIcon);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (newIcon == null) {
|
||||
// These are only cached per object
|
||||
long hIcon = extractIcon(getParentIShellFolder(),
|
||||
getRelativePIDL(), getLargeIcon);
|
||||
newIcon = makeIcon(hIcon, getLargeIcon);
|
||||
disposeIcon(hIcon);
|
||||
}
|
||||
|
||||
if (newIcon == null) {
|
||||
newIcon = Win32ShellFolder2.super.getIcon(getLargeIcon);
|
||||
}
|
||||
return newIcon;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (icon == null) {
|
||||
// These are only cached per object
|
||||
long hIcon = extractIcon(getParentIShellFolder(), getRelativePIDL(), getLargeIcon);
|
||||
icon = makeIcon(hIcon, getLargeIcon);
|
||||
disposeIcon(hIcon);
|
||||
}
|
||||
|
||||
});
|
||||
if (getLargeIcon) {
|
||||
largeIcon = icon;
|
||||
} else {
|
||||
smallIcon = icon;
|
||||
}
|
||||
}
|
||||
if (icon == null) {
|
||||
icon = super.getIcon(getLargeIcon);
|
||||
}
|
||||
return icon;
|
||||
}
|
||||
|
||||
@ -969,39 +1113,50 @@ final class Win32ShellFolder2 extends ShellFolder {
|
||||
private static final int LVCFMT_CENTER = 2;
|
||||
|
||||
public ShellFolderColumnInfo[] getFolderColumns() {
|
||||
ShellFolderColumnInfo[] columns = doGetColumnInfo(getIShellFolder());
|
||||
return ShellFolder.getInvoker().invoke(new Callable<ShellFolderColumnInfo[]>() {
|
||||
public ShellFolderColumnInfo[] call() throws Exception {
|
||||
ShellFolderColumnInfo[] columns = doGetColumnInfo(getIShellFolder());
|
||||
|
||||
if (columns != null) {
|
||||
List<ShellFolderColumnInfo> notNullColumns =
|
||||
new ArrayList<ShellFolderColumnInfo>();
|
||||
for (int i = 0; i < columns.length; i++) {
|
||||
ShellFolderColumnInfo column = columns[i];
|
||||
if (column != null) {
|
||||
column.setAlignment(column.getAlignment() == LVCFMT_RIGHT
|
||||
? SwingConstants.RIGHT
|
||||
: column.getAlignment() == LVCFMT_CENTER
|
||||
? SwingConstants.CENTER
|
||||
: SwingConstants.LEADING);
|
||||
if (columns != null) {
|
||||
List<ShellFolderColumnInfo> notNullColumns =
|
||||
new ArrayList<ShellFolderColumnInfo>();
|
||||
for (int i = 0; i < columns.length; i++) {
|
||||
ShellFolderColumnInfo column = columns[i];
|
||||
if (column != null) {
|
||||
column.setAlignment(column.getAlignment() == LVCFMT_RIGHT
|
||||
? SwingConstants.RIGHT
|
||||
: column.getAlignment() == LVCFMT_CENTER
|
||||
? SwingConstants.CENTER
|
||||
: SwingConstants.LEADING);
|
||||
|
||||
column.setComparator(new ColumnComparator(getIShellFolder(), i));
|
||||
column.setComparator(new ColumnComparator(getIShellFolder(), i));
|
||||
|
||||
notNullColumns.add(column);
|
||||
notNullColumns.add(column);
|
||||
}
|
||||
}
|
||||
columns = new ShellFolderColumnInfo[notNullColumns.size()];
|
||||
notNullColumns.toArray(columns);
|
||||
}
|
||||
return columns;
|
||||
}
|
||||
columns = new ShellFolderColumnInfo[notNullColumns.size()];
|
||||
notNullColumns.toArray(columns);
|
||||
}
|
||||
return columns;
|
||||
});
|
||||
}
|
||||
|
||||
public Object getFolderColumnValue(int column) {
|
||||
return doGetColumnValue(getParentIShellFolder(), getRelativePIDL(), column);
|
||||
public Object getFolderColumnValue(final int column) {
|
||||
return ShellFolder.getInvoker().invoke(new Callable<Object>() {
|
||||
public Object call() throws Exception {
|
||||
return doGetColumnValue(getParentIShellFolder(), getRelativePIDL(), column);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// NOTE: this method uses COM and must be called on the 'COM thread'. See ComInvoker for the details
|
||||
private native ShellFolderColumnInfo[] doGetColumnInfo(long iShellFolder2);
|
||||
|
||||
// NOTE: this method uses COM and must be called on the 'COM thread'. See ComInvoker for the details
|
||||
private native Object doGetColumnValue(long parentIShellFolder2, long childPIDL, int columnIdx);
|
||||
|
||||
// NOTE: this method uses COM and must be called on the 'COM thread'. See ComInvoker for the details
|
||||
private static native int compareIDsByColumn(long pParentIShellFolder, long pidl1, long pidl2, int columnIdx);
|
||||
|
||||
|
||||
@ -1020,17 +1175,20 @@ final class Win32ShellFolder2 extends ShellFolder {
|
||||
}
|
||||
|
||||
// compares 2 objects within this folder by the specified column
|
||||
public int compare(File o, File o1) {
|
||||
if (o instanceof Win32ShellFolder2
|
||||
&& o1 instanceof Win32ShellFolder2) {
|
||||
// delegates comparison to native method
|
||||
return compareIDsByColumn(parentIShellFolder,
|
||||
((Win32ShellFolder2) o).getRelativePIDL(),
|
||||
((Win32ShellFolder2) o1).getRelativePIDL(),
|
||||
columnIdx);
|
||||
}
|
||||
return 0;
|
||||
public int compare(final File o, final File o1) {
|
||||
return ShellFolder.getInvoker().invoke(new Callable<Integer>() {
|
||||
public Integer call() throws Exception {
|
||||
if (o instanceof Win32ShellFolder2
|
||||
&& o1 instanceof Win32ShellFolder2) {
|
||||
// delegates comparison to native method
|
||||
return compareIDsByColumn(parentIShellFolder,
|
||||
((Win32ShellFolder2) o).getRelativePIDL(),
|
||||
((Win32ShellFolder2) o1).getRelativePIDL(),
|
||||
columnIdx);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -31,7 +31,10 @@ import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.*;
|
||||
|
||||
import sun.security.action.LoadLibraryAction;
|
||||
|
||||
import static sun.awt.shell.Win32ShellFolder2.*;
|
||||
@ -408,4 +411,102 @@ public class Win32ShellFolderManager2 extends ShellFolderManager {
|
||||
return name1.compareTo(name2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Invoker createInvoker() {
|
||||
return new ComInvoker();
|
||||
}
|
||||
|
||||
private static class ComInvoker extends ThreadPoolExecutor implements ThreadFactory, ShellFolder.Invoker {
|
||||
private static Thread comThread;
|
||||
|
||||
private ComInvoker() {
|
||||
super(1, 1, 0, TimeUnit.DAYS, new LinkedBlockingQueue<Runnable>());
|
||||
allowCoreThreadTimeOut(false);
|
||||
setThreadFactory(this);
|
||||
final Runnable shutdownHook = new Runnable() {
|
||||
public void run() {
|
||||
AccessController.doPrivileged(new PrivilegedAction<Void>() {
|
||||
public Void run() {
|
||||
shutdownNow();
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
AccessController.doPrivileged(new PrivilegedAction<Void>() {
|
||||
public Void run() {
|
||||
Runtime.getRuntime().addShutdownHook(
|
||||
new Thread(shutdownHook)
|
||||
);
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public synchronized Thread newThread(final Runnable task) {
|
||||
final Runnable comRun = new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
initializeCom();
|
||||
task.run();
|
||||
} finally {
|
||||
uninitializeCom();
|
||||
}
|
||||
}
|
||||
};
|
||||
comThread =
|
||||
AccessController.doPrivileged(
|
||||
new PrivilegedAction<Thread>() {
|
||||
public Thread run() {
|
||||
/* The thread must be a member of a thread group
|
||||
* which will not get GCed before VM exit.
|
||||
* Make its parent the top-level thread group.
|
||||
*/
|
||||
ThreadGroup tg = Thread.currentThread().getThreadGroup();
|
||||
for (ThreadGroup tgn = tg;
|
||||
tgn != null;
|
||||
tg = tgn, tgn = tg.getParent());
|
||||
Thread thread = new Thread(tg, comRun, "Swing-Shell");
|
||||
thread.setDaemon(true);
|
||||
return thread;
|
||||
}
|
||||
}
|
||||
);
|
||||
return comThread;
|
||||
}
|
||||
|
||||
public <T> T invoke(Callable<T> task) {
|
||||
try {
|
||||
T result;
|
||||
if (Thread.currentThread() == comThread) {
|
||||
// if it's already called from the COM
|
||||
// thread, we don't need to delegate the task
|
||||
result = task.call();
|
||||
} else {
|
||||
Future<T> future = submit(task);
|
||||
try {
|
||||
result = future.get();
|
||||
} catch (InterruptedException e) {
|
||||
result = null;
|
||||
future.cancel(true);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
} catch (Exception e) {
|
||||
Throwable cause = (e instanceof ExecutionException) ? e.getCause() : e;
|
||||
if (cause instanceof RuntimeException) {
|
||||
throw (RuntimeException) cause;
|
||||
}
|
||||
if (cause instanceof Error) {
|
||||
throw (Error) cause;
|
||||
}
|
||||
throw new RuntimeException(cause);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static native void initializeCom();
|
||||
|
||||
static native void uninitializeCom();
|
||||
}
|
||||
|
@ -225,6 +225,34 @@ JNIEXPORT void JNICALL Java_sun_awt_shell_Win32ShellFolder2_initIDs
|
||||
FID_folderType = env->GetFieldID(cls, "folderType", "Ljava/lang/String;");
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Class: sun_awt_shell_Win32ShellFolderManager2
|
||||
* Method: initializeCom
|
||||
* Signature: ()V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_sun_awt_shell_Win32ShellFolderManager2_initializeCom
|
||||
(JNIEnv* env, jclass cls)
|
||||
{
|
||||
HRESULT hr = ::CoInitialize(NULL);
|
||||
if (FAILED(hr)) {
|
||||
char c[64];
|
||||
sprintf(c, "Could not initialize COM: HRESULT=0x%08X", hr);
|
||||
JNU_ThrowInternalError(env, c);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: sun_awt_shell_Win32ShellFolderManager2
|
||||
* Method: uninitializeCom
|
||||
* Signature: ()V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_sun_awt_shell_Win32ShellFolderManager2_uninitializeCom
|
||||
(JNIEnv* env, jclass cls)
|
||||
{
|
||||
::CoUninitialize();
|
||||
}
|
||||
|
||||
static IShellIcon* getIShellIcon(IShellFolder* pIShellFolder) {
|
||||
// http://msdn.microsoft.com/library/en-us/shellcc/platform/Shell/programmersguide/shell_int/shell_int_programming/std_ifaces.asp
|
||||
HRESULT hres;
|
||||
@ -239,29 +267,6 @@ static IShellIcon* getIShellIcon(IShellFolder* pIShellFolder) {
|
||||
return (IShellIcon*)NULL;
|
||||
}
|
||||
|
||||
// Fixed 6263669
|
||||
//
|
||||
// CoInitialize wrapper
|
||||
// call CoInitialize to initialize COM in STA mode and check result
|
||||
// RPC_E_CHANGED_MODE means COM has already been initialized in MTA mode,
|
||||
// so don't set the flag to call CoUninitialize later
|
||||
|
||||
BOOL CoInit(BOOL& doCoUninit) { // returns TRUE if initialized successfully
|
||||
switch(::CoInitialize(NULL)) {
|
||||
case S_OK:
|
||||
case S_FALSE:
|
||||
doCoUninit = TRUE;
|
||||
return TRUE;
|
||||
break;
|
||||
case RPC_E_CHANGED_MODE:
|
||||
doCoUninit = FALSE;
|
||||
return TRUE;
|
||||
break;
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Class: sun_awt_shell_Win32ShellFolder2
|
||||
@ -507,10 +512,10 @@ JNIEXPORT jint JNICALL Java_sun_awt_shell_Win32ShellFolder2_getAttributes0
|
||||
|
||||
/*
|
||||
* Class: sun_awt_shell_Win32ShellFolder2
|
||||
* Method: getFileSystemPath
|
||||
* Method: getFileSystemPath0
|
||||
* Signature: (I)Ljava/lang/String;
|
||||
*/
|
||||
JNIEXPORT jstring JNICALL Java_sun_awt_shell_Win32ShellFolder2_getFileSystemPath__I
|
||||
JNIEXPORT jstring JNICALL Java_sun_awt_shell_Win32ShellFolder2_getFileSystemPath0
|
||||
(JNIEnv* env, jclass cls, jint csidl)
|
||||
{
|
||||
LPITEMIDLIST relPIDL;
|
||||
@ -611,18 +616,6 @@ JNIEXPORT jlong JNICALL Java_sun_awt_shell_Win32ShellFolder2_bindToObject
|
||||
if (SUCCEEDED (hr)) {
|
||||
return (jlong)pFolder;
|
||||
}
|
||||
if (IS_WINVISTA) {
|
||||
BOOL doCoUninit;
|
||||
if (CoInit(doCoUninit)) {
|
||||
hr = pParent->BindToObject(pidl, NULL, IID_IShellFolder, (void**)&pFolder);
|
||||
if (doCoUninit) {
|
||||
::CoUninitialize();
|
||||
}
|
||||
if (SUCCEEDED (hr)) {
|
||||
return (jlong)pFolder;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -650,7 +643,10 @@ JNIEXPORT jlong JNICALL Java_sun_awt_shell_Win32ShellFolder2_getLinkLocation
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pParent->GetDisplayNameOf(pidl, SHGDN_NORMAL | SHGDN_FORPARSING, &strret);
|
||||
hres = pParent->GetDisplayNameOf(pidl, SHGDN_NORMAL | SHGDN_FORPARSING, &strret);
|
||||
if (FAILED(hres)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
switch (strret.uType) {
|
||||
case STRRET_CSTR :
|
||||
@ -669,10 +665,6 @@ JNIEXPORT jlong JNICALL Java_sun_awt_shell_Win32ShellFolder2_getLinkLocation
|
||||
break;
|
||||
}
|
||||
|
||||
BOOL doCoUninit;
|
||||
if (!CoInit(doCoUninit)) {
|
||||
return 0;
|
||||
}
|
||||
IShellLinkW* psl;
|
||||
hres = ::CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLinkW, (LPVOID *)&psl);
|
||||
if (SUCCEEDED(hres)) {
|
||||
@ -692,10 +684,10 @@ JNIEXPORT jlong JNICALL Java_sun_awt_shell_Win32ShellFolder2_getLinkLocation
|
||||
}
|
||||
psl->Release();
|
||||
}
|
||||
if (doCoUninit) {
|
||||
::CoUninitialize();
|
||||
}
|
||||
|
||||
if (strret.uType == STRRET_WSTR) {
|
||||
CoTaskMemFree(strret.pOleStr);
|
||||
}
|
||||
if (SUCCEEDED(hres)) {
|
||||
return (jlong)pidl;
|
||||
} else {
|
||||
@ -741,7 +733,7 @@ JNIEXPORT jlong JNICALL Java_sun_awt_shell_Win32ShellFolder2_parseDisplayName0
|
||||
/*
|
||||
* Class: sun_awt_shell_Win32ShellFolder2
|
||||
* Method: getDisplayNameOf
|
||||
* Signature: (JJ)Ljava/lang/String;
|
||||
* Signature: (JJI)Ljava/lang/String;
|
||||
*/
|
||||
JNIEXPORT jstring JNICALL Java_sun_awt_shell_Win32ShellFolder2_getDisplayNameOf
|
||||
(JNIEnv* env, jclass cls, jlong parentIShellFolder, jlong relativePIDL, jint attrs)
|
||||
@ -758,7 +750,11 @@ JNIEXPORT jstring JNICALL Java_sun_awt_shell_Win32ShellFolder2_getDisplayNameOf
|
||||
if (pParent->GetDisplayNameOf(pidl, attrs, &strret) != S_OK) {
|
||||
return NULL;
|
||||
}
|
||||
return jstringFromSTRRET(env, pidl, &strret);
|
||||
jstring result = jstringFromSTRRET(env, pidl, &strret);
|
||||
if (strret.uType == STRRET_WSTR) {
|
||||
CoTaskMemFree(strret.pOleStr);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -833,10 +829,6 @@ JNIEXPORT jint JNICALL Java_sun_awt_shell_Win32ShellFolder2_getIconIndex
|
||||
}
|
||||
|
||||
INT index = -1;
|
||||
BOOL doCoUninit;
|
||||
if (!CoInit(doCoUninit)) {
|
||||
return (jint)index;
|
||||
}
|
||||
|
||||
HRESULT hres;
|
||||
// http://msdn.microsoft.com/library/en-us/shellcc/platform/Shell/programmersguide/shell_int/shell_int_programming/std_ifaces.asp
|
||||
@ -844,9 +836,6 @@ JNIEXPORT jint JNICALL Java_sun_awt_shell_Win32ShellFolder2_getIconIndex
|
||||
hres = pIShellIcon->GetIconOf(pidl, GIL_FORSHELL, &index);
|
||||
}
|
||||
|
||||
if (doCoUninit) {
|
||||
::CoUninitialize();
|
||||
}
|
||||
return (jint)index;
|
||||
}
|
||||
|
||||
@ -866,10 +855,6 @@ JNIEXPORT jlong JNICALL Java_sun_awt_shell_Win32ShellFolder2_extractIcon
|
||||
}
|
||||
|
||||
HICON hIcon = NULL;
|
||||
BOOL doCoUninit;
|
||||
if (!CoInit(doCoUninit)) {
|
||||
return (jlong)hIcon;
|
||||
}
|
||||
|
||||
HRESULT hres;
|
||||
IExtractIconW* pIcon;
|
||||
@ -894,9 +879,6 @@ JNIEXPORT jlong JNICALL Java_sun_awt_shell_Win32ShellFolder2_extractIcon
|
||||
}
|
||||
pIcon->Release();
|
||||
}
|
||||
if (doCoUninit) {
|
||||
::CoUninitialize();
|
||||
}
|
||||
return (jlong)hIcon;
|
||||
}
|
||||
|
||||
@ -994,14 +976,10 @@ JNIEXPORT jintArray JNICALL Java_sun_awt_shell_Win32ShellFolder2_getFileChooserB
|
||||
HINSTANCE libComCtl32;
|
||||
HINSTANCE libShell32;
|
||||
|
||||
|
||||
libShell32 = LoadLibrary(TEXT("shell32.dll"));
|
||||
if (libShell32 != NULL) {
|
||||
long osVersion = GetVersion();
|
||||
BOOL isVista = (!(osVersion & 0x80000000) && (LOBYTE(LOWORD(osVersion)) >= 6));
|
||||
|
||||
hBitmap = (HBITMAP)LoadImage(libShell32,
|
||||
isVista ? TEXT("IDB_TB_SH_DEF_16") : MAKEINTRESOURCE(216),
|
||||
IS_WINVISTA ? TEXT("IDB_TB_SH_DEF_16") : MAKEINTRESOURCE(216),
|
||||
IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION);
|
||||
}
|
||||
if (hBitmap == NULL) {
|
||||
@ -1095,46 +1073,6 @@ JNIEXPORT jlong JNICALL Java_sun_awt_shell_Win32ShellFolder2_getIconResource
|
||||
}
|
||||
|
||||
|
||||
// Helper functions for workaround COM initialization:
|
||||
|
||||
static HRESULT GetDetailsOfFolder(
|
||||
IShellFolder2 *folder,
|
||||
LPCITEMIDLIST pidl,
|
||||
UINT column,
|
||||
SHELLDETAILS *psd)
|
||||
{
|
||||
HRESULT hr = folder->GetDetailsOf(pidl, column, psd);
|
||||
if (IS_WINVISTA && FAILED (hr)) {
|
||||
BOOL doCoUninit;
|
||||
if (CoInit(doCoUninit)) {
|
||||
hr = folder->GetDetailsOf(pidl, column, psd);
|
||||
if (doCoUninit) {
|
||||
::CoUninitialize();
|
||||
}
|
||||
}
|
||||
}
|
||||
return hr;
|
||||
}
|
||||
|
||||
static HRESULT GetDetailsOf(
|
||||
IShellDetails *details,
|
||||
LPCITEMIDLIST pidl,
|
||||
UINT column,
|
||||
SHELLDETAILS *psd)
|
||||
{
|
||||
HRESULT hr = details->GetDetailsOf(pidl, column, psd);
|
||||
if (IS_WINVISTA && FAILED (hr)) {
|
||||
BOOL doCoUninit;
|
||||
if (CoInit(doCoUninit)) {
|
||||
hr = details->GetDetailsOf(pidl, column, psd);
|
||||
if (doCoUninit) {
|
||||
::CoUninitialize();
|
||||
}
|
||||
}
|
||||
}
|
||||
return hr;
|
||||
}
|
||||
|
||||
/*
|
||||
* Helper function for creating Java column info object
|
||||
*/
|
||||
@ -1187,7 +1125,7 @@ JNIEXPORT jobjectArray JNICALL
|
||||
int colNum = -1;
|
||||
hr = S_OK;
|
||||
do{
|
||||
hr = GetDetailsOfFolder(pIShellFolder2, NULL, ++colNum, &sd);
|
||||
hr = pIShellFolder2->GetDetailsOf(NULL, ++colNum, &sd);
|
||||
} while (SUCCEEDED (hr));
|
||||
|
||||
jobjectArray columns =
|
||||
@ -1202,7 +1140,7 @@ JNIEXPORT jobjectArray JNICALL
|
||||
colNum = 0;
|
||||
hr = S_OK;
|
||||
while (SUCCEEDED (hr)) {
|
||||
hr = GetDetailsOfFolder(pIShellFolder2, NULL, colNum, &sd);
|
||||
hr = pIShellFolder2->GetDetailsOf(NULL, colNum, &sd);
|
||||
|
||||
if (SUCCEEDED (hr)) {
|
||||
hr = pIShellFolder2->GetDefaultColumnState(colNum, &csFlags);
|
||||
@ -1232,7 +1170,7 @@ JNIEXPORT jobjectArray JNICALL
|
||||
int colNum = -1;
|
||||
hr = S_OK;
|
||||
do{
|
||||
hr = GetDetailsOf(pIShellDetails, NULL, ++colNum, &sd);
|
||||
hr = pIShellDetails->GetDetailsOf(NULL, ++colNum, &sd);
|
||||
} while (SUCCEEDED (hr));
|
||||
|
||||
jobjectArray columns =
|
||||
@ -1246,7 +1184,7 @@ JNIEXPORT jobjectArray JNICALL
|
||||
colNum = 0;
|
||||
hr = S_OK;
|
||||
while (SUCCEEDED (hr)) {
|
||||
hr = GetDetailsOf(pIShellDetails, NULL, colNum, &sd);
|
||||
hr = pIShellDetails->GetDetailsOf(NULL, colNum, &sd);
|
||||
if (SUCCEEDED (hr)) {
|
||||
jobject column = CreateColumnInfo(env,
|
||||
&columnClass, &columnConstructor,
|
||||
@ -1288,7 +1226,7 @@ JNIEXPORT jobject JNICALL
|
||||
if(SUCCEEDED (hr)) {
|
||||
// The folder exposes IShellFolder2 interface
|
||||
IShellFolder2 *pIShellFolder2 = (IShellFolder2*) pIUnknown;
|
||||
hr = GetDetailsOfFolder(pIShellFolder2, pidl, (UINT)columnIdx, &sd);
|
||||
hr = pIShellFolder2->GetDetailsOf(pidl, (UINT)columnIdx, &sd);
|
||||
pIShellFolder2->Release();
|
||||
if (SUCCEEDED (hr)) {
|
||||
STRRET strRet = sd.str;
|
||||
@ -1300,7 +1238,7 @@ JNIEXPORT jobject JNICALL
|
||||
if(SUCCEEDED (hr)) {
|
||||
// The folder exposes IShellDetails interface
|
||||
IShellDetails *pIShellDetails = (IShellDetails*) pIUnknown;
|
||||
hr = GetDetailsOf(pIShellDetails, pidl, (UINT)columnIdx, &sd);
|
||||
hr = pIShellDetails->GetDetailsOf(pidl, (UINT)columnIdx, &sd);
|
||||
pIShellDetails->Release();
|
||||
if (SUCCEEDED (hr)) {
|
||||
STRRET strRet = sd.str;
|
||||
|
65
jdk/test/com/sun/java/swing/plaf/gtk/Test6635110.java
Normal file
65
jdk/test/com/sun/java/swing/plaf/gtk/Test6635110.java
Normal file
@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Copyright 2008 Sun Microsystems, Inc. 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.
|
||||
*
|
||||
* 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
/* @test
|
||||
@bug 6635110
|
||||
@summary GTK icons should not throw NPE when called by non-GTK UI
|
||||
@author Peter Zhelezniakov
|
||||
@run main Test6635110
|
||||
*/
|
||||
|
||||
import com.sun.java.swing.plaf.gtk.GTKLookAndFeel;
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
import javax.swing.plaf.basic.*;
|
||||
|
||||
|
||||
public class Test6635110 implements Runnable {
|
||||
|
||||
static final int WIDTH = 160;
|
||||
static final int HEIGHT = 80;
|
||||
final BufferedImage IMAGE =
|
||||
new BufferedImage(WIDTH, HEIGHT, BufferedImage.TYPE_INT_ARGB);
|
||||
|
||||
@Override public void run() {
|
||||
JMenu menu = new JMenu("menu");
|
||||
menu.setUI(new BasicMenuUI());
|
||||
paint(menu);
|
||||
|
||||
JToolBar tb = new JToolBar();
|
||||
tb.setFloatable(true);
|
||||
tb.setUI(new BasicToolBarUI());
|
||||
paint(tb);
|
||||
}
|
||||
|
||||
void paint(Component c) {
|
||||
c.setSize(WIDTH, HEIGHT);
|
||||
c.paint(IMAGE.getGraphics());
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
UIManager.setLookAndFeel(new GTKLookAndFeel());
|
||||
SwingUtilities.invokeAndWait(new Test6635110());
|
||||
}
|
||||
}
|
52
jdk/test/java/beans/Beans/6669869/TestDesignTime.java
Normal file
52
jdk/test/java/beans/Beans/6669869/TestDesignTime.java
Normal file
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright 2009 Sun Microsystems, Inc. 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.
|
||||
*
|
||||
* 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 6669869
|
||||
* @summary Tests DesignTime property in different application contexts
|
||||
* @author Sergey Malenkov
|
||||
*/
|
||||
|
||||
import java.beans.Beans;
|
||||
import sun.awt.SunToolkit;
|
||||
|
||||
public class TestDesignTime implements Runnable {
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
if (Beans.isDesignTime()) {
|
||||
throw new Error("unexpected DesignTime property");
|
||||
}
|
||||
Beans.setDesignTime(!Beans.isDesignTime());
|
||||
ThreadGroup group = new ThreadGroup("$$$");
|
||||
Thread thread = new Thread(group, new TestDesignTime());
|
||||
thread.start();
|
||||
thread.join();
|
||||
}
|
||||
|
||||
public void run() {
|
||||
SunToolkit.createNewAppContext();
|
||||
if (Beans.isDesignTime()) {
|
||||
throw new Error("shared DesignTime property");
|
||||
}
|
||||
}
|
||||
}
|
53
jdk/test/java/beans/Beans/6669869/TestGuiAvailable.java
Normal file
53
jdk/test/java/beans/Beans/6669869/TestGuiAvailable.java
Normal file
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright 2009 Sun Microsystems, Inc. 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.
|
||||
*
|
||||
* 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 6669869
|
||||
* @summary Tests GuiAvailable property in different application contexts
|
||||
* @author Sergey Malenkov
|
||||
*/
|
||||
|
||||
import java.awt.GraphicsEnvironment;
|
||||
import java.beans.Beans;
|
||||
import sun.awt.SunToolkit;
|
||||
|
||||
public class TestGuiAvailable implements Runnable {
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
if (Beans.isGuiAvailable() == GraphicsEnvironment.isHeadless()) {
|
||||
throw new Error("unexpected GuiAvailable property");
|
||||
}
|
||||
Beans.setGuiAvailable(!Beans.isGuiAvailable());
|
||||
ThreadGroup group = new ThreadGroup("$$$");
|
||||
Thread thread = new Thread(group, new TestGuiAvailable());
|
||||
thread.start();
|
||||
thread.join();
|
||||
}
|
||||
|
||||
public void run() {
|
||||
SunToolkit.createNewAppContext();
|
||||
if (Beans.isGuiAvailable() == GraphicsEnvironment.isHeadless()) {
|
||||
throw new Error("shared GuiAvailable property");
|
||||
}
|
||||
}
|
||||
}
|
@ -72,7 +72,7 @@ public class ToLowerCase {
|
||||
// I-dot tests (Turkish and Azeri)
|
||||
test("\u0130", turkish, "i");
|
||||
test("\u0130", az, "i");
|
||||
test("\u0130", Locale.US, "i");
|
||||
test("\u0130", Locale.US, "i\u0307");
|
||||
|
||||
// Remove dot_above in the sequence I + dot_above (Turkish and Azeri)
|
||||
test("I\u0307", turkish, "i");
|
||||
|
20
jdk/test/javax/swing/JFileChooser/6570445/bug6570445.java
Normal file
20
jdk/test/javax/swing/JFileChooser/6570445/bug6570445.java
Normal file
@ -0,0 +1,20 @@
|
||||
/*
|
||||
* @test
|
||||
* @bug 6570445
|
||||
* @summary Checks if Win32ShellFolder2's COM-using methods work under a security manager
|
||||
* @author Leonid Popov
|
||||
*/
|
||||
|
||||
import javax.swing.filechooser.FileSystemView;
|
||||
|
||||
public class bug6570445 {
|
||||
public static void main(String[] args) {
|
||||
System.setSecurityManager(new SecurityManager());
|
||||
|
||||
// The next line of code forces FileSystemView to request data from Win32ShellFolder2,
|
||||
// what causes an exception if a security manager installed (see the bug 6570445 description)
|
||||
FileSystemView.getFileSystemView().getRoots();
|
||||
|
||||
System.out.println("Passed.");
|
||||
}
|
||||
}
|
44
jdk/test/javax/swing/JFileChooser/6738668/bug6738668.java
Normal file
44
jdk/test/javax/swing/JFileChooser/6738668/bug6738668.java
Normal file
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright 2009 Sun Microsystems, Inc. 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.
|
||||
*
|
||||
* 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
/* @test
|
||||
@bug 6738668
|
||||
@summary JFileChooser cannot be created under SecurityManager
|
||||
@author Pavel Porvatov
|
||||
@run main/othervm/policy=security.policy bug6738668
|
||||
*/
|
||||
|
||||
import javax.swing.*;
|
||||
import java.io.File;
|
||||
|
||||
public class bug6738668 {
|
||||
public static void main(String[] args) throws Exception {
|
||||
for (UIManager.LookAndFeelInfo lookAndFeelInfo : UIManager.getInstalledLookAndFeels()) {
|
||||
UIManager.setLookAndFeel(lookAndFeelInfo.getClassName());
|
||||
|
||||
new JFileChooser(new File("c:/temp"));
|
||||
|
||||
System.out.println("Test passed for LookAndFeel " + lookAndFeelInfo.getClassName());
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
grant {
|
||||
permission java.io.FilePermission "C:\\temp\\*", "read";
|
||||
permission java.io.FilePermission "C:\\temp", "read";
|
||||
permission java.util.PropertyPermission "*", "read";
|
||||
};
|
11
jdk/test/javax/swing/JFileChooser/6798062/bug6798062.html
Normal file
11
jdk/test/javax/swing/JFileChooser/6798062/bug6798062.html
Normal file
@ -0,0 +1,11 @@
|
||||
<html>
|
||||
<body>
|
||||
<applet code="bug6798062.class" width=400 height=300></applet>
|
||||
1. Create a link
|
||||
2. Copy path to the link into TextField
|
||||
3. Run the Windows Task Manager. Select the Processes tab and find the java process
|
||||
4. Press the Start button in the test window
|
||||
5. Wait several minutes and observe in the Windows Task Manager
|
||||
that Memory Usage of java process is not increasing
|
||||
</body>
|
||||
</html>
|
189
jdk/test/javax/swing/JFileChooser/6798062/bug6798062.java
Normal file
189
jdk/test/javax/swing/JFileChooser/6798062/bug6798062.java
Normal file
@ -0,0 +1,189 @@
|
||||
/*
|
||||
* Copyright 2009 Sun Microsystems, Inc. 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.
|
||||
*
|
||||
* 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
/* @test %W% %E%
|
||||
@bug 6798062
|
||||
@summary Memory Leak on using getFiles of FileSystemView
|
||||
@author Pavel Porvatov
|
||||
@run applet/manual=done bug6798062.html
|
||||
*/
|
||||
|
||||
import sun.awt.shell.ShellFolder;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.*;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
|
||||
public class bug6798062 extends JApplet {
|
||||
|
||||
private final JSlider slider = new JSlider(0, 100);
|
||||
|
||||
private final JTextField tfLink = new JTextField();
|
||||
|
||||
private final JButton btnStart = new JButton("Start");
|
||||
|
||||
private final JButton btnStop = new JButton("Stop");
|
||||
|
||||
private final JButton btnGC = new JButton("Run System.gc()");
|
||||
|
||||
private ShellFolder folder;
|
||||
|
||||
private Thread thread;
|
||||
|
||||
public static void main(String[] args) {
|
||||
JFrame frame = new JFrame("bug6798062");
|
||||
|
||||
frame.setSize(400, 300);
|
||||
frame.setLocationRelativeTo(null);
|
||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
frame.add(new bug6798062().initialize());
|
||||
|
||||
frame.setVisible(true);
|
||||
}
|
||||
|
||||
public void init() {
|
||||
add(initialize());
|
||||
}
|
||||
|
||||
private JPanel initialize() {
|
||||
File file = new File("c:/");
|
||||
|
||||
try {
|
||||
folder = ShellFolder.getShellFolder(file);
|
||||
} catch (FileNotFoundException e) {
|
||||
fail("Directory " + file.getPath() + " not found");
|
||||
}
|
||||
|
||||
slider.setMajorTickSpacing(10);
|
||||
slider.setPaintTicks(true);
|
||||
slider.setPaintLabels(true);
|
||||
slider.setSnapToTicks(true);
|
||||
slider.setValue(10);
|
||||
|
||||
btnStart.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
setEnabledState(false);
|
||||
|
||||
thread = new MyThread(slider.getValue(), tfLink.getText());
|
||||
thread.start();
|
||||
}
|
||||
});
|
||||
|
||||
btnStop.setEnabled(false);
|
||||
|
||||
btnStop.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
thread.interrupt();
|
||||
thread = null;
|
||||
|
||||
setEnabledState(true);
|
||||
}
|
||||
});
|
||||
|
||||
btnGC.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
System.gc();
|
||||
}
|
||||
});
|
||||
|
||||
setEnabledState(true);
|
||||
|
||||
JPanel pnButtons = new JPanel();
|
||||
|
||||
pnButtons.setLayout(new BoxLayout(pnButtons, BoxLayout.X_AXIS));
|
||||
|
||||
pnButtons.add(btnStart);
|
||||
pnButtons.add(btnStop);
|
||||
pnButtons.add(btnGC);
|
||||
|
||||
tfLink.setMaximumSize(new Dimension(300, 20));
|
||||
|
||||
JPanel pnContent = new JPanel();
|
||||
|
||||
pnContent.setLayout(new BoxLayout(pnContent, BoxLayout.Y_AXIS));
|
||||
pnContent.add(new JLabel("Delay between listFiles() invocation (ms):"));
|
||||
pnContent.add(slider);
|
||||
pnContent.add(new JLabel("Provide link here:"));
|
||||
pnContent.add(tfLink);
|
||||
pnContent.add(pnButtons);
|
||||
|
||||
return pnContent;
|
||||
}
|
||||
|
||||
private void setEnabledState(boolean enabled) {
|
||||
slider.setEnabled(enabled);
|
||||
btnStart.setEnabled(enabled);
|
||||
btnStop.setEnabled(!enabled);
|
||||
}
|
||||
|
||||
private static void fail(String msg) {
|
||||
throw new RuntimeException(msg);
|
||||
}
|
||||
|
||||
private class MyThread extends Thread {
|
||||
private final int delay;
|
||||
|
||||
private final ShellFolder link;
|
||||
|
||||
private MyThread(int delay, String link) {
|
||||
this.delay = delay;
|
||||
|
||||
ShellFolder linkFolder;
|
||||
|
||||
try {
|
||||
linkFolder = ShellFolder.getShellFolder(new File(link));
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
|
||||
linkFolder = null;
|
||||
}
|
||||
|
||||
this.link = linkFolder;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
while (!isInterrupted()) {
|
||||
folder.listFiles();
|
||||
if (link != null) {
|
||||
try {
|
||||
link.getLinkLocation();
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (delay > 0) {
|
||||
try {
|
||||
Thread.sleep(delay);
|
||||
} catch (InterruptedException e1) {
|
||||
// The thread was interrupted
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
105
jdk/test/javax/swing/JSlider/6794831/bug6794831.java
Normal file
105
jdk/test/javax/swing/JSlider/6794831/bug6794831.java
Normal file
@ -0,0 +1,105 @@
|
||||
/*
|
||||
* Copyright 2009 Sun Microsystems, Inc. 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.
|
||||
*
|
||||
* 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
/* @test
|
||||
* @bug 6794831
|
||||
* @summary Infinite loop while painting ticks on Slider with maximum=MAX_INT
|
||||
* @author Pavel Porvatov
|
||||
@run main bug6794831
|
||||
*/
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.plaf.basic.BasicSliderUI;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class bug6794831 {
|
||||
private final CountDownLatch countDownLatch = new CountDownLatch(1);
|
||||
|
||||
public static void main(String args[]) throws InterruptedException {
|
||||
new bug6794831().run();
|
||||
}
|
||||
|
||||
private void run() throws InterruptedException {
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
for (UIManager.LookAndFeelInfo lookAndFeelInfo : UIManager.getInstalledLookAndFeels()) {
|
||||
try {
|
||||
UIManager.setLookAndFeel(lookAndFeelInfo.getClassName());
|
||||
} catch (Exception e) {
|
||||
fail(e.getMessage());
|
||||
}
|
||||
|
||||
BufferedImage image = new BufferedImage(300, 200, BufferedImage.TYPE_INT_ARGB);
|
||||
|
||||
// Test 1
|
||||
JSlider slider = new JSlider(0, Integer.MAX_VALUE - 1, 0);
|
||||
|
||||
slider.setMajorTickSpacing((Integer.MAX_VALUE - 1) / 4);
|
||||
slider.setPaintTicks(true);
|
||||
|
||||
((BasicSliderUI) slider.getUI()).paintTicks(image.getGraphics());
|
||||
|
||||
// Test 2
|
||||
slider = new JSlider(0, Integer.MAX_VALUE - 1, 0);
|
||||
|
||||
slider.setMinorTickSpacing((Integer.MAX_VALUE - 1) / 4);
|
||||
slider.setPaintTicks(true);
|
||||
|
||||
((BasicSliderUI) slider.getUI()).paintTicks(image.getGraphics());
|
||||
|
||||
// Test 3
|
||||
slider = new JSlider(0, Integer.MAX_VALUE - 1, 0);
|
||||
|
||||
slider.setOrientation(JSlider.VERTICAL);
|
||||
slider.setMajorTickSpacing((Integer.MAX_VALUE - 1) / 4);
|
||||
slider.setPaintTicks(true);
|
||||
|
||||
((BasicSliderUI) slider.getUI()).paintTicks(image.getGraphics());
|
||||
|
||||
// Test 4
|
||||
slider = new JSlider(0, Integer.MAX_VALUE - 1, 0);
|
||||
|
||||
slider.setOrientation(JSlider.VERTICAL);
|
||||
slider.setMinorTickSpacing((Integer.MAX_VALUE - 1) / 4);
|
||||
slider.setPaintTicks(true);
|
||||
|
||||
((BasicSliderUI) slider.getUI()).paintTicks(image.getGraphics());
|
||||
|
||||
countDownLatch.countDown();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (countDownLatch.await(3000, TimeUnit.MILLISECONDS)) {
|
||||
System.out.println("bug6794831 passed");
|
||||
} else {
|
||||
fail("bug6794831 failed");
|
||||
}
|
||||
}
|
||||
|
||||
private static void fail(String msg) {
|
||||
throw new RuntimeException(msg);
|
||||
}
|
||||
}
|
203
jdk/test/javax/swing/system/6799345/TestShutdown.java
Normal file
203
jdk/test/javax/swing/system/6799345/TestShutdown.java
Normal file
@ -0,0 +1,203 @@
|
||||
/*
|
||||
* Copyright 2009 Sun Microsystems, Inc. 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.
|
||||
*
|
||||
* 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
/* @test
|
||||
@bug 6799345
|
||||
@summary Tests that no exceptions are thrown from TimerQueue and
|
||||
SwingWorker on AppContext shutdown
|
||||
@author art
|
||||
@run main TestShutdown
|
||||
*/
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
import sun.awt.*;
|
||||
|
||||
public class TestShutdown
|
||||
{
|
||||
private static AppContext targetAppContext;
|
||||
|
||||
private static JFrame f;
|
||||
private static JTextField tf;
|
||||
|
||||
private static volatile boolean exceptionsOccurred = false;
|
||||
private static volatile boolean appcontextInitDone = false;
|
||||
|
||||
private static int timerValue = 0;
|
||||
|
||||
public static void main(String[] args)
|
||||
throws Exception
|
||||
{
|
||||
ThreadGroup tg = new TestThreadGroup("TTG");
|
||||
Thread t = new Thread(tg, new TestRunnable(), "InitThread");
|
||||
t.start();
|
||||
|
||||
while (!appcontextInitDone)
|
||||
{
|
||||
Thread.sleep(500);
|
||||
}
|
||||
|
||||
targetAppContext.dispose();
|
||||
|
||||
if (exceptionsOccurred)
|
||||
{
|
||||
throw new RuntimeException("Test FAILED: some exceptions occurred");
|
||||
}
|
||||
}
|
||||
|
||||
static void initGUI()
|
||||
{
|
||||
f = new JFrame("F");
|
||||
f.setBounds(100, 100, 200, 100);
|
||||
tf = new JTextField("Test");
|
||||
f.add(tf);
|
||||
f.setVisible(true);
|
||||
}
|
||||
|
||||
static void startGUI()
|
||||
{
|
||||
// caret blink Timer
|
||||
tf.requestFocusInWindow();
|
||||
|
||||
// misc Timer
|
||||
ActionListener al = new ActionListener()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent ae)
|
||||
{
|
||||
System.out.println("Timer tick: " + timerValue++);
|
||||
}
|
||||
};
|
||||
new javax.swing.Timer(30, al).start();
|
||||
}
|
||||
|
||||
static class TestThreadGroup extends ThreadGroup
|
||||
{
|
||||
public TestThreadGroup(String name)
|
||||
{
|
||||
super(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void uncaughtException(Thread thread, Throwable t)
|
||||
{
|
||||
if (t instanceof ThreadDeath)
|
||||
{
|
||||
// this one is expected, rethrow
|
||||
throw (ThreadDeath)t;
|
||||
}
|
||||
System.err.println("Test FAILED: an exception is caught in the " +
|
||||
"target thread group on thread " + thread.getName());
|
||||
t.printStackTrace(System.err);
|
||||
exceptionsOccurred = true;
|
||||
}
|
||||
}
|
||||
|
||||
static class TestRunnable implements Runnable
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
SunToolkit stk = (SunToolkit)Toolkit.getDefaultToolkit();
|
||||
targetAppContext = stk.createNewAppContext();
|
||||
|
||||
// create and show frame and text field
|
||||
SwingUtilities.invokeLater(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
initGUI();
|
||||
}
|
||||
});
|
||||
stk.realSync();
|
||||
|
||||
// start some Timers
|
||||
SwingUtilities.invokeLater(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
startGUI();
|
||||
}
|
||||
});
|
||||
stk.realSync();
|
||||
|
||||
// start multiple SwingWorkers
|
||||
while (!Thread.interrupted())
|
||||
{
|
||||
try
|
||||
{
|
||||
new TestSwingWorker().execute();
|
||||
Thread.sleep(40);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
// exception here is expected, skip
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static class TestSwingWorker extends SwingWorker<String, Integer>
|
||||
{
|
||||
@Override
|
||||
public String doInBackground()
|
||||
{
|
||||
Random r = new Random();
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
int delay = r.nextInt() % 50;
|
||||
Thread.sleep(delay);
|
||||
publish(delay);
|
||||
}
|
||||
catch (Exception z)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!appcontextInitDone)
|
||||
{
|
||||
appcontextInitDone = true;
|
||||
}
|
||||
return "Done";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void process(java.util.List<Integer> chunks)
|
||||
{
|
||||
for (Integer i : chunks)
|
||||
{
|
||||
System.err.println("Processed: " + i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
59
jdk/test/javax/swing/text/LayoutQueue/Test6588003.java
Normal file
59
jdk/test/javax/swing/text/LayoutQueue/Test6588003.java
Normal file
@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright 2007 Sun Microsystems, Inc. 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.
|
||||
*
|
||||
* 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
/* @test
|
||||
@bug 6588003
|
||||
@summary LayoutQueue should not share its DefaultQueue across AppContexts
|
||||
@author Peter Zhelezniakov
|
||||
@run main Test6588003
|
||||
*/
|
||||
|
||||
import javax.swing.text.LayoutQueue;
|
||||
import sun.awt.SunToolkit;
|
||||
|
||||
public class Test6588003 implements Runnable {
|
||||
private static final LayoutQueue DEFAULT = new LayoutQueue();
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
LayoutQueue.setDefaultQueue(DEFAULT);
|
||||
|
||||
ThreadGroup group = new ThreadGroup("Test6588003");
|
||||
Thread thread = new Thread(group, new Test6588003());
|
||||
thread.start();
|
||||
thread.join();
|
||||
|
||||
if (LayoutQueue.getDefaultQueue() != DEFAULT) {
|
||||
throw new RuntimeException("Sharing detected");
|
||||
}
|
||||
}
|
||||
|
||||
public void run() {
|
||||
SunToolkit.createNewAppContext();
|
||||
|
||||
if (LayoutQueue.getDefaultQueue() == DEFAULT) {
|
||||
throw new RuntimeException("Sharing detected");
|
||||
}
|
||||
|
||||
LayoutQueue.setDefaultQueue(new LayoutQueue());
|
||||
}
|
||||
}
|
93
jdk/test/javax/swing/text/html/Test4783068.java
Normal file
93
jdk/test/javax/swing/text/html/Test4783068.java
Normal file
@ -0,0 +1,93 @@
|
||||
/*
|
||||
* Copyright 2007 Sun Microsystems, Inc. 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.
|
||||
*
|
||||
* 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
/* @test
|
||||
@bug 4783068
|
||||
@summary Disabled components should render grayed-out HTML
|
||||
@author Peter Zhelezniakov
|
||||
@run main Test4783068
|
||||
*/
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
import javax.swing.*;
|
||||
import javax.swing.plaf.metal.MetalLookAndFeel;
|
||||
|
||||
public class Test4783068 {
|
||||
final static Color TEST_COLOR = Color.WHITE;
|
||||
|
||||
final static String html = "<html>" +
|
||||
"This is a <font color='red'>colored</font> <b>text</b>" +
|
||||
"<p>with a <a href='http://ru.sun.com'>link</a>" +
|
||||
"<ul><li>an unordered<li>list</ul>" +
|
||||
"<ol><li>and an ordered<li>list</ol>" +
|
||||
"</html>";
|
||||
|
||||
|
||||
void test() {
|
||||
try {
|
||||
UIManager.setLookAndFeel(new MetalLookAndFeel());
|
||||
} catch (UnsupportedLookAndFeelException e) {
|
||||
throw new Error("Cannot set Metal LAF");
|
||||
}
|
||||
// Render text using background color
|
||||
UIManager.put("textInactiveText", TEST_COLOR);
|
||||
|
||||
test(new JLabel(html));
|
||||
test(new JButton(html));
|
||||
|
||||
JEditorPane pane = new JEditorPane("text/html", html);
|
||||
pane.setDisabledTextColor(TEST_COLOR);
|
||||
test(pane);
|
||||
}
|
||||
|
||||
void test(JComponent c) {
|
||||
c.setEnabled(false);
|
||||
c.setOpaque(true);
|
||||
c.setBackground(TEST_COLOR);
|
||||
c.setBorder(null);
|
||||
Dimension size = c.getPreferredSize();
|
||||
c.setBounds(0, 0, size.width, size.height);
|
||||
|
||||
BufferedImage image = new BufferedImage(size.width, size.height, BufferedImage.TYPE_INT_ARGB);
|
||||
c.paint(image.getGraphics());
|
||||
|
||||
int rgb = TEST_COLOR.getRGB();
|
||||
for (int i = 0; i < size.height; i++) {
|
||||
for (int j = 0; j < size.width; j++) {
|
||||
if (image.getRGB(j, i) != rgb) {
|
||||
throw new RuntimeException(
|
||||
String.format("Color mismatch at [%d, %d]", j, i));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
@Override public void run() {
|
||||
new Test4783068().test();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user