ICU-12716 FindBugs fixes & comments for false-positive warnings
X-SVN-Rev: 39163
This commit is contained in:
parent
08c37f83f0
commit
4bf12725a1
@ -34,7 +34,7 @@ class CharsetMBCS extends CharsetICU {
|
||||
private byte[] fromUSubstitution = null;
|
||||
UConverterSharedData sharedData = null;
|
||||
private static final int MAX_VERSION_LENGTH = 4;
|
||||
|
||||
|
||||
// these variables are used in getUnicodeSet() and may be changed in future
|
||||
// typedef enum UConverterSetFilter {
|
||||
static final int UCNV_SET_FILTER_NONE = 1;
|
||||
@ -95,7 +95,7 @@ class CharsetMBCS extends CharsetICU {
|
||||
UConverterSharedData baseSharedData;
|
||||
// int extIndexes[];
|
||||
ByteBuffer extIndexes; // create int[] view etc. as needed
|
||||
|
||||
|
||||
CharBuffer mbcsIndex; /* for fast conversion from most of BMP to MBCS (utf8Friendly data) */
|
||||
// char sbcsIndex[/* SBCS_FAST_LIMIT>>6 */]; /* for fast conversion from low BMP to SBCS (utf8Friendly data) */
|
||||
boolean utf8Friendly; /* for utf8Friendly data */
|
||||
@ -154,7 +154,7 @@ class CharsetMBCS extends CharsetICU {
|
||||
int countStates, countToUFallbacks, offsetToUCodeUnits, offsetFromUTable, offsetFromUBytes;
|
||||
int flags;
|
||||
int fromUBytesLength;
|
||||
|
||||
|
||||
/* new and required in version 5 */
|
||||
int options;
|
||||
|
||||
@ -169,14 +169,14 @@ class CharsetMBCS extends CharsetICU {
|
||||
public CharsetMBCS(String icuCanonicalName, String javaCanonicalName, String[] aliases, String classPath,
|
||||
ClassLoader loader) throws InvalidFormatException {
|
||||
super(icuCanonicalName, javaCanonicalName, aliases);
|
||||
|
||||
|
||||
/* See if the icuCanonicalName contains certain option information. */
|
||||
if (icuCanonicalName.indexOf(UConverterConstants.OPTION_SWAP_LFNL_STRING) > -1) {
|
||||
options = UConverterConstants.OPTION_SWAP_LFNL;
|
||||
icuCanonicalName = icuCanonicalName.substring(0, icuCanonicalName.indexOf(UConverterConstants.OPTION_SWAP_LFNL_STRING));
|
||||
super.icuCanonicalName = icuCanonicalName;
|
||||
}
|
||||
|
||||
|
||||
// now try to load the data
|
||||
sharedData = loadConverter(1, icuCanonicalName, classPath, loader);
|
||||
|
||||
@ -189,7 +189,7 @@ class CharsetMBCS extends CharsetICU {
|
||||
subChar1 = sharedData.staticData.subChar1;
|
||||
fromUSubstitution = new byte[sharedData.staticData.subCharLen];
|
||||
System.arraycopy(sharedData.staticData.subChar, 0, fromUSubstitution, 0, sharedData.staticData.subCharLen);
|
||||
|
||||
|
||||
initializeConverter(options);
|
||||
}
|
||||
|
||||
@ -277,7 +277,7 @@ class CharsetMBCS extends CharsetICU {
|
||||
// agljport:add this would be unnecessary if extIndexes were memory mapped
|
||||
/*
|
||||
* if(mbcsTable.extIndexes != null) {
|
||||
*
|
||||
*
|
||||
* try { //int nbytes = mbcsTable.extIndexes[UConverterExt.UCNV_EXT_TO_U_LENGTH]*4 +
|
||||
* mbcsTable.extIndexes[UConverterExt.UCNV_EXT_TO_U_UCHARS_LENGTH]*2 +
|
||||
* mbcsTable.extIndexes[UConverterExt.UCNV_EXT_FROM_U_LENGTH]*6 +
|
||||
@ -449,11 +449,11 @@ class CharsetMBCS extends CharsetICU {
|
||||
throw new InvalidFormatException();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (header.version[1] >= 3 && (mbcsTable.unicodeMask & UConverterConstants.HAS_SURROGATES) == 0 &&
|
||||
(mbcsTable.countStates == 1 ? ((char)header.version[2] >= (SBCS_FAST_MAX>>8)) : ((char)header.version[2] >= (MBCS_FAST_MAX>>8)))) {
|
||||
mbcsTable.utf8Friendly = true;
|
||||
|
||||
|
||||
if (mbcsTable.countStates == 1) {
|
||||
/*
|
||||
* SBCS: Stage 3 is allocated in 64-entry blocks for U+0000..SBCS_FAST_MAX or higher.
|
||||
@ -537,7 +537,7 @@ class CharsetMBCS extends CharsetICU {
|
||||
if(value<=0xffffff) {
|
||||
/* short sequences are stored directly */
|
||||
/* code set 0 or 1 */
|
||||
} else if(value<=0x8effffff) {
|
||||
} else if(value<=0x8effffffL) {
|
||||
/* code set 2 */
|
||||
value&=0x7fffff;
|
||||
} else /* first byte is 0x8f */ {
|
||||
@ -558,7 +558,7 @@ class CharsetMBCS extends CharsetICU {
|
||||
/* locate the stage 2 & 3 data */
|
||||
stage2 = table[c>>10] + ((c>>4)&0x3f);
|
||||
st3 = tableInts[stage2];
|
||||
st3 = (int)(char)(st3 * 16 + (c&0xf));
|
||||
st3 = (char)(st3 * 16 + (c&0xf));
|
||||
|
||||
/* write the codepage bytes into stage 3 */
|
||||
switch(mbcsTable.outputType) {
|
||||
@ -578,7 +578,9 @@ class CharsetMBCS extends CharsetICU {
|
||||
break;
|
||||
}
|
||||
|
||||
/* set the roundtrip flag */
|
||||
// Set the roundtrip flag.
|
||||
// FindBugs complains about "possible bad parsing of shift operation"
|
||||
// but this is as intended.
|
||||
temp = (1L<<(16+(c&0xf)));
|
||||
tableInts[stage2] |= temp;
|
||||
}
|
||||
@ -654,7 +656,7 @@ class CharsetMBCS extends CharsetICU {
|
||||
/* reconstitute fromUnicodeBytes with roundtrips from toUnicode data */
|
||||
MBCSEnumToUnicode(mbcsTable);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Internal function enumerating the toUnicode data of an MBCS converter.
|
||||
* Currently only used for reconstituting data for a MBCS_OPT_NO_FROM_U
|
||||
@ -668,49 +670,49 @@ class CharsetMBCS extends CharsetICU {
|
||||
* Properties for each state, to speed up the enumeration.
|
||||
* Ignorable actions are unassigned/illegal/state-change-only:
|
||||
* They do not lead to mappings.
|
||||
*
|
||||
*
|
||||
* Bits 7..6
|
||||
* 1 direct/initial state (stateful converters have mulitple)
|
||||
* 0 non-initial state with transitions or with nonignorable result actions
|
||||
* -1 final state with only ignorable actions
|
||||
*
|
||||
*
|
||||
* Bits 5..3
|
||||
* The lowest byte value with non-ignorable actions is
|
||||
* value<<5 (rounded down).
|
||||
*
|
||||
*
|
||||
* Bits 2..0:
|
||||
* The highest byte value with non-ignorable actions is
|
||||
* (value<<5)&0x1f (rounded up).
|
||||
*/
|
||||
byte stateProps[] = new byte[MBCS_MAX_STATE_COUNT];
|
||||
int state;
|
||||
|
||||
|
||||
/* recurse from state 0 and set all stateProps */
|
||||
getStateProp(mbcsTable.stateTable, stateProps, 0);
|
||||
|
||||
|
||||
for (state = 0; state < mbcsTable.countStates; ++state) {
|
||||
if (stateProps[state] >= 0x40) {
|
||||
/* start from each direct state */
|
||||
enumToU(mbcsTable, stateProps, state, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
private static boolean enumToU(UConverterMBCSTable mbcsTable, byte stateProps[], int state, int offset, int value) {
|
||||
int[] codePoints = new int[32];
|
||||
int[] row;
|
||||
char[] unicodeCodeUnits;
|
||||
int anyCodePoints;
|
||||
int b, limit;
|
||||
|
||||
|
||||
row = mbcsTable.stateTable[state];
|
||||
unicodeCodeUnits = mbcsTable.unicodeCodeUnits;
|
||||
|
||||
|
||||
value<<=8;
|
||||
anyCodePoints = -1; /* becomes non-negative if there is a mapping */
|
||||
|
||||
|
||||
b = (stateProps[state]&0x38)<<2;
|
||||
if (b == 0 && stateProps[state] >= 0x40) {
|
||||
/* skip byte sequences with leading zeros because they are note stored in the fromUnicode table */
|
||||
@ -732,7 +734,7 @@ class CharsetMBCS extends CharsetICU {
|
||||
} else {
|
||||
int c;
|
||||
int action;
|
||||
|
||||
|
||||
/*
|
||||
* An if-else-if chain provides more reliable performance for
|
||||
* the most common cases compared to a switch.
|
||||
@ -769,7 +771,7 @@ class CharsetMBCS extends CharsetICU {
|
||||
} else {
|
||||
c = UConverterConstants.U_SENTINEL;
|
||||
}
|
||||
|
||||
|
||||
codePoints[b&0x1f] = c;
|
||||
anyCodePoints&=c;
|
||||
}
|
||||
@ -782,10 +784,10 @@ class CharsetMBCS extends CharsetICU {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Only called if stateProps[state]==-1.
|
||||
* A recursive call may do stateProps[state]|=0x40 if this state is the target of an
|
||||
@ -794,10 +796,10 @@ class CharsetMBCS extends CharsetICU {
|
||||
private static byte getStateProp(int stateTable[][], byte stateProps[], int state) {
|
||||
int[] row;
|
||||
int min, max, entry, nextState;
|
||||
|
||||
|
||||
row = stateTable[state];
|
||||
stateProps[state] = 0;
|
||||
|
||||
|
||||
/* find first non-ignorable state */
|
||||
for (min = 0;;++min) {
|
||||
entry = row[min];
|
||||
@ -818,7 +820,7 @@ class CharsetMBCS extends CharsetICU {
|
||||
}
|
||||
}
|
||||
stateProps[state]|=(byte)((min>>5)<<3);
|
||||
|
||||
|
||||
/* find last non-ignorable state */
|
||||
for (max = 0xff; min < max; --max) {
|
||||
entry = row[max];
|
||||
@ -835,7 +837,7 @@ class CharsetMBCS extends CharsetICU {
|
||||
}
|
||||
}
|
||||
stateProps[state]|=(byte)(max>>5);
|
||||
|
||||
|
||||
/* recurse further and collect direct-state information */
|
||||
while (min <= max) {
|
||||
entry = row[min];
|
||||
@ -925,16 +927,16 @@ class CharsetMBCS extends CharsetICU {
|
||||
* OS/390 (z/OS) Unix System Services (Open Edition).
|
||||
* The difference is in the mapping of Line Feed and New Line control codes:
|
||||
* Standard EBDIC maps
|
||||
*
|
||||
*
|
||||
* <U000A> \x25 |0
|
||||
* <U0085> \x15 |0
|
||||
*
|
||||
*
|
||||
* but OS/390 USS EBCDIC swaps the control codes for LF and NL,
|
||||
* mapping
|
||||
*
|
||||
*
|
||||
* <U000A> \x15 |0
|
||||
* <U0085> \x25 |0
|
||||
*
|
||||
*
|
||||
* This code modifies a loaded standard EBCDIC<->Unicode mapping table
|
||||
* by copying it into allocated memory and swapping the LF and NL values.
|
||||
* It allows to support the same EBCDIC charset in both version without
|
||||
@ -943,15 +945,15 @@ class CharsetMBCS extends CharsetICU {
|
||||
/* standard EBCDIC codes */
|
||||
private static final short EBCDIC_LF = 0x0025;
|
||||
private static final short EBCDIC_NL = 0x0015;
|
||||
|
||||
|
||||
/* standard EBCDIC codes with roundtrip flag as stored in Unicode-to-single-byte tables */
|
||||
private static final short EBCDIC_RT_LF = 0x0f25;
|
||||
private static final short EBCDIC_RT_NL = 0x0f15;
|
||||
|
||||
|
||||
/* Unicode code points */
|
||||
private static final short U_LF = 0x000A;
|
||||
private static final short U_NL = 0x0085;
|
||||
|
||||
|
||||
private boolean EBCDICSwapLFNL() throws Exception {
|
||||
UConverterMBCSTable mbcsTable;
|
||||
|
||||
@ -963,7 +965,7 @@ class CharsetMBCS extends CharsetICU {
|
||||
int stage2Entry;
|
||||
|
||||
mbcsTable = sharedData.mbcs;
|
||||
|
||||
|
||||
table = mbcsTable.fromUnicodeTable;
|
||||
int[] tableInts = sharedData.mbcs.fromUnicodeTableInts;
|
||||
char[] chars = mbcsTable.fromUnicodeChars;
|
||||
@ -972,7 +974,7 @@ class CharsetMBCS extends CharsetICU {
|
||||
/*
|
||||
* Check that this is an EBCDIC table with SBCS portion -
|
||||
* SBCS or EBCDIC with standard EBCDIC LF and NL mappings.
|
||||
*
|
||||
*
|
||||
* If not, ignore the option. Options are always ignored if they do not apply.
|
||||
*/
|
||||
if (!((mbcsTable.outputType == MBCS_OUTPUT_1 || mbcsTable.outputType == MBCS_OUTPUT_2_SISO) &&
|
||||
@ -980,7 +982,7 @@ class CharsetMBCS extends CharsetICU {
|
||||
mbcsTable.stateTable[0][EBCDIC_NL] == MBCS_ENTRY_FINAL(0, MBCS_STATE_VALID_DIRECT_16, U_NL))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if (mbcsTable.outputType == MBCS_OUTPUT_1) {
|
||||
if (!(EBCDIC_RT_LF == MBCS_SINGLE_RESULT_FROM_U(table, results, U_LF) &&
|
||||
EBCDIC_RT_NL == MBCS_SINGLE_RESULT_FROM_U(table, results, U_NL))) {
|
||||
@ -992,14 +994,14 @@ class CharsetMBCS extends CharsetICU {
|
||||
EBCDIC_LF == MBCS_VALUE_2_FROM_STAGE_2(chars, stage2Entry, U_LF))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
stage2Entry = MBCS_STAGE_2_FROM_U(table, tableInts, U_NL);
|
||||
if (!(MBCS_FROM_U_IS_ROUNDTRIP(stage2Entry, U_NL) &&
|
||||
EBCDIC_NL == MBCS_VALUE_2_FROM_STAGE_2(chars, stage2Entry, U_NL))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (mbcsTable.fromUBytesLength > 0) {
|
||||
/*
|
||||
* We _know_ the number of bytes in the fromUnicodeBytes array
|
||||
@ -1015,7 +1017,7 @@ class CharsetMBCS extends CharsetICU {
|
||||
*/
|
||||
throw new Exception("U_INVALID_FORMAT_ERROR");
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* The table has an appropriate format.
|
||||
* Allocate and build
|
||||
@ -1024,16 +1026,16 @@ class CharsetMBCS extends CharsetICU {
|
||||
* - a converter name string with the swap option appended
|
||||
*/
|
||||
// size = mbcsTable.countStates * 1024 + sizeofFromUBytes + UConverterConstants.MAX_CONVERTER_NAME_LENGTH + 20;
|
||||
|
||||
|
||||
/* copy and modify the to-Unicode state table */
|
||||
newStateTable = new int[mbcsTable.stateTable.length][mbcsTable.stateTable[0].length];
|
||||
for (int i = 0; i < newStateTable.length; i++) {
|
||||
System.arraycopy(mbcsTable.stateTable[i], 0, newStateTable[i], 0, newStateTable[i].length);
|
||||
}
|
||||
|
||||
|
||||
newStateTable[0][EBCDIC_LF] = MBCS_ENTRY_FINAL(0, MBCS_STATE_VALID_DIRECT_16, U_NL);
|
||||
newStateTable[0][EBCDIC_NL] = MBCS_ENTRY_FINAL(0, MBCS_STATE_VALID_DIRECT_16, U_LF);
|
||||
|
||||
|
||||
/* copy and modify the from-Unicode result table */
|
||||
char[] newResults = new char[chars.length];
|
||||
System.arraycopy(chars, 0, newResults, 0, chars.length);
|
||||
@ -1044,11 +1046,11 @@ class CharsetMBCS extends CharsetICU {
|
||||
} else /* MBCS_OUTPUT_2_SISO */ {
|
||||
stage2Entry = MBCS_STAGE_2_FROM_U(table, tableInts, U_LF);
|
||||
MBCS_VALUE_2_FROM_STAGE_2_SET(newResults, stage2Entry, U_LF, EBCDIC_NL);
|
||||
|
||||
|
||||
stage2Entry = MBCS_STAGE_2_FROM_U(table, tableInts, U_NL);
|
||||
MBCS_VALUE_2_FROM_STAGE_2_SET(newResults, stage2Entry, U_NL, EBCDIC_LF);
|
||||
}
|
||||
|
||||
|
||||
/* set the canonical converter name */
|
||||
newName = icuCanonicalName.concat(UConverterConstants.OPTION_SWAP_LFNL_STRING);
|
||||
|
||||
@ -1093,7 +1095,7 @@ class CharsetMBCS extends CharsetICU {
|
||||
* Some ranges of GB 18030 where both the Unicode code points and the GB four-byte sequences are contiguous and are
|
||||
* handled algorithmically by the special callback functions below. The values are start & end of Unicode & GB
|
||||
* codes.
|
||||
*
|
||||
*
|
||||
* Note that single surrogates are not mapped by GB 18030 as of the re-released mapping tables from 2000-nov-30.
|
||||
*/
|
||||
private static final int gb18030Ranges[][] = new int[/* 14 */][/* 4 */] {
|
||||
@ -1114,24 +1116,24 @@ class CharsetMBCS extends CharsetICU {
|
||||
|
||||
/* bit flag for UConverter.options indicating GB 18030 special handling */
|
||||
private static final int MBCS_OPTION_GB18030 = 0x8000;
|
||||
|
||||
/* bit flag for UConverter.options indicating KEIS,JEF,JIF special handling */
|
||||
|
||||
/* bit flag for UConverter.options indicating KEIS,JEF,JIF special handling */
|
||||
private static final int MBCS_OPTION_KEIS = 0x01000;
|
||||
private static final int MBCS_OPTION_JEF = 0x02000;
|
||||
private static final int MBCS_OPTION_JIPS = 0x04000;
|
||||
|
||||
private static final int MBCS_OPTION_JIPS = 0x04000;
|
||||
|
||||
private static enum SISO_Option {
|
||||
SI,
|
||||
SO
|
||||
}
|
||||
|
||||
|
||||
private static final byte[] KEIS_SO_CHAR = { 0x0A, 0x42 };
|
||||
private static final byte[] KEIS_SI_CHAR = { 0x0A, 0x41 };
|
||||
private static final byte JEF_SO_CHAR = 0x28;
|
||||
private static final byte JEF_SI_CHAR = 0x29;
|
||||
private static final byte[] JIPS_SO_CHAR = { 0x1A, 0x70 };
|
||||
private static final byte[] JIPS_SI_CHAR = { 0x1A, 0x71 };
|
||||
|
||||
|
||||
private static int getSISOBytes(SISO_Option option, int cnvOption, byte[] value) {
|
||||
int SISOLength = 0;
|
||||
|
||||
@ -1192,8 +1194,8 @@ class CharsetMBCS extends CharsetICU {
|
||||
static final int MBCS_STATE_UNASSIGNED = MBCS_STATE_VALID_16_PAIR + 1;
|
||||
static final int MBCS_STATE_ILLEGAL = MBCS_STATE_UNASSIGNED + 1;
|
||||
static final int MBCS_STATE_CHANGE_ONLY = MBCS_STATE_ILLEGAL + 1;
|
||||
|
||||
static int MBCS_ENTRY_SET_STATE(int entry, int state) {
|
||||
|
||||
static int MBCS_ENTRY_SET_STATE(int entry, int state) {
|
||||
return (entry&0x80ffffff)|(state<<24L);
|
||||
}
|
||||
|
||||
@ -1245,11 +1247,11 @@ class CharsetMBCS extends CharsetICU {
|
||||
static char MBCS_ENTRY_FINAL_VALUE_16(int entry) {
|
||||
return (char) (entry);
|
||||
}
|
||||
|
||||
|
||||
static boolean MBCS_IS_ASCII_ROUNDTRIP(int b, long asciiRoundtrips) {
|
||||
return (((asciiRoundtrips) & (1<<((b)>>2)))!=0);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This macro version of _MBCSSingleSimpleGetNextUChar() gets a code point from a byte. It works for single-byte,
|
||||
* single-state codepages that only map to and from BMP code points, and it always returns fallback values.
|
||||
@ -1265,7 +1267,7 @@ class CharsetMBCS extends CharsetICU {
|
||||
int i = table[i1] + (c & 0xf);
|
||||
return results[i];
|
||||
}
|
||||
|
||||
|
||||
/* single-byte fromUnicode: set the 16-bit result word with newValue*/
|
||||
static void MBCS_SINGLE_RESULT_FROM_U_SET(char[] table, char[] results, int c, int newValue) {
|
||||
int i1 = table[c >>> 10] + ((c >>> 4) & 0x3f);
|
||||
@ -1407,7 +1409,7 @@ class CharsetMBCS extends CharsetICU {
|
||||
|
||||
/* trie access, returns the stage 3 value=index to stage 3b; s1Index=c>>10 */
|
||||
static int FROM_U(CharBuffer stage12, CharBuffer stage3, int s1Index, int c) {
|
||||
return stage3.get(((int) stage12.get((stage12.get(s1Index) + ((c >>> 4) & 0x3f))) << STAGE_2_LEFT_SHIFT)
|
||||
return stage3.get((stage12.get((stage12.get(s1Index) + ((c >>> 4) & 0x3f))) << STAGE_2_LEFT_SHIFT)
|
||||
+ (c & 0xf));
|
||||
}
|
||||
|
||||
@ -1600,7 +1602,7 @@ class CharsetMBCS extends CharsetICU {
|
||||
if (byt == TO_U_GET_BYTE((int)word)) {
|
||||
return TO_U_GET_VALUE((int) word); /* never 0 */
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0; /* not found */
|
||||
}
|
||||
|
||||
@ -1614,7 +1616,7 @@ class CharsetMBCS extends CharsetICU {
|
||||
/*
|
||||
* get the SI/SO toU state (state 0 is for SBCS, 1 for DBCS), or 1 for DBCS-only, or -1 if the converter is not
|
||||
* SI/SO stateful
|
||||
*
|
||||
*
|
||||
* Note: For SI/SO stateful converters getting here, cnv->mode==0 is equivalent to firstLength==1.
|
||||
*/
|
||||
private static int SISO_STATE(UConverterSharedData sharedData, int mode) {
|
||||
@ -1628,6 +1630,7 @@ class CharsetMBCS extends CharsetICU {
|
||||
super(cs);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CoderResult decodeLoop(ByteBuffer source, CharBuffer target, IntBuffer offsets, boolean flush) {
|
||||
/* Just call cnvMBCSToUnicodeWithOffsets() to remove duplicate code. */
|
||||
return cnvMBCSToUnicodeWithOffsets(source, target, offsets, flush);
|
||||
@ -1675,13 +1678,13 @@ class CharsetMBCS extends CharsetICU {
|
||||
} else /* match==0 */{
|
||||
/*
|
||||
* no match
|
||||
*
|
||||
*
|
||||
* We need to split the previous input into two parts:
|
||||
*
|
||||
*
|
||||
* 1. The first codepage character is unmappable - that's how we got into trying the extension data in
|
||||
* the first place. We need to move it from the preToU buffer to the error buffer, set an error code,
|
||||
* and prepare the rest of the previous input for 2.
|
||||
*
|
||||
*
|
||||
* 2. The rest of the previous input must be converted once we come back from the callback for the first
|
||||
* character. At that time, we have to try again from scratch to convert these input characters. The
|
||||
* replay will be handled by the ucnv.c conversion code.
|
||||
@ -1729,7 +1732,7 @@ class CharsetMBCS extends CharsetICU {
|
||||
|
||||
matchValue = 0;
|
||||
i = j = matchLength = 0;
|
||||
if (source != null) {
|
||||
if (source != null) {
|
||||
srcLength = source.remaining();
|
||||
}
|
||||
|
||||
@ -2650,7 +2653,7 @@ class CharsetMBCS extends CharsetICU {
|
||||
* returns an "assigned" result if it consumes the entire input. It does not use state from the converter, nor
|
||||
* error codes. It does not handle the EBCDIC swaplfnl option (set in UConverter). It handles conversion
|
||||
* extensions but not GB 18030.
|
||||
*
|
||||
*
|
||||
* @return U+fffe unassigned U+ffff illegal otherwise the Unicode code point
|
||||
*/
|
||||
int simpleGetNextUChar(ByteBuffer source, boolean useFallback) {
|
||||
@ -2802,14 +2805,14 @@ class CharsetMBCS extends CharsetICU {
|
||||
/* Then recurse for transition entries. */
|
||||
for (b = 0; b <= 0xff; b++) {
|
||||
entry = row[b];
|
||||
if (MBCS_ENTRY_IS_TRANSITION(entry) &&
|
||||
if (MBCS_ENTRY_IS_TRANSITION(entry) &&
|
||||
hasValidTrailBytes(stateTable, (short)MBCS_ENTRY_TRANSITION_STATE(entry))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
private boolean isSingleOrLead(int[][] stateTable, int state, boolean isDBCSOnly, int b) {
|
||||
int[] row = stateTable[state];
|
||||
int entry = row[b];
|
||||
@ -2824,7 +2827,7 @@ class CharsetMBCS extends CharsetICU {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -2837,11 +2840,13 @@ class CharsetMBCS extends CharsetICU {
|
||||
implReset();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void implReset() {
|
||||
super.implReset();
|
||||
preFromUFirstCP = UConverterConstants.U_SENTINEL;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("fallthrough")
|
||||
protected CoderResult encodeLoop(CharBuffer source, ByteBuffer target, IntBuffer offsets, boolean flush) {
|
||||
CoderResult[] cr = { CoderResult.UNDERFLOW };
|
||||
@ -2858,7 +2863,7 @@ class CharsetMBCS extends CharsetICU {
|
||||
int stage2Entry = 0, value = 0, length = 0, prevLength;
|
||||
short uniMask;
|
||||
// long asciiRoundtrips;
|
||||
|
||||
|
||||
byte[] si_value = new byte[2];
|
||||
byte[] so_value = new byte[2];
|
||||
int si_value_length = 0, so_value_length = 0;
|
||||
@ -2938,7 +2943,7 @@ class CharsetMBCS extends CharsetICU {
|
||||
* if(c==0) and duplicating the trail-surrogate-handling code in the else branch of that check. I could
|
||||
* not find any other way to get around this other than using a function call for the conversion and
|
||||
* callback, which would be even more inefficient.
|
||||
*
|
||||
*
|
||||
* Markus Scherer 2000-jul-19
|
||||
*/
|
||||
boolean doloop = true;
|
||||
@ -3021,25 +3026,25 @@ class CharsetMBCS extends CharsetICU {
|
||||
/*
|
||||
* The basic lookup is a triple-stage compact array (trie) lookup. For details see the
|
||||
* beginning of this file.
|
||||
*
|
||||
*
|
||||
* Single-byte codepages are handled with a different data structure by _MBCSSingle...
|
||||
* functions.
|
||||
*
|
||||
*
|
||||
* The result consists of a 32-bit value from stage 2 and a pointer to as many bytes as are
|
||||
* stored per character. The pointer points to the character's bytes in stage 3. Bits 15..0
|
||||
* of the stage 2 entry contain the stage 3 index for that pointer, while bits 31..16 are
|
||||
* flags for which of the 16 characters in the block are roundtrip-assigned.
|
||||
*
|
||||
*
|
||||
* For 2-byte and 4-byte codepages, the bytes are stored as uint16_t respectively as
|
||||
* uint32_t, in the platform encoding. For 3-byte codepages, the bytes are always stored in
|
||||
* big-endian order.
|
||||
*
|
||||
*
|
||||
* For EUC encodings that use only either 0x8e or 0x8f as the first byte of their longest
|
||||
* byte sequences, the first two bytes in this third stage indicate with their 7th bits
|
||||
* whether these bytes are to be written directly or actually need to be preceeded by one of
|
||||
* the two Single-Shift codes. With this, the third stage stores one byte fewer per
|
||||
* character than the actual maximum length of EUC byte sequences.
|
||||
*
|
||||
*
|
||||
* Other than that, leading zero bytes are removed and the other bytes output. A single zero
|
||||
* byte may be output if the "assigned" bit in stage 2 was on. The data structure does not
|
||||
* support zero byte output as a fallback, and also does not allow output of leading zeros.
|
||||
@ -3191,7 +3196,7 @@ class CharsetMBCS extends CharsetICU {
|
||||
length = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
/* is this code point assigned, or do we use fallbacks? */
|
||||
if (gotoUnassigned || (!(MBCS_FROM_U_IS_ROUNDTRIP(stage2Entry, c) || (isFromUUseFallback(c) && value != 0)))) {
|
||||
gotoUnassigned = false;
|
||||
@ -3318,7 +3323,7 @@ class CharsetMBCS extends CharsetICU {
|
||||
/*
|
||||
* the end of the input stream and detection of truncated input are handled by the framework, but for
|
||||
* EBCDIC_STATEFUL conversion we need to emit an SI at the very end
|
||||
*
|
||||
*
|
||||
* conditions: successful EBCDIC_STATEFUL in DBCS mode end of input and no truncated input
|
||||
*/
|
||||
if (outputType == MBCS_OUTPUT_2_SISO && prevLength == 2 && flush && sourceArrayIndex >= source.limit()
|
||||
@ -3368,11 +3373,11 @@ class CharsetMBCS extends CharsetICU {
|
||||
* This is another simple conversion function for internal use by other conversion implementations. It does not
|
||||
* use the converter state nor call callbacks. It does not handle the EBCDIC swaplfnl option (set in
|
||||
* UConverter). It handles conversion extensions but not GB 18030.
|
||||
*
|
||||
*
|
||||
* It converts one single Unicode code point into codepage bytes, encoded as one 32-bit value. The function
|
||||
* returns the number of bytes in *pValue: 1..4 the number of bytes in *pValue 0 unassigned (*pValue undefined)
|
||||
* -1 illegal (currently not used, *pValue undefined)
|
||||
*
|
||||
*
|
||||
* *pValue will contain the resulting bytes with the last byte in bits 7..0, the second to last byte in bits
|
||||
* 15..8, etc. Currently, the function assumes but does not check that 0<=c<=0x10ffff.
|
||||
*/
|
||||
@ -3561,13 +3566,13 @@ class CharsetMBCS extends CharsetICU {
|
||||
} else { /* match==0 or 1 */
|
||||
/*
|
||||
* no match
|
||||
*
|
||||
*
|
||||
* We need to split the previous input into two parts:
|
||||
*
|
||||
*
|
||||
* 1. The first code point is unmappable - that's how we got into trying the extension data in the first
|
||||
* place. We need to move it from the preFromU buffer to the error buffer, set an error code, and
|
||||
* prepare the rest of the previous input for 2.
|
||||
*
|
||||
*
|
||||
* 2. The rest of the previous input must be converted once we come back from the callback for the first
|
||||
* code point. At that time, we have to try again from scratch to convert these input characters. The
|
||||
* replay will be handled by the ucnv.c conversion code.
|
||||
@ -3971,7 +3976,7 @@ class CharsetMBCS extends CharsetICU {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
CoderResult cnvMBCSFromUnicodeWithOffsets(CharBuffer source, ByteBuffer target, IntBuffer offsets, boolean flush) {
|
||||
// Just call encodeLoop to remove duplicate code.
|
||||
return encodeLoop(source, target, offsets, flush);
|
||||
@ -4668,13 +4673,14 @@ class CharsetMBCS extends CharsetICU {
|
||||
|
||||
/**
|
||||
* Overrides super class method
|
||||
*
|
||||
*
|
||||
* @param encoder
|
||||
* @param source
|
||||
* @param target
|
||||
* @param offsets
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
protected CoderResult cbFromUWriteSub(CharsetEncoderICU encoder, CharBuffer source, ByteBuffer target,
|
||||
IntBuffer offsets) {
|
||||
CharsetMBCS cs = (CharsetMBCS) encoder.charset();
|
||||
@ -4735,10 +4741,11 @@ class CharsetMBCS extends CharsetICU {
|
||||
/**
|
||||
* Gets called whenever CharsetEncoder.replaceWith gets called. allowReplacementChanges only allows subChar and
|
||||
* subChar1 to be modified outside construction (since replaceWith is called once during construction).
|
||||
*
|
||||
*
|
||||
* @param replacement
|
||||
* The replacement for subchar.
|
||||
*/
|
||||
@Override
|
||||
protected void implReplaceWith(byte[] replacement) {
|
||||
if (allowReplacementChanges) {
|
||||
CharsetMBCS cs = (CharsetMBCS) this.charset();
|
||||
@ -4750,10 +4757,12 @@ class CharsetMBCS extends CharsetICU {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public CharsetDecoder newDecoder() {
|
||||
return new CharsetDecoderMBCS(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CharsetEncoder newEncoder() {
|
||||
return new CharsetEncoderMBCS(this);
|
||||
}
|
||||
@ -4765,9 +4774,9 @@ class CharsetMBCS extends CharsetICU {
|
||||
char st1,maxStage1, st2;
|
||||
int st3;
|
||||
int c ;
|
||||
|
||||
|
||||
mbcsTable = data.mbcs;
|
||||
table = mbcsTable.fromUnicodeTable;
|
||||
table = mbcsTable.fromUnicodeTable;
|
||||
if(mbcsTable.hasSupplementary()){
|
||||
maxStage1 = 0x440;
|
||||
}
|
||||
@ -4775,7 +4784,7 @@ class CharsetMBCS extends CharsetICU {
|
||||
maxStage1 = 0x40;
|
||||
}
|
||||
c=0; /* keep track of current code point while enumerating */
|
||||
|
||||
|
||||
if(mbcsTable.outputType==MBCS_OUTPUT_1){
|
||||
char stage2, stage3;
|
||||
char minValue;
|
||||
@ -4835,7 +4844,7 @@ class CharsetMBCS extends CharsetICU {
|
||||
}
|
||||
|
||||
for(st1=0;st1<maxStage1;++st1){
|
||||
st2 = table[st1];
|
||||
st2 = table[st1];
|
||||
if(st2>(maxStage1>>1)){
|
||||
stage2 = st2 ;
|
||||
for(st2=0;st2<64;++st2){
|
||||
@ -4888,7 +4897,7 @@ class CharsetMBCS extends CharsetICU {
|
||||
case UCNV_SET_FILTER_2022_CN :
|
||||
/* only add code points that map to CNS 11643 planes 1&2 for non-EXT ISO-2202-CN. */
|
||||
do {
|
||||
if(((st3&1) != 0 || useFallBack) &&
|
||||
if(((st3&1) != 0 || useFallBack) &&
|
||||
((value= (UConverterConstants.UNSIGNED_BYTE_MASK & bytes[stage3]))==0x81 || value==0x82) ){
|
||||
setFillIn.add(c);
|
||||
}
|
||||
@ -4909,8 +4918,8 @@ class CharsetMBCS extends CharsetICU {
|
||||
case UCNV_SET_FILTER_GR94DBCS:
|
||||
/* only add code points that maps to ISO 2022 GR 94 DBCS codes*/
|
||||
do {
|
||||
if(((st3&1) != 0 || useFallBack) &&
|
||||
(UConverterConstants.UNSIGNED_SHORT_MASK & ((value=chars[stage3 / 2])- 0xa1a1))<=(0xfefe - 0xa1a1) &&
|
||||
if(((st3&1) != 0 || useFallBack) &&
|
||||
(UConverterConstants.UNSIGNED_SHORT_MASK & ((value=chars[stage3 / 2])- 0xa1a1))<=(0xfefe - 0xa1a1) &&
|
||||
(UConverterConstants.UNSIGNED_BYTE_MASK & (value - 0xa1)) <= (0xfe - 0xa1)){
|
||||
setFillIn.add(c);
|
||||
}
|
||||
@ -4921,7 +4930,7 @@ class CharsetMBCS extends CharsetICU {
|
||||
case UCNV_SET_FILTER_HZ:
|
||||
/*Only add code points that are suitable for HZ DBCS*/
|
||||
do {
|
||||
if( ((st3&1) != 0 || useFallBack) &&
|
||||
if( ((st3&1) != 0 || useFallBack) &&
|
||||
(UConverterConstants.UNSIGNED_SHORT_MASK & ((value=chars[stage3 / 2])-0xa1a1))<=(0xfdfe - 0xa1a1) &&
|
||||
(UConverterConstants.UNSIGNED_BYTE_MASK & (value - 0xa1)) <= (0xfe - 0xa1)){
|
||||
setFillIn.add(c);
|
||||
@ -4944,8 +4953,8 @@ class CharsetMBCS extends CharsetICU {
|
||||
}
|
||||
extGetUnicodeSet(setFillIn, which, filter, data);
|
||||
}
|
||||
|
||||
static void extGetUnicodeSetString(ByteBuffer cx,UnicodeSet setFillIn, boolean useFallback,
|
||||
|
||||
static void extGetUnicodeSetString(ByteBuffer cx,UnicodeSet setFillIn, boolean useFallback,
|
||||
int minLength, int c, char s[],int length,int sectionIndex){
|
||||
CharBuffer fromUSectionUChar;
|
||||
IntBuffer fromUSectionValues;
|
||||
@ -4954,7 +4963,7 @@ class CharsetMBCS extends CharsetICU {
|
||||
int fromUSectionUCharIndex = fromUSectionUChar.position()+sectionIndex;
|
||||
int fromUSectionValuesIndex = fromUSectionValues.position()+sectionIndex;
|
||||
int value, i, count;
|
||||
|
||||
|
||||
/* read first pair of the section */
|
||||
count = fromUSectionUChar.get(fromUSectionUCharIndex++);
|
||||
value = fromUSectionValues.get(fromUSectionValuesIndex++);
|
||||
@ -4972,17 +4981,17 @@ class CharsetMBCS extends CharsetICU {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for(i=0; i<count; ++i){
|
||||
s[length] = fromUSectionUChar.get(fromUSectionUCharIndex + i);
|
||||
value = fromUSectionValues.get(fromUSectionValuesIndex + i);
|
||||
|
||||
|
||||
if(value==0) {
|
||||
/* no mapping, do nothing */
|
||||
} else if (FROM_U_IS_PARTIAL(value)) {
|
||||
extGetUnicodeSetString( cx, setFillIn, useFallback, minLength, UConverterConstants.U_SENTINEL, s, length+1,
|
||||
FROM_U_GET_PARTIAL_INDEX(value));
|
||||
} else if ((useFallback ? (value&FROM_U_RESERVED_MASK)==0:((value&(FROM_U_ROUNDTRIP_FLAG|FROM_U_RESERVED_MASK))==FROM_U_ROUNDTRIP_FLAG))
|
||||
} else if ((useFallback ? (value&FROM_U_RESERVED_MASK)==0:((value&(FROM_U_ROUNDTRIP_FLAG|FROM_U_RESERVED_MASK))==FROM_U_ROUNDTRIP_FLAG))
|
||||
&& FROM_U_GET_LENGTH(value)>=minLength) {
|
||||
StringBuilder normalizedStringBuilder = new StringBuilder(); // String for composite characters
|
||||
for(int j=0; j<(length+1);j++){
|
||||
@ -4991,14 +5000,14 @@ class CharsetMBCS extends CharsetICU {
|
||||
setFillIn.add(normalizedStringBuilder.toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static void extGetUnicodeSet(UnicodeSet setFillIn, int which, int filter, UConverterSharedData Data){
|
||||
int st1, stage1Length, st2, st3, minLength;
|
||||
int ps2, ps3;
|
||||
|
||||
|
||||
CharBuffer stage12, stage3;
|
||||
int value, length;
|
||||
IntBuffer stage3b;
|
||||
@ -5012,10 +5021,10 @@ class CharsetMBCS extends CharsetICU {
|
||||
stage12 = (CharBuffer)ARRAY(cx, EXT_FROM_U_STAGE_12_INDEX,char.class );
|
||||
stage3 = (CharBuffer)ARRAY(cx, EXT_FROM_U_STAGE_3_INDEX,char.class );
|
||||
stage3b = (IntBuffer)ARRAY(cx, EXT_FROM_U_STAGE_3B_INDEX,int.class );
|
||||
|
||||
|
||||
stage1Length = cx.asIntBuffer().get(EXT_FROM_U_STAGE_1_LENGTH);
|
||||
useFallback = (which==ROUNDTRIP_AND_FALLBACK_SET);
|
||||
|
||||
|
||||
c = 0;
|
||||
if(filter == UCNV_SET_FILTER_2022_CN) {
|
||||
minLength = 3;
|
||||
@ -5025,13 +5034,13 @@ class CharsetMBCS extends CharsetICU {
|
||||
} else {
|
||||
minLength = 1;
|
||||
}
|
||||
|
||||
|
||||
for(st1=0; st1< stage1Length; ++st1){
|
||||
st2 = stage12.get(st1);
|
||||
if(st2>stage1Length) {
|
||||
ps2 = st2;
|
||||
for(st2=0;st2<64;++st2){
|
||||
st3=((int) stage12.get(ps2+st2))<<STAGE_2_LEFT_SHIFT;
|
||||
st3=(stage12.get(ps2+st2))<<STAGE_2_LEFT_SHIFT;
|
||||
if(st3!= 0){
|
||||
ps3 = st3;
|
||||
do {
|
||||
@ -5042,9 +5051,9 @@ class CharsetMBCS extends CharsetICU {
|
||||
length = 0;
|
||||
length=UTF16.append(s, length, c);
|
||||
extGetUnicodeSetString(cx,setFillIn,useFallback,minLength,c,s,length,FROM_U_GET_PARTIAL_INDEX(value));
|
||||
} else if ((useFallback ? (value&FROM_U_RESERVED_MASK)==0 :((value&(FROM_U_ROUNDTRIP_FLAG|FROM_U_RESERVED_MASK))== FROM_U_ROUNDTRIP_FLAG)) &&
|
||||
} else if ((useFallback ? (value&FROM_U_RESERVED_MASK)==0 :((value&(FROM_U_ROUNDTRIP_FLAG|FROM_U_RESERVED_MASK))== FROM_U_ROUNDTRIP_FLAG)) &&
|
||||
FROM_U_GET_LENGTH(value)>=minLength){
|
||||
|
||||
|
||||
switch(filter) {
|
||||
case UCNV_SET_FILTER_2022_CN:
|
||||
if(!(FROM_U_GET_LENGTH(value)==3 && FROM_U_GET_DATA(value)<=0x82ffff)){
|
||||
@ -5076,10 +5085,10 @@ class CharsetMBCS extends CharsetICU {
|
||||
break;
|
||||
}
|
||||
setFillIn.add(c);
|
||||
|
||||
|
||||
}
|
||||
}while((++c&0xf) != 0);
|
||||
|
||||
|
||||
} else {
|
||||
c+=16; /* emplty stage3 block */
|
||||
}
|
||||
@ -5089,12 +5098,13 @@ class CharsetMBCS extends CharsetICU {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MBCSGetUnicodeSetForUnicode(UConverterSharedData data, UnicodeSet setFillIn, int which){
|
||||
MBCSGetFilteredUnicodeSetForUnicode(data, setFillIn, which,
|
||||
MBCSGetFilteredUnicodeSetForUnicode(data, setFillIn, which,
|
||||
this.sharedData.mbcs.outputType==MBCS_OUTPUT_DBCS_ONLY ? UCNV_SET_FILTER_DBCS_ONLY : UCNV_SET_FILTER_NONE );
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
void getUnicodeSetImpl( UnicodeSet setFillIn, int which){
|
||||
if((options & MBCS_OPTION_GB18030)!=0){
|
||||
setFillIn.add(0, 0xd7ff);
|
||||
|
@ -205,6 +205,8 @@ public final class CollationFastLatin /* all static */ {
|
||||
if(header == null) { return -1; }
|
||||
assert((header[0] >> 8) == VERSION);
|
||||
assert(primaries.length == LATIN_LIMIT);
|
||||
// FindBugs complains that primaries.length == LATIN_LIMIT is known after the assert,
|
||||
// but we keep this here for when assertions are disabled.
|
||||
if(primaries.length != LATIN_LIMIT) { return -1; }
|
||||
|
||||
int miniVarTop;
|
||||
|
@ -107,6 +107,7 @@ public class JavaTimeZone extends TimeZone {
|
||||
/* (non-Javadoc)
|
||||
* @see com.ibm.icu.util.TimeZone#getOffset(int, int, int, int, int, int)
|
||||
*/
|
||||
@Override
|
||||
public int getOffset(int era, int year, int month, int day, int dayOfWeek, int milliseconds) {
|
||||
return javatz.getOffset(era, year, month, day, dayOfWeek, milliseconds);
|
||||
}
|
||||
@ -114,6 +115,7 @@ public class JavaTimeZone extends TimeZone {
|
||||
/* (non-Javadoc)
|
||||
* @see com.ibm.icu.util.TimeZone#getOffset(long, boolean, int[])
|
||||
*/
|
||||
@Override
|
||||
public void getOffset(long date, boolean local, int[] offsets) {
|
||||
synchronized (javacal) {
|
||||
if (local) {
|
||||
@ -159,6 +161,7 @@ public class JavaTimeZone extends TimeZone {
|
||||
/* (non-Javadoc)
|
||||
* @see com.ibm.icu.util.TimeZone#getRawOffset()
|
||||
*/
|
||||
@Override
|
||||
public int getRawOffset() {
|
||||
return javatz.getRawOffset();
|
||||
}
|
||||
@ -166,6 +169,7 @@ public class JavaTimeZone extends TimeZone {
|
||||
/* (non-Javadoc)
|
||||
* @see com.ibm.icu.util.TimeZone#inDaylightTime(java.util.Date)
|
||||
*/
|
||||
@Override
|
||||
public boolean inDaylightTime(Date date) {
|
||||
return javatz.inDaylightTime(date);
|
||||
}
|
||||
@ -173,6 +177,7 @@ public class JavaTimeZone extends TimeZone {
|
||||
/* (non-Javadoc)
|
||||
* @see com.ibm.icu.util.TimeZone#setRawOffset(int)
|
||||
*/
|
||||
@Override
|
||||
public void setRawOffset(int offsetMillis) {
|
||||
if (isFrozen()) {
|
||||
throw new UnsupportedOperationException("Attempt to modify a frozen JavaTimeZone instance.");
|
||||
@ -183,6 +188,7 @@ public class JavaTimeZone extends TimeZone {
|
||||
/* (non-Javadoc)
|
||||
* @see com.ibm.icu.util.TimeZone#useDaylightTime()
|
||||
*/
|
||||
@Override
|
||||
public boolean useDaylightTime() {
|
||||
return javatz.useDaylightTime();
|
||||
}
|
||||
@ -190,6 +196,7 @@ public class JavaTimeZone extends TimeZone {
|
||||
/* (non-Javadoc)
|
||||
* @see com.ibm.icu.util.TimeZone#observesDaylightTime()
|
||||
*/
|
||||
@Override
|
||||
public boolean observesDaylightTime() {
|
||||
if (mObservesDaylightTime != null) {
|
||||
// Java 7+
|
||||
@ -206,6 +213,7 @@ public class JavaTimeZone extends TimeZone {
|
||||
/* (non-Javadoc)
|
||||
* @see com.ibm.icu.util.TimeZone#getDSTSavings()
|
||||
*/
|
||||
@Override
|
||||
public int getDSTSavings() {
|
||||
return javatz.getDSTSavings();
|
||||
}
|
||||
@ -217,6 +225,7 @@ public class JavaTimeZone extends TimeZone {
|
||||
/* (non-Javadoc)
|
||||
* @see com.ibm.icu.util.TimeZone#clone()
|
||||
*/
|
||||
@Override
|
||||
public Object clone() {
|
||||
if (isFrozen()) {
|
||||
return this;
|
||||
@ -227,6 +236,7 @@ public class JavaTimeZone extends TimeZone {
|
||||
/* (non-Javadoc)
|
||||
* @see com.ibm.icu.util.TimeZone#hashCode()
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return super.hashCode() + javatz.hashCode();
|
||||
}
|
||||
@ -242,6 +252,7 @@ public class JavaTimeZone extends TimeZone {
|
||||
/* (non-Javadoc)
|
||||
* @see com.ibm.icu.util.TimeZone#isFrozen()
|
||||
*/
|
||||
@Override
|
||||
public boolean isFrozen() {
|
||||
return isFrozen;
|
||||
}
|
||||
@ -249,6 +260,7 @@ public class JavaTimeZone extends TimeZone {
|
||||
/* (non-Javadoc)
|
||||
* @see com.ibm.icu.util.TimeZone#freeze()
|
||||
*/
|
||||
@Override
|
||||
public TimeZone freeze() {
|
||||
isFrozen = true;
|
||||
return this;
|
||||
@ -257,12 +269,11 @@ public class JavaTimeZone extends TimeZone {
|
||||
/* (non-Javadoc)
|
||||
* @see com.ibm.icu.util.TimeZone#cloneAsThawed()
|
||||
*/
|
||||
@Override
|
||||
public TimeZone cloneAsThawed() {
|
||||
JavaTimeZone tz = (JavaTimeZone)super.cloneAsThawed();
|
||||
tz.javatz = (java.util.TimeZone)javatz.clone();
|
||||
synchronized(javacal) {
|
||||
tz.javacal = (java.util.GregorianCalendar)javacal.clone();
|
||||
}
|
||||
tz.javacal = new java.util.GregorianCalendar(javatz); // easier than synchronized javacal.clone()
|
||||
tz.isFrozen = false;
|
||||
return tz;
|
||||
}
|
||||
|
@ -668,6 +668,8 @@ public class TimeZoneNamesImpl extends TimeZoneNames {
|
||||
for (int i = 0; i < ZNames.NUM_NAME_TYPES; ++i) {
|
||||
String name = names[i];
|
||||
if (name != null) {
|
||||
// FindBugs complains about == but
|
||||
// we do want to check for the NO_NAME reference, not its contents!
|
||||
if (name == NO_NAME) {
|
||||
names[i] = null;
|
||||
} else {
|
||||
|
@ -124,7 +124,7 @@ public final class Utility {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Convenience utility to compare two int[]s.
|
||||
* @param len the length to compare.
|
||||
* The start indices and start+len must be valid.
|
||||
@ -176,17 +176,17 @@ public final class Utility {
|
||||
* Convenience utility. Does null checks on objects, then calls equals.
|
||||
*/
|
||||
public final static boolean objectEquals(Object a, Object b) {
|
||||
return a == null ?
|
||||
b == null ? true : false :
|
||||
return a == null ?
|
||||
b == null ? true : false :
|
||||
b == null ? false : a.equals(b);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Convenience utility. Does null checks on objects, then calls compare.
|
||||
*/
|
||||
public static <T extends Comparable<T>> int checkCompare(T a, T b) {
|
||||
return a == null ?
|
||||
b == null ? 0 : -1 :
|
||||
return a == null ?
|
||||
b == null ? 0 : -1 :
|
||||
b == null ? 1 : a.compareTo(b);
|
||||
}
|
||||
|
||||
@ -196,7 +196,7 @@ public final class Utility {
|
||||
public static int checkHash(Object a) {
|
||||
return a == null ? 0 : a.hashCode();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The ESCAPE character is used during run-length encoding. It signals
|
||||
* a run of identical chars.
|
||||
@ -360,8 +360,8 @@ public final class Utility {
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (length == (int) ESCAPE) {
|
||||
if (value == (int) ESCAPE) {
|
||||
if (length == ESCAPE) {
|
||||
if (value == ESCAPE) {
|
||||
appendInt(buffer, ESCAPE);
|
||||
}
|
||||
appendInt(buffer, value);
|
||||
@ -388,22 +388,26 @@ public final class Utility {
|
||||
*/
|
||||
private static final <T extends Appendable> void encodeRun(T buffer, short value, int length) {
|
||||
try {
|
||||
char valueChar = (char) value;
|
||||
if (length < 4) {
|
||||
for (int j=0; j<length; ++j) {
|
||||
if (value == (int) ESCAPE)
|
||||
if (valueChar == ESCAPE) {
|
||||
buffer.append(ESCAPE);
|
||||
buffer.append((char) value);
|
||||
}
|
||||
buffer.append(valueChar);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (length == (int) ESCAPE) {
|
||||
if (value == (int) ESCAPE) buffer.append(ESCAPE);
|
||||
buffer.append((char) value);
|
||||
if (length == ESCAPE) {
|
||||
if (valueChar == ESCAPE) {
|
||||
buffer.append(ESCAPE);
|
||||
}
|
||||
buffer.append(valueChar);
|
||||
--length;
|
||||
}
|
||||
buffer.append(ESCAPE);
|
||||
buffer.append((char) length);
|
||||
buffer.append((char) value); // Don't need to escape this value
|
||||
buffer.append(valueChar); // Don't need to escape this value
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new IllegalIcuArgumentException(e);
|
||||
@ -423,7 +427,7 @@ public final class Utility {
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (length == ESCAPE_BYTE) {
|
||||
if ((byte)length == ESCAPE_BYTE) {
|
||||
if (value == ESCAPE_BYTE) appendEncodedByte(buffer, ESCAPE_BYTE, state);
|
||||
appendEncodedByte(buffer, value, state);
|
||||
--length;
|
||||
@ -446,7 +450,7 @@ public final class Utility {
|
||||
byte[] state) {
|
||||
try {
|
||||
if (state[0] != 0) {
|
||||
char c = (char) ((state[1] << 8) | (((int) value) & 0xFF));
|
||||
char c = (char) ((state[1] << 8) | ((value) & 0xFF));
|
||||
buffer.append(c);
|
||||
state[0] = 0;
|
||||
}
|
||||
@ -495,14 +499,14 @@ public final class Utility {
|
||||
return array;
|
||||
}
|
||||
static final int getInt(String s, int i) {
|
||||
return (((int) s.charAt(2*i)) << 16) | (int) s.charAt(2*i+1);
|
||||
return ((s.charAt(2*i)) << 16) | s.charAt(2*i+1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct an array of shorts from a run-length encoded string.
|
||||
*/
|
||||
static public final short[] RLEStringToShortArray(String s) {
|
||||
int length = (((int) s.charAt(0)) << 16) | ((int) s.charAt(1));
|
||||
int length = ((s.charAt(0)) << 16) | (s.charAt(1));
|
||||
short[] array = new short[length];
|
||||
int ai = 0;
|
||||
for (int i=2; i<s.length(); ++i) {
|
||||
@ -512,7 +516,7 @@ public final class Utility {
|
||||
if (c == ESCAPE) {
|
||||
array[ai++] = (short) c;
|
||||
} else {
|
||||
int runLength = (int) c;
|
||||
int runLength = c;
|
||||
short runValue = (short) s.charAt(++i);
|
||||
for (int j=0; j<runLength; ++j) array[ai++] = runValue;
|
||||
}
|
||||
@ -532,7 +536,7 @@ public final class Utility {
|
||||
* Construct an array of shorts from a run-length encoded string.
|
||||
*/
|
||||
static public final char[] RLEStringToCharArray(String s) {
|
||||
int length = (((int) s.charAt(0)) << 16) | ((int) s.charAt(1));
|
||||
int length = ((s.charAt(0)) << 16) | (s.charAt(1));
|
||||
char[] array = new char[length];
|
||||
int ai = 0;
|
||||
for (int i=2; i<s.length(); ++i) {
|
||||
@ -542,7 +546,7 @@ public final class Utility {
|
||||
if (c == ESCAPE) {
|
||||
array[ai++] = c;
|
||||
} else {
|
||||
int runLength = (int) c;
|
||||
int runLength = c;
|
||||
char runValue = s.charAt(++i);
|
||||
for (int j=0; j<runLength; ++j) array[ai++] = runValue;
|
||||
}
|
||||
@ -562,7 +566,7 @@ public final class Utility {
|
||||
* Construct an array of bytes from a run-length encoded string.
|
||||
*/
|
||||
static public final byte[] RLEStringToByteArray(String s) {
|
||||
int length = (((int) s.charAt(0)) << 16) | ((int) s.charAt(1));
|
||||
int length = ((s.charAt(0)) << 16) | (s.charAt(1));
|
||||
byte[] array = new byte[length];
|
||||
boolean nextChar = true;
|
||||
char c = 0;
|
||||
@ -1030,7 +1034,7 @@ public final class Utility {
|
||||
*/
|
||||
public static <S extends CharSequence> String hex(S s, int width, S separator) {
|
||||
return hex(s, width, separator, true, new StringBuilder()).toString();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Split a string into pieces based on the given divider character
|
||||
@ -1673,7 +1677,7 @@ public final class Utility {
|
||||
target += MAGIC_UNSIGNED;
|
||||
if (source < target) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else if (source > target) {
|
||||
return 1;
|
||||
}
|
||||
@ -1726,7 +1730,7 @@ public final class Utility {
|
||||
}
|
||||
/**
|
||||
* Utility method to take a int[] containing codepoints and return
|
||||
* a string representation with code units.
|
||||
* a string representation with code units.
|
||||
*/
|
||||
public static String valueOf(int[]source){
|
||||
// TODO: Investigate why this method is not on UTF16 class
|
||||
@ -1752,7 +1756,7 @@ public final class Utility {
|
||||
}
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
|
||||
public static String[] splitString(String src, String target) {
|
||||
return src.split("\\Q" + target + "\\E");
|
||||
}
|
||||
@ -1774,7 +1778,7 @@ public final class Utility {
|
||||
public static String fromHex(String string, int minLength, String separator) {
|
||||
return fromHex(string, minLength, Pattern.compile(separator != null ? separator : "\\s+"));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Parse a list of hex numbers and return a string
|
||||
* @param string String of hex numbers.
|
||||
|
@ -161,7 +161,7 @@ public class SpoofChecker {
|
||||
ASCII,
|
||||
/**
|
||||
* All characters in each identifier must be from a single script.
|
||||
*
|
||||
*
|
||||
* @stable ICU 53
|
||||
*/
|
||||
SINGLE_SCRIPT_RESTRICTIVE,
|
||||
@ -1077,7 +1077,7 @@ public class SpoofChecker {
|
||||
StringBuilder mapString = new StringBuilder();
|
||||
while (m.find()) {
|
||||
int c = Integer.parseInt(m.group(1), 16);
|
||||
if (keyChar > 0x10ffff) {
|
||||
if (c > 0x10ffff) {
|
||||
throw new ParseException("Confusables, line " + fLineNum + ": Bad code point: "
|
||||
+ Integer.toString(c, 16), matcher.start(2));
|
||||
}
|
||||
@ -1091,7 +1091,7 @@ public class SpoofChecker {
|
||||
SPUString smapString = stringPool.addString(mapString.toString());
|
||||
|
||||
// Add the char . string mapping to the appropriate table.
|
||||
Hashtable<Integer, SPUString> table =
|
||||
Hashtable<Integer, SPUString> table =
|
||||
matcher.start(3) >= 0 ? fSLTable :
|
||||
matcher.start(4) >= 0 ? fSATable :
|
||||
matcher.start(5) >= 0 ? fMLTable :
|
||||
@ -1400,6 +1400,7 @@ public class SpoofChecker {
|
||||
// by code point order.
|
||||
|
||||
private static class SPUStringComparator implements Comparator<SPUString> {
|
||||
@Override
|
||||
public int compare(SPUString sL, SPUString sR) {
|
||||
int lenL = sL.fStr.length();
|
||||
int lenR = sR.fStr.length();
|
||||
@ -1876,7 +1877,7 @@ public class SpoofChecker {
|
||||
* The latest proposed update, UAX 39 Version 8 draft 1, says "the tables SL, SA, and ML
|
||||
* were still problematic, and discouraged from use in [Uniocde] 7.0.
|
||||
* They were thus removed from version 8.0"
|
||||
*
|
||||
*
|
||||
* In light of this, the default mapping data included with ICU 55 uses the
|
||||
* Unicode 7 MA (Multi script Any case) table data for the other type options
|
||||
* (Single Script, Any Case), (Single Script, Lower Case) and (Multi Script, Lower Case).
|
||||
@ -2243,6 +2244,7 @@ public class SpoofChecker {
|
||||
static class SpoofStringLengthsElement {
|
||||
int fLastString; // index in string table of last string with this length
|
||||
int fStrLength; // Length of strings
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
if (!(other instanceof SpoofStringLengthsElement)) {
|
||||
return false;
|
||||
@ -2257,6 +2259,7 @@ public class SpoofChecker {
|
||||
|
||||
private static final class IsAcceptable implements Authenticate {
|
||||
// @Override when we switch to Java 6
|
||||
@Override
|
||||
public boolean isDataVersionAcceptable(byte version[]) {
|
||||
return version[0] == 1;
|
||||
}
|
||||
@ -2294,6 +2297,7 @@ public class SpoofChecker {
|
||||
readData(bytes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
if (!(other instanceof SpoofData)) {
|
||||
return false;
|
||||
@ -2422,6 +2426,7 @@ public class SpoofChecker {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
if (!(other instanceof ScriptSet)) {
|
||||
return false;
|
||||
|
@ -96,7 +96,7 @@ public final class CompactByteArray implements Cloneable {
|
||||
throw new IllegalArgumentException("Index out of bounds.");
|
||||
for (i = 0; i < INDEXCOUNT; ++i) {
|
||||
char index = indexArray[i];
|
||||
if ((index < 0) || (index >= newValues.length+BLOCKCOUNT))
|
||||
if (index >= newValues.length+BLOCKCOUNT)
|
||||
throw new IllegalArgumentException("Index out of bounds.");
|
||||
}
|
||||
indices = indexArray;
|
||||
@ -150,7 +150,7 @@ public final class CompactByteArray implements Cloneable {
|
||||
{
|
||||
if (isCompact)
|
||||
expand();
|
||||
values[(int)index] = value;
|
||||
values[index] = value;
|
||||
touchBlock(index >> BLOCKSHIFT, value);
|
||||
}
|
||||
|
||||
@ -307,6 +307,7 @@ public final class CompactByteArray implements Cloneable {
|
||||
* @internal
|
||||
* @deprecated This API is ICU internal only.
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public Object clone()
|
||||
{
|
||||
@ -329,6 +330,7 @@ public final class CompactByteArray implements Cloneable {
|
||||
* @internal
|
||||
* @deprecated This API is ICU internal only.
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null) return false;
|
||||
@ -350,6 +352,7 @@ public final class CompactByteArray implements Cloneable {
|
||||
* @internal
|
||||
* @deprecated This API is ICU internal only.
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public int hashCode() {
|
||||
int result = 0;
|
||||
|
@ -97,7 +97,7 @@ public final class CompactCharArray implements Cloneable {
|
||||
throw new IllegalArgumentException("Index out of bounds.");
|
||||
for (i = 0; i < INDEXCOUNT; ++i) {
|
||||
char index = indexArray[i];
|
||||
if ((index < 0) || (index >= newValues.length+BLOCKCOUNT))
|
||||
if (index >= newValues.length+BLOCKCOUNT)
|
||||
throw new IllegalArgumentException("Index out of bounds.");
|
||||
}
|
||||
indices = indexArray;
|
||||
@ -152,7 +152,7 @@ public final class CompactCharArray implements Cloneable {
|
||||
{
|
||||
if (isCompact)
|
||||
expand();
|
||||
values[(int)index] = value;
|
||||
values[index] = value;
|
||||
touchBlock(index >> BLOCKSHIFT, value);
|
||||
}
|
||||
|
||||
@ -331,6 +331,7 @@ public final class CompactCharArray implements Cloneable {
|
||||
* @internal
|
||||
* @deprecated This API is ICU internal only.
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public Object clone()
|
||||
{
|
||||
@ -353,6 +354,7 @@ public final class CompactCharArray implements Cloneable {
|
||||
* @internal
|
||||
* @deprecated This API is ICU internal only.
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null) return false;
|
||||
@ -374,6 +376,7 @@ public final class CompactCharArray implements Cloneable {
|
||||
* @internal
|
||||
* @deprecated This API is ICU internal only.
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public int hashCode() {
|
||||
int result = 0;
|
||||
|
@ -466,7 +466,7 @@ public final class ULocale implements Serializable, Comparable<ULocale> {
|
||||
* are distinguished by position as indicated by the underscores. The
|
||||
* start of the keyword list is indicated by '@', and consists of two
|
||||
* or more keyword/value pairs separated by semicolons(';').
|
||||
*
|
||||
*
|
||||
* <p>This constructor does not canonicalize the localeID. So, for
|
||||
* example, "zh__pinyin" remains unchanged instead of converting
|
||||
* to "zh@collation=pinyin". By default ICU only recognizes the
|
||||
@ -581,7 +581,7 @@ public final class ULocale implements Serializable, Comparable<ULocale> {
|
||||
// Locale.getDefault().
|
||||
|
||||
// Note: The "user.script" property is only used by initialization.
|
||||
//
|
||||
//
|
||||
if (JDKLocaleHelper.hasLocaleCategories()) {
|
||||
for (Category cat: Category.values()) {
|
||||
int idx = cat.ordinal();
|
||||
@ -636,7 +636,7 @@ public final class ULocale implements Serializable, Comparable<ULocale> {
|
||||
* or older systems supporting other <code>user.*</code> system properties to initialize
|
||||
* the default ULocale. The <code>user.script</code> override for default ULocale is not
|
||||
* used on Java 7, or if the current Java default Locale is changed after start up.
|
||||
*
|
||||
*
|
||||
* @return the default ULocale.
|
||||
* @stable ICU 2.8
|
||||
*/
|
||||
@ -702,7 +702,7 @@ public final class ULocale implements Serializable, Comparable<ULocale> {
|
||||
|
||||
/**
|
||||
* Returns the current default ULocale for the specified category.
|
||||
*
|
||||
*
|
||||
* @param category the category
|
||||
* @return the default ULocale for the specified category.
|
||||
* @stable ICU 49
|
||||
@ -760,7 +760,7 @@ public final class ULocale implements Serializable, Comparable<ULocale> {
|
||||
* of the JVM. If the caller does not have write permission to the
|
||||
* user.language property, a security exception will be thrown,
|
||||
* and the default ULocale for the specified Category will remain unchanged.
|
||||
*
|
||||
*
|
||||
* @param category the specified category to set the default locale
|
||||
* @param newLocale the new default locale
|
||||
* @see SecurityManager#checkPermission(java.security.Permission)
|
||||
@ -780,6 +780,7 @@ public final class ULocale implements Serializable, Comparable<ULocale> {
|
||||
* immutable, there is no reason to clone it, so this API returns 'this'.
|
||||
* @stable ICU 3.0
|
||||
*/
|
||||
@Override
|
||||
public Object clone() {
|
||||
return this;
|
||||
}
|
||||
@ -788,6 +789,7 @@ public final class ULocale implements Serializable, Comparable<ULocale> {
|
||||
* Returns the hashCode.
|
||||
* @stable ICU 3.0
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return localeID.hashCode();
|
||||
}
|
||||
@ -801,6 +803,7 @@ public final class ULocale implements Serializable, Comparable<ULocale> {
|
||||
* @return true if this Locale is equal to the specified object.
|
||||
* @stable ICU 3.0
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
@ -814,14 +817,15 @@ public final class ULocale implements Serializable, Comparable<ULocale> {
|
||||
/**
|
||||
* Compares two ULocale for ordering.
|
||||
* <p><b>Note:</b> The order might change in future.
|
||||
*
|
||||
*
|
||||
* @param other the ULocale to be compared.
|
||||
* @return a negative integer, zero, or a positive integer as this ULocale is less than, equal to, or greater
|
||||
* than the specified ULocale.
|
||||
* @throws NullPointerException if <code>other</code> is null.
|
||||
*
|
||||
*
|
||||
* @stable ICU 53
|
||||
*/
|
||||
@Override
|
||||
public int compareTo(ULocale other) {
|
||||
if (this == other) {
|
||||
return 0;
|
||||
@ -1179,6 +1183,7 @@ public final class ULocale implements Serializable, Comparable<ULocale> {
|
||||
* Returns a string representation of this object.
|
||||
* @stable ICU 3.0
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return localeID;
|
||||
}
|
||||
@ -2166,7 +2171,7 @@ public final class ULocale implements Serializable, Comparable<ULocale> {
|
||||
/**
|
||||
* Package local method used for parsing Accept-Language string
|
||||
*/
|
||||
static ULocale[] parseAcceptLanguage(String acceptLanguage, boolean isLenient)
|
||||
static ULocale[] parseAcceptLanguage(String acceptLanguage, boolean isLenient)
|
||||
throws ParseException {
|
||||
class ULocaleAcceptLanguageQ implements Comparable<ULocaleAcceptLanguageQ> {
|
||||
private double q;
|
||||
@ -2175,6 +2180,7 @@ public final class ULocale implements Serializable, Comparable<ULocale> {
|
||||
q = theq;
|
||||
serial = theserial;
|
||||
}
|
||||
@Override
|
||||
public int compareTo(ULocaleAcceptLanguageQ other) {
|
||||
if (q > other.q) { // reverse - to sort in descending order
|
||||
return -1;
|
||||
@ -2192,7 +2198,7 @@ public final class ULocale implements Serializable, Comparable<ULocale> {
|
||||
}
|
||||
|
||||
// parse out the acceptLanguage into an array
|
||||
TreeMap<ULocaleAcceptLanguageQ, ULocale> map =
|
||||
TreeMap<ULocaleAcceptLanguageQ, ULocale> map =
|
||||
new TreeMap<ULocaleAcceptLanguageQ, ULocale>();
|
||||
StringBuilder languageRangeBuf = new StringBuilder();
|
||||
StringBuilder qvalBuf = new StringBuilder();
|
||||
@ -2337,7 +2343,7 @@ public final class ULocale implements Serializable, Comparable<ULocale> {
|
||||
}
|
||||
break;
|
||||
case 8: // before q value fraction part
|
||||
if ('0' <= c || c <= '9') {
|
||||
if ('0' <= c && c <= '9') {
|
||||
if (q1 && c != '0' && !isLenient) {
|
||||
// if q value starts with 1, the fraction part must be 0
|
||||
state = -1;
|
||||
@ -2501,64 +2507,64 @@ public final class ULocale implements Serializable, Comparable<ULocale> {
|
||||
* @stable ICU 4.0
|
||||
*/
|
||||
public static ULocale minimizeSubtags(ULocale loc) {
|
||||
return minimizeSubtags(loc, Minimize.FAVOR_REGION);
|
||||
}
|
||||
return minimizeSubtags(loc, Minimize.FAVOR_REGION);
|
||||
}
|
||||
|
||||
/**
|
||||
* Options for minimizeSubtags.
|
||||
/**
|
||||
* Options for minimizeSubtags.
|
||||
* @internal
|
||||
* @deprecated This API is ICU internal only.
|
||||
*/
|
||||
*/
|
||||
@Deprecated
|
||||
public enum Minimize {
|
||||
/**
|
||||
public enum Minimize {
|
||||
/**
|
||||
* Favor including the script, when either the region <b>or</b> the script could be suppressed, but not both.
|
||||
* @internal
|
||||
* @deprecated This API is ICU internal only.
|
||||
*/
|
||||
@Deprecated
|
||||
FAVOR_SCRIPT,
|
||||
FAVOR_SCRIPT,
|
||||
/**
|
||||
* Favor including the region, when either the region <b>or</b> the script could be suppressed, but not both.
|
||||
* @internal
|
||||
* @deprecated This API is ICU internal only.
|
||||
*/
|
||||
@Deprecated
|
||||
FAVOR_REGION
|
||||
}
|
||||
FAVOR_REGION
|
||||
}
|
||||
|
||||
/**
|
||||
* {@icu} Minimizes the subtags for a provided locale ID, per the algorithm described
|
||||
* in the following CLDR technical report:<blockquote>
|
||||
*
|
||||
* <a href="http://www.unicode.org/reports/tr35/#Likely_Subtags"
|
||||
*>http://www.unicode.org/reports/tr35/#Likely_Subtags</a></blockquote>
|
||||
*
|
||||
* If the provided ULocale instance is already in the minimal form, or there
|
||||
* is no data available for minimization, it will be returned. Since the
|
||||
* minimization algorithm relies on proper maximization, see the comments
|
||||
* for addLikelySubtags for reasons why there might not be any data.
|
||||
*
|
||||
* Examples:<pre>
|
||||
*
|
||||
* "en_Latn_US" minimizes to "en"
|
||||
*
|
||||
* "de_Latn_US" minimizes to "de"
|
||||
*
|
||||
* "sr_Cyrl_RS" minimizes to "sr"
|
||||
*
|
||||
* "zh_Hant_TW" minimizes to "zh_TW" if fieldToFavor == {@link Minimize#FAVOR_REGION}
|
||||
* "zh_Hant_TW" minimizes to "zh_Hant" if fieldToFavor == {@link Minimize#FAVOR_SCRIPT}
|
||||
* </pre>
|
||||
* The fieldToFavor only has an effect if either the region or the script could be suppressed, but not both.
|
||||
* @param loc The ULocale to minimize
|
||||
* @param fieldToFavor Indicate which should be preferred, when either the region <b>or</b> the script could be suppressed, but not both.
|
||||
* @return The minimized ULocale instance.
|
||||
/**
|
||||
* {@icu} Minimizes the subtags for a provided locale ID, per the algorithm described
|
||||
* in the following CLDR technical report:<blockquote>
|
||||
*
|
||||
* <a href="http://www.unicode.org/reports/tr35/#Likely_Subtags"
|
||||
*>http://www.unicode.org/reports/tr35/#Likely_Subtags</a></blockquote>
|
||||
*
|
||||
* If the provided ULocale instance is already in the minimal form, or there
|
||||
* is no data available for minimization, it will be returned. Since the
|
||||
* minimization algorithm relies on proper maximization, see the comments
|
||||
* for addLikelySubtags for reasons why there might not be any data.
|
||||
*
|
||||
* Examples:<pre>
|
||||
*
|
||||
* "en_Latn_US" minimizes to "en"
|
||||
*
|
||||
* "de_Latn_US" minimizes to "de"
|
||||
*
|
||||
* "sr_Cyrl_RS" minimizes to "sr"
|
||||
*
|
||||
* "zh_Hant_TW" minimizes to "zh_TW" if fieldToFavor == {@link Minimize#FAVOR_REGION}
|
||||
* "zh_Hant_TW" minimizes to "zh_Hant" if fieldToFavor == {@link Minimize#FAVOR_SCRIPT}
|
||||
* </pre>
|
||||
* The fieldToFavor only has an effect if either the region or the script could be suppressed, but not both.
|
||||
* @param loc The ULocale to minimize
|
||||
* @param fieldToFavor Indicate which should be preferred, when either the region <b>or</b> the script could be suppressed, but not both.
|
||||
* @return The minimized ULocale instance.
|
||||
* @internal
|
||||
* @deprecated This API is ICU internal only.
|
||||
*/
|
||||
*/
|
||||
@Deprecated
|
||||
public static ULocale minimizeSubtags(ULocale loc, Minimize fieldToFavor) {
|
||||
public static ULocale minimizeSubtags(ULocale loc, Minimize fieldToFavor) {
|
||||
String[] tags = new String[3];
|
||||
|
||||
int trailingIndex = parseTagString(
|
||||
@ -2622,85 +2628,85 @@ public final class ULocale implements Serializable, Comparable<ULocale> {
|
||||
/**
|
||||
* Next, try the language and region.
|
||||
**/
|
||||
if (fieldToFavor == Minimize.FAVOR_REGION) {
|
||||
if (originalRegion.length() != 0) {
|
||||
String tag =
|
||||
createLikelySubtagsString(
|
||||
originalLang,
|
||||
null,
|
||||
originalRegion,
|
||||
null);
|
||||
if (fieldToFavor == Minimize.FAVOR_REGION) {
|
||||
if (originalRegion.length() != 0) {
|
||||
String tag =
|
||||
createLikelySubtagsString(
|
||||
originalLang,
|
||||
null,
|
||||
originalRegion,
|
||||
null);
|
||||
|
||||
if (tag.equals(maximizedLocaleID)) {
|
||||
String newLocaleID =
|
||||
createTagString(
|
||||
originalLang,
|
||||
null,
|
||||
originalRegion,
|
||||
originalTrailing);
|
||||
if (tag.equals(maximizedLocaleID)) {
|
||||
String newLocaleID =
|
||||
createTagString(
|
||||
originalLang,
|
||||
null,
|
||||
originalRegion,
|
||||
originalTrailing);
|
||||
|
||||
return new ULocale(newLocaleID);
|
||||
}
|
||||
}
|
||||
if (originalScript.length() != 0){
|
||||
String tag =
|
||||
createLikelySubtagsString(
|
||||
originalLang,
|
||||
originalScript,
|
||||
null,
|
||||
null);
|
||||
return new ULocale(newLocaleID);
|
||||
}
|
||||
}
|
||||
if (originalScript.length() != 0){
|
||||
String tag =
|
||||
createLikelySubtagsString(
|
||||
originalLang,
|
||||
originalScript,
|
||||
null,
|
||||
null);
|
||||
|
||||
if (tag.equals(maximizedLocaleID)) {
|
||||
String newLocaleID =
|
||||
createTagString(
|
||||
originalLang,
|
||||
originalScript,
|
||||
null,
|
||||
originalTrailing);
|
||||
if (tag.equals(maximizedLocaleID)) {
|
||||
String newLocaleID =
|
||||
createTagString(
|
||||
originalLang,
|
||||
originalScript,
|
||||
null,
|
||||
originalTrailing);
|
||||
|
||||
return new ULocale(newLocaleID);
|
||||
}
|
||||
}
|
||||
} else { // FAVOR_SCRIPT, so
|
||||
if (originalScript.length() != 0){
|
||||
String tag =
|
||||
createLikelySubtagsString(
|
||||
originalLang,
|
||||
originalScript,
|
||||
null,
|
||||
null);
|
||||
return new ULocale(newLocaleID);
|
||||
}
|
||||
}
|
||||
} else { // FAVOR_SCRIPT, so
|
||||
if (originalScript.length() != 0){
|
||||
String tag =
|
||||
createLikelySubtagsString(
|
||||
originalLang,
|
||||
originalScript,
|
||||
null,
|
||||
null);
|
||||
|
||||
if (tag.equals(maximizedLocaleID)) {
|
||||
String newLocaleID =
|
||||
createTagString(
|
||||
originalLang,
|
||||
originalScript,
|
||||
null,
|
||||
originalTrailing);
|
||||
if (tag.equals(maximizedLocaleID)) {
|
||||
String newLocaleID =
|
||||
createTagString(
|
||||
originalLang,
|
||||
originalScript,
|
||||
null,
|
||||
originalTrailing);
|
||||
|
||||
return new ULocale(newLocaleID);
|
||||
}
|
||||
}
|
||||
if (originalRegion.length() != 0) {
|
||||
String tag =
|
||||
createLikelySubtagsString(
|
||||
originalLang,
|
||||
null,
|
||||
originalRegion,
|
||||
null);
|
||||
return new ULocale(newLocaleID);
|
||||
}
|
||||
}
|
||||
if (originalRegion.length() != 0) {
|
||||
String tag =
|
||||
createLikelySubtagsString(
|
||||
originalLang,
|
||||
null,
|
||||
originalRegion,
|
||||
null);
|
||||
|
||||
if (tag.equals(maximizedLocaleID)) {
|
||||
String newLocaleID =
|
||||
createTagString(
|
||||
originalLang,
|
||||
null,
|
||||
originalRegion,
|
||||
originalTrailing);
|
||||
if (tag.equals(maximizedLocaleID)) {
|
||||
String newLocaleID =
|
||||
createTagString(
|
||||
originalLang,
|
||||
null,
|
||||
originalRegion,
|
||||
originalTrailing);
|
||||
|
||||
return new ULocale(newLocaleID);
|
||||
}
|
||||
}
|
||||
}
|
||||
return new ULocale(newLocaleID);
|
||||
}
|
||||
}
|
||||
}
|
||||
return loc;
|
||||
}
|
||||
|
||||
@ -2994,7 +3000,7 @@ public final class ULocale implements Serializable, Comparable<ULocale> {
|
||||
System.err.println("Tag mismatch: \"" + likelySubtags + "\" \"(null)\"");
|
||||
}
|
||||
else if (!likelySubtags.equals(likelySubtags2)) {
|
||||
System.err.println("Tag mismatch: \"" + likelySubtags + "\" \"" + likelySubtags2
|
||||
System.err.println("Tag mismatch: \"" + likelySubtags + "\" \"" + likelySubtags2
|
||||
+ "\"");
|
||||
}
|
||||
*/
|
||||
@ -3177,7 +3183,7 @@ public final class ULocale implements Serializable, Comparable<ULocale> {
|
||||
* locale does not define the key.
|
||||
* @throws IllegalArgumentException if the key is not well-formed
|
||||
* @throws NullPointerException if <code>key</code> is null
|
||||
*
|
||||
*
|
||||
* @stable ICU 4.4
|
||||
*/
|
||||
public String getUnicodeLocaleType(String key) {
|
||||
@ -3193,7 +3199,7 @@ public final class ULocale implements Serializable, Comparable<ULocale> {
|
||||
*
|
||||
* @return The set of Unicode locale keys, or the empty set if this locale has
|
||||
* no Unicode locale keywords.
|
||||
*
|
||||
*
|
||||
* @stable ICU 4.4
|
||||
*/
|
||||
public Set<String> getUnicodeLocaleKeys() {
|
||||
@ -3214,7 +3220,7 @@ public final class ULocale implements Serializable, Comparable<ULocale> {
|
||||
*
|
||||
* <p><b>Script:</b> If script is not well-formed (for example "12"
|
||||
* or "Latin"), it will be omitted.
|
||||
*
|
||||
*
|
||||
* <p><b>Country:</b> If country is not well-formed (for example "12"
|
||||
* or "USA"), it will be omitted.
|
||||
*
|
||||
@ -3245,7 +3251,7 @@ public final class ULocale implements Serializable, Comparable<ULocale> {
|
||||
* necessarily a valid BCP 47 language tag. For example,
|
||||
* <pre>
|
||||
* new Locale("xx", "YY").toLanguageTag();</pre>
|
||||
*
|
||||
*
|
||||
* will return "xx-YY", but the language subtag "xx" and the
|
||||
* region subtag "YY" are invalid because they are not registered
|
||||
* in the IANA Language Subtag Registry.
|
||||
@ -3369,7 +3375,7 @@ public final class ULocale implements Serializable, Comparable<ULocale> {
|
||||
* private use language tags. Stand alone private use tags are
|
||||
* represented as empty language and extension 'x-whatever',
|
||||
* and grandfathered tags are converted to their canonical replacements
|
||||
* where they exist.
|
||||
* where they exist.
|
||||
*
|
||||
* <p>Grandfathered tags with canonical replacements are as follows:
|
||||
*
|
||||
@ -3445,13 +3451,13 @@ public final class ULocale implements Serializable, Comparable<ULocale> {
|
||||
* then the lower-case version of the input keyword will be returned.
|
||||
* For example,
|
||||
* <code>toUnicodeLocaleKey("ZZ")</code> returns "zz".
|
||||
*
|
||||
*
|
||||
* @param keyword the input locale keyword (either legacy key
|
||||
* such as "collation" or BCP 47 Unicode locale extension
|
||||
* key such as "co").
|
||||
* @return the well-formed BCP 47 Unicode locale extension key,
|
||||
* or null if the specified locale keyword cannot be mapped
|
||||
* to a well-formed BCP 47 Unicode locale extension key.
|
||||
* to a well-formed BCP 47 Unicode locale extension key.
|
||||
* @see #toLegacyKey(String)
|
||||
* @stable ICU 54
|
||||
*/
|
||||
@ -3478,7 +3484,7 @@ public final class ULocale implements Serializable, Comparable<ULocale> {
|
||||
* will be returned. For example,
|
||||
* <code>toUnicodeLocaleType("Foo", "Bar")</code> returns "bar",
|
||||
* <code>toUnicodeLocaleType("variableTop", "00A4")</code> returns "00a4".
|
||||
*
|
||||
*
|
||||
* @param keyword the locale keyword (either legacy key such as
|
||||
* "collation" or BCP 47 Unicode locale extension
|
||||
* key such as "co").
|
||||
@ -3504,7 +3510,7 @@ public final class ULocale implements Serializable, Comparable<ULocale> {
|
||||
* {@icu} Converts the specified keyword (BCP 47 Unicode locale extension key, or
|
||||
* legacy key) to the legacy key. For example, legacy key "collation" is
|
||||
* returned for the input BCP 47 Unicode locale extension key "co".
|
||||
*
|
||||
*
|
||||
* @param keyword the input locale keyword (either BCP 47 Unicode locale
|
||||
* extension key or legacy key).
|
||||
* @return the well-formed legacy key, or null if the specified
|
||||
@ -4465,6 +4471,7 @@ public final class ULocale implements Serializable, Comparable<ULocale> {
|
||||
if (System.getSecurityManager() != null) {
|
||||
try {
|
||||
val = AccessController.doPrivileged(new PrivilegedAction<String>() {
|
||||
@Override
|
||||
public String run() {
|
||||
return System.getProperty(fkey);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user