mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 07:14:30 +02:00
8187443: Forest Consolidation: Move files to unified layout
Reviewed-by: darcy, ihse
This commit is contained in:
parent
270fe13182
commit
3789983e89
56923 changed files with 3 additions and 15727 deletions
511
src/java.base/share/classes/sun/net/idn/Punycode.java
Normal file
511
src/java.base/share/classes/sun/net/idn/Punycode.java
Normal file
|
@ -0,0 +1,511 @@
|
|||
/*
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2003-2004, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
//
|
||||
// CHANGELOG
|
||||
// 2005-05-19 Edward Wang
|
||||
// - copy this file from icu4jsrc_3_2/src/com/ibm/icu/text/Punycode.java
|
||||
// - move from package com.ibm.icu.text to package sun.net.idn
|
||||
// - use ParseException instead of StringPrepParseException
|
||||
// 2007-08-14 Martin Buchholz
|
||||
// - remove redundant casts
|
||||
//
|
||||
package sun.net.idn;
|
||||
|
||||
import java.text.ParseException;
|
||||
import sun.text.normalizer.UCharacter;
|
||||
import sun.text.normalizer.UTF16;
|
||||
|
||||
/**
|
||||
* Ported code from ICU punycode.c
|
||||
* @author ram
|
||||
*/
|
||||
|
||||
/* Package Private class */
|
||||
public final class Punycode {
|
||||
|
||||
/* Punycode parameters for Bootstring */
|
||||
private static final int BASE = 36;
|
||||
private static final int TMIN = 1;
|
||||
private static final int TMAX = 26;
|
||||
private static final int SKEW = 38;
|
||||
private static final int DAMP = 700;
|
||||
private static final int INITIAL_BIAS = 72;
|
||||
private static final int INITIAL_N = 0x80;
|
||||
|
||||
/* "Basic" Unicode/ASCII code points */
|
||||
private static final int HYPHEN = 0x2d;
|
||||
private static final int DELIMITER = HYPHEN;
|
||||
|
||||
private static final int ZERO = 0x30;
|
||||
private static final int NINE = 0x39;
|
||||
|
||||
private static final int SMALL_A = 0x61;
|
||||
private static final int SMALL_Z = 0x7a;
|
||||
|
||||
private static final int CAPITAL_A = 0x41;
|
||||
private static final int CAPITAL_Z = 0x5a;
|
||||
|
||||
// TODO: eliminate the 256 limitation
|
||||
private static final int MAX_CP_COUNT = 256;
|
||||
|
||||
private static final int UINT_MAGIC = 0x80000000;
|
||||
private static final long ULONG_MAGIC = 0x8000000000000000L;
|
||||
|
||||
private static int adaptBias(int delta, int length, boolean firstTime){
|
||||
if(firstTime){
|
||||
delta /=DAMP;
|
||||
}else{
|
||||
delta /= 2;
|
||||
}
|
||||
delta += delta/length;
|
||||
|
||||
int count=0;
|
||||
for(; delta>((BASE-TMIN)*TMAX)/2; count+=BASE) {
|
||||
delta/=(BASE-TMIN);
|
||||
}
|
||||
|
||||
return count+(((BASE-TMIN+1)*delta)/(delta+SKEW));
|
||||
}
|
||||
|
||||
/**
|
||||
* basicToDigit[] contains the numeric value of a basic code
|
||||
* point (for use in representing integers) in the range 0 to
|
||||
* BASE-1, or -1 if b is does not represent a value.
|
||||
*/
|
||||
static final int[] basicToDigit= new int[]{
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
26, 27, 28, 29, 30, 31, 32, 33, 34, 35, -1, -1, -1, -1, -1, -1,
|
||||
|
||||
-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
|
||||
15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1,
|
||||
|
||||
-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
|
||||
15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1,
|
||||
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
|
||||
};
|
||||
|
||||
private static char asciiCaseMap(char b, boolean uppercase) {
|
||||
if(uppercase) {
|
||||
if(SMALL_A<=b && b<=SMALL_Z) {
|
||||
b-=(SMALL_A-CAPITAL_A);
|
||||
}
|
||||
} else {
|
||||
if(CAPITAL_A<=b && b<=CAPITAL_Z) {
|
||||
b+=(SMALL_A-CAPITAL_A);
|
||||
}
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
/**
|
||||
* digitToBasic() returns the basic code point whose value
|
||||
* (when used for representing integers) is d, which must be in the
|
||||
* range 0 to BASE-1. The lowercase form is used unless the uppercase flag is
|
||||
* nonzero, in which case the uppercase form is used.
|
||||
*/
|
||||
private static char digitToBasic(int digit, boolean uppercase) {
|
||||
/* 0..25 map to ASCII a..z or A..Z */
|
||||
/* 26..35 map to ASCII 0..9 */
|
||||
if(digit<26) {
|
||||
if(uppercase) {
|
||||
return (char)(CAPITAL_A+digit);
|
||||
} else {
|
||||
return (char)(SMALL_A+digit);
|
||||
}
|
||||
} else {
|
||||
return (char)((ZERO-26)+digit);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Converts Unicode to Punycode.
|
||||
* The input string must not contain single, unpaired surrogates.
|
||||
* The output will be represented as an array of ASCII code points.
|
||||
*
|
||||
* @param src
|
||||
* @param caseFlags
|
||||
* @return
|
||||
* @throws ParseException
|
||||
*/
|
||||
public static StringBuffer encode(StringBuffer src, boolean[] caseFlags) throws ParseException{
|
||||
|
||||
int[] cpBuffer = new int[MAX_CP_COUNT];
|
||||
int n, delta, handledCPCount, basicLength, destLength, bias, j, m, q, k, t, srcCPCount;
|
||||
char c, c2;
|
||||
int srcLength = src.length();
|
||||
int destCapacity = MAX_CP_COUNT;
|
||||
char[] dest = new char[destCapacity];
|
||||
StringBuffer result = new StringBuffer();
|
||||
/*
|
||||
* Handle the basic code points and
|
||||
* convert extended ones to UTF-32 in cpBuffer (caseFlag in sign bit):
|
||||
*/
|
||||
srcCPCount=destLength=0;
|
||||
|
||||
for(j=0; j<srcLength; ++j) {
|
||||
if(srcCPCount==MAX_CP_COUNT) {
|
||||
/* too many input code points */
|
||||
throw new IndexOutOfBoundsException();
|
||||
}
|
||||
c=src.charAt(j);
|
||||
if(isBasic(c)) {
|
||||
if(destLength<destCapacity) {
|
||||
cpBuffer[srcCPCount++]=0;
|
||||
dest[destLength]=
|
||||
caseFlags!=null ?
|
||||
asciiCaseMap(c, caseFlags[j]) :
|
||||
c;
|
||||
}
|
||||
++destLength;
|
||||
} else {
|
||||
n=((caseFlags!=null && caseFlags[j])? 1 : 0)<<31L;
|
||||
if(!UTF16.isSurrogate(c)) {
|
||||
n|=c;
|
||||
} else if(UTF16.isLeadSurrogate(c) && (j+1)<srcLength && UTF16.isTrailSurrogate(c2=src.charAt(j+1))) {
|
||||
++j;
|
||||
|
||||
n|=UCharacter.getCodePoint(c, c2);
|
||||
} else {
|
||||
/* error: unmatched surrogate */
|
||||
throw new ParseException("Illegal char found", -1);
|
||||
}
|
||||
cpBuffer[srcCPCount++]=n;
|
||||
}
|
||||
}
|
||||
|
||||
/* Finish the basic string - if it is not empty - with a delimiter. */
|
||||
basicLength=destLength;
|
||||
if(basicLength>0) {
|
||||
if(destLength<destCapacity) {
|
||||
dest[destLength]=DELIMITER;
|
||||
}
|
||||
++destLength;
|
||||
}
|
||||
|
||||
/*
|
||||
* handledCPCount is the number of code points that have been handled
|
||||
* basicLength is the number of basic code points
|
||||
* destLength is the number of chars that have been output
|
||||
*/
|
||||
|
||||
/* Initialize the state: */
|
||||
n=INITIAL_N;
|
||||
delta=0;
|
||||
bias=INITIAL_BIAS;
|
||||
|
||||
/* Main encoding loop: */
|
||||
for(handledCPCount=basicLength; handledCPCount<srcCPCount; /* no op */) {
|
||||
/*
|
||||
* All non-basic code points < n have been handled already.
|
||||
* Find the next larger one:
|
||||
*/
|
||||
for(m=0x7fffffff, j=0; j<srcCPCount; ++j) {
|
||||
q=cpBuffer[j]&0x7fffffff; /* remove case flag from the sign bit */
|
||||
if(n<=q && q<m) {
|
||||
m=q;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Increase delta enough to advance the decoder's
|
||||
* <n,i> state to <m,0>, but guard against overflow:
|
||||
*/
|
||||
if(m-n>(0x7fffffff-MAX_CP_COUNT-delta)/(handledCPCount+1)) {
|
||||
throw new RuntimeException("Internal program error");
|
||||
}
|
||||
delta+=(m-n)*(handledCPCount+1);
|
||||
n=m;
|
||||
|
||||
/* Encode a sequence of same code points n */
|
||||
for(j=0; j<srcCPCount; ++j) {
|
||||
q=cpBuffer[j]&0x7fffffff; /* remove case flag from the sign bit */
|
||||
if(q<n) {
|
||||
++delta;
|
||||
} else if(q==n) {
|
||||
/* Represent delta as a generalized variable-length integer: */
|
||||
for(q=delta, k=BASE; /* no condition */; k+=BASE) {
|
||||
|
||||
/** RAM: comment out the old code for conformance with draft-ietf-idn-punycode-03.txt
|
||||
|
||||
t=k-bias;
|
||||
if(t<TMIN) {
|
||||
t=TMIN;
|
||||
} else if(t>TMAX) {
|
||||
t=TMAX;
|
||||
}
|
||||
*/
|
||||
|
||||
t=k-bias;
|
||||
if(t<TMIN) {
|
||||
t=TMIN;
|
||||
} else if(k>=(bias+TMAX)) {
|
||||
t=TMAX;
|
||||
}
|
||||
|
||||
if(q<t) {
|
||||
break;
|
||||
}
|
||||
|
||||
if(destLength<destCapacity) {
|
||||
dest[destLength++]=digitToBasic(t+(q-t)%(BASE-t), false);
|
||||
}
|
||||
q=(q-t)/(BASE-t);
|
||||
}
|
||||
|
||||
if(destLength<destCapacity) {
|
||||
dest[destLength++]=digitToBasic(q, (cpBuffer[j]<0));
|
||||
}
|
||||
bias=adaptBias(delta, handledCPCount+1,(handledCPCount==basicLength));
|
||||
delta=0;
|
||||
++handledCPCount;
|
||||
}
|
||||
}
|
||||
|
||||
++delta;
|
||||
++n;
|
||||
}
|
||||
|
||||
return result.append(dest, 0, destLength);
|
||||
}
|
||||
|
||||
private static boolean isBasic(int ch){
|
||||
return (ch < INITIAL_N);
|
||||
}
|
||||
|
||||
private static boolean isBasicUpperCase(int ch){
|
||||
return( CAPITAL_A <= ch && ch <= CAPITAL_Z);
|
||||
}
|
||||
|
||||
private static boolean isSurrogate(int ch){
|
||||
return (((ch)&0xfffff800)==0xd800);
|
||||
}
|
||||
/**
|
||||
* Converts Punycode to Unicode.
|
||||
* The Unicode string will be at most as long as the Punycode string.
|
||||
*
|
||||
* @param src
|
||||
* @param caseFlags
|
||||
* @return
|
||||
* @throws ParseException
|
||||
*/
|
||||
public static StringBuffer decode(StringBuffer src, boolean[] caseFlags)
|
||||
throws ParseException{
|
||||
int srcLength = src.length();
|
||||
StringBuffer result = new StringBuffer();
|
||||
int n, destLength, i, bias, basicLength, j, in, oldi, w, k, digit, t,
|
||||
destCPCount, firstSupplementaryIndex, cpLength;
|
||||
char b;
|
||||
int destCapacity = MAX_CP_COUNT;
|
||||
char[] dest = new char[destCapacity];
|
||||
|
||||
/*
|
||||
* Handle the basic code points:
|
||||
* Let basicLength be the number of input code points
|
||||
* before the last delimiter, or 0 if there is none,
|
||||
* then copy the first basicLength code points to the output.
|
||||
*
|
||||
* The two following loops iterate backward.
|
||||
*/
|
||||
for(j=srcLength; j>0;) {
|
||||
if(src.charAt(--j)==DELIMITER) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
destLength=basicLength=destCPCount=j;
|
||||
|
||||
while(j>0) {
|
||||
b=src.charAt(--j);
|
||||
if(!isBasic(b)) {
|
||||
throw new ParseException("Illegal char found", -1);
|
||||
}
|
||||
|
||||
if(j<destCapacity) {
|
||||
dest[j]= b;
|
||||
|
||||
if(caseFlags!=null) {
|
||||
caseFlags[j]=isBasicUpperCase(b);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Initialize the state: */
|
||||
n=INITIAL_N;
|
||||
i=0;
|
||||
bias=INITIAL_BIAS;
|
||||
firstSupplementaryIndex=1000000000;
|
||||
|
||||
/*
|
||||
* Main decoding loop:
|
||||
* Start just after the last delimiter if any
|
||||
* basic code points were copied; start at the beginning otherwise.
|
||||
*/
|
||||
for(in=basicLength>0 ? basicLength+1 : 0; in<srcLength; /* no op */) {
|
||||
/*
|
||||
* in is the index of the next character to be consumed, and
|
||||
* destCPCount is the number of code points in the output array.
|
||||
*
|
||||
* Decode a generalized variable-length integer into delta,
|
||||
* which gets added to i. The overflow checking is easier
|
||||
* if we increase i as we go, then subtract off its starting
|
||||
* value at the end to obtain delta.
|
||||
*/
|
||||
for(oldi=i, w=1, k=BASE; /* no condition */; k+=BASE) {
|
||||
if(in>=srcLength) {
|
||||
throw new ParseException("Illegal char found", -1);
|
||||
}
|
||||
|
||||
digit=basicToDigit[(byte)src.charAt(in++)];
|
||||
if(digit<0) {
|
||||
throw new ParseException("Invalid char found", -1);
|
||||
}
|
||||
if(digit>(0x7fffffff-i)/w) {
|
||||
/* integer overflow */
|
||||
throw new ParseException("Illegal char found", -1);
|
||||
}
|
||||
|
||||
i+=digit*w;
|
||||
t=k-bias;
|
||||
if(t<TMIN) {
|
||||
t=TMIN;
|
||||
} else if(k>=(bias+TMAX)) {
|
||||
t=TMAX;
|
||||
}
|
||||
if(digit<t) {
|
||||
break;
|
||||
}
|
||||
|
||||
if(w>0x7fffffff/(BASE-t)) {
|
||||
/* integer overflow */
|
||||
throw new ParseException("Illegal char found", -1);
|
||||
}
|
||||
w*=BASE-t;
|
||||
}
|
||||
|
||||
/*
|
||||
* Modification from sample code:
|
||||
* Increments destCPCount here,
|
||||
* where needed instead of in for() loop tail.
|
||||
*/
|
||||
++destCPCount;
|
||||
bias=adaptBias(i-oldi, destCPCount, (oldi==0));
|
||||
|
||||
/*
|
||||
* i was supposed to wrap around from (incremented) destCPCount to 0,
|
||||
* incrementing n each time, so we'll fix that now:
|
||||
*/
|
||||
if(i/destCPCount>(0x7fffffff-n)) {
|
||||
/* integer overflow */
|
||||
throw new ParseException("Illegal char found", -1);
|
||||
}
|
||||
|
||||
n+=i/destCPCount;
|
||||
i%=destCPCount;
|
||||
/* not needed for Punycode: */
|
||||
/* if (decode_digit(n) <= BASE) return punycode_invalid_input; */
|
||||
|
||||
if(n>0x10ffff || isSurrogate(n)) {
|
||||
/* Unicode code point overflow */
|
||||
throw new ParseException("Illegal char found", -1);
|
||||
}
|
||||
|
||||
/* Insert n at position i of the output: */
|
||||
cpLength=UTF16.getCharCount(n);
|
||||
if((destLength+cpLength)<destCapacity) {
|
||||
int codeUnitIndex;
|
||||
|
||||
/*
|
||||
* Handle indexes when supplementary code points are present.
|
||||
*
|
||||
* In almost all cases, there will be only BMP code points before i
|
||||
* and even in the entire string.
|
||||
* This is handled with the same efficiency as with UTF-32.
|
||||
*
|
||||
* Only the rare cases with supplementary code points are handled
|
||||
* more slowly - but not too bad since this is an insertion anyway.
|
||||
*/
|
||||
if(i<=firstSupplementaryIndex) {
|
||||
codeUnitIndex=i;
|
||||
if(cpLength>1) {
|
||||
firstSupplementaryIndex=codeUnitIndex;
|
||||
} else {
|
||||
++firstSupplementaryIndex;
|
||||
}
|
||||
} else {
|
||||
codeUnitIndex=firstSupplementaryIndex;
|
||||
codeUnitIndex=UTF16.moveCodePointOffset(dest, 0, destLength, codeUnitIndex, i-codeUnitIndex);
|
||||
}
|
||||
|
||||
/* use the UChar index codeUnitIndex instead of the code point index i */
|
||||
if(codeUnitIndex<destLength) {
|
||||
System.arraycopy(dest, codeUnitIndex,
|
||||
dest, codeUnitIndex+cpLength,
|
||||
(destLength-codeUnitIndex));
|
||||
if(caseFlags!=null) {
|
||||
System.arraycopy(caseFlags, codeUnitIndex,
|
||||
caseFlags, codeUnitIndex+cpLength,
|
||||
destLength-codeUnitIndex);
|
||||
}
|
||||
}
|
||||
if(cpLength==1) {
|
||||
/* BMP, insert one code unit */
|
||||
dest[codeUnitIndex]=(char)n;
|
||||
} else {
|
||||
/* supplementary character, insert two code units */
|
||||
dest[codeUnitIndex]=UTF16.getLeadSurrogate(n);
|
||||
dest[codeUnitIndex+1]=UTF16.getTrailSurrogate(n);
|
||||
}
|
||||
if(caseFlags!=null) {
|
||||
/* Case of last character determines uppercase flag: */
|
||||
caseFlags[codeUnitIndex]=isBasicUpperCase(src.charAt(in-1));
|
||||
if(cpLength==2) {
|
||||
caseFlags[codeUnitIndex+1]=false;
|
||||
}
|
||||
}
|
||||
}
|
||||
destLength+=cpLength;
|
||||
++i;
|
||||
}
|
||||
result.append(dest, 0, destLength);
|
||||
return result;
|
||||
}
|
||||
}
|
486
src/java.base/share/classes/sun/net/idn/StringPrep.java
Normal file
486
src/java.base/share/classes/sun/net/idn/StringPrep.java
Normal file
|
@ -0,0 +1,486 @@
|
|||
/*
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
/*
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2003-2004, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
//
|
||||
// CHANGELOG
|
||||
// 2005-05-19 Edward Wang
|
||||
// - copy this file from icu4jsrc_3_2/src/com/ibm/icu/text/StringPrep.java
|
||||
// - move from package com.ibm.icu.text to package sun.net.idn
|
||||
// - use ParseException instead of StringPrepParseException
|
||||
// - change 'Normalizer.getUnicodeVersion()' to 'NormalizerImpl.getUnicodeVersion()'
|
||||
// - remove all @deprecated tag to make compiler happy
|
||||
// 2007-08-14 Martin Buchholz
|
||||
// - remove redundant casts
|
||||
//
|
||||
package sun.net.idn;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.text.ParseException;
|
||||
|
||||
import sun.text.Normalizer;
|
||||
import sun.text.normalizer.CharTrie;
|
||||
import sun.text.normalizer.Trie;
|
||||
import sun.text.normalizer.VersionInfo;
|
||||
import sun.text.normalizer.UCharacter;
|
||||
import sun.text.normalizer.UCharacterIterator;
|
||||
import sun.text.normalizer.UTF16;
|
||||
import sun.net.idn.UCharacterDirection;
|
||||
import sun.net.idn.StringPrepDataReader;
|
||||
|
||||
/**
|
||||
* StringPrep API implements the StingPrep framework as described by
|
||||
* <a href="http://www.ietf.org/rfc/rfc3454.txt">RFC 3454</a>.
|
||||
* StringPrep prepares Unicode strings for use in network protocols.
|
||||
* Profiles of StingPrep are set of rules and data according to which the
|
||||
* Unicode Strings are prepared. Each profiles contains tables which describe
|
||||
* how a code point should be treated. The tables are broadly classied into
|
||||
* <ul>
|
||||
* <li> Unassigned Table: Contains code points that are unassigned
|
||||
* in the Unicode Version supported by StringPrep. Currently
|
||||
* RFC 3454 supports Unicode 3.2. </li>
|
||||
* <li> Prohibited Table: Contains code points that are prohibted from
|
||||
* the output of the StringPrep processing function. </li>
|
||||
* <li> Mapping Table: Contains code ponts that are deleted from the output or case mapped. </li>
|
||||
* </ul>
|
||||
*
|
||||
* The procedure for preparing Unicode strings:
|
||||
* <ol>
|
||||
* <li> Map: For each character in the input, check if it has a mapping
|
||||
* and, if so, replace it with its mapping. </li>
|
||||
* <li> Normalize: Possibly normalize the result of step 1 using Unicode
|
||||
* normalization. </li>
|
||||
* <li> Prohibit: Check for any characters that are not allowed in the
|
||||
* output. If any are found, return an error.</li>
|
||||
* <li> Check bidi: Possibly check for right-to-left characters, and if
|
||||
* any are found, make sure that the whole string satisfies the
|
||||
* requirements for bidirectional strings. If the string does not
|
||||
* satisfy the requirements for bidirectional strings, return an
|
||||
* error. </li>
|
||||
* </ol>
|
||||
* @author Ram Viswanadha
|
||||
* @draft ICU 2.8
|
||||
*/
|
||||
public final class StringPrep {
|
||||
/**
|
||||
* Option to prohibit processing of unassigned code points in the input
|
||||
*
|
||||
* @see #prepare
|
||||
* @draft ICU 2.8
|
||||
*/
|
||||
public static final int DEFAULT = 0x0000;
|
||||
|
||||
/**
|
||||
* Option to allow processing of unassigned code points in the input
|
||||
*
|
||||
* @see #prepare
|
||||
* @draft ICU 2.8
|
||||
*/
|
||||
public static final int ALLOW_UNASSIGNED = 0x0001;
|
||||
|
||||
private static final int UNASSIGNED = 0x0000;
|
||||
private static final int MAP = 0x0001;
|
||||
private static final int PROHIBITED = 0x0002;
|
||||
private static final int DELETE = 0x0003;
|
||||
private static final int TYPE_LIMIT = 0x0004;
|
||||
|
||||
private static final int NORMALIZATION_ON = 0x0001;
|
||||
private static final int CHECK_BIDI_ON = 0x0002;
|
||||
|
||||
private static final int TYPE_THRESHOLD = 0xFFF0;
|
||||
private static final int MAX_INDEX_VALUE = 0x3FBF; /*16139*/
|
||||
private static final int MAX_INDEX_TOP_LENGTH = 0x0003;
|
||||
|
||||
/* indexes[] value names */
|
||||
private static final int INDEX_TRIE_SIZE = 0; /* number of bytes in normalization trie */
|
||||
private static final int INDEX_MAPPING_DATA_SIZE = 1; /* The array that contains the mapping */
|
||||
private static final int NORM_CORRECTNS_LAST_UNI_VERSION = 2; /* The index of Unicode version of last entry in NormalizationCorrections.txt */
|
||||
private static final int ONE_UCHAR_MAPPING_INDEX_START = 3; /* The starting index of 1 UChar mapping index in the mapping data array */
|
||||
private static final int TWO_UCHARS_MAPPING_INDEX_START = 4; /* The starting index of 2 UChars mapping index in the mapping data array */
|
||||
private static final int THREE_UCHARS_MAPPING_INDEX_START = 5;
|
||||
private static final int FOUR_UCHARS_MAPPING_INDEX_START = 6;
|
||||
private static final int OPTIONS = 7; /* Bit set of options to turn on in the profile */
|
||||
private static final int INDEX_TOP = 16; /* changing this requires a new formatVersion */
|
||||
|
||||
|
||||
/**
|
||||
* Default buffer size of datafile
|
||||
*/
|
||||
private static final int DATA_BUFFER_SIZE = 25000;
|
||||
|
||||
/* Wrappers for Trie implementations */
|
||||
private static final class StringPrepTrieImpl implements Trie.DataManipulate{
|
||||
private CharTrie sprepTrie = null;
|
||||
/**
|
||||
* 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 property 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){
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
// CharTrie implementation for reading the trie data
|
||||
private StringPrepTrieImpl sprepTrieImpl;
|
||||
// Indexes read from the data file
|
||||
private int[] indexes;
|
||||
// mapping data read from the data file
|
||||
private char[] mappingData;
|
||||
// format version of the data file
|
||||
private byte[] formatVersion;
|
||||
// the version of Unicode supported by the data file
|
||||
private VersionInfo sprepUniVer;
|
||||
// the Unicode version of last entry in the
|
||||
// NormalizationCorrections.txt file if normalization
|
||||
// is turned on
|
||||
private VersionInfo normCorrVer;
|
||||
// Option to turn on Normalization
|
||||
private boolean doNFKC;
|
||||
// Option to turn on checking for BiDi rules
|
||||
private boolean checkBiDi;
|
||||
|
||||
|
||||
private char getCodePointValue(int ch){
|
||||
return sprepTrieImpl.sprepTrie.getCodePointValue(ch);
|
||||
}
|
||||
|
||||
private static VersionInfo getVersionInfo(int comp){
|
||||
int micro = comp & 0xFF;
|
||||
int milli =(comp >> 8) & 0xFF;
|
||||
int minor =(comp >> 16) & 0xFF;
|
||||
int major =(comp >> 24) & 0xFF;
|
||||
return VersionInfo.getInstance(major,minor,milli,micro);
|
||||
}
|
||||
private static VersionInfo getVersionInfo(byte[] version){
|
||||
if(version.length != 4){
|
||||
return null;
|
||||
}
|
||||
return VersionInfo.getInstance((int)version[0],(int) version[1],(int) version[2],(int) version[3]);
|
||||
}
|
||||
/**
|
||||
* Creates an StringPrep object after reading the input stream.
|
||||
* The object does not hold a reference to the input steam, so the stream can be
|
||||
* closed after the method returns.
|
||||
*
|
||||
* @param inputStream The stream for reading the StringPrep profile binarySun
|
||||
* @throws IOException
|
||||
* @draft ICU 2.8
|
||||
*/
|
||||
public StringPrep(InputStream inputStream) throws IOException{
|
||||
|
||||
BufferedInputStream b = new BufferedInputStream(inputStream,DATA_BUFFER_SIZE);
|
||||
|
||||
StringPrepDataReader reader = new StringPrepDataReader(b);
|
||||
|
||||
// read the indexes
|
||||
indexes = reader.readIndexes(INDEX_TOP);
|
||||
|
||||
byte[] sprepBytes = new byte[indexes[INDEX_TRIE_SIZE]];
|
||||
|
||||
|
||||
//indexes[INDEX_MAPPING_DATA_SIZE] store the size of mappingData in bytes
|
||||
mappingData = new char[indexes[INDEX_MAPPING_DATA_SIZE]/2];
|
||||
// load the rest of the data data and initialize the data members
|
||||
reader.read(sprepBytes,mappingData);
|
||||
|
||||
sprepTrieImpl = new StringPrepTrieImpl();
|
||||
sprepTrieImpl.sprepTrie = new CharTrie( new ByteArrayInputStream(sprepBytes),sprepTrieImpl );
|
||||
|
||||
// get the data format version
|
||||
formatVersion = reader.getDataFormatVersion();
|
||||
|
||||
// get the options
|
||||
doNFKC = ((indexes[OPTIONS] & NORMALIZATION_ON) > 0);
|
||||
checkBiDi = ((indexes[OPTIONS] & CHECK_BIDI_ON) > 0);
|
||||
sprepUniVer = getVersionInfo(reader.getUnicodeVersion());
|
||||
normCorrVer = getVersionInfo(indexes[NORM_CORRECTNS_LAST_UNI_VERSION]);
|
||||
VersionInfo normUniVer = UCharacter.getUnicodeVersion();
|
||||
if(normUniVer.compareTo(sprepUniVer) < 0 && /* the Unicode version of SPREP file must be less than the Unicode Vesion of the normalization data */
|
||||
normUniVer.compareTo(normCorrVer) < 0 && /* the Unicode version of the NormalizationCorrections.txt file should be less than the Unicode Vesion of the normalization data */
|
||||
((indexes[OPTIONS] & NORMALIZATION_ON) > 0) /* normalization turned on*/
|
||||
){
|
||||
throw new IOException("Normalization Correction version not supported");
|
||||
}
|
||||
b.close();
|
||||
}
|
||||
|
||||
private static final class Values{
|
||||
boolean isIndex;
|
||||
int value;
|
||||
int type;
|
||||
public void reset(){
|
||||
isIndex = false;
|
||||
value = 0;
|
||||
type = -1;
|
||||
}
|
||||
}
|
||||
|
||||
private static final void getValues(char trieWord,Values values){
|
||||
values.reset();
|
||||
if(trieWord == 0){
|
||||
/*
|
||||
* Initial value stored in the mapping table
|
||||
* just return TYPE_LIMIT .. so that
|
||||
* the source codepoint is copied to the destination
|
||||
*/
|
||||
values.type = TYPE_LIMIT;
|
||||
}else if(trieWord >= TYPE_THRESHOLD){
|
||||
values.type = (trieWord - TYPE_THRESHOLD);
|
||||
}else{
|
||||
/* get the type */
|
||||
values.type = MAP;
|
||||
/* ascertain if the value is index or delta */
|
||||
if((trieWord & 0x02)>0){
|
||||
values.isIndex = true;
|
||||
values.value = trieWord >> 2; //mask off the lower 2 bits and shift
|
||||
|
||||
}else{
|
||||
values.isIndex = false;
|
||||
values.value = (trieWord<<16)>>16;
|
||||
values.value = (values.value >> 2);
|
||||
|
||||
}
|
||||
|
||||
if((trieWord>>2) == MAX_INDEX_VALUE){
|
||||
values.type = DELETE;
|
||||
values.isIndex = false;
|
||||
values.value = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private StringBuffer map( UCharacterIterator iter, int options)
|
||||
throws ParseException {
|
||||
|
||||
Values val = new Values();
|
||||
char result = 0;
|
||||
int ch = UCharacterIterator.DONE;
|
||||
StringBuffer dest = new StringBuffer();
|
||||
boolean allowUnassigned = ((options & ALLOW_UNASSIGNED)>0);
|
||||
|
||||
while((ch=iter.nextCodePoint())!= UCharacterIterator.DONE){
|
||||
|
||||
result = getCodePointValue(ch);
|
||||
getValues(result,val);
|
||||
|
||||
// check if the source codepoint is unassigned
|
||||
if(val.type == UNASSIGNED && allowUnassigned == false){
|
||||
throw new ParseException("An unassigned code point was found in the input " +
|
||||
iter.getText(), iter.getIndex());
|
||||
}else if((val.type == MAP)){
|
||||
int index, length;
|
||||
|
||||
if(val.isIndex){
|
||||
index = val.value;
|
||||
if(index >= indexes[ONE_UCHAR_MAPPING_INDEX_START] &&
|
||||
index < indexes[TWO_UCHARS_MAPPING_INDEX_START]){
|
||||
length = 1;
|
||||
}else if(index >= indexes[TWO_UCHARS_MAPPING_INDEX_START] &&
|
||||
index < indexes[THREE_UCHARS_MAPPING_INDEX_START]){
|
||||
length = 2;
|
||||
}else if(index >= indexes[THREE_UCHARS_MAPPING_INDEX_START] &&
|
||||
index < indexes[FOUR_UCHARS_MAPPING_INDEX_START]){
|
||||
length = 3;
|
||||
}else{
|
||||
length = mappingData[index++];
|
||||
}
|
||||
/* copy mapping to destination */
|
||||
dest.append(mappingData,index,length);
|
||||
continue;
|
||||
|
||||
}else{
|
||||
ch -= val.value;
|
||||
}
|
||||
}else if(val.type == DELETE){
|
||||
// just consume the codepoint and contine
|
||||
continue;
|
||||
}
|
||||
//copy the source into destination
|
||||
UTF16.append(dest,ch);
|
||||
}
|
||||
|
||||
return dest;
|
||||
}
|
||||
|
||||
|
||||
private StringBuffer normalize(StringBuffer src){
|
||||
/*
|
||||
* Option UNORM_BEFORE_PRI_29:
|
||||
*
|
||||
* IDNA as interpreted by IETF members (see unicode mailing list 2004H1)
|
||||
* requires strict adherence to Unicode 3.2 normalization,
|
||||
* including buggy composition from before fixing Public Review Issue #29.
|
||||
* Note that this results in some valid but nonsensical text to be
|
||||
* either corrupted or rejected, depending on the text.
|
||||
* See http://www.unicode.org/review/resolved-pri.html#pri29
|
||||
* See unorm.cpp and cnormtst.c
|
||||
*/
|
||||
return new StringBuffer(
|
||||
Normalizer.normalize(
|
||||
src.toString(),
|
||||
java.text.Normalizer.Form.NFKC,
|
||||
Normalizer.UNICODE_3_2));
|
||||
}
|
||||
/*
|
||||
boolean isLabelSeparator(int ch){
|
||||
int result = getCodePointValue(ch);
|
||||
if( (result & 0x07) == LABEL_SEPARATOR){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
/*
|
||||
1) Map -- For each character in the input, check if it has a mapping
|
||||
and, if so, replace it with its mapping.
|
||||
|
||||
2) Normalize -- Possibly normalize the result of step 1 using Unicode
|
||||
normalization.
|
||||
|
||||
3) Prohibit -- Check for any characters that are not allowed in the
|
||||
output. If any are found, return an error.
|
||||
|
||||
4) Check bidi -- Possibly check for right-to-left characters, and if
|
||||
any are found, make sure that the whole string satisfies the
|
||||
requirements for bidirectional strings. If the string does not
|
||||
satisfy the requirements for bidirectional strings, return an
|
||||
error.
|
||||
[Unicode3.2] defines several bidirectional categories; each character
|
||||
has one bidirectional category assigned to it. For the purposes of
|
||||
the requirements below, an "RandALCat character" is a character that
|
||||
has Unicode bidirectional categories "R" or "AL"; an "LCat character"
|
||||
is a character that has Unicode bidirectional category "L". Note
|
||||
|
||||
|
||||
that there are many characters which fall in neither of the above
|
||||
definitions; Latin digits (<U+0030> through <U+0039>) are examples of
|
||||
this because they have bidirectional category "EN".
|
||||
|
||||
In any profile that specifies bidirectional character handling, all
|
||||
three of the following requirements MUST be met:
|
||||
|
||||
1) The characters in section 5.8 MUST be prohibited.
|
||||
|
||||
2) If a string contains any RandALCat character, the string MUST NOT
|
||||
contain any LCat character.
|
||||
|
||||
3) If a string contains any RandALCat character, a RandALCat
|
||||
character MUST be the first character of the string, and a
|
||||
RandALCat character MUST be the last character of the string.
|
||||
*/
|
||||
/**
|
||||
* Prepare the input buffer for use in applications with the given profile. This operation maps, normalizes(NFKC),
|
||||
* checks for prohited and BiDi characters in the order defined by RFC 3454
|
||||
* depending on the options specified in the profile.
|
||||
*
|
||||
* @param src A UCharacterIterator object containing the source string
|
||||
* @param options A bit set of options:
|
||||
*
|
||||
* - StringPrep.NONE Prohibit processing of unassigned code points in the input
|
||||
*
|
||||
* - StringPrep.ALLOW_UNASSIGNED Treat the unassigned code points are in the input
|
||||
* as normal Unicode code points.
|
||||
*
|
||||
* @return StringBuffer A StringBuffer containing the output
|
||||
* @throws ParseException
|
||||
* @draft ICU 2.8
|
||||
*/
|
||||
public StringBuffer prepare(UCharacterIterator src, int options)
|
||||
throws ParseException{
|
||||
|
||||
// map
|
||||
StringBuffer mapOut = map(src,options);
|
||||
StringBuffer normOut = mapOut;// initialize
|
||||
|
||||
if(doNFKC){
|
||||
// normalize
|
||||
normOut = normalize(mapOut);
|
||||
}
|
||||
|
||||
int ch;
|
||||
char result;
|
||||
UCharacterIterator iter = UCharacterIterator.getInstance(normOut);
|
||||
Values val = new Values();
|
||||
int direction=UCharacterDirection.CHAR_DIRECTION_COUNT,
|
||||
firstCharDir=UCharacterDirection.CHAR_DIRECTION_COUNT;
|
||||
int rtlPos=-1, ltrPos=-1;
|
||||
boolean rightToLeft=false, leftToRight=false;
|
||||
|
||||
while((ch=iter.nextCodePoint())!= UCharacterIterator.DONE){
|
||||
result = getCodePointValue(ch);
|
||||
getValues(result,val);
|
||||
|
||||
if(val.type == PROHIBITED ){
|
||||
throw new ParseException("A prohibited code point was found in the input" +
|
||||
iter.getText(), val.value);
|
||||
}
|
||||
|
||||
direction = UCharacter.getDirection(ch);
|
||||
if(firstCharDir == UCharacterDirection.CHAR_DIRECTION_COUNT){
|
||||
firstCharDir = direction;
|
||||
}
|
||||
if(direction == UCharacterDirection.LEFT_TO_RIGHT){
|
||||
leftToRight = true;
|
||||
ltrPos = iter.getIndex()-1;
|
||||
}
|
||||
if(direction == UCharacterDirection.RIGHT_TO_LEFT || direction == UCharacterDirection.RIGHT_TO_LEFT_ARABIC){
|
||||
rightToLeft = true;
|
||||
rtlPos = iter.getIndex()-1;
|
||||
}
|
||||
}
|
||||
if(checkBiDi == true){
|
||||
// satisfy 2
|
||||
if( leftToRight == true && rightToLeft == true){
|
||||
throw new ParseException("The input does not conform to the rules for BiDi code points." +
|
||||
iter.getText(),
|
||||
(rtlPos>ltrPos) ? rtlPos : ltrPos);
|
||||
}
|
||||
|
||||
//satisfy 3
|
||||
if( rightToLeft == true &&
|
||||
!((firstCharDir == UCharacterDirection.RIGHT_TO_LEFT || firstCharDir == UCharacterDirection.RIGHT_TO_LEFT_ARABIC) &&
|
||||
(direction == UCharacterDirection.RIGHT_TO_LEFT || direction == UCharacterDirection.RIGHT_TO_LEFT_ARABIC))
|
||||
){
|
||||
throw new ParseException("The input does not conform to the rules for BiDi code points." +
|
||||
iter.getText(),
|
||||
(rtlPos>ltrPos) ? rtlPos : ltrPos);
|
||||
}
|
||||
}
|
||||
return normOut;
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,127 @@
|
|||
/*
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
/*
|
||||
/*
|
||||
******************************************************************************
|
||||
* Copyright (C) 2003, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
******************************************************************************
|
||||
*
|
||||
* Created on May 2, 2003
|
||||
*
|
||||
* To change the template for this generated file go to
|
||||
* Window>Preferences>Java>Code Generation>Code and Comments
|
||||
*/
|
||||
// CHANGELOG
|
||||
// 2005-05-19 Edward Wang
|
||||
// - copy this file from icu4jsrc_3_2/src/com/ibm/icu/impl/StringPrepDataReader.java
|
||||
// - move from package com.ibm.icu.impl to package sun.net.idn
|
||||
//
|
||||
package sun.net.idn;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import sun.text.normalizer.ICUBinary;
|
||||
|
||||
|
||||
/**
|
||||
* @author ram
|
||||
*
|
||||
* To change the template for this generated type comment go to
|
||||
* Window>Preferences>Java>Code Generation>Code and Comments
|
||||
*/
|
||||
final class StringPrepDataReader implements ICUBinary.Authenticate {
|
||||
|
||||
/**
|
||||
* <p>private constructor.</p>
|
||||
* @param inputStream ICU uprop.dat file input stream
|
||||
* @exception IOException throw if data file fails authentication
|
||||
* @draft 2.1
|
||||
*/
|
||||
public StringPrepDataReader(InputStream inputStream)
|
||||
throws IOException{
|
||||
|
||||
unicodeVersion = ICUBinary.readHeader(inputStream, DATA_FORMAT_ID, this);
|
||||
|
||||
|
||||
dataInputStream = new DataInputStream(inputStream);
|
||||
|
||||
}
|
||||
|
||||
public void read(byte[] idnaBytes,
|
||||
char[] mappingTable)
|
||||
throws IOException{
|
||||
|
||||
//Read the bytes that make up the idnaTrie
|
||||
dataInputStream.read(idnaBytes);
|
||||
|
||||
//Read the extra data
|
||||
for(int i=0;i<mappingTable.length;i++){
|
||||
mappingTable[i]=dataInputStream.readChar();
|
||||
}
|
||||
}
|
||||
|
||||
public byte[] getDataFormatVersion(){
|
||||
return DATA_FORMAT_VERSION;
|
||||
}
|
||||
|
||||
public boolean isDataVersionAcceptable(byte version[]){
|
||||
return version[0] == DATA_FORMAT_VERSION[0]
|
||||
&& version[2] == DATA_FORMAT_VERSION[2]
|
||||
&& version[3] == DATA_FORMAT_VERSION[3];
|
||||
}
|
||||
public int[] readIndexes(int length)throws IOException{
|
||||
int[] indexes = new int[length];
|
||||
//Read the indexes
|
||||
for (int i = 0; i <length ; i++) {
|
||||
indexes[i] = dataInputStream.readInt();
|
||||
}
|
||||
return indexes;
|
||||
}
|
||||
|
||||
public byte[] getUnicodeVersion(){
|
||||
return unicodeVersion;
|
||||
}
|
||||
// private data members -------------------------------------------------
|
||||
|
||||
|
||||
/**
|
||||
* ICU data file input stream
|
||||
*/
|
||||
private DataInputStream dataInputStream;
|
||||
private byte[] unicodeVersion;
|
||||
/**
|
||||
* File format version that this class understands.
|
||||
* No guarantees are made if a older version is used
|
||||
* see store.c of gennorm for more information and values
|
||||
*/
|
||||
///* dataFormat="SPRP" 0x53, 0x50, 0x52, 0x50 */
|
||||
private static final byte DATA_FORMAT_ID[] = {(byte)0x53, (byte)0x50,
|
||||
(byte)0x52, (byte)0x50};
|
||||
private static final byte DATA_FORMAT_VERSION[] = {(byte)0x3, (byte)0x2,
|
||||
(byte)0x5, (byte)0x2};
|
||||
|
||||
}
|
112
src/java.base/share/classes/sun/net/idn/UCharacterDirection.java
Normal file
112
src/java.base/share/classes/sun/net/idn/UCharacterDirection.java
Normal file
|
@ -0,0 +1,112 @@
|
|||
/*
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
/*
|
||||
/**
|
||||
*******************************************************************************
|
||||
* Copyright (C) 1996-2004, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
// CHANGELOG
|
||||
// 2005-05-19 Edward Wang
|
||||
// - copy this file from icu4jsrc_3_2/src/com/ibm/icu/lang/UCharacterDirection.java
|
||||
// - move from package com.ibm.icu.lang to package sun.net.idn
|
||||
//
|
||||
|
||||
package sun.net.idn;
|
||||
|
||||
/**
|
||||
* Enumerated Unicode character linguistic direction constants.
|
||||
* Used as return results from <a href=UCharacter.html>UCharacter</a>
|
||||
* <p>
|
||||
* This class is not subclassable
|
||||
* </p>
|
||||
* @author Syn Wee Quek
|
||||
* @stable ICU 2.1
|
||||
*/
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
final class UCharacterDirection implements UCharacterEnums.ECharacterDirection {
|
||||
|
||||
// private constructor =========================================
|
||||
///CLOVER:OFF
|
||||
/**
|
||||
* Private constructor to prevent initialisation
|
||||
*/
|
||||
private UCharacterDirection()
|
||||
{
|
||||
}
|
||||
///CLOVER:ON
|
||||
|
||||
/**
|
||||
* Gets the name of the argument direction
|
||||
* @param dir direction type to retrieve name
|
||||
* @return directional name
|
||||
* @stable ICU 2.1
|
||||
*/
|
||||
public static String toString(int dir) {
|
||||
switch(dir)
|
||||
{
|
||||
case LEFT_TO_RIGHT :
|
||||
return "Left-to-Right";
|
||||
case RIGHT_TO_LEFT :
|
||||
return "Right-to-Left";
|
||||
case EUROPEAN_NUMBER :
|
||||
return "European Number";
|
||||
case EUROPEAN_NUMBER_SEPARATOR :
|
||||
return "European Number Separator";
|
||||
case EUROPEAN_NUMBER_TERMINATOR :
|
||||
return "European Number Terminator";
|
||||
case ARABIC_NUMBER :
|
||||
return "Arabic Number";
|
||||
case COMMON_NUMBER_SEPARATOR :
|
||||
return "Common Number Separator";
|
||||
case BLOCK_SEPARATOR :
|
||||
return "Paragraph Separator";
|
||||
case SEGMENT_SEPARATOR :
|
||||
return "Segment Separator";
|
||||
case WHITE_SPACE_NEUTRAL :
|
||||
return "Whitespace";
|
||||
case OTHER_NEUTRAL :
|
||||
return "Other Neutrals";
|
||||
case LEFT_TO_RIGHT_EMBEDDING :
|
||||
return "Left-to-Right Embedding";
|
||||
case LEFT_TO_RIGHT_OVERRIDE :
|
||||
return "Left-to-Right Override";
|
||||
case RIGHT_TO_LEFT_ARABIC :
|
||||
return "Right-to-Left Arabic";
|
||||
case RIGHT_TO_LEFT_EMBEDDING :
|
||||
return "Right-to-Left Embedding";
|
||||
case RIGHT_TO_LEFT_OVERRIDE :
|
||||
return "Right-to-Left Override";
|
||||
case POP_DIRECTIONAL_FORMAT :
|
||||
return "Pop Directional Format";
|
||||
case DIR_NON_SPACING_MARK :
|
||||
return "Non-Spacing Mark";
|
||||
case BOUNDARY_NEUTRAL :
|
||||
return "Boundary Neutral";
|
||||
}
|
||||
return "Unassigned";
|
||||
}
|
||||
}
|
587
src/java.base/share/classes/sun/net/idn/UCharacterEnums.java
Normal file
587
src/java.base/share/classes/sun/net/idn/UCharacterEnums.java
Normal file
|
@ -0,0 +1,587 @@
|
|||
/*
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
/*
|
||||
/**
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2004, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
// CHANGELOG
|
||||
// 2005-05-19 Edward Wang
|
||||
// - copy this file from icu4jsrc_3_2/src/com/ibm/icu/lang/UCharacterEnums.java
|
||||
// - move from package com.ibm.icu.lang to package sun.net.idn
|
||||
//
|
||||
// 2011-09-06 Kurchi Subhra Hazra
|
||||
// - Added @Deprecated tag to the following:
|
||||
// - class UCharacterEnums
|
||||
// - interfaces ECharacterCategory, ECharacterDirection
|
||||
// - fields INITIAL_QUOTE_PUNCTUATION, FINAL_QUOTE_PUNCTUATION,
|
||||
// DIRECTIONALITY_LEFT_TO_RIGHT, DIRECTIONALITY_RIGHT_TO_LEFT,
|
||||
// DIRECTIONALITY_EUROPEAN_NUMBER, DIRECTIONALITY_EUROPEAN_NUMBER_SEPARATOR
|
||||
// DIRECTIONALITY_EUROPEAN_NUMBER_TERMINATOR, DIRECTIONALITY_ARABIC_NUMBER,
|
||||
// DIRECTIONALITY_COMMON_NUMBER_SEPARATOR, DIRECTIONALITY_PARAGRAPH_SEPARATOR,
|
||||
// DIRECTIONALITY_SEGMENT_SEPARATOR, DIRECTIONALITY_WHITESPACE,
|
||||
// DIRECTIONALITY_OTHER_NEUTRALS, DIRECTIONALITY_LEFT_TO_RIGHT_EMBEDDING,
|
||||
// DIRECTIONALITY_LEFT_TO_RIGHT_OVERRIDE, DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC,
|
||||
// DIRECTIONALITY_RIGHT_TO_LEFT_EMBEDDING, DIRECTIONALITY_RIGHT_TO_LEFT_OVERRIDE,
|
||||
// DIRECTIONALITY_POP_DIRECTIONAL_FORMAT, DIRECTIONALITY_NON_SPACING_MARK,
|
||||
// DIRECTIONALITY_BOUNDARY_NEUTRAL, DIRECTIONALITY_UNDEFINED
|
||||
//
|
||||
|
||||
package sun.net.idn;
|
||||
|
||||
/**
|
||||
* A container for the different 'enumerated types' used by UCharacter.
|
||||
* @draft ICU 3.0
|
||||
* @deprecated This is a draft API and might change in a future release of ICU.
|
||||
*/
|
||||
|
||||
@Deprecated
|
||||
class UCharacterEnums {
|
||||
|
||||
/** This is just a namespace, it is not instantiatable. */
|
||||
private UCharacterEnums() {};
|
||||
|
||||
/**
|
||||
* '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.
|
||||
*/
|
||||
@Deprecated
|
||||
public static interface ECharacterCategory {
|
||||
/**
|
||||
* Unassigned character type
|
||||
* @stable ICU 2.1
|
||||
*/
|
||||
public static final int UNASSIGNED = 0;
|
||||
|
||||
/**
|
||||
* Character type Cn
|
||||
* Not Assigned (no characters in [UnicodeData.txt] have this property)
|
||||
* @stable ICU 2.6
|
||||
*/
|
||||
public static final int GENERAL_OTHER_TYPES = 0;
|
||||
|
||||
/**
|
||||
* Character type Lu
|
||||
* @stable ICU 2.1
|
||||
*/
|
||||
public static final int UPPERCASE_LETTER = 1;
|
||||
|
||||
/**
|
||||
* Character type Ll
|
||||
* @stable ICU 2.1
|
||||
*/
|
||||
public static final int LOWERCASE_LETTER = 2;
|
||||
|
||||
/**
|
||||
* Character type Lt
|
||||
* @stable ICU 2.1
|
||||
*/
|
||||
|
||||
public static final int TITLECASE_LETTER = 3;
|
||||
|
||||
/**
|
||||
* Character type Lm
|
||||
* @stable ICU 2.1
|
||||
*/
|
||||
public static final int MODIFIER_LETTER = 4;
|
||||
|
||||
/**
|
||||
* Character type Lo
|
||||
* @stable ICU 2.1
|
||||
*/
|
||||
public static final int OTHER_LETTER = 5;
|
||||
|
||||
/**
|
||||
* Character type Mn
|
||||
* @stable ICU 2.1
|
||||
*/
|
||||
public static final int NON_SPACING_MARK = 6;
|
||||
|
||||
/**
|
||||
* Character type Me
|
||||
* @stable ICU 2.1
|
||||
*/
|
||||
public static final int ENCLOSING_MARK = 7;
|
||||
|
||||
/**
|
||||
* Character type Mc
|
||||
* @stable ICU 2.1
|
||||
*/
|
||||
public static final int COMBINING_SPACING_MARK = 8;
|
||||
|
||||
/**
|
||||
* Character type Nd
|
||||
* @stable ICU 2.1
|
||||
*/
|
||||
public static final int DECIMAL_DIGIT_NUMBER = 9;
|
||||
|
||||
/**
|
||||
* Character type Nl
|
||||
* @stable ICU 2.1
|
||||
*/
|
||||
public static final int LETTER_NUMBER = 10;
|
||||
|
||||
/**
|
||||
* Character type No
|
||||
* @stable ICU 2.1
|
||||
*/
|
||||
public static final int OTHER_NUMBER = 11;
|
||||
|
||||
/**
|
||||
* Character type Zs
|
||||
* @stable ICU 2.1
|
||||
*/
|
||||
public static final int SPACE_SEPARATOR = 12;
|
||||
|
||||
/**
|
||||
* Character type Zl
|
||||
* @stable ICU 2.1
|
||||
*/
|
||||
public static final int LINE_SEPARATOR = 13;
|
||||
|
||||
/**
|
||||
* Character type Zp
|
||||
* @stable ICU 2.1
|
||||
*/
|
||||
public static final int PARAGRAPH_SEPARATOR = 14;
|
||||
|
||||
/**
|
||||
* Character type Cc
|
||||
* @stable ICU 2.1
|
||||
*/
|
||||
public static final int CONTROL = 15;
|
||||
|
||||
/**
|
||||
* Character type Cf
|
||||
* @stable ICU 2.1
|
||||
*/
|
||||
public static final int FORMAT = 16;
|
||||
|
||||
/**
|
||||
* Character type Co
|
||||
* @stable ICU 2.1
|
||||
*/
|
||||
public static final int PRIVATE_USE = 17;
|
||||
|
||||
/**
|
||||
* Character type Cs
|
||||
* @stable ICU 2.1
|
||||
*/
|
||||
public static final int SURROGATE = 18;
|
||||
|
||||
/**
|
||||
* Character type Pd
|
||||
* @stable ICU 2.1
|
||||
*/
|
||||
public static final int DASH_PUNCTUATION = 19;
|
||||
|
||||
/**
|
||||
* Character type Ps
|
||||
* @stable ICU 2.1
|
||||
*/
|
||||
public static final int START_PUNCTUATION = 20;
|
||||
|
||||
/**
|
||||
* Character type Pe
|
||||
* @stable ICU 2.1
|
||||
*/
|
||||
public static final int END_PUNCTUATION = 21;
|
||||
|
||||
/**
|
||||
* Character type Pc
|
||||
* @stable ICU 2.1
|
||||
*/
|
||||
public static final int CONNECTOR_PUNCTUATION = 22;
|
||||
|
||||
/**
|
||||
* Character type Po
|
||||
* @stable ICU 2.1
|
||||
*/
|
||||
public static final int OTHER_PUNCTUATION = 23;
|
||||
|
||||
/**
|
||||
* Character type Sm
|
||||
* @stable ICU 2.1
|
||||
*/
|
||||
public static final int MATH_SYMBOL = 24;
|
||||
|
||||
/**
|
||||
* Character type Sc
|
||||
* @stable ICU 2.1
|
||||
*/
|
||||
public static final int CURRENCY_SYMBOL = 25;
|
||||
|
||||
/**
|
||||
* Character type Sk
|
||||
* @stable ICU 2.1
|
||||
*/
|
||||
public static final int MODIFIER_SYMBOL = 26;
|
||||
|
||||
/**
|
||||
* Character type So
|
||||
* @stable ICU 2.1
|
||||
*/
|
||||
public static final int OTHER_SYMBOL = 27;
|
||||
|
||||
/**
|
||||
* Character type Pi
|
||||
* @see #INITIAL_QUOTE_PUNCTUATION
|
||||
* @stable ICU 2.1
|
||||
*/
|
||||
public static final int INITIAL_PUNCTUATION = 28;
|
||||
|
||||
/**
|
||||
* Character type Pi
|
||||
* This name is compatible with java.lang.Character's name for this type.
|
||||
* @see #INITIAL_PUNCTUATION
|
||||
* @draft ICU 2.8
|
||||
* @deprecated This is a draft API and might change in a future release of ICU.
|
||||
*/
|
||||
@Deprecated
|
||||
public static final int INITIAL_QUOTE_PUNCTUATION = 28;
|
||||
|
||||
/**
|
||||
* Character type Pf
|
||||
* @see #FINAL_QUOTE_PUNCTUATION
|
||||
* @stable ICU 2.1
|
||||
*/
|
||||
public static final int FINAL_PUNCTUATION = 29;
|
||||
|
||||
/**
|
||||
* Character type Pf
|
||||
* This name is compatible with java.lang.Character's name for this type.
|
||||
* @see #FINAL_PUNCTUATION
|
||||
* @draft ICU 2.8
|
||||
* @deprecated This is a draft API and might change in a future release of ICU.
|
||||
*/
|
||||
@Deprecated
|
||||
public static final int FINAL_QUOTE_PUNCTUATION = 29;
|
||||
|
||||
/**
|
||||
* Character type count
|
||||
* @stable ICU 2.1
|
||||
*/
|
||||
public static final int CHAR_CATEGORY_COUNT = 30;
|
||||
}
|
||||
|
||||
/**
|
||||
* 'Enum' for the CharacterDirection constants. There are two sets
|
||||
* of names, those used in ICU, and those used in the JDK. The
|
||||
* JDK constants are compatible in name <b>but not in value</b>
|
||||
* with those defined in <code>java.lang.Character</code>.
|
||||
* @see UCharacterDirection
|
||||
* @draft ICU 3.0
|
||||
* @deprecated This is a draft API and might change in a future release of ICU.
|
||||
*/
|
||||
|
||||
@Deprecated
|
||||
public static interface ECharacterDirection {
|
||||
/**
|
||||
* Directional type L
|
||||
* @stable ICU 2.1
|
||||
*/
|
||||
public static final int LEFT_TO_RIGHT = 0;
|
||||
|
||||
/**
|
||||
* JDK-compatible synonum for LEFT_TO_RIGHT.
|
||||
* @draft ICU 3.0
|
||||
* @deprecated This is a draft API and might change in a future release of ICU.
|
||||
*/
|
||||
@Deprecated
|
||||
public static final byte DIRECTIONALITY_LEFT_TO_RIGHT = (byte)LEFT_TO_RIGHT;
|
||||
|
||||
/**
|
||||
* Directional type R
|
||||
* @stable ICU 2.1
|
||||
*/
|
||||
public static final int RIGHT_TO_LEFT = 1;
|
||||
|
||||
/**
|
||||
* JDK-compatible synonum for RIGHT_TO_LEFT.
|
||||
* @draft ICU 3.0
|
||||
* @deprecated This is a draft API and might change in a future release of ICU.
|
||||
*/
|
||||
@Deprecated
|
||||
public static final byte DIRECTIONALITY_RIGHT_TO_LEFT = (byte)RIGHT_TO_LEFT;
|
||||
|
||||
/**
|
||||
* Directional type EN
|
||||
* @stable ICU 2.1
|
||||
*/
|
||||
public static final int EUROPEAN_NUMBER = 2;
|
||||
|
||||
/**
|
||||
* JDK-compatible synonum for EUROPEAN_NUMBER.
|
||||
* @draft ICU 3.0
|
||||
* @deprecated This is a draft API and might change in a future release of ICU.
|
||||
*/
|
||||
@Deprecated
|
||||
public static final byte DIRECTIONALITY_EUROPEAN_NUMBER = (byte)EUROPEAN_NUMBER;
|
||||
|
||||
/**
|
||||
* Directional type ES
|
||||
* @stable ICU 2.1
|
||||
*/
|
||||
public static final int EUROPEAN_NUMBER_SEPARATOR = 3;
|
||||
|
||||
/**
|
||||
* JDK-compatible synonum for EUROPEAN_NUMBER_SEPARATOR.
|
||||
* @draft ICU 3.0
|
||||
* @deprecated This is a draft API and might change in a future release of ICU.
|
||||
*/
|
||||
@Deprecated
|
||||
public static final byte DIRECTIONALITY_EUROPEAN_NUMBER_SEPARATOR = (byte)EUROPEAN_NUMBER_SEPARATOR;
|
||||
|
||||
/**
|
||||
* Directional type ET
|
||||
* @stable ICU 2.1
|
||||
*/
|
||||
public static final int EUROPEAN_NUMBER_TERMINATOR = 4;
|
||||
|
||||
/**
|
||||
* JDK-compatible synonum for EUROPEAN_NUMBER_TERMINATOR.
|
||||
* @draft ICU 3.0
|
||||
* @deprecated This is a draft API and might change in a future release of ICU.
|
||||
*/
|
||||
@Deprecated
|
||||
public static final byte DIRECTIONALITY_EUROPEAN_NUMBER_TERMINATOR = (byte)EUROPEAN_NUMBER_TERMINATOR;
|
||||
|
||||
/**
|
||||
* Directional type AN
|
||||
* @stable ICU 2.1
|
||||
*/
|
||||
public static final int ARABIC_NUMBER = 5;
|
||||
|
||||
/**
|
||||
* JDK-compatible synonum for ARABIC_NUMBER.
|
||||
* @draft ICU 3.0
|
||||
* @deprecated This is a draft API and might change in a future release of ICU.
|
||||
*/
|
||||
@Deprecated
|
||||
public static final byte DIRECTIONALITY_ARABIC_NUMBER = (byte)ARABIC_NUMBER;
|
||||
|
||||
/**
|
||||
* Directional type CS
|
||||
* @stable ICU 2.1
|
||||
*/
|
||||
public static final int COMMON_NUMBER_SEPARATOR = 6;
|
||||
|
||||
/**
|
||||
* JDK-compatible synonum for COMMON_NUMBER_SEPARATOR.
|
||||
* @draft ICU 3.0
|
||||
* @deprecated This is a draft API and might change in a future release of ICU.
|
||||
*/
|
||||
@Deprecated
|
||||
public static final byte DIRECTIONALITY_COMMON_NUMBER_SEPARATOR = (byte)COMMON_NUMBER_SEPARATOR;
|
||||
|
||||
/**
|
||||
* Directional type B
|
||||
* @stable ICU 2.1
|
||||
*/
|
||||
public static final int BLOCK_SEPARATOR = 7;
|
||||
|
||||
/**
|
||||
* JDK-compatible synonum for BLOCK_SEPARATOR.
|
||||
* @draft ICU 3.0
|
||||
* @deprecated This is a draft API and might change in a future release of ICU.
|
||||
*/
|
||||
@Deprecated
|
||||
public static final byte DIRECTIONALITY_PARAGRAPH_SEPARATOR = (byte)BLOCK_SEPARATOR;
|
||||
|
||||
/**
|
||||
* Directional type S
|
||||
* @stable ICU 2.1
|
||||
*/
|
||||
public static final int SEGMENT_SEPARATOR = 8;
|
||||
|
||||
/**
|
||||
* JDK-compatible synonum for SEGMENT_SEPARATOR.
|
||||
* @draft ICU 3.0
|
||||
* @deprecated This is a draft API and might change in a future release of ICU.
|
||||
*/
|
||||
@Deprecated
|
||||
public static final byte DIRECTIONALITY_SEGMENT_SEPARATOR = (byte)SEGMENT_SEPARATOR;
|
||||
|
||||
/**
|
||||
* Directional type WS
|
||||
* @stable ICU 2.1
|
||||
*/
|
||||
public static final int WHITE_SPACE_NEUTRAL = 9;
|
||||
|
||||
/**
|
||||
* JDK-compatible synonum for WHITE_SPACE_NEUTRAL.
|
||||
* @draft ICU 3.0
|
||||
* @deprecated This is a draft API and might change in a future release of ICU.
|
||||
*/
|
||||
@Deprecated
|
||||
public static final byte DIRECTIONALITY_WHITESPACE = (byte)WHITE_SPACE_NEUTRAL;
|
||||
|
||||
/**
|
||||
* Directional type ON
|
||||
* @stable ICU 2.1
|
||||
*/
|
||||
public static final int OTHER_NEUTRAL = 10;
|
||||
|
||||
/**
|
||||
* JDK-compatible synonum for OTHER_NEUTRAL.
|
||||
* @draft ICU 3.0
|
||||
* @deprecated This is a draft API and might change in a future release of ICU.
|
||||
*/
|
||||
@Deprecated
|
||||
public static final byte DIRECTIONALITY_OTHER_NEUTRALS = (byte)OTHER_NEUTRAL;
|
||||
|
||||
/**
|
||||
* Directional type LRE
|
||||
* @stable ICU 2.1
|
||||
*/
|
||||
public static final int LEFT_TO_RIGHT_EMBEDDING = 11;
|
||||
|
||||
/**
|
||||
* JDK-compatible synonum for LEFT_TO_RIGHT_EMBEDDING.
|
||||
* @draft ICU 3.0
|
||||
* @deprecated This is a draft API and might change in a future release of ICU.
|
||||
*/
|
||||
@Deprecated
|
||||
public static final byte DIRECTIONALITY_LEFT_TO_RIGHT_EMBEDDING = (byte)LEFT_TO_RIGHT_EMBEDDING;
|
||||
|
||||
/**
|
||||
* Directional type LRO
|
||||
* @stable ICU 2.1
|
||||
*/
|
||||
public static final int LEFT_TO_RIGHT_OVERRIDE = 12;
|
||||
|
||||
/**
|
||||
* JDK-compatible synonum for LEFT_TO_RIGHT_OVERRIDE.
|
||||
* @draft ICU 3.0
|
||||
* @deprecated This is a draft API and might change in a future release of ICU.
|
||||
*/
|
||||
@Deprecated
|
||||
public static final byte DIRECTIONALITY_LEFT_TO_RIGHT_OVERRIDE = (byte)LEFT_TO_RIGHT_OVERRIDE;
|
||||
|
||||
/**
|
||||
* Directional type AL
|
||||
* @stable ICU 2.1
|
||||
*/
|
||||
public static final int RIGHT_TO_LEFT_ARABIC = 13;
|
||||
|
||||
/**
|
||||
* JDK-compatible synonum for RIGHT_TO_LEFT_ARABIC.
|
||||
* @draft ICU 3.0
|
||||
* @deprecated This is a draft API and might change in a future release of ICU.
|
||||
*/
|
||||
@Deprecated
|
||||
public static final byte DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC = (byte)RIGHT_TO_LEFT_ARABIC;
|
||||
|
||||
/**
|
||||
* Directional type RLE
|
||||
* @stable ICU 2.1
|
||||
*/
|
||||
public static final int RIGHT_TO_LEFT_EMBEDDING = 14;
|
||||
|
||||
/**
|
||||
* JDK-compatible synonum for RIGHT_TO_LEFT_EMBEDDING.
|
||||
* @draft ICU 3.0
|
||||
* @deprecated This is a draft API and might change in a future release of ICU.
|
||||
*/
|
||||
@Deprecated
|
||||
public static final byte DIRECTIONALITY_RIGHT_TO_LEFT_EMBEDDING = (byte)RIGHT_TO_LEFT_EMBEDDING;
|
||||
|
||||
/**
|
||||
* Directional type RLO
|
||||
* @stable ICU 2.1
|
||||
*/
|
||||
public static final int RIGHT_TO_LEFT_OVERRIDE = 15;
|
||||
|
||||
/**
|
||||
* JDK-compatible synonum for RIGHT_TO_LEFT_OVERRIDE.
|
||||
* @draft ICU 3.0
|
||||
* @deprecated This is a draft API and might change in a future release of ICU.
|
||||
*/
|
||||
@Deprecated
|
||||
public static final byte DIRECTIONALITY_RIGHT_TO_LEFT_OVERRIDE = (byte)RIGHT_TO_LEFT_OVERRIDE;
|
||||
|
||||
/**
|
||||
* Directional type PDF
|
||||
* @stable ICU 2.1
|
||||
*/
|
||||
public static final int POP_DIRECTIONAL_FORMAT = 16;
|
||||
|
||||
/**
|
||||
* JDK-compatible synonum for POP_DIRECTIONAL_FORMAT.
|
||||
* @draft ICU 3.0
|
||||
* @deprecated This is a draft API and might change in a future release of ICU.
|
||||
*/
|
||||
@Deprecated
|
||||
public static final byte DIRECTIONALITY_POP_DIRECTIONAL_FORMAT = (byte)POP_DIRECTIONAL_FORMAT;
|
||||
|
||||
/**
|
||||
* Directional type NSM
|
||||
* @stable ICU 2.1
|
||||
*/
|
||||
public static final int DIR_NON_SPACING_MARK = 17;
|
||||
|
||||
/**
|
||||
* JDK-compatible synonum for DIR_NON_SPACING_MARK.
|
||||
* @draft ICU 3.0
|
||||
* @deprecated This is a draft API and might change in a future release of ICU.
|
||||
*/
|
||||
@Deprecated
|
||||
public static final byte DIRECTIONALITY_NON_SPACING_MARK = (byte)DIR_NON_SPACING_MARK;
|
||||
|
||||
/**
|
||||
* Directional type BN
|
||||
* @stable ICU 2.1
|
||||
*/
|
||||
public static final int BOUNDARY_NEUTRAL = 18;
|
||||
|
||||
/**
|
||||
* JDK-compatible synonum for BOUNDARY_NEUTRAL.
|
||||
* @draft ICU 3.0
|
||||
* @deprecated This is a draft API and might change in a future release of ICU.
|
||||
*/
|
||||
@Deprecated
|
||||
public static final byte DIRECTIONALITY_BOUNDARY_NEUTRAL = (byte)BOUNDARY_NEUTRAL;
|
||||
|
||||
/**
|
||||
* Number of directional types
|
||||
* @stable ICU 2.1
|
||||
*/
|
||||
public static final int CHAR_DIRECTION_COUNT = 19;
|
||||
|
||||
/**
|
||||
* Undefined bidirectional character type. Undefined <code>char</code>
|
||||
* values have undefined directionality in the Unicode specification.
|
||||
* @draft ICU 3.0
|
||||
* @deprecated This is a draft API and might change in a future release of ICU.
|
||||
*/
|
||||
@Deprecated
|
||||
public static final byte DIRECTIONALITY_UNDEFINED = -1;
|
||||
}
|
||||
}
|
BIN
src/java.base/share/classes/sun/net/idn/uidna.spp
Normal file
BIN
src/java.base/share/classes/sun/net/idn/uidna.spp
Normal file
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue