From c1425af28f279f326fd4775f4ea7f41c14b8da0e Mon Sep 17 00:00:00 2001
From: Craig Cornelius
Date: Wed, 21 Sep 2016 19:55:37 +0000
Subject: [PATCH] ICU-12748 Add @Overrides and fix whitespace, thanks to
Eclipse
X-SVN-Rev: 39313
---
.../src/com/ibm/icu/charset/Charset88591.java | 19 +-
.../src/com/ibm/icu/charset/CharsetASCII.java | 30 +-
.../src/com/ibm/icu/charset/CharsetBOCU1.java | 165 +--
.../src/com/ibm/icu/charset/CharsetCESU8.java | 7 +-
.../com/ibm/icu/charset/CharsetCallback.java | 132 +-
.../ibm/icu/charset/CharsetCompoundText.java | 167 +--
.../ibm/icu/charset/CharsetDecoderICU.java | 164 +--
.../ibm/icu/charset/CharsetEncoderICU.java | 55 +-
.../src/com/ibm/icu/charset/CharsetHZ.java | 15 +-
.../src/com/ibm/icu/charset/CharsetICU.java | 69 +-
.../com/ibm/icu/charset/CharsetISO2022.java | 572 ++++----
.../src/com/ibm/icu/charset/CharsetLMBCS.java | 219 +--
.../ibm/icu/charset/CharsetProviderICU.java | 52 +-
.../src/com/ibm/icu/charset/CharsetSCSU.java | 215 +--
.../src/com/ibm/icu/charset/CharsetUTF16.java | 31 +-
.../src/com/ibm/icu/charset/CharsetUTF32.java | 13 +-
.../src/com/ibm/icu/charset/CharsetUTF7.java | 139 +-
.../src/com/ibm/icu/charset/CharsetUTF8.java | 18 +-
.../charset/UConverterAliasDataReader.java | 5 +-
.../ibm/icu/charset/UConverterDataReader.java | 13 +-
.../ibm/icu/impl/coll/CollationBuilder.java | 5 +-
.../icu/impl/coll/CollationDataReader.java | 2 +-
.../ibm/icu/impl/coll/CollationWeights.java | 4 +-
.../src/com/ibm/icu/text/AlphabeticIndex.java | 72 +-
.../com/ibm/icu/text/CollatorServiceShim.java | 11 +
.../icu/util/GlobalizationPreferences.java | 135 +-
.../com/ibm/icu/impl/CalendarAstronomer.java | 404 +++---
.../core/src/com/ibm/icu/impl/CharTrie.java | 36 +-
.../icu/impl/CharacterIteratorWrapper.java | 39 +-
.../src/com/ibm/icu/impl/ClassLoaderUtil.java | 13 +-
.../com/ibm/icu/impl/DateNumberFormat.java | 18 +-
.../core/src/com/ibm/icu/impl/ICUBinary.java | 20 +-
.../core/src/com/ibm/icu/impl/ICUConfig.java | 1 +
.../core/src/com/ibm/icu/impl/ICUData.java | 3 +
.../com/ibm/icu/impl/ICULocaleService.java | 50 +-
.../src/com/ibm/icu/impl/ICUNotifier.java | 7 +-
.../core/src/com/ibm/icu/impl/ICURWLock.java | 11 +-
.../core/src/com/ibm/icu/impl/ICUService.java | 13 +-
.../icu/impl/IllegalIcuArgumentException.java | 9 +-
.../core/src/com/ibm/icu/impl/IntTrie.java | 34 +-
.../com/ibm/icu/impl/IterableComparator.java | 1 +
.../ibm/icu/impl/LocaleDisplayNamesImpl.java | 3 +
.../src/com/ibm/icu/impl/LocaleIDParser.java | 19 +-
.../src/com/ibm/icu/impl/Norm2AllModes.java | 1 +
.../src/com/ibm/icu/impl/Normalizer2Impl.java | 9 +-
.../src/com/ibm/icu/impl/OlsonTimeZone.java | 79 +-
.../icu/impl/PVecToTrieCompactHandler.java | 6 +-
.../src/com/ibm/icu/impl/PropsVectors.java | 67 +-
.../core/src/com/ibm/icu/impl/Relation.java | 17 +-
.../impl/ReplaceableUCharacterIterator.java | 81 +-
.../ibm/icu/impl/ResourceBundleWrapper.java | 29 +-
.../core/src/com/ibm/icu/impl/Row.java | 8 +
.../ibm/icu/impl/RuleCharacterIterator.java | 9 +-
.../src/com/ibm/icu/impl/SimpleCache.java | 3 +
.../ibm/icu/impl/StringPrepDataReader.java | 7 +-
.../src/com/ibm/icu/impl/StringRange.java | 21 +-
.../com/ibm/icu/impl/TZDBTimeZoneNames.java | 9 +-
.../src/com/ibm/icu/impl/TextTrieMap.java | 18 +-
.../src/com/ibm/icu/impl/TimeZoneAdapter.java | 19 +-
.../ibm/icu/impl/TimeZoneGenericNames.java | 30 +-
.../core/src/com/ibm/icu/impl/Trie.java | 83 +-
.../core/src/com/ibm/icu/impl/Trie2.java | 282 ++--
.../src/com/ibm/icu/impl/TrieIterator.java | 142 +-
.../core/src/com/ibm/icu/impl/UBiDiProps.java | 5 +-
.../com/ibm/icu/impl/UCharArrayIterator.java | 16 +-
.../icu/impl/UCharacterIteratorWrapper.java | 22 +-
.../ibm/icu/impl/UCharacterNameReader.java | 47 +-
.../com/ibm/icu/impl/UCharacterProperty.java | 35 +-
.../com/ibm/icu/impl/UPropertyAliases.java | 3 +-
.../core/src/com/ibm/icu/impl/URLHandler.java | 64 +-
.../src/com/ibm/icu/impl/UnicodeRegex.java | 23 +-
.../com/ibm/icu/impl/data/HolidayBundle.java | 10 +-
.../ibm/icu/impl/data/HolidayBundle_da.java | 1 +
.../icu/impl/data/HolidayBundle_da_DK.java | 36 +-
.../ibm/icu/impl/data/HolidayBundle_de.java | 1 +
.../icu/impl/data/HolidayBundle_de_AT.java | 1 +
.../icu/impl/data/HolidayBundle_de_DE.java | 1 +
.../ibm/icu/impl/data/HolidayBundle_el.java | 1 +
.../icu/impl/data/HolidayBundle_el_GR.java | 1 +
.../ibm/icu/impl/data/HolidayBundle_en.java | 1 +
.../icu/impl/data/HolidayBundle_en_CA.java | 1 +
.../icu/impl/data/HolidayBundle_en_GB.java | 1 +
.../icu/impl/data/HolidayBundle_en_US.java | 1 +
.../ibm/icu/impl/data/HolidayBundle_es.java | 1 +
.../icu/impl/data/HolidayBundle_es_MX.java | 1 +
.../ibm/icu/impl/data/HolidayBundle_fr.java | 1 +
.../icu/impl/data/HolidayBundle_fr_CA.java | 1 +
.../icu/impl/data/HolidayBundle_fr_FR.java | 1 +
.../ibm/icu/impl/data/HolidayBundle_it.java | 1 +
.../icu/impl/data/HolidayBundle_it_IT.java | 1 +
.../ibm/icu/impl/data/HolidayBundle_iw.java | 1 +
.../icu/impl/data/HolidayBundle_iw_IL.java | 1 +
.../icu/impl/data/HolidayBundle_ja_JP.java | 1 +
.../com/ibm/icu/impl/data/ResourceReader.java | 11 +-
.../impl/duration/BasicDurationFormatter.java | 27 +-
.../BasicDurationFormatterFactory.java | 13 +-
.../duration/BasicPeriodBuilderFactory.java | 59 +-
.../impl/duration/BasicPeriodFormatter.java | 18 +-
.../duration/BasicPeriodFormatterFactory.java | 11 +-
.../duration/BasicPeriodFormatterService.java | 8 +-
.../src/com/ibm/icu/impl/duration/Period.java | 28 +-
.../com/ibm/icu/impl/duration/TimeUnit.java | 23 +-
...sourceBasedPeriodFormatterDataService.java | 2 +
.../impl/duration/impl/XMLRecordReader.java | 11 +
.../impl/duration/impl/XMLRecordWriter.java | 11 +
.../com/ibm/icu/impl/locale/AsciiUtil.java | 2 +
.../com/ibm/icu/impl/locale/BaseLocale.java | 8 +
.../com/ibm/icu/impl/locale/Extension.java | 1 +
.../impl/locale/InternalLocaleBuilder.java | 4 +
.../com/ibm/icu/impl/locale/KeyTypeData.java | 11 +-
.../com/ibm/icu/impl/locale/LanguageTag.java | 25 +-
.../ibm/icu/impl/locale/LocaleExtensions.java | 3 +
.../ibm/icu/lang/UCharacterNameIterator.java | 5 +-
.../core/src/com/ibm/icu/math/BigDecimal.java | 262 ++--
.../src/com/ibm/icu/math/MathContext.java | 103 +-
.../src/com/ibm/icu/text/ArabicShaping.java | 403 +++---
.../core/src/com/ibm/icu/text/BidiRun.java | 1 +
.../src/com/ibm/icu/text/BreakIterator.java | 35 +-
.../com/ibm/icu/text/BurmeseBreakEngine.java | 24 +-
.../ibm/icu/text/BytesDictionaryMatcher.java | 8 +-
.../ibm/icu/text/CharsDictionaryMatcher.java | 6 +-
.../src/com/ibm/icu/text/CharsetMatch.java | 37 +-
.../com/ibm/icu/text/CharsetRecog_2022.java | 64 +-
.../com/ibm/icu/text/CharsetRecog_UTF8.java | 20 +-
.../ibm/icu/text/CharsetRecog_Unicode.java | 58 +-
.../com/ibm/icu/text/CharsetRecog_mbcs.java | 314 +++--
.../com/ibm/icu/text/CharsetRecog_sbcs.java | 1183 +++++++++--------
.../com/ibm/icu/text/ChineseDateFormat.java | 24 +-
.../icu/text/ChineseDateFormatSymbols.java | 5 +-
.../src/com/ibm/icu/text/CjkBreakEngine.java | 33 +-
.../com/ibm/icu/text/DateFormatSymbols.java | 5 +-
.../ibm/icu/text/DictionaryBreakEngine.java | 36 +-
.../src/com/ibm/icu/text/DurationFormat.java | 12 +-
.../com/ibm/icu/text/LocaleDisplayNames.java | 3 +-
.../src/com/ibm/icu/text/MessageFormat.java | 25 +-
.../src/com/ibm/icu/text/MessagePattern.java | 7 +-
.../core/src/com/ibm/icu/text/Normalizer.java | 333 ++---
.../src/com/ibm/icu/text/PluralFormat.java | 13 +-
.../src/com/ibm/icu/text/PluralRanges.java | 19 +-
.../icu/text/StringPrepParseException.java | 65 +-
.../src/com/ibm/icu/text/StringTransform.java | 1 +
.../src/com/ibm/icu/text/TimeZoneFormat.java | 117 +-
.../com/ibm/icu/text/UCharacterIterator.java | 423 +++---
.../src/com/ibm/icu/text/UnicodeFilter.java | 1 +
.../core/src/com/ibm/icu/text/UnicodeSet.java | 99 +-
.../com/ibm/icu/util/AnnualTimeZoneRule.java | 35 +-
.../core/src/com/ibm/icu/util/BytesTrie.java | 4 +
.../core/src/com/ibm/icu/util/CharsTrie.java | 4 +
.../core/src/com/ibm/icu/util/Currency.java | 106 +-
.../src/com/ibm/icu/util/DateTimeRule.java | 65 +-
.../src/com/ibm/icu/util/EasterHoliday.java | 10 +-
.../core/src/com/ibm/icu/util/Holiday.java | 6 +-
.../com/ibm/icu/util/InitialTimeZoneRule.java | 24 +-
.../core/src/com/ibm/icu/util/LocaleData.java | 35 +-
.../core/src/com/ibm/icu/util/Measure.java | 9 +-
.../core/src/com/ibm/icu/util/Output.java | 3 +-
.../core/src/com/ibm/icu/util/OutputInt.java | 1 +
.../src/com/ibm/icu/util/SimpleTimeZone.java | 5 +
.../ibm/icu/util/TimeArrayTimeZoneRule.java | 19 +-
.../core/src/com/ibm/icu/util/TimeZone.java | 88 +-
.../src/com/ibm/icu/util/TimeZoneRule.java | 61 +-
.../com/ibm/icu/util/TimeZoneTransition.java | 21 +-
.../src/com/ibm/icu/util/UResourceBundle.java | 39 +-
.../com/ibm/icu/impl/ICUCurrencyMetaInfo.java | 13 +-
.../javaspi/util/CurrencyNameProviderICU.java | 2 +-
.../javaspi/util/LocaleNameProviderICU.java | 2 +-
.../ibm/icu/impl/jdkadapter/CollatorICU.java | 11 +
.../com/ibm/icu/text/AnyTransliterator.java | 7 +-
.../com/ibm/icu/text/BreakTransliterator.java | 13 +
.../ibm/icu/text/CaseFoldTransliterator.java | 11 +-
.../ibm/icu/text/CompoundTransliterator.java | 6 +-
.../ibm/icu/text/EscapeTransliterator.java | 17 +-
.../com/ibm/icu/text/FunctionReplacer.java | 3 +
.../icu/text/NameUnicodeTransliterator.java | 10 +-
.../icu/text/NormalizationTransliterator.java | 12 +-
.../com/ibm/icu/text/NullTransliterator.java | 1 +
.../ibm/icu/text/RemoveTransliterator.java | 2 +
.../ibm/icu/text/RuleBasedTransliterator.java | 6 +-
.../src/com/ibm/icu/text/StringMatcher.java | 9 +-
.../src/com/ibm/icu/text/StringReplacer.java | 5 +-
.../com/ibm/icu/text/TransliterationRule.java | 3 +-
.../src/com/ibm/icu/text/Transliterator.java | 110 +-
.../ibm/icu/text/TransliteratorParser.java | 30 +-
.../ibm/icu/text/TransliteratorRegistry.java | 6 +-
.../ibm/icu/text/UnescapeTransliterator.java | 14 +-
.../icu/text/UnicodeNameTransliterator.java | 8 +-
186 files changed, 4949 insertions(+), 4118 deletions(-)
diff --git a/icu4j/main/classes/charset/src/com/ibm/icu/charset/Charset88591.java b/icu4j/main/classes/charset/src/com/ibm/icu/charset/Charset88591.java
index 1893f31ea3c..1ea9cfc9f21 100644
--- a/icu4j/main/classes/charset/src/com/ibm/icu/charset/Charset88591.java
+++ b/icu4j/main/classes/charset/src/com/ibm/icu/charset/Charset88591.java
@@ -27,6 +27,7 @@ class Charset88591 extends CharsetASCII {
super(cs);
}
+ @Override
protected CoderResult decodeLoopCoreOptimized(ByteBuffer source, CharBuffer target,
byte[] sourceArray, char[] targetArray, int oldSource, int offset, int limit) {
@@ -40,6 +41,7 @@ class Charset88591 extends CharsetASCII {
return null;
}
+ @Override
protected CoderResult decodeLoopCoreUnoptimized(ByteBuffer source, CharBuffer target) {
byte ch;
/*
@@ -54,7 +56,7 @@ class Charset88591 extends CharsetASCII {
return CoderResult.OVERFLOW;
}
}
-
+
return CoderResult.UNDERFLOW;
}
}
@@ -64,6 +66,7 @@ class Charset88591 extends CharsetASCII {
super(cs);
}
+ @Override
protected final CoderResult encodeLoopCoreOptimized(CharBuffer source, ByteBuffer target,
char[] sourceArray, byte[] targetArray, int oldSource, int offset, int limit,
boolean flush) {
@@ -74,7 +77,7 @@ class Charset88591 extends CharsetASCII {
* char in the source is within the correct range
*/
for (i = oldSource; i < limit; i++) {
- ch = (int) sourceArray[i];
+ ch = sourceArray[i];
if ((ch & 0xff00) == 0) {
targetArray[i + offset] = (byte) ch;
} else {
@@ -95,6 +98,7 @@ class Charset88591 extends CharsetASCII {
return null;
}
+ @Override
protected final CoderResult encodeLoopCoreUnoptimized(CharBuffer source, ByteBuffer target, boolean flush) {
int ch;
@@ -102,9 +106,9 @@ class Charset88591 extends CharsetASCII {
* perform 88591 conversion from the source buffer to the target buffer, making sure
* each char in the source is within the correct range
*/
-
+
while (source.hasRemaining()) {
- ch = (int) source.get();
+ ch = source.get();
if ((ch & 0xff00) == 0) {
if (target.hasRemaining()) {
target.put((byte) ch);
@@ -119,20 +123,23 @@ class Charset88591 extends CharsetASCII {
return encodeMalformedOrUnmappable(source, ch, flush);
}
}
-
+
return CoderResult.UNDERFLOW;
}
}
+ @Override
public CharsetDecoder newDecoder() {
return new CharsetDecoder88591(this);
}
+ @Override
public CharsetEncoder newEncoder() {
return new CharsetEncoder88591(this);
}
-
+
+ @Override
void getUnicodeSetImpl( UnicodeSet setFillIn, int which){
setFillIn.add(0,0xff);
}
diff --git a/icu4j/main/classes/charset/src/com/ibm/icu/charset/CharsetASCII.java b/icu4j/main/classes/charset/src/com/ibm/icu/charset/CharsetASCII.java
index deb34a2e4af..5ea22793666 100644
--- a/icu4j/main/classes/charset/src/com/ibm/icu/charset/CharsetASCII.java
+++ b/icu4j/main/classes/charset/src/com/ibm/icu/charset/CharsetASCII.java
@@ -36,6 +36,7 @@ class CharsetASCII extends CharsetICU {
super(cs);
}
+ @Override
protected CoderResult decodeLoop(ByteBuffer source, CharBuffer target, IntBuffer offsets,
boolean flush) {
if (!source.hasRemaining()) {
@@ -62,7 +63,7 @@ class CharsetASCII extends CharsetICU {
int sourceOffset = source.arrayOffset();
int sourceIndex = oldSource + sourceOffset;
int sourceLength = source.limit() - oldSource;
-
+
char[] targetArray = target.array();
int targetOffset = target.arrayOffset();
int targetIndex = oldTarget + targetOffset;
@@ -140,7 +141,7 @@ class CharsetASCII extends CharsetICU {
*/
while (source.hasRemaining()) {
ch = source.get() & 0xff;
-
+
if ((ch & 0x80) == 0) {
if (target.hasRemaining()) {
target.put((char)ch);
@@ -155,7 +156,7 @@ class CharsetASCII extends CharsetICU {
return decodeMalformedOrUnmappable(ch);
}
}
-
+
return CoderResult.UNDERFLOW;
}
@@ -179,11 +180,13 @@ class CharsetASCII extends CharsetICU {
private final static int NEED_TO_WRITE_BOM = 1;
+ @Override
protected void implReset() {
super.implReset();
fromUnicodeStatus = NEED_TO_WRITE_BOM;
}
+ @Override
protected CoderResult encodeLoop(CharBuffer source, ByteBuffer target, IntBuffer offsets,
boolean flush) {
if (!source.hasRemaining()) {
@@ -246,9 +249,9 @@ class CharsetASCII extends CharsetICU {
}
} else {
/* unoptimized loop */
-
+
cr = encodeLoopCoreUnoptimized(source, target, flush);
-
+
if (cr == CoderResult.OVERFLOW) {
source.position(source.position() - 1); /* rewind by 1 */
}
@@ -274,7 +277,7 @@ class CharsetASCII extends CharsetICU {
* perform ascii conversion from the source array to the target array, making sure each
* char in the source is within the correct range
*/
- for (i = oldSource; i < limit && (((ch = (int) sourceArray[i]) & 0xff80) == 0); i++)
+ for (i = oldSource; i < limit && (((ch = sourceArray[i]) & 0xff80) == 0); i++)
targetArray[i + offset] = (byte) ch;
/*
@@ -292,14 +295,14 @@ class CharsetASCII extends CharsetICU {
protected CoderResult encodeLoopCoreUnoptimized(CharBuffer source, ByteBuffer target, boolean flush) {
int ch;
-
+
/*
* perform ascii conversion from the source buffer to the target buffer, making sure
* each char in the source is within the correct range
*/
while (source.hasRemaining()) {
- ch = (int) source.get();
-
+ ch = source.get();
+
if ((ch & 0xff80) == 0) {
if (target.hasRemaining()) {
target.put((byte) ch);
@@ -314,7 +317,7 @@ class CharsetASCII extends CharsetICU {
return encodeMalformedOrUnmappable(source, ch, flush);
}
}
-
+
return CoderResult.UNDERFLOW;
}
@@ -331,7 +334,7 @@ class CharsetASCII extends CharsetICU {
private final CoderResult encodeTrail(CharBuffer source, char lead, boolean flush) {
/*
* ASCII doesn't support characters in the BMP, so if handleSurrogates returns null,
- * we leave fromUChar32 alone (it should store a new codepoint) and call it unmappable.
+ * we leave fromUChar32 alone (it should store a new codepoint) and call it unmappable.
*/
CoderResult cr = handleSurrogates(source, lead);
if (cr != null) {
@@ -344,14 +347,17 @@ class CharsetASCII extends CharsetICU {
}
+ @Override
public CharsetDecoder newDecoder() {
return new CharsetDecoderASCII(this);
}
+ @Override
public CharsetEncoder newEncoder() {
return new CharsetEncoderASCII(this);
}
-
+
+ @Override
void getUnicodeSetImpl( UnicodeSet setFillIn, int which){
setFillIn.add(0,0x7f);
}
diff --git a/icu4j/main/classes/charset/src/com/ibm/icu/charset/CharsetBOCU1.java b/icu4j/main/classes/charset/src/com/ibm/icu/charset/CharsetBOCU1.java
index f68a11c5c8f..d4111dfaad2 100644
--- a/icu4j/main/classes/charset/src/com/ibm/icu/charset/CharsetBOCU1.java
+++ b/icu4j/main/classes/charset/src/com/ibm/icu/charset/CharsetBOCU1.java
@@ -23,12 +23,12 @@ import com.ibm.icu.text.UnicodeSet;
* @author krajwade
*
*/
-class CharsetBOCU1 extends CharsetICU {
+class CharsetBOCU1 extends CharsetICU {
/* BOCU constants and macros */
-
+
/* initial value for "prev": middle of the ASCII range */
private static final byte BOCU1_ASCII_PREV = 0x40;
-
+
/* bounding byte values for differences */
private static final int BOCU1_MIN = 0x21;
private static final int BOCU1_MIDDLE = 0x90;
@@ -45,7 +45,7 @@ class CharsetBOCU1 extends CharsetICU {
/* number of trail bytes */
private static final int BOCU1_TRAIL_COUNT =((BOCU1_MAX_TRAIL-BOCU1_MIN+1)+BOCU1_TRAIL_CONTROLS_COUNT);
-
+
/*
* number of positive and negative single-byte codes
* (counting 0==BOCU1_MIDDLE among the positive ones)
@@ -84,8 +84,8 @@ class CharsetBOCU1 extends CharsetICU {
/* The length of a byte sequence, according to the lead byte (!=BOCU1_RESET). */
/* private static int BOCU1_LENGTH_FROM_LEAD(int lead) {
- return ((BOCU1_START_NEG_2<=(lead) && (lead)>24 : 4);
}
-
+
/*
* Byte value map for control codes,
* from external byte values 0x00..0x20
@@ -123,7 +123,7 @@ class CharsetBOCU1 extends CharsetICU {
* from trail byte values 0..19 (0..0x13) as used in the difference calculation
* to external byte values 0x00..0x20.
*/
- private static final int[]
+ private static final int[]
bocu1TrailToByte = {
/* 0 1 2 3 4 5 6 7 */
0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x10, 0x11,
@@ -134,8 +134,8 @@ class CharsetBOCU1 extends CharsetICU {
/* 10 11 12 13 */
0x1c, 0x1d, 0x1e, 0x1f
};
-
-
+
+
/*
* 12 commonly used C0 control codes (and space) are only used to encode
* themselves directly,
@@ -166,8 +166,8 @@ class CharsetBOCU1 extends CharsetICU {
*/
private static int BOCU1_TRAIL_TO_BYTE(int trail) {
return ((trail)>=BOCU1_TRAIL_CONTROLS_COUNT ? (trail)+BOCU1_TRAIL_BYTE_OFFSET : bocu1TrailToByte[trail]);
- }
-
+ }
+
/* BOCU-1 implementation functions ------------------------------------------ */
private static int BOCU1_SIMPLE_PREV(int c){
return (((c)&~0x7f)+BOCU1_ASCII_PREV);
@@ -201,7 +201,7 @@ class CharsetBOCU1 extends CharsetICU {
private static int BOCU1_PREV(int c) {
return ((c)<0x3040 || (c)>0xd7a3 ? BOCU1_SIMPLE_PREV(c) : bocu1Prev(c));
}
-
+
protected byte[] fromUSubstitution = new byte[]{(byte)0x1A};
/* Faster versions of packDiff() for single-byte-encoded diff values. */
@@ -219,35 +219,35 @@ class CharsetBOCU1 extends CharsetICU {
/** Is a diff value encodable in two bytes? */
private static boolean DIFF_IS_DOUBLE(int diff){
return (BOCU1_REACH_NEG_2<=(diff) && (diff)<=BOCU1_REACH_POS_2);
- }
-
+ }
+
public CharsetBOCU1(String icuCanonicalName, String javaCanonicalName, String[] aliases){
super(icuCanonicalName, javaCanonicalName, aliases);
- maxBytesPerChar = 4;
+ maxBytesPerChar = 4;
minBytesPerChar = 1;
maxCharsPerByte = 1;
}
-
+
class CharsetEncoderBOCU extends CharsetEncoderICU {
public CharsetEncoderBOCU(CharsetICU cs) {
super(cs,fromUSubstitution);
}
-
+
int sourceIndex, nextSourceIndex;
int prev, c , diff;
boolean checkNegative;
boolean LoopAfterTrail;
int targetCapacity;
- CoderResult cr;
-
+ CoderResult cr;
+
/* label values for supporting behavior similar to goto in C */
private static final int fastSingle=0;
private static final int getTrail=1;
private static final int regularLoop=2;
-
+
private boolean LabelLoop; //used to break the while loop
private int labelType = fastSingle; //labeType is set to fastSingle to start the code from fastSingle:
-
+
/**
* Integer division and modulo with negative numerators
* yields negative modulo results and quotients that are one more than
@@ -263,15 +263,15 @@ class CharsetBOCU1 extends CharsetICU {
*/
private int NEGDIVMOD(int n, int d, int m) {
diff = n;
- (m)=(diff)%(d);
- (diff)/=(d);
- if((m)<0) {
+ (m)=(diff)%(d);
+ (diff)/=(d);
+ if((m)<0) {
--(diff);
(m)+=(d);
}
return m;
}
-
+
/**
* Encode a difference -0x10ffff..0x10ffff in 1..4 bytes
* and return a packed integer with them.
@@ -385,32 +385,33 @@ class CharsetBOCU1 extends CharsetICU {
}
return result;
}
-
+
+ @Override
protected CoderResult encodeLoop(CharBuffer source, ByteBuffer target, IntBuffer offsets, boolean flush){
cr = CoderResult.UNDERFLOW;
-
+
LabelLoop = true; //used to break the while loop
checkNegative = false; // its value is set to true to get out of while loop when c = -c
LoopAfterTrail = false; // its value is set to true to ignore code before getTrail:
-
+
/*set up the local pointers*/
targetCapacity = target.limit() - target.position();
c = fromUChar32;
prev = fromUnicodeStatus;
-
+
if(prev==0){
prev = BOCU1_ASCII_PREV;
}
-
+
/*sourceIndex ==-1 if the current characte began in the previous buffer*/
sourceIndex = c == 0 ? 0: -1;
nextSourceIndex = 0;
-
+
/*conversion loop*/
if(c!=0 && targetCapacity>0){
labelType = getTrail;
}
-
+
while(LabelLoop){
switch(labelType){
case fastSingle:
@@ -424,12 +425,12 @@ class CharsetBOCU1 extends CharsetICU {
break;
}
}
-
+
return cr;
}
-
- private int fastSingle(CharBuffer source, ByteBuffer target, IntBuffer offsets){
-//fastSingle:
+
+ private int fastSingle(CharBuffer source, ByteBuffer target, IntBuffer offsets){
+//fastSingle:
/*fast loop for single-byte differences*/
/*use only one loop counter variable , targetCapacity, not also source*/
diff = source.limit() - source.position();
@@ -464,7 +465,7 @@ class CharsetBOCU1 extends CharsetICU {
}
return regularLoop;
}
-
+
private int getTrail(CharBuffer source, ByteBuffer target, IntBuffer offsets){
if(source.hasRemaining()){
/*test the following code unit*/
@@ -493,11 +494,11 @@ class CharsetBOCU1 extends CharsetICU {
/*regular loop for all classes*/
while(LoopAfterTrail || source.hasRemaining()){
if(LoopAfterTrail || targetCapacity>0){
-
+
if(!LoopAfterTrail){
c = source.get();
++nextSourceIndex;
-
+
if(c<=0x20){
/*
* ISO C0 control & space:
@@ -512,11 +513,11 @@ class CharsetBOCU1 extends CharsetICU {
offsets.put(sourceIndex++);
}
--targetCapacity;
-
+
sourceIndex=nextSourceIndex;
continue;
}
-
+
if(UTF16.isLeadSurrogate((char)c)){
getTrail(source, target, offsets);
if(checkNegative){
@@ -524,11 +525,11 @@ class CharsetBOCU1 extends CharsetICU {
}
}
}
-
+
if(LoopAfterTrail){
- LoopAfterTrail = false;
+ LoopAfterTrail = false;
}
-
+
/*
* all other Unicode code points c==U+0021..U+10ffff
* are encoded with the difference c-prev
@@ -576,7 +577,7 @@ class CharsetBOCU1 extends CharsetICU {
int length; /*will be 2..4*/
diff = packDiff(diff);
length = BOCU1_LENGTH_FROM_PACKED(diff);
-
+
/*write the output character bytes from diff and length*/
/*from the first if in the loop we know that targetCapacity>0*/
if(length<=targetCapacity){
@@ -631,7 +632,7 @@ class CharsetBOCU1 extends CharsetICU {
break;
}
errorBufferLength = length;
-
+
/* now output what fits into the regular target */
diff>>=8*length; /* length was reduced by targetCapacity */
switch(targetCapacity) {
@@ -667,7 +668,7 @@ class CharsetBOCU1 extends CharsetICU {
cr = CoderResult.OVERFLOW;
break;
}
-
+
}
/*set the converter state back into UConverter*/
fromUChar32 = c<0 ? -c :0;
@@ -676,26 +677,26 @@ class CharsetBOCU1 extends CharsetICU {
labelType = fastSingle;
return labelType;
}
-
+
}
-
+
static class CharsetDecoderBOCU extends CharsetDecoderICU{
public CharsetDecoderBOCU(CharsetICU cs) {
super(cs);
}
-
+
int byteIndex;
int sourceIndex, nextSourceIndex;
int prev, c , diff, count;
byte[] bytes;
CoderResult cr;
-
+
/* label values for supporting behavior similar to goto in C */
private static final int fastSingle=0;
private static final int getTrail=1;
private static final int regularLoop=2;
private static final int endLoop=3;
-
+
private boolean LabelLoop;//used to break the while loop
private boolean afterTrail; // its value is set to true to ignore code after getTrail:
private int labelType;
@@ -711,8 +712,8 @@ class CharsetBOCU1 extends CharsetICU {
/* BOCU-1-from-Unicode conversion functions --------------------------------- */
-
-
+
+
/**
* Function for BOCU-1 decoder; handles multi-byte lead bytes.
*
@@ -758,7 +759,7 @@ class CharsetBOCU1 extends CharsetICU {
/* return the state for decoding the trail byte(s) */
return (diffValue<<2)|countValue;
}
-
+
/**
* Function for BOCU-1 decoder; handles multi-byte trail bytes.
*
@@ -788,37 +789,38 @@ class CharsetBOCU1 extends CharsetICU {
return b*(BOCU1_TRAIL_COUNT*BOCU1_TRAIL_COUNT);
}
}
-
+
+ @Override
protected CoderResult decodeLoop(ByteBuffer source, CharBuffer target, IntBuffer offsets,
boolean flush){
cr = CoderResult.UNDERFLOW;
-
- LabelLoop = true;
- afterTrail = false;
+
+ LabelLoop = true;
+ afterTrail = false;
labelType = fastSingle; // labelType is set to fastSingle so t
-
+
/*get the converter state*/
prev = toUnicodeStatus;
-
+
if(prev==0){
prev = BOCU1_ASCII_PREV;
}
diff = mode;
count = diff&3;
diff>>=2;
-
+
byteIndex = toULength;
bytes = toUBytesArray;
-
+
/* sourceIndex=-1 if the current character began in the previous buffer */
sourceIndex=byteIndex==0 ? 0 : -1;
nextSourceIndex=0;
-
+
/* conversion "loop" similar to _SCSUToUnicodeWithOffsets() */
if(count>0 && byteIndex>0 && target.position() Callback API for CharsetICU API
- *
- * CharsetCallback class defines some error behaviour functions called
+ *
+ * CharsetCallback class defines some error behaviour functions called
* by CharsetDecoderICU and CharsetEncoderICU. The class also provides
* the facility by which clients can write their own callbacks.
*
* These functions, although public, should NEVER be called directly.
- * They should be used as parameters to the onUmappableCharacter() and
+ * They should be used as parameters to the onUmappableCharacter() and
* onMalformedInput() methods, to set the behaviour of a converter
* when it encounters UNMAPPED/INVALID sequences.
* Currently the only way to set callbacks is by using CodingErrorAction.
@@ -44,7 +44,7 @@ public class CharsetCallback {
// private static final String SKIP_STOP_ON_ILLEGAL = "i";
// /*
-// * FROM_U_CALLBACK_ESCAPE context option to escape the code unit according to ICU (%UXXXX)
+// * FROM_U_CALLBACK_ESCAPE context option to escape the code unit according to ICU (%UXXXX)
// */
// private static final String ESCAPE_ICU = null;
@@ -92,36 +92,36 @@ public class CharsetCallback {
* For a list of the default ignorable code points, use this link: http://unicode.org/cldr/utility/list-unicodeset.jsp?a=[%3ADI%3A]&g=
*
* This list should be sync with the one in ucnv_err.c
- *
+ *
*/
private static boolean IS_DEFAULT_IGNORABLE_CODE_POINT(int c) {
- return ((c == 0x00AD) ||
- (c == 0x034F) ||
- (c == 0x061C) ||
- (c == 0x115F) ||
- (c == 0x1160) ||
- (0x17B4 <= c && c <= 0x17B5) ||
- (0x180B <= c && c <= 0x180E) ||
- (0x200B <= c && c <= 0x200F) ||
- (0x202A <= c && c <= 0x202E) ||
- (c == 0x2060) ||
- (0x2066 <= c && c <= 0x2069) ||
- (0x2061 <= c && c <= 0x2064) ||
- (0x206A <= c && c <= 0x206F) ||
- (c == 0x3164) ||
- (0x0FE00 <= c && c <= 0x0FE0F) ||
- (c == 0x0FEFF) ||
- (c == 0x0FFA0) ||
- (0x01BCA0 <= c && c <= 0x01BCA3) ||
- (0x01D173 <= c && c <= 0x01D17A) ||
- (c == 0x0E0001) ||
- (0x0E0020 <= c && c <= 0x0E007F) ||
- (0x0E0100 <= c && c <= 0x0E01EF) ||
- (c == 0x2065) ||
- (0x0FFF0 <= c && c <= 0x0FFF8) ||
- (c == 0x0E0000) ||
- (0x0E0002 <= c && c <= 0x0E001F) ||
- (0x0E0080 <= c && c <= 0x0E00FF) ||
+ return ((c == 0x00AD) ||
+ (c == 0x034F) ||
+ (c == 0x061C) ||
+ (c == 0x115F) ||
+ (c == 0x1160) ||
+ (0x17B4 <= c && c <= 0x17B5) ||
+ (0x180B <= c && c <= 0x180E) ||
+ (0x200B <= c && c <= 0x200F) ||
+ (0x202A <= c && c <= 0x202E) ||
+ (c == 0x2060) ||
+ (0x2066 <= c && c <= 0x2069) ||
+ (0x2061 <= c && c <= 0x2064) ||
+ (0x206A <= c && c <= 0x206F) ||
+ (c == 0x3164) ||
+ (0x0FE00 <= c && c <= 0x0FE0F) ||
+ (c == 0x0FEFF) ||
+ (c == 0x0FFA0) ||
+ (0x01BCA0 <= c && c <= 0x01BCA3) ||
+ (0x01D173 <= c && c <= 0x01D17A) ||
+ (c == 0x0E0001) ||
+ (0x0E0020 <= c && c <= 0x0E007F) ||
+ (0x0E0100 <= c && c <= 0x0E01EF) ||
+ (c == 0x2065) ||
+ (0x0FFF0 <= c && c <= 0x0FFF8) ||
+ (c == 0x0E0000) ||
+ (0x0E0002 <= c && c <= 0x0E001F) ||
+ (0x0E0080 <= c && c <= 0x0E00FF) ||
(0x0E01F0 <= c && c <= 0x0E0FFF)
);
}
@@ -133,12 +133,12 @@ public class CharsetCallback {
/**
* This function is called when the bytes in the source cannot be handled,
* and this function is meant to handle or fix the error if possible.
- *
+ *
* @return Result of decoding action. This returned object is set to an error
* if this function could not handle the conversion.
* @stable ICU 3.6
*/
- public CoderResult call(CharsetDecoderICU decoder, Object context,
+ public CoderResult call(CharsetDecoderICU decoder, Object context,
ByteBuffer source, CharBuffer target, IntBuffer offsets,
char[] buffer, int length, CoderResult cr);
}
@@ -154,17 +154,18 @@ public class CharsetCallback {
* if this function could not handle the conversion.
* @stable ICU 3.6
*/
- public CoderResult call(CharsetEncoderICU encoder, Object context,
- CharBuffer source, ByteBuffer target, IntBuffer offsets,
+ public CoderResult call(CharsetEncoderICU encoder, Object context,
+ CharBuffer source, ByteBuffer target, IntBuffer offsets,
char[] buffer, int length, int cp, CoderResult cr);
- }
+ }
/**
* Skip callback
* @stable ICU 3.6
*/
public static final Encoder FROM_U_CALLBACK_SKIP = new Encoder() {
- public CoderResult call(CharsetEncoderICU encoder, Object context,
- CharBuffer source, ByteBuffer target, IntBuffer offsets,
+ @Override
+ public CoderResult call(CharsetEncoderICU encoder, Object context,
+ CharBuffer source, ByteBuffer target, IntBuffer offsets,
char[] buffer, int length, int cp, CoderResult cr){
if(context==null){
return CoderResult.UNDERFLOW;
@@ -183,7 +184,8 @@ public class CharsetCallback {
* @stable ICU 3.6
*/
public static final Decoder TO_U_CALLBACK_SKIP = new Decoder() {
- public CoderResult call(CharsetDecoderICU decoder, Object context,
+ @Override
+ public CoderResult call(CharsetDecoderICU decoder, Object context,
ByteBuffer source, CharBuffer target, IntBuffer offsets,
char[] buffer, int length, CoderResult cr){
if(context==null){
@@ -202,9 +204,10 @@ public class CharsetCallback {
* Write substitute callback
* @stable ICU 3.6
*/
- public static final Encoder FROM_U_CALLBACK_SUBSTITUTE = new Encoder(){
- public CoderResult call(CharsetEncoderICU encoder, Object context,
- CharBuffer source, ByteBuffer target, IntBuffer offsets,
+ public static final Encoder FROM_U_CALLBACK_SUBSTITUTE = new Encoder(){
+ @Override
+ public CoderResult call(CharsetEncoderICU encoder, Object context,
+ CharBuffer source, ByteBuffer target, IntBuffer offsets,
char[] buffer, int length, int cp, CoderResult cr){
if (cr.isUnmappable() && IS_DEFAULT_IGNORABLE_CODE_POINT(cp)) {
return CoderResult.UNDERFLOW;
@@ -227,7 +230,8 @@ public class CharsetCallback {
* @stable ICU 3.6
*/
public static final Decoder TO_U_CALLBACK_SUBSTITUTE = new Decoder() {
- public CoderResult call(CharsetDecoderICU decoder, Object context,
+ @Override
+ public CoderResult call(CharsetDecoderICU decoder, Object context,
ByteBuffer source, CharBuffer target, IntBuffer offsets,
char[] buffer, int length, CoderResult cr){
@@ -238,7 +242,7 @@ public class CharsetCallback {
if (replacementChar.length == 1 && (replacementChar[0] == kSubstituteChar1[0] || replacementChar[0] == kSubstituteChar[0])) {
useReplacement = false;
}
-
+
/* could optimize this case, just one uchar */
if(decoder.invalidCharLength == 1 && cs.subChar1 != 0) {
return CharsetDecoderICU.toUWriteUChars(decoder, useReplacement ? replacementChar : kSubstituteChar1, 0, useReplacement ? replacementChar.length : 1, target, offsets, source.position());
@@ -252,8 +256,9 @@ public class CharsetCallback {
* @stable ICU 3.6
*/
public static final Encoder FROM_U_CALLBACK_STOP = new Encoder() {
- public CoderResult call(CharsetEncoderICU encoder, Object context,
- CharBuffer source, ByteBuffer target, IntBuffer offsets,
+ @Override
+ public CoderResult call(CharsetEncoderICU encoder, Object context,
+ CharBuffer source, ByteBuffer target, IntBuffer offsets,
char[] buffer, int length, int cp, CoderResult cr){
if (cr.isUnmappable() && IS_DEFAULT_IGNORABLE_CODE_POINT(cp)) {
return CoderResult.UNDERFLOW;
@@ -266,12 +271,13 @@ public class CharsetCallback {
* @stable ICU 3.6
*/
public static final Decoder TO_U_CALLBACK_STOP = new Decoder() {
- public CoderResult call(CharsetDecoderICU decoder, Object context,
+ @Override
+ public CoderResult call(CharsetDecoderICU decoder, Object context,
ByteBuffer source, CharBuffer target, IntBuffer offsets,
char[] buffer, int length, CoderResult cr){
return cr;
}
- };
+ };
private static final int VALUE_STRING_LENGTH = 32;
private static final char UNICODE_PERCENT_SIGN_CODEPOINT = 0x0025;
private static final char UNICODE_U_CODEPOINT = 0x0055;
@@ -291,17 +297,18 @@ public class CharsetCallback {
* @stable ICU 4.0
*/
public static final Encoder FROM_U_CALLBACK_ESCAPE = new Encoder() {
- public CoderResult call(CharsetEncoderICU encoder, Object context,
- CharBuffer source, ByteBuffer target, IntBuffer offsets,
+ @Override
+ public CoderResult call(CharsetEncoderICU encoder, Object context,
+ CharBuffer source, ByteBuffer target, IntBuffer offsets,
char[] buffer, int length, int cp, CoderResult cr){
char[] valueString = new char[VALUE_STRING_LENGTH];
int valueStringLength = 0;
int i = 0;
-
+
if (cr.isUnmappable() && IS_DEFAULT_IGNORABLE_CODE_POINT(cp)) {
return CoderResult.UNDERFLOW;
}
-
+
if (context == null || !(context instanceof String)) {
while (i < length) {
valueString[valueStringLength++] = UNICODE_PERCENT_SIGN_CODEPOINT; /* adding % */
@@ -317,7 +324,7 @@ public class CharsetCallback {
}
} else if (((String)context).equals(ESCAPE_C)) {
valueString[valueStringLength++] = UNICODE_RS_CODEPOINT; /* adding \ */
-
+
if (length == 2) {
valueString[valueStringLength++] = UNICODE_U_CODEPOINT; /* adding U */
valueStringLength = itou(valueString, valueStringLength, cp, 16, 8);
@@ -376,13 +383,14 @@ public class CharsetCallback {
* @stable ICU 4.0
*/
public static final Decoder TO_U_CALLBACK_ESCAPE = new Decoder() {
- public CoderResult call(CharsetDecoderICU decoder, Object context,
+ @Override
+ public CoderResult call(CharsetDecoderICU decoder, Object context,
ByteBuffer source, CharBuffer target, IntBuffer offsets,
char[] buffer, int length, CoderResult cr){
char[] uniValueString = new char[VALUE_STRING_LENGTH];
int valueStringLength = 0;
int i = 0;
-
+
if (context == null || !(context instanceof String)) {
while (i < length) {
uniValueString[valueStringLength++] = UNICODE_PERCENT_SIGN_CODEPOINT; /* adding % */
@@ -420,12 +428,12 @@ public class CharsetCallback {
}
}
}
-
+
cr = CharsetDecoderICU.toUWriteUChars(decoder, uniValueString, 0, valueStringLength, target, offsets, 0);
-
+
return cr;
}
- };
+ };
/***
* Java port of uprv_itou() in ICU4C used by TO_U_CALLBACK_ESCAPE and FROM_U_CALLBACK_ESCAPE.
* Fills in a char string with the radix-based representation of a number padded with zeroes
@@ -436,13 +444,13 @@ public class CharsetCallback {
int digit;
int j;
char temp;
-
+
do {
digit = i % radix;
buffer[sourceIndex + length++] = (char)(digit <= 9 ? (0x0030+digit) : (0x0030+digit+7));
i = i/radix;
} while (i != 0 && (sourceIndex + length) < buffer.length);
-
+
while (length < minwidth) {
buffer[sourceIndex + length++] = (char)0x0030; /* zero padding */
}
@@ -452,7 +460,7 @@ public class CharsetCallback {
buffer[(sourceIndex + length-1) -j] = buffer[sourceIndex + j];
buffer[sourceIndex + j] = temp;
}
-
+
return length;
}
diff --git a/icu4j/main/classes/charset/src/com/ibm/icu/charset/CharsetCompoundText.java b/icu4j/main/classes/charset/src/com/ibm/icu/charset/CharsetCompoundText.java
index 7acebfe8e1a..2e2b3146850 100644
--- a/icu4j/main/classes/charset/src/com/ibm/icu/charset/CharsetCompoundText.java
+++ b/icu4j/main/classes/charset/src/com/ibm/icu/charset/CharsetCompoundText.java
@@ -25,14 +25,14 @@ class CharsetCompoundText extends CharsetICU {
private static final byte[] fromUSubstitution = new byte[] { (byte) 0x3F };
private CharsetMBCS myConverterArray[];
private byte state;
-
+
private final static byte INVALID = -2;
private final static byte DO_SEARCH = -1;
private final static byte COMPOUND_TEXT_SINGLE_0 = 0;
private final static byte COMPOUND_TEXT_SINGLE_1 = 1;
private final static byte COMPOUND_TEXT_SINGLE_2 = 2;
private final static byte COMPOUND_TEXT_SINGLE_3 = 3;
-
+
/*private final static byte COMPOUND_TEXT_DOUBLE_1 = 4;
private final static byte COMPOUND_TEXT_DOUBLE_2 = 5;
private final static byte COMPOUND_TEXT_DOUBLE_3 = 6;
@@ -40,9 +40,9 @@ class CharsetCompoundText extends CharsetICU {
private final static byte COMPOUND_TEXT_DOUBLE_5 = 8;
private final static byte COMPOUND_TEXT_DOUBLE_6 = 9;
private final static byte COMPOUND_TEXT_DOUBLE_7 = 10;
-
+
private final static byte COMPOUND_TEXT_TRIPLE_DOUBLE = 11;*/
-
+
private final static byte IBM_915 = 12;
private final static byte IBM_916 = 13;
private final static byte IBM_914 = 14;
@@ -51,18 +51,18 @@ class CharsetCompoundText extends CharsetICU {
private final static byte IBM_913 = 17;
private final static byte ISO_8859_14 = 18;
private final static byte IBM_923 = 19;
-
+
private final static byte NUM_OF_CONVERTERS = 20;
-
+
private final static byte SEARCH_LENGTH = 12;
-
+
private final static byte[][] escSeqCompoundText = {
/* Single */
{ 0x1B, 0x2D, 0x41 },
{ 0x1B, 0x2D, 0x4D },
{ 0x1B, 0x2D, 0x46 },
{ 0x1B, 0x2D, 0x47 },
-
+
/* Double */
{ 0x1B, 0x24, 0x29, 0x41 },
{ 0x1B, 0x24, 0x29, 0x42 },
@@ -71,10 +71,10 @@ class CharsetCompoundText extends CharsetICU {
{ 0x1B, 0x24, 0x29, 0x47 },
{ 0x1B, 0x24, 0x29, 0x48 },
{ 0x1B, 0x24, 0x29, 0x49 },
-
+
/* Triple/Double */
{ 0x1B, 0x25, 0x47 },
-
+
/*IBM-915*/
{ 0x1B, 0x2D, 0x4C },
/*IBM-916*/
@@ -92,9 +92,9 @@ class CharsetCompoundText extends CharsetICU {
/* IBM-923 */
{ 0x1B, 0x2D, 0x62 },
};
-
+
private final static byte ESC_START = 0x1B;
-
+
private static boolean isASCIIRange(int codepoint) {
if ((codepoint == 0x0000) || (codepoint == 0x0009) || (codepoint == 0x000A) ||
(codepoint >= 0x0020 && codepoint <= 0x007f) || (codepoint >= 0x00A0 && codepoint <= 0x00FF)) {
@@ -102,21 +102,21 @@ class CharsetCompoundText extends CharsetICU {
}
return false;
}
-
+
private static boolean isIBM915(int codepoint) {
if ((codepoint >= 0x0401 && codepoint <= 0x045F) || (codepoint == 0x2116)) {
return true;
}
return false;
}
-
+
private static boolean isIBM916(int codepoint) {
if ((codepoint >= 0x05D0 && codepoint <= 0x05EA) || (codepoint == 0x2017) || (codepoint == 0x203E)) {
return true;
}
return false;
}
-
+
private static boolean isCompoundS3(int codepoint) {
if ((codepoint == 0x060C) || (codepoint == 0x061B) || (codepoint == 0x061F) || (codepoint >= 0x0621 && codepoint <= 0x063A) ||
(codepoint >= 0x0640 && codepoint <= 0x0652) || (codepoint >= 0x0660 && codepoint <= 0x066D) || (codepoint == 0x200B) ||
@@ -125,14 +125,14 @@ class CharsetCompoundText extends CharsetICU {
}
return false;
}
-
+
private static boolean isCompoundS2(int codepoint) {
if ((codepoint == 0x02BC) || (codepoint == 0x02BD) || (codepoint >= 0x0384 && codepoint <= 0x03CE) || (codepoint == 0x2015)) {
return true;
}
return false;
}
-
+
private static boolean isIBM914(int codepoint) {
if ((codepoint == 0x0100) || (codepoint == 0x0101) || (codepoint == 0x0112) || (codepoint == 0x0113) || (codepoint == 0x0116) || (codepoint == 0x0117) ||
(codepoint == 0x0122) || (codepoint == 0x0123) || (codepoint >= 0x0128 && codepoint <= 0x012B) || (codepoint == 0x012E) || (codepoint == 0x012F) ||
@@ -143,14 +143,14 @@ class CharsetCompoundText extends CharsetICU {
}
return false;
}
-
+
private static boolean isIBM874(int codepoint) {
if ((codepoint >= 0x0E01 && codepoint <= 0x0E3A) || (codepoint >= 0x0E3F && codepoint <= 0x0E5B)) {
return true;
}
return false;
}
-
+
private static boolean isIBM912(int codepoint) {
return ((codepoint >= 0x0102 && codepoint <= 0x0107) || (codepoint >= 0x010C && codepoint <= 0x0111) || (codepoint >= 0x0118 && codepoint <= 0x011B) ||
(codepoint == 0x0139) || (codepoint == 0x013A) || (codepoint == 0x013D) || (codepoint == 0x013E) || (codepoint >= 0x0141 && codepoint <= 0x0144) ||
@@ -159,7 +159,7 @@ class CharsetCompoundText extends CharsetICU {
(codepoint == 0x016E) || (codepoint == 0x016F) || (codepoint == 0x0170) || (codepoint == 0x0171) || (codepoint >= 0x0179 && codepoint <= 0x017E) ||
(codepoint == 0x02C7) || (codepoint == 0x02D8) || (codepoint == 0x02D9) || (codepoint == 0x02DB) || (codepoint == 0x02DD));
}
-
+
private static boolean isIBM913(int codepoint) {
if ((codepoint >= 0x0108 && codepoint <= 0x010B) || (codepoint == 0x011C) ||
(codepoint == 0x011D) || (codepoint == 0x0120) || (codepoint == 0x0121) ||
@@ -169,7 +169,7 @@ class CharsetCompoundText extends CharsetICU {
}
return false;
}
-
+
private static boolean isCompoundS1(int codepoint) {
if ((codepoint == 0x011E) || (codepoint == 0x011F) || (codepoint == 0x0130) ||
(codepoint == 0x0131) || (codepoint >= 0x0218 && codepoint <= 0x021B)) {
@@ -177,7 +177,7 @@ class CharsetCompoundText extends CharsetICU {
}
return false;
}
-
+
private static boolean isISO8859_14(int codepoint) {
if ((codepoint >= 0x0174 && codepoint <= 0x0177) || (codepoint == 0x1E0A) ||
(codepoint == 0x1E0B) || (codepoint == 0x1E1E) || (codepoint == 0x1E1F) ||
@@ -189,14 +189,14 @@ class CharsetCompoundText extends CharsetICU {
}
return false;
}
-
+
private static boolean isIBM923(int codepoint) {
if ((codepoint == 0x0152) || (codepoint == 0x0153) || (codepoint == 0x0178) || (codepoint == 0x20AC)) {
return true;
}
return false;
}
-
+
private static int findNextEsc(ByteBuffer source) {
int sourceLimit = source.limit();
for (int i = (source.position() + 1); i < sourceLimit; i++) {
@@ -206,10 +206,10 @@ class CharsetCompoundText extends CharsetICU {
}
return sourceLimit;
}
-
+
private static byte getState(int codepoint) {
byte state = -1;
-
+
if (isASCIIRange(codepoint)) {
state = COMPOUND_TEXT_SINGLE_0;
} else if (isIBM912(codepoint)) {
@@ -235,10 +235,10 @@ class CharsetCompoundText extends CharsetICU {
} else if (isCompoundS1(codepoint)) {
state = COMPOUND_TEXT_SINGLE_1;
}
-
+
return state;
}
-
+
private static byte findStateFromEscSeq(ByteBuffer source, byte[] toUBytes, int toUBytesLength) {
byte state = INVALID;
int sourceIndex = source.position();
@@ -246,7 +246,7 @@ class CharsetCompoundText extends CharsetICU {
byte i, n;
int offset = toUBytesLength;
int sourceLimit = source.limit();
-
+
for (i = 0; i < escSeqCompoundText.length; i++) {
matchFound = true;
for (n = 0; n < escSeqCompoundText[i].length; n++) {
@@ -266,30 +266,30 @@ class CharsetCompoundText extends CharsetICU {
break;
}
}
-
+
if (matchFound) {
state = i;
source.position(sourceIndex + (escSeqCompoundText[i].length - offset));
}
-
+
return state;
}
-
+
public CharsetCompoundText(String icuCanonicalName, String javaCanonicalName, String[] aliases) {
super(icuCanonicalName, javaCanonicalName, aliases);
-
+
LoadConverters();
-
+
maxBytesPerChar = 6;
minBytesPerChar = 1;
maxCharsPerByte = 1;
}
-
+
private void LoadConverters() {
myConverterArray = new CharsetMBCS[NUM_OF_CONVERTERS];
-
+
myConverterArray[COMPOUND_TEXT_SINGLE_0] = null;
-
+
for (int i = 1; i < SEARCH_LENGTH; i++) {
String name = "icu-internal-compound-";
if (i <= 3) {
@@ -299,10 +299,10 @@ class CharsetCompoundText extends CharsetICU {
} else {
name = name + "t";
}
-
+
myConverterArray[i] = (CharsetMBCS)CharsetICU.forNameICU(name);
}
-
+
myConverterArray[IBM_915] = (CharsetMBCS)CharsetICU.forNameICU("ibm-915_P100-1995");
myConverterArray[IBM_916] = (CharsetMBCS)CharsetICU.forNameICU("ibm-916_P100-1995");
myConverterArray[IBM_914] = (CharsetMBCS)CharsetICU.forNameICU("ibm-914_P100-1995");
@@ -312,15 +312,15 @@ class CharsetCompoundText extends CharsetICU {
myConverterArray[ISO_8859_14] = (CharsetMBCS)CharsetICU.forNameICU("iso-8859_14-1998");
myConverterArray[IBM_923] = (CharsetMBCS)CharsetICU.forNameICU("ibm-923_P100-1998");
}
-
+
class CharsetEncoderCompoundText extends CharsetEncoderICU {
CharsetEncoderMBCS gbEncoder[];
-
+
public CharsetEncoderCompoundText(CharsetICU cs) {
super(cs, fromUSubstitution);
-
+
gbEncoder = new CharsetEncoderMBCS[NUM_OF_CONVERTERS];
-
+
for (int i = 0; i < NUM_OF_CONVERTERS; i++) {
if (i == 0) {
gbEncoder[i] = null;
@@ -329,7 +329,8 @@ class CharsetCompoundText extends CharsetICU {
}
}
}
-
+
+ @Override
protected void implReset() {
super.implReset();
for (int i = 0; i < NUM_OF_CONVERTERS; i++) {
@@ -338,7 +339,8 @@ class CharsetCompoundText extends CharsetICU {
}
}
}
-
+
+ @Override
protected CoderResult encodeLoop(CharBuffer source, ByteBuffer target, IntBuffer offsets, boolean flush) {
CoderResult err = CoderResult.UNDERFLOW;
int sourceChar;
@@ -350,35 +352,35 @@ class CharsetCompoundText extends CharsetICU {
byte tmpState = 0;
int i = 0;
boolean gotoGetTrail = false;
-
+
if (!source.hasRemaining())
return CoderResult.UNDERFLOW;
else if (!target.hasRemaining())
return CoderResult.OVERFLOW;
-
+
/* check if the last codepoint of previous buffer was a lead surrogate */
if ((sourceChar = fromUChar32) != 0 && target.hasRemaining()) {
// goto getTrail label
- gotoGetTrail = true;
+ gotoGetTrail = true;
}
-
+
while (source.hasRemaining()) {
if (target.hasRemaining()) {
if (!gotoGetTrail) {
sourceChar = source.get();
}
-
+
targetLength = 0;
tmpTargetBuffer.position(0);
tmpTargetBuffer.limit(3);
-
+
/* check if the char is a First surrogate */
if (UTF16.isSurrogate((char)sourceChar) || gotoGetTrail) {
if (UTF16.isLeadSurrogate((char)sourceChar) || gotoGetTrail) {
// getTrail label
/* reset gotoGetTrail flag*/
gotoGetTrail = false;
-
+
/* look ahead to find the trail surrogate */
if (source.hasRemaining()) {
/* test the following code unit */
@@ -410,11 +412,11 @@ class CharsetCompoundText extends CharsetICU {
break;
}
}
-
+
tmpState = getState(sourceChar);
-
+
sourceCharArray[0] = (char)sourceChar;
-
+
if (tmpState < 0) {
/* Test all available converters */
for (i = 1; i < SEARCH_LENGTH; i++) {
@@ -438,22 +440,22 @@ class CharsetCompoundText extends CharsetICU {
if (err.isError()) {
break;
}
-
+
if (currentState != tmpState) {
currentState = tmpState;
-
+
/* Write escape sequence if necessary */
for (i = 0; i < escSeqCompoundText[currentState].length; i++) {
targetBytes[i] = escSeqCompoundText[currentState][i];
}
targetLength = i;
}
-
+
for (i = 0; i < tmpTargetBuffer.limit(); i++) {
targetBytes[i+targetLength] = tmpTargetBuffer.get(i);
}
targetLength += i;
-
+
for (i = 0; i < targetLength; i++) {
if (target.hasRemaining()) {
target.put(targetBytes[i]);
@@ -467,7 +469,7 @@ class CharsetCompoundText extends CharsetICU {
break;
}
}
-
+
if (err.isOverflow()) {
int m = 0;
for (int n = i; n < targetLength; n++) {
@@ -476,18 +478,18 @@ class CharsetCompoundText extends CharsetICU {
this.errorBufferLength = m;
}
state = currentState;
-
+
return err;
}
}
-
+
class CharsetDecoderCompoundText extends CharsetDecoderICU {
CharsetDecoderMBCS gbDecoder[];
-
+
public CharsetDecoderCompoundText(CharsetICU cs) {
super(cs);
gbDecoder = new CharsetDecoderMBCS[NUM_OF_CONVERTERS];
-
+
for (int i = 0; i < NUM_OF_CONVERTERS; i++) {
if (i == 0) {
gbDecoder[i] = null;
@@ -496,7 +498,8 @@ class CharsetCompoundText extends CharsetICU {
}
}
}
-
+
+ @Override
protected void implReset() {
super.implReset();
for (int i = 0; i < NUM_OF_CONVERTERS; i++) {
@@ -505,7 +508,8 @@ class CharsetCompoundText extends CharsetICU {
}
}
}
-
+
+ @Override
protected CoderResult decodeLoop(ByteBuffer source, CharBuffer target, IntBuffer offsets, boolean flush) {
CoderResult err = CoderResult.UNDERFLOW;
byte[] sourceChar = { 0x00 };
@@ -513,12 +517,12 @@ class CharsetCompoundText extends CharsetICU {
byte tmpState = currentState;
CharsetDecoderMBCS decoder;
int sourceLimit = source.limit();;
-
+
if (!source.hasRemaining())
return CoderResult.UNDERFLOW;
else if (!target.hasRemaining())
return CoderResult.OVERFLOW;
-
+
while (source.hasRemaining()) {
if (target.hasRemaining()) {
if (this.toULength > 0) {
@@ -526,7 +530,7 @@ class CharsetCompoundText extends CharsetICU {
} else {
sourceChar[0] = source.get(source.position());
}
-
+
if (sourceChar[0] == ESC_START) {
tmpState = findStateFromEscSeq(source, this.toUBytesArray, this.toULength);
if (tmpState == DO_SEARCH) {
@@ -542,14 +546,14 @@ class CharsetCompoundText extends CharsetICU {
}
break;
}
-
+
this.toULength = 0;
}
-
+
if (tmpState != currentState) {
currentState = tmpState;
}
-
+
if (currentState == COMPOUND_TEXT_SINGLE_0) {
while (source.hasRemaining()) {
if (!target.hasRemaining()) {
@@ -567,29 +571,29 @@ class CharsetCompoundText extends CharsetICU {
source.limit(findNextEsc(source));
decoder = gbDecoder[currentState];
-
+
decoder.toUBytesArray = this.toUBytesArray;
decoder.toULength = this.toULength;
err = decoder.decodeLoop(source, target, offsets, true);
-
+
this.toULength = decoder.toULength;
decoder.toULength = 0;
-
+
if (err.isError()) {
if (err.isOverflow()) {
this.charErrorBufferArray = decoder.charErrorBufferArray;
this.charErrorBufferBegin = decoder.charErrorBufferBegin;
this.charErrorBufferLength = decoder.charErrorBufferLength;
-
+
decoder.charErrorBufferBegin = 0;
decoder.charErrorBufferLength = 0;
}
}
-
+
source.limit(sourceLimit);
}
-
+
if (err.isError()) {
break;
}
@@ -602,15 +606,18 @@ class CharsetCompoundText extends CharsetICU {
return err;
}
}
-
+
+ @Override
public CharsetDecoder newDecoder() {
return new CharsetDecoderCompoundText(this);
}
+ @Override
public CharsetEncoder newEncoder() {
return new CharsetEncoderCompoundText(this);
}
-
+
+ @Override
void getUnicodeSetImpl( UnicodeSet setFillIn, int which){
for (int i = 1; i < NUM_OF_CONVERTERS; i++) {
myConverterArray[i].MBCSGetFilteredUnicodeSetForUnicode(myConverterArray[i].sharedData, setFillIn, which, CharsetMBCS.UCNV_SET_FILTER_NONE);
diff --git a/icu4j/main/classes/charset/src/com/ibm/icu/charset/CharsetDecoderICU.java b/icu4j/main/classes/charset/src/com/ibm/icu/charset/CharsetDecoderICU.java
index 797875714c7..267fa086a81 100644
--- a/icu4j/main/classes/charset/src/com/ibm/icu/charset/CharsetDecoderICU.java
+++ b/icu4j/main/classes/charset/src/com/ibm/icu/charset/CharsetDecoderICU.java
@@ -7,7 +7,7 @@
*******************************************************************************
*
*******************************************************************************
-*/
+*/
package com.ibm.icu.charset;
@@ -22,11 +22,11 @@ import com.ibm.icu.impl.Assert;
/**
* An abstract class that provides framework methods of decoding operations for concrete
- * subclasses.
+ * subclasses.
* In the future this class will contain API that will implement converter sematics of ICU4C.
* @stable ICU 3.6
*/
-public abstract class CharsetDecoderICU extends CharsetDecoder{
+public abstract class CharsetDecoderICU extends CharsetDecoder{
int toUnicodeStatus;
byte[] toUBytesArray = new byte[128];
@@ -37,7 +37,7 @@ public abstract class CharsetDecoderICU extends CharsetDecoder{
int charErrorBufferBegin;
char[] invalidCharBuffer = new char[128];
int invalidCharLength;
-
+
/**
* Maximum number of indexed bytes
* @internal
@@ -52,11 +52,12 @@ public abstract class CharsetDecoderICU extends CharsetDecoder{
int preToULength; /* negative: replay */
int preToUFirstLength; /* length of first character */
int mode;
-
+
Object toUContext = null;
private CharsetCallback.Decoder onUnmappableCharacter = CharsetCallback.TO_U_CALLBACK_STOP;
private CharsetCallback.Decoder onMalformedInput = CharsetCallback.TO_U_CALLBACK_STOP;
CharsetCallback.Decoder toCharErrorBehaviour = new CharsetCallback.Decoder() {
+ @Override
public CoderResult call(CharsetDecoderICU decoder, Object context, ByteBuffer source,
CharBuffer target, IntBuffer offsets, char[] buffer, int length, CoderResult cr) {
if (cr.isUnmappable()) {
@@ -69,14 +70,14 @@ public abstract class CharsetDecoderICU extends CharsetDecoder{
// return CharsetCallback.TO_U_CALLBACK_STOP.call(decoder, context, source, target, offsets, buffer, length, cr);
}
};
-
+
// exist to keep implOnMalformedInput and implOnUnmappableInput from being too recursive
private boolean malformedInputCalled = false;
private boolean unmappableCharacterCalled = false;
-
+
/*
* Construct a CharsetDecorderICU based on the information provided from a CharsetICU object.
- *
+ *
* @param cs The CharsetICU object containing information about how to charset to decode.
*/
CharsetDecoderICU(CharsetICU cs) {
@@ -93,65 +94,67 @@ public abstract class CharsetDecoderICU extends CharsetDecoder{
final boolean isFallbackUsed() {
return true;
}
-
+
/**
* Fallback is currently always used by icu4j decoders.
*/
static final boolean isToUUseFallback() {
return isToUUseFallback(true);
}
-
+
/**
* Fallback is currently always used by icu4j decoders.
*/
static final boolean isToUUseFallback(boolean iUseFallback) {
return true;
}
-
+
/**
* Sets the action to be taken if an illegal sequence is encountered
- *
+ *
* @param newAction action to be taken
* @exception IllegalArgumentException
* @stable ICU 3.6
*/
+ @Override
protected final void implOnMalformedInput(CodingErrorAction newAction) {
// don't run infinitely
if (malformedInputCalled)
return;
-
+
// if we get a replace, do not let the nio replace
if (newAction == CodingErrorAction.REPLACE) {
malformedInputCalled = true;
super.onMalformedInput(CodingErrorAction.IGNORE);
malformedInputCalled = false;
}
-
+
onMalformedInput = getCallback(newAction);
}
-
+
/**
* Sets the action to be taken if an illegal sequence is encountered
- *
+ *
* @param newAction action to be taken
* @exception IllegalArgumentException
* @stable ICU 3.6
*/
+ @Override
protected final void implOnUnmappableCharacter(CodingErrorAction newAction) {
// dont run infinitely
if (unmappableCharacterCalled)
return;
-
+
// if we get a replace, do not let the nio replace
if (newAction == CodingErrorAction.REPLACE) {
unmappableCharacterCalled = true;
super.onUnmappableCharacter(CodingErrorAction.IGNORE);
unmappableCharacterCalled = false;
}
-
+
onUnmappableCharacter = getCallback(newAction);
}
-
+
/**
* Sets the callback encoder method and context to be used if an illegal sequence is encounterd.
* You would normally call this twice to set both the malform and unmappable error. In this case,
@@ -170,12 +173,12 @@ public abstract class CharsetDecoderICU extends CharsetDecoder{
} else {
/* Error: Only malformed and unmappable are handled. */
}
-
+
if (toUContext == null || !toUContext.equals(newContext)) {
toUContext = newContext;
}
}
-
+
private static CharsetCallback.Decoder getCallback(CodingErrorAction action){
if(action==CodingErrorAction.REPLACE){
return CharsetCallback.TO_U_CALLBACK_SUBSTITUTE;
@@ -190,42 +193,44 @@ public abstract class CharsetDecoderICU extends CharsetDecoder{
* Flushes any characters saved in the converter's internal buffer and
* resets the converter.
* @param out action to be taken
- * @return result of flushing action and completes the decoding all input.
+ * @return result of flushing action and completes the decoding all input.
* Returns CoderResult.UNDERFLOW if the action succeeds.
* @stable ICU 3.6
*/
+ @Override
protected final CoderResult implFlush(CharBuffer out) {
return decode(EMPTY, out, null, true);
}
-
+
/**
* Resets the to Unicode mode of converter
* @stable ICU 3.6
*/
+ @Override
protected void implReset() {
toUnicodeStatus = 0 ;
toULength = 0;
charErrorBufferLength = 0;
charErrorBufferBegin = 0;
-
+
/* store previous UChars/chars to continue partial matches */
preToUBegin = 0;
preToULength = 0; /* negative: replay */
- preToUFirstLength = 0;
+ preToUFirstLength = 0;
mode = 0;
}
-
+
/**
* Decodes one or more bytes. The default behaviour of the converter
- * is stop and report if an error in input stream is encountered.
+ * is stop and report if an error in input stream is encountered.
* To set different behaviour use @see CharsetDecoder.onMalformedInput()
- * This method allows a buffer by buffer conversion of a data stream.
- * The state of the conversion is saved between calls to convert.
- * Among other things, this means multibyte input sequences can be
- * split between calls. If a call to convert results in an Error, the
- * conversion may be continued by calling convert again with suitably
- * modified parameters.All conversions should be finished with a call to
+ * This method allows a buffer by buffer conversion of a data stream.
+ * The state of the conversion is saved between calls to convert.
+ * Among other things, this means multibyte input sequences can be
+ * split between calls. If a call to convert results in an Error, the
+ * conversion may be continued by calling convert again with suitably
+ * modified parameters.All conversions should be finished with a call to
* the flush method.
* @param in buffer to decode
* @param out buffer to populate with decoded result
@@ -233,6 +238,7 @@ public abstract class CharsetDecoderICU extends CharsetDecoder{
* action succeeds or more input is needed for completing the decoding action.
* @stable ICU 3.6
*/
+ @Override
protected CoderResult decodeLoop(ByteBuffer in,CharBuffer out){
if(in.remaining() < toUCountPending()){
return CoderResult.UNDERFLOW;
@@ -241,16 +247,16 @@ public abstract class CharsetDecoderICU extends CharsetDecoder{
// toULength = 0;
// return CoderResult.UNDERFLOW;
// }
-
+
in.position(in.position() + toUCountPending());
-
+
/* do the conversion */
CoderResult ret = decode(in, out, null, false);
- // ok was there input held in the previous invocation of decodeLoop
+ // ok was there input held in the previous invocation of decodeLoop
// that resulted in output in this invocation?
in.position(in.position() - toUCountPending());
-
+
return ret;
}
@@ -262,7 +268,7 @@ public abstract class CharsetDecoderICU extends CharsetDecoder{
* action succeeds or more input is needed for completing the decoding action.
*/
abstract CoderResult decodeLoop(ByteBuffer in, CharBuffer out, IntBuffer offsets, boolean flush);
-
+
/*
* Implements the ICU semantic for decode operation
* @param source The input byte buffer
@@ -274,12 +280,12 @@ public abstract class CharsetDecoderICU extends CharsetDecoder{
* action succeeds or more input is needed for completing the decoding action.
*/
final CoderResult decode(ByteBuffer source, CharBuffer target, IntBuffer offsets, boolean flush) {
-
+
/* check parameters */
if (target == null || source == null) {
throw new IllegalArgumentException();
}
-
+
/*
* Make sure that the buffer sizes do not exceed the number range for
* int32_t because some functions use the size (in units or bytes)
@@ -301,7 +307,7 @@ public abstract class CharsetDecoderICU extends CharsetDecoder{
return;
}
*/
-
+
/* flush the target overflow buffer */
if (charErrorBufferLength > 0) {
int i = 0;
@@ -328,12 +334,12 @@ public abstract class CharsetDecoderICU extends CharsetDecoder{
/* the overflow buffer is completely copied to the target */
charErrorBufferLength = 0;
}
-
+
if (!flush && !source.hasRemaining() && toULength == 0 && preToULength >= 0) {
/* the overflow buffer is emptied and there is no new input: we are done */
return CoderResult.UNDERFLOW;
}
-
+
/*
* Do not simply return with a buffer overflow error if
* !flush && t==targetLimit
@@ -341,7 +347,7 @@ public abstract class CharsetDecoderICU extends CharsetDecoder{
* For example, the skip callback may be called;
* it does not output anything.
*/
-
+
return toUnicodeWithCallback(source, target, offsets, flush);
}
@@ -388,7 +394,7 @@ public abstract class CharsetDecoderICU extends CharsetDecoder{
}
} */
final CoderResult toUnicodeWithCallback(ByteBuffer source, CharBuffer target, IntBuffer offsets, boolean flush){
-
+
int sourceIndex;
int errorInputLength;
boolean converterSawEndOfInput, calledCallback;
@@ -397,14 +403,14 @@ public abstract class CharsetDecoderICU extends CharsetDecoder{
/* variables for m:n conversion */
ByteBuffer replayArray = ByteBuffer.allocate(EXT_MAX_BYTES);
int replayArrayIndex = 0;
-
+
ByteBuffer realSource=null;
boolean realFlush=false;
int realSourceIndex=0;
-
+
CoderResult cr = CoderResult.UNDERFLOW;
-
+
/* get the converter implementation function */
sourceIndex=0;
@@ -428,7 +434,7 @@ public abstract class CharsetDecoderICU extends CharsetDecoder{
sourceIndex=-1;
preToULength=0;
}
-
+
/*
* loop for conversion and error handling
*
@@ -454,13 +460,13 @@ public abstract class CharsetDecoderICU extends CharsetDecoder{
* s0) {
updateOffsets(offsets, length, sourceIndex, errorInputLength);
-
-
+
+
/*
* if a converter handles offsets and updates the offsets
* pointer at the end, then pArgs->offset should not change
@@ -488,13 +494,13 @@ public abstract class CharsetDecoderICU extends CharsetDecoder{
*/
//TODO: pArgs->offsets=offsets+=length;
/* }
-
+
if(sourceIndex>=0) {
sourceIndex+=(source.position()-s);
}
-
+
} */
-
+
if(preToULength<0) {
/*
* switch the source to new replay units (cannot occur while replaying)
@@ -505,7 +511,7 @@ public abstract class CharsetDecoderICU extends CharsetDecoder{
realSource=source;
realFlush=flush;
realSourceIndex=sourceIndex;
-
+
//UConverterUtility.uprv_memcpy(replayArray, replayBegin, preToUArray, preToUBegin, -preToULength);
replayArray.put(preToUArray,0, -preToULength);
// reset position
@@ -517,7 +523,7 @@ public abstract class CharsetDecoderICU extends CharsetDecoder{
if((sourceIndex+=preToULength)<0) {
sourceIndex=-1;
}
-
+
preToULength=0;
} else {
/* see implementation note before _fromUnicodeWithCallback() */
@@ -525,11 +531,11 @@ public abstract class CharsetDecoderICU extends CharsetDecoder{
Assert.assrt(realSource==null);
}
}
-
+
/* update pointers */
s=source.position();
//t=target.position();
-
+
if(cr.isUnderflow()) {
if(s0) {
copy(toUBytesArray, 0, invalidCharBuffer, 0, errorInputLength);
}
-
+
/* set the converter state to deal with the next character */
toULength=0;
-
+
/* call the callback function */
cr = toCharErrorBehaviour.call(this, toUContext, source, target, offsets, invalidCharBuffer, errorInputLength, cr);
/*
@@ -634,7 +640,7 @@ public abstract class CharsetDecoderICU extends CharsetDecoder{
/*
* Returns the number of chars held in the converter's internal state
- * because more input is needed for completing the conversion. This function is
+ * because more input is needed for completing the conversion. This function is
* useful for mapping semantics of ICU's converter interface to those of iconv,
* and this information is not needed for normal conversion.
* @return The number of chars in the state. -1 if an error is encountered.
@@ -650,7 +656,7 @@ public abstract class CharsetDecoderICU extends CharsetDecoder{
return 0;
}
}
-
+
private void copy(byte[] src, int srcOffset, char[] dst, int dstOffset, int length) {
for(int i=srcOffset; i0 && target.hasRemaining()) {
@@ -685,7 +691,7 @@ public abstract class CharsetDecoderICU extends CharsetDecoder{
}
}
/* write overflow */
- if(length>0) {
+ if(length>0) {
cnv.charErrorBufferLength= 0;
cr = CoderResult.OVERFLOW;
do {
@@ -707,8 +713,8 @@ public abstract class CharsetDecoderICU extends CharsetDecoder{
/* Note: Currently, this method is not being used because the callback method calls toUWriteUChars with
* the substitution characters. Will leave in here for the time being. To be removed later. (4.0)
*/
- /*CoderResult cbToUWriteSub(CharsetDecoderICU decoder,
- ByteBuffer source, CharBuffer target,
+ /*CoderResult cbToUWriteSub(CharsetDecoderICU decoder,
+ ByteBuffer source, CharBuffer target,
IntBuffer offsets){
String sub = decoder.replacement();
CharsetICU cs = (CharsetICU) decoder.charset();
@@ -719,10 +725,10 @@ public abstract class CharsetDecoderICU extends CharsetDecoder{
} else {
return CharsetDecoderICU.toUWriteUChars(decoder, sub.toCharArray(),
0, sub.length(), target, offsets, source.position());
-
+
}
}*/
-
+
/**
* Returns the maxBytesPerChar value for the Charset that created this decoder.
* @return maxBytesPerChar
diff --git a/icu4j/main/classes/charset/src/com/ibm/icu/charset/CharsetEncoderICU.java b/icu4j/main/classes/charset/src/com/ibm/icu/charset/CharsetEncoderICU.java
index 4f680094b5a..8c960ecd293 100644
--- a/icu4j/main/classes/charset/src/com/ibm/icu/charset/CharsetEncoderICU.java
+++ b/icu4j/main/classes/charset/src/com/ibm/icu/charset/CharsetEncoderICU.java
@@ -25,7 +25,7 @@ import com.ibm.icu.text.UTF16;
/**
* An abstract class that provides framework methods of decoding operations for concrete
- * subclasses.
+ * subclasses.
* In the future this class will contain API that will implement converter semantics of ICU4C.
* @stable ICU 3.6
*/
@@ -70,6 +70,7 @@ public abstract class CharsetEncoderICU extends CharsetEncoder {
private CharsetCallback.Encoder onMalformedInput = CharsetCallback.FROM_U_CALLBACK_STOP;
CharsetCallback.Encoder fromCharErrorBehaviour = new CharsetCallback.Encoder() {
+ @Override
public CoderResult call(CharsetEncoderICU encoder, Object context,
CharBuffer source, ByteBuffer target, IntBuffer offsets,
char[] buffer, int length, int cp, CoderResult cr) {
@@ -87,7 +88,7 @@ public abstract class CharsetEncoderICU extends CharsetEncoder {
/*
* Construcs a new encoder for the given charset
- *
+ *
* @param cs
* for which the decoder is created
* @param replacement
@@ -144,28 +145,30 @@ public abstract class CharsetEncoderICU extends CharsetEncoder {
/**
* Sets the action to be taken if an illegal sequence is encountered
- *
+ *
* @param newAction
* action to be taken
* @exception IllegalArgumentException
* @stable ICU 3.6
*/
+ @Override
protected void implOnMalformedInput(CodingErrorAction newAction) {
onMalformedInput = getCallback(newAction);
}
-
+
/**
* Sets the action to be taken if an illegal sequence is encountered
- *
+ *
* @param newAction
* action to be taken
* @exception IllegalArgumentException
* @stable ICU 3.6
*/
+ @Override
protected void implOnUnmappableCharacter(CodingErrorAction newAction) {
onUnmappableInput = getCallback(newAction);
}
-
+
/**
* Sets the callback encoder method and context to be used if an illegal sequence is encountered.
* You would normally call this twice to set both the malform and unmappable error. In this case,
@@ -184,7 +187,7 @@ public abstract class CharsetEncoderICU extends CharsetEncoder {
} else {
/* Error: Only malformed and unmappable are handled. */
}
-
+
if (fromUContext == null || !fromUContext.equals(newContext)) {
setFromUContext(newContext);
}
@@ -192,7 +195,7 @@ public abstract class CharsetEncoderICU extends CharsetEncoder {
/**
* Sets fromUContext used in callbacks.
- *
+ *
* @param newContext Object
* @exception IllegalArgumentException The object is an illegal argument for UContext.
* @stable ICU 4.0
@@ -200,7 +203,7 @@ public abstract class CharsetEncoderICU extends CharsetEncoder {
public final void setFromUContext(Object newContext) {
fromUContext = newContext;
}
-
+
private static CharsetCallback.Encoder getCallback(CodingErrorAction action) {
if (action == CodingErrorAction.REPLACE) {
return CharsetCallback.FROM_U_CALLBACK_SUBSTITUTE;
@@ -217,10 +220,11 @@ public abstract class CharsetEncoderICU extends CharsetEncoder {
* Flushes any characters saved in the converter's internal buffer and
* resets the converter.
* @param out action to be taken
- * @return result of flushing action and completes the decoding all input.
+ * @return result of flushing action and completes the decoding all input.
* Returns CoderResult.UNDERFLOW if the action succeeds.
* @stable ICU 3.6
*/
+ @Override
protected CoderResult implFlush(ByteBuffer out) {
return encode(EMPTY, out, null, true);
}
@@ -229,6 +233,7 @@ public abstract class CharsetEncoderICU extends CharsetEncoder {
* Resets the from Unicode mode of converter
* @stable ICU 3.6
*/
+ @Override
protected void implReset() {
errorBufferLength = 0;
fromUnicodeStatus = 0;
@@ -252,6 +257,7 @@ public abstract class CharsetEncoderICU extends CharsetEncoder {
* action succeeds or more input is needed for completing the decoding action.
* @stable ICU 3.6
*/
+ @Override
protected CoderResult encodeLoop(CharBuffer in, ByteBuffer out) {
if (!in.hasRemaining() && this.errorBufferLength == 0) { // make sure the errorBuffer is empty
// The Java framework should have already substituted what was left.
@@ -596,7 +602,7 @@ public abstract class CharsetEncoderICU extends CharsetEncoder {
/* callback handling */
{
int codePoint;
-
+
/* get and write the code point */
codePoint = fromUChar32;
errorInputLength = UTF16.append(invalidUCharBuffer, 0,
@@ -671,8 +677,9 @@ public abstract class CharsetEncoderICU extends CharsetEncoder {
}*/
/**
* Overrides super class method
- * @stable ICU 3.6
+ * @stable ICU 3.6
*/
+ @Override
public boolean isLegalReplacement(byte[] repl) {
return true;
}
@@ -701,7 +708,7 @@ public abstract class CharsetEncoderICU extends CharsetEncoder {
out.put(bytesArray[bytesBegin]);
bytesBegin++;
}
- // success
+ // success
bytesLength = 0;
} catch (BufferOverflowException ex) {
cr = CoderResult.OVERFLOW;
@@ -713,7 +720,7 @@ public abstract class CharsetEncoderICU extends CharsetEncoder {
--obl;
}
}
- //write overflow
+ //write overflow
cnv.errorBufferLength = bytesLimit - bytesBegin;
if (cnv.errorBufferLength > 0) {
int index = 0;
@@ -727,7 +734,7 @@ public abstract class CharsetEncoderICU extends CharsetEncoder {
/*
* Returns the number of chars held in the converter's internal state
- * because more input is needed for completing the conversion. This function is
+ * because more input is needed for completing the conversion. This function is
* useful for mapping semantics of ICU's converter interface to those of iconv,
* and this information is not needed for normal conversion.
* @return The number of chars in the state. -1 if an error is encountered.
@@ -746,12 +753,12 @@ public abstract class CharsetEncoderICU extends CharsetEncoder {
}
/**
- *
+ *
* @param source
*/
private final void setSourcePosition(CharBuffer source) {
- // ok was there input held in the previous invocation of encodeLoop
+ // ok was there input held in the previous invocation of encodeLoop
// that resulted in output in this invocation?
source.position(source.position() - fromUCountPending());
}
@@ -816,7 +823,7 @@ public abstract class CharsetEncoderICU extends CharsetEncoder {
*/
if (cr.isOverflow()) {
/* Overflowed target. Now, we'll write into the charErrorBuffer.
- * It's a fixed size. If we overflow it...Hm
+ * It's a fixed size. If we overflow it...Hm
*/
/* start the new target at the first free slot in the error buffer */
@@ -840,13 +847,13 @@ public abstract class CharsetEncoderICU extends CharsetEncoder {
* a lead surrogate followed by a trail surrogate. This method can change
* the source position and will modify fromUChar32.
*
- *
+ *
*
* If null is returned, then there was success in reading a
* surrogate pair, the codepoint is stored in fromUChar32 and
* fromUChar32 should be reset (to 0) after being read.
*
- *
+ *
* @param source
* The encoding source.
* @param lead
@@ -886,8 +893,8 @@ public abstract class CharsetEncoderICU extends CharsetEncoder {
* requirement, the calling method must also increment the index if this method returns
* null.
*
- *
- *
+ *
+ *
* @param source
* The encoding source.
* @param lead
@@ -920,7 +927,7 @@ public abstract class CharsetEncoderICU extends CharsetEncoder {
fromUChar32 = UCharacter.getCodePoint(lead, trail);
return null;
}
-
+
/**
* Returns the maxCharsPerByte value for the Charset that created this encoder.
* @return maxCharsPerByte
@@ -929,7 +936,7 @@ public abstract class CharsetEncoderICU extends CharsetEncoder {
public final float maxCharsPerByte() {
return ((CharsetICU)(this.charset())).maxCharsPerByte;
}
-
+
/**
* Calculates the size of a buffer for conversion from Unicode to a charset.
* The calculated size is guaranteed to be sufficient for this conversion.
diff --git a/icu4j/main/classes/charset/src/com/ibm/icu/charset/CharsetHZ.java b/icu4j/main/classes/charset/src/com/ibm/icu/charset/CharsetHZ.java
index 5aa6eb37f9b..e2294c03053 100644
--- a/icu4j/main/classes/charset/src/com/ibm/icu/charset/CharsetHZ.java
+++ b/icu4j/main/classes/charset/src/com/ibm/icu/charset/CharsetHZ.java
@@ -42,7 +42,7 @@ class CharsetHZ extends CharsetICU {
maxBytesPerChar = 4;
minBytesPerChar = 1;
maxCharsPerByte = 1;
-
+
isEmptySegment = false;
}
@@ -55,6 +55,7 @@ class CharsetHZ extends CharsetICU {
gbDecoder = (CharsetMBCS.CharsetDecoderMBCS) gbCharset.newDecoder();
}
+ @Override
protected void implReset() {
super.implReset();
gbDecoder.implReset();
@@ -63,6 +64,7 @@ class CharsetHZ extends CharsetICU {
isEmptySegment = false;
}
+ @Override
protected CoderResult decodeLoop(ByteBuffer source, CharBuffer target, IntBuffer offsets, boolean flush) {
CoderResult err = CoderResult.UNDERFLOW;
byte[] tempBuf = new byte[2];
@@ -141,7 +143,7 @@ class CharsetHZ extends CharsetICU {
* add another bit to distinguish a 0 byte from not having seen a lead byte
*/
toUnicodeStatus = mySourceChar | 0x100;
- isEmptySegment = false; /* the segment has something, either valid or will produce a different error, so reset this */
+ isEmptySegment = false; /* the segment has something, either valid or will produce a different error, so reset this */
}
continue;
} else {
@@ -154,7 +156,7 @@ class CharsetHZ extends CharsetICU {
* - We include at least the first byte in the illegal sequence.
* - If any of the non-initial bytes could be the start of a character,
* we stop the illegal sequence before the first one of those
- *
+ *
* In HZ DBCS, if the second byte is in the 21..7e range,
* we report ony the first byte as the illegal sequence.
* Otherwise we convert of report the pair of bytes.
@@ -230,6 +232,7 @@ class CharsetHZ extends CharsetICU {
gbEncoder = (CharsetMBCS.CharsetEncoderMBCS) gbCharset.newEncoder();
}
+ @Override
protected void implReset() {
super.implReset();
gbEncoder.implReset();
@@ -238,6 +241,7 @@ class CharsetHZ extends CharsetICU {
isTargetUCharDBCS = false;
}
+ @Override
protected CoderResult encodeLoop(CharBuffer source, ByteBuffer target, IntBuffer offsets, boolean flush) {
int length = 0;
int[] targetUniChar = new int[] { 0 };
@@ -375,14 +379,17 @@ class CharsetHZ extends CharsetICU {
}
}
+ @Override
public CharsetDecoder newDecoder() {
return new CharsetDecoderHZ(this);
}
+ @Override
public CharsetEncoder newEncoder() {
return new CharsetEncoderHZ(this);
}
-
+
+ @Override
void getUnicodeSetImpl( UnicodeSet setFillIn, int which){
setFillIn.add(0,0x7f);
// CharsetMBCS mbcshz = (CharsetMBCS)CharsetICU.forNameICU("icu-internal-25546");
diff --git a/icu4j/main/classes/charset/src/com/ibm/icu/charset/CharsetICU.java b/icu4j/main/classes/charset/src/com/ibm/icu/charset/CharsetICU.java
index eff49cca893..8fd7d876da3 100644
--- a/icu4j/main/classes/charset/src/com/ibm/icu/charset/CharsetICU.java
+++ b/icu4j/main/classes/charset/src/com/ibm/icu/charset/CharsetICU.java
@@ -5,7 +5,7 @@
* Copyright (C) 2006-2016, International Business Machines Corporation and
* others. All Rights Reserved.
*******************************************************************************
-*/
+*/
package com.ibm.icu.charset;
@@ -69,7 +69,7 @@ public abstract class CharsetICU extends Charset{
int options;
float maxCharsPerByte;
-
+
String name; /* +4: 60 internal name of the converter- invariant chars */
int codepage; /* +64: 4 codepage # (now IBM-$codepage) */
@@ -82,20 +82,20 @@ public abstract class CharsetICU extends Charset{
byte subChar[/*UCNV_MAX_SUBCHAR_LEN*/]; /* +72: 4 [note: 4 and 8 byte boundary] */
byte subCharLen; /* +76: 1 */
-
+
byte hasToUnicodeFallback; /* +77: 1 UBool needs to be changed to UBool to be consistent across platform */
byte hasFromUnicodeFallback; /* +78: 1 */
short unicodeMask; /* +79: 1 bit 0: has supplementary bit 1: has single surrogates */
byte subChar1; /* +80: 1 single-byte substitution character for IBM MBCS (0 if none) */
//byte reserved[/*19*/]; /* +81: 19 to round out the structure */
-
-
+
+
// typedef enum UConverterUnicodeSet {
- /**
- * Parameter that select the set of roundtrippable Unicode code points.
+ /**
+ * Parameter that select the set of roundtrippable Unicode code points.
* @stable ICU 4.0
*/
- public static final int ROUNDTRIP_SET=0;
+ public static final int ROUNDTRIP_SET=0;
/**
* Select the set of Unicode code points with roundtrip or fallback mappings.
* Not supported at this point.
@@ -106,9 +106,9 @@ public abstract class CharsetICU extends Charset{
public static final int ROUNDTRIP_AND_FALLBACK_SET =1;
//} UConverterUnicodeSet;
-
+
/**
- *
+ *
* @param icuCanonicalName
* @param canonicalName
* @param aliases
@@ -121,7 +121,7 @@ public abstract class CharsetICU extends Charset{
}
this.icuCanonicalName = icuCanonicalName;
}
-
+
/**
* Ascertains if a charset is a sub set of this charset
* Implements the abstract method of super class.
@@ -129,6 +129,7 @@ public abstract class CharsetICU extends Charset{
* @return true if the given charset is a subset of this charset
* @stable ICU 3.6
*/
+ @Override
public boolean contains(Charset cs){
if (null == cs) {
return false;
@@ -152,7 +153,7 @@ public abstract class CharsetICU extends Charset{
algorithmicCharsets.put("LMBCS-18", "com.ibm.icu.charset.CharsetLMBCS");
algorithmicCharsets.put("LMBCS-19", "com.ibm.icu.charset.CharsetLMBCS");
algorithmicCharsets.put("BOCU-1", "com.ibm.icu.charset.CharsetBOCU1" );
- algorithmicCharsets.put("SCSU", "com.ibm.icu.charset.CharsetSCSU" );
+ algorithmicCharsets.put("SCSU", "com.ibm.icu.charset.CharsetSCSU" );
algorithmicCharsets.put("US-ASCII", "com.ibm.icu.charset.CharsetASCII" );
algorithmicCharsets.put("ISO-8859-1", "com.ibm.icu.charset.Charset88591" );
algorithmicCharsets.put("UTF-16", "com.ibm.icu.charset.CharsetUTF16" );
@@ -206,7 +207,7 @@ public abstract class CharsetICU extends Charset{
Class>[] paramTypes = new Class>[]{ String.class, String.class, String[].class};
final Constructor extends CharsetICU> c = cs.getConstructor(paramTypes);
Object[] params = new Object[]{ icuCanonicalName, javaCanonicalName, aliases};
-
+
// Run constructor
try {
conv = c.newInstance(params);
@@ -222,18 +223,18 @@ public abstract class CharsetICU extends Charset{
}
}catch(ClassNotFoundException ex){
}catch(NoSuchMethodException ex){
- }catch (IllegalAccessException ex){
- }catch (InstantiationException ex){
+ }catch (IllegalAccessException ex){
+ }catch (InstantiationException ex){
}
- throw new UnsupportedCharsetException( icuCanonicalName+": "+"Could not load " + className);
+ throw new UnsupportedCharsetException( icuCanonicalName+": "+"Could not load " + className);
}
-
+
static final boolean isSurrogate(int c){
return (((c)&0xfffff800)==0xd800);
}
-
+
/*
- * Returns the default charset name
+ * Returns the default charset name
*/
// static final String getDefaultCharsetName(){
// String defaultEncoding = new InputStreamReader(new ByteArrayInputStream(new byte[0])).getEncoding();
@@ -246,7 +247,7 @@ public abstract class CharsetICU extends Charset{
* available. If the ICU charset provider does not support
* the specified charset, then try other charset providers
* including the standard Java charset provider.
- *
+ *
* @param charsetName The name of the requested charset,
* may be either a canonical name or an alias
* @return A charset object for the named charset
@@ -281,11 +282,11 @@ public abstract class CharsetICU extends Charset{
* This follows ucnv.c method ucnv_detectUnicodeSignature() to detect the
* start of the stream for example U+FEFF (the Unicode BOM/signature
* character) that can be ignored.
- *
+ *
* Detects Unicode signature byte sequences at the start of the byte stream
* and returns number of bytes of the BOM of the indicated Unicode charset.
* 0 is returned when no Unicode signature is recognized.
- *
+ *
*/
// TODO This should be proposed as CharsetDecoderICU API.
// static String detectUnicodeSignature(ByteBuffer source) {
@@ -373,17 +374,17 @@ public abstract class CharsetICU extends Charset{
// /* no known Unicode signature byte sequence recognized */
// return null;
// }
-
-
+
+
abstract void getUnicodeSetImpl(UnicodeSet setFillIn, int which);
-
+
/**
* Returns the set of Unicode code points that can be converted by an ICU Converter.
*
*
The current implementation returns only one kind of set (UCNV_ROUNDTRIP_SET): The set of all Unicode code points that can be
- * roundtrip-converted (converted without any data loss) with the converter This set will not include code points that have fallback
+ * roundtrip-converted (converted without any data loss) with the converter This set will not include code points that have fallback
* mappings or are only the result of reverse fallback mappings. See UTR #22 "Character Mapping Markup Language" at http://www.unicode.org/reports/tr22/
- *
+ *
*
In the future, there may be more UConverterUnicodeSet choices to select sets with different properties.
*
*
The following shows an example of building an index directly.
* The "show..." methods below are just to illustrate usage.
- *
+ *
*
* // Create a simple index where the values for the strings are Integers, and add the strings
- *
+ *
* AlphabeticIndex<Integer> index = new AlphabeticIndex<Integer>(desiredLocale).addLabels(additionalLocale);
* int counter = 0;
* for (String item : test) {
- * index.addRecord(item, counter++);
+ * index.addRecord(item, counter++);
* }
* ...
* // Show index at top. We could skip or gray out empty buckets
- *
+ *
* for (AlphabeticIndex.Bucket<Integer> bucket : index) {
* if (showAll || bucket.size() != 0) {
* showLabelAtTop(UI, bucket.getLabel());
@@ -76,7 +76,7 @@ import com.ibm.icu.util.ULocale;
* }
* ...
* // Show the buckets with their contents, skipping empty buckets
- *
+ *
* for (AlphabeticIndex.Bucket<Integer> bucket : index) {
* if (bucket.size() != 0) {
* showLabelInList(UI, bucket.getLabel());
@@ -140,6 +140,7 @@ public final class AlphabeticIndex implements Iterable> {
// Comparator for records, so that the Record class can be static.
private final Comparator> recordComparator = new Comparator>() {
+ @Override
public int compare(Record o1, Record o2) {
return collatorOriginal.compare(o1.name, o2.name);
}
@@ -218,6 +219,7 @@ public final class AlphabeticIndex implements Iterable> {
* {@inheritDoc}
* @stable ICU 51
*/
+ @Override
public Iterator> iterator() {
return buckets.iterator();
}
@@ -225,7 +227,7 @@ public final class AlphabeticIndex implements Iterable> {
/**
* Create the index object.
- *
+ *
* @param locale
* The locale for the index.
* @stable ICU 4.8
@@ -236,7 +238,7 @@ public final class AlphabeticIndex implements Iterable> {
/**
* Create the index object.
- *
+ *
* @param locale
* The locale for the index.
* @stable ICU 4.8
@@ -245,16 +247,16 @@ public final class AlphabeticIndex implements Iterable> {
this(ULocale.forLocale(locale), null);
}
- /**
+ /**
* Create an AlphabeticIndex that uses a specific collator.
- *
+ *
*
The index will be created with no labels; the addLabels() function must be called
* after creation to add the desired labels to the index.
- *
- *
The index will work directly with the supplied collator. If the caller will need to
+ *
+ *
The index will work directly with the supplied collator. If the caller will need to
* continue working with the collator it should be cloned first, so that the
* collator provided to the AlphabeticIndex remains unchanged after creation of the index.
- *
+ *
* @param collator The collator to use to order the contents of this index.
* @stable ICU 51
*/
@@ -353,7 +355,7 @@ public final class AlphabeticIndex implements Iterable> {
/**
* Get the default label used in the IndexCharacters' locale for underflow, eg the last item in: X Y Z ...
- *
+ *
* @return underflow label
* @stable ICU 4.8
*/
@@ -376,7 +378,7 @@ public final class AlphabeticIndex implements Iterable> {
/**
* Get the default label used in the IndexCharacters' locale for overflow, eg the first item in: ... A B C
- *
+ *
* @return overflow label
* @stable ICU 4.8
*/
@@ -400,7 +402,7 @@ public final class AlphabeticIndex implements Iterable> {
/**
* Get the default label used for abbreviated buckets between other labels. For example, consider the labels
* for Latin and Greek are used: X Y Z ... Α Β Γ.
- *
+ *
* @return inflow label
* @stable ICU 4.8
*/
@@ -411,7 +413,7 @@ public final class AlphabeticIndex implements Iterable> {
/**
* Get the limit on the number of labels in the index. The number of buckets can be slightly larger: see getBucketCount().
- *
+ *
* @return maxLabelCount maximum number of labels.
* @stable ICU 4.8
*/
@@ -632,7 +634,7 @@ public final class AlphabeticIndex implements Iterable> {
/**
* Get the labels.
- *
+ *
* @return The list of bucket labels, after processing.
* @stable ICU 4.8
*/
@@ -651,7 +653,7 @@ public final class AlphabeticIndex implements Iterable> {
*
* Don't use this method across threads if you are changing the settings on the collator, at least not without
* synchronizing.
- *
+ *
* @return a clone of the collator used internally
* @stable ICU 4.8
*/
@@ -671,7 +673,7 @@ public final class AlphabeticIndex implements Iterable> {
* Add a record (name and data) to the index. The name will be used to sort the items into buckets, and to sort
* within the bucket. Two records may have the same name. When they do, the sort order is according to the order added:
* the first added comes first.
- *
+ *
* @param name
* Name, such as a name
* @param data
@@ -698,7 +700,7 @@ public final class AlphabeticIndex implements Iterable> {
*
* Note that the bucket number (and sort key) are only valid for the settings of the current AlphabeticIndex; if
* those are changed, then the bucket number and sort key must be regenerated.
- *
+ *
* @param name
* Name, such as a name
* @return the bucket index for the name
@@ -711,7 +713,7 @@ public final class AlphabeticIndex implements Iterable> {
/**
* Clear the index.
- *
+ *
* @return this, for chaining
* @stable ICU 4.8
*/
@@ -725,7 +727,7 @@ public final class AlphabeticIndex implements Iterable> {
/**
* Return the number of buckets in the index. This will be the same as the number of labels, plus buckets for the underflow, overflow, and inflow(s).
- *
+ *
* @return number of buckets
* @stable ICU 4.8
*/
@@ -736,7 +738,7 @@ public final class AlphabeticIndex implements Iterable> {
/**
* Return the number of records in the index: that is, the total number of distinct <name,data> pairs added with addRecord(...), over all the buckets.
- *
+ *
* @return total number of records in buckets
* @stable ICU 4.8
*/
@@ -746,10 +748,11 @@ public final class AlphabeticIndex implements Iterable> {
/**
* Return an iterator over the buckets.
- *
+ *
* @return iterator over buckets.
* @stable ICU 4.8
*/
+ @Override
public Iterator> iterator() {
initBuckets();
return buckets.iterator();
@@ -839,7 +842,7 @@ public final class AlphabeticIndex implements Iterable> {
/**
* A (name, data) pair, to be sorted by name into one of the index buckets.
* The user data is not used by the index implementation.
- *
+ *
* @stable ICU 4.8
*/
public static class Record {
@@ -853,7 +856,7 @@ public final class AlphabeticIndex implements Iterable> {
/**
* Get the name
- *
+ *
* @return the name
* @stable ICU 4.8
*/
@@ -863,7 +866,7 @@ public final class AlphabeticIndex implements Iterable> {
/**
* Get the data
- *
+ *
* @return the data
* @stable ICU 4.8
*/
@@ -875,6 +878,7 @@ public final class AlphabeticIndex implements Iterable> {
* Standard toString()
* @stable ICU 4.8
*/
+ @Override
public String toString() {
return name + "=" + data;
}
@@ -887,7 +891,7 @@ public final class AlphabeticIndex implements Iterable> {
* returned by {@link AlphabeticIndex.ImmutableIndex#getBucket(int)},
* and {@link AlphabeticIndex#addRecord(CharSequence, Object)} adds a record
* into a bucket according to the record's name.
- *
+ *
* @param
* Data type
* @stable ICU 4.8
@@ -902,7 +906,7 @@ public final class AlphabeticIndex implements Iterable> {
/**
* Type of the label
- *
+ *
* @stable ICU 4.8
*/
public enum LabelType {
@@ -930,7 +934,7 @@ public final class AlphabeticIndex implements Iterable> {
/**
* Set up the bucket.
- *
+ *
* @param label
* label for the bucket
* @param labelType
@@ -945,7 +949,7 @@ public final class AlphabeticIndex implements Iterable> {
/**
* Get the label
- *
+ *
* @return label for the bucket
* @stable ICU 4.8
*/
@@ -955,7 +959,7 @@ public final class AlphabeticIndex implements Iterable> {
/**
* Is a normal, underflow, overflow, or inflow bucket
- *
+ *
* @return is an underflow, overflow, or inflow bucket
* @stable ICU 4.8
*/
@@ -965,7 +969,7 @@ public final class AlphabeticIndex implements Iterable> {
/**
* Get the number of records in the bucket.
- *
+ *
* @return number of records in bucket
* @stable ICU 4.8
*/
@@ -977,6 +981,7 @@ public final class AlphabeticIndex implements Iterable> {
* Iterator over the records in the bucket
* @stable ICU 4.8
*/
+ @Override
public Iterator> iterator() {
if (records == null) {
return Collections.>emptyList().iterator();
@@ -1188,6 +1193,7 @@ public final class AlphabeticIndex implements Iterable> {
/**
* Iterator over just the visible buckets.
*/
+ @Override
public Iterator> iterator() {
return immutableVisibleList.iterator(); // use immutable list to prevent remove().
}
diff --git a/icu4j/main/classes/collate/src/com/ibm/icu/text/CollatorServiceShim.java b/icu4j/main/classes/collate/src/com/ibm/icu/text/CollatorServiceShim.java
index c006bbfd72a..53403a34f57 100644
--- a/icu4j/main/classes/collate/src/com/ibm/icu/text/CollatorServiceShim.java
+++ b/icu4j/main/classes/collate/src/com/ibm/icu/text/CollatorServiceShim.java
@@ -28,6 +28,7 @@ import com.ibm.icu.util.ULocale;
final class CollatorServiceShim extends Collator.ServiceShim {
+ @Override
Collator getInstance(ULocale locale) {
// use service cache, it's faster than instantiation
// if (service.isDefault()) {
@@ -51,6 +52,7 @@ final class CollatorServiceShim extends Collator.ServiceShim {
}
}
+ @Override
Object registerInstance(Collator collator, ULocale locale) {
// Set the collator locales while registering so that getInstance()
// need not guess whether the collator's locales are already set properly
@@ -59,6 +61,7 @@ final class CollatorServiceShim extends Collator.ServiceShim {
return service.registerObject(collator, locale);
}
+ @Override
Object registerFactory(CollatorFactory f) {
class CFactory extends LocaleKeyFactory {
CollatorFactory delegate;
@@ -68,16 +71,19 @@ final class CollatorServiceShim extends Collator.ServiceShim {
this.delegate = fctry;
}
+ @Override
public Object handleCreate(ULocale loc, int kind, ICUService srvc) {
Object coll = delegate.createCollator(loc);
return coll;
}
+ @Override
public String getDisplayName(String id, ULocale displayLocale) {
ULocale objectLocale = new ULocale(id);
return delegate.getDisplayName(objectLocale, displayLocale);
}
+ @Override
public Set getSupportedIDs() {
return delegate.getSupportedLocaleIDs();
}
@@ -86,10 +92,12 @@ final class CollatorServiceShim extends Collator.ServiceShim {
return service.registerFactory(new CFactory(f));
}
+ @Override
boolean unregister(Object registryKey) {
return service.unregisterFactory((Factory)registryKey);
}
+ @Override
Locale[] getAvailableLocales() {
// TODO rewrite this to just wrap getAvailableULocales later
Locale[] result;
@@ -102,6 +110,7 @@ final class CollatorServiceShim extends Collator.ServiceShim {
return result;
}
+ @Override
ULocale[] getAvailableULocales() {
ULocale[] result;
if (service.isDefault()) {
@@ -113,6 +122,7 @@ final class CollatorServiceShim extends Collator.ServiceShim {
return result;
}
+ @Override
String getDisplayName(ULocale objectLocale, ULocale displayLocale) {
String id = objectLocale.getName();
return service.getDisplayName(id, displayLocale);
@@ -152,6 +162,7 @@ final class CollatorServiceShim extends Collator.ServiceShim {
///CLOVER:OFF
// The following method can not be reached by testing
+ @Override
protected Object handleDefault(Key key, String[] actualIDReturn) {
if (actualIDReturn != null) {
actualIDReturn[0] = "root";
diff --git a/icu4j/main/classes/collate/src/com/ibm/icu/util/GlobalizationPreferences.java b/icu4j/main/classes/collate/src/com/ibm/icu/util/GlobalizationPreferences.java
index f351154d2d2..cab3bdfba89 100644
--- a/icu4j/main/classes/collate/src/com/ibm/icu/util/GlobalizationPreferences.java
+++ b/icu4j/main/classes/collate/src/com/ibm/icu/util/GlobalizationPreferences.java
@@ -86,7 +86,7 @@ import com.ibm.icu.text.SimpleDateFormat;
// - Other utilities?
public class GlobalizationPreferences implements Freezable {
-
+
/**
* Default constructor
* @draft ICU 3.6
@@ -98,7 +98,7 @@ public class GlobalizationPreferences implements Freezable();
+ result = new ArrayList();
result.addAll(locales);
}
return result;
@@ -214,7 +214,7 @@ public class GlobalizationPreferences implements Freezable
* After: en_US, en_GB, en, fr_FR, fr
- *
+ *
*
* The final locale list is used to produce a default value for the appropriate territory,
* currency, timezone, etc. The list also represents the lookup order used in
* getResourceBundle for this object. A subclass may override this method
* to customize the algorithm used for populating the locale list.
- *
+ *
* @param inputLocales The list of input locales
* @draft ICU 3.6
* @provisional This API might change or be removed in a future release.
@@ -853,7 +853,7 @@ public class GlobalizationPreferences implements Freezable 0 && c.length() == 0) {
// We want to see zh_HK before zh_Hant
result.add(j, uloc);
@@ -907,7 +907,7 @@ public class GlobalizationPreferences implements FreezableIt MUST return a 'safe' value,
* one whose modification will not affect this object.
- *
+ *
* @param dateStyle
* @param timeStyle
* @draft ICU 3.6
@@ -964,7 +964,7 @@ public class GlobalizationPreferences implements FreezableIt MUST return a 'safe' value,
* one whose modification will not affect this object.
- *
+ *
* @param style
* @draft ICU 3.6
* @provisional This API might change or be removed in a future release.
@@ -1000,7 +1000,7 @@ public class GlobalizationPreferences implements FreezableIt MUST return a 'safe' value,
* one whose modification will not affect this object.
- *
+ *
* @draft ICU 3.6
* @provisional This API might change or be removed in a future release.
*/
@@ -1064,7 +1064,7 @@ public class GlobalizationPreferences implements FreezableIt MUST return a 'safe' value,
* one whose modification will not affect this object.
- *
+ *
* @draft ICU 3.6
* @provisional This API might change or be removed in a future release.
*/
@@ -1080,7 +1080,7 @@ public class GlobalizationPreferences implements FreezableIt MUST return a 'safe' value,
* one whose modification will not affect this object.
- *
+ *
* @param type
* @draft ICU 3.6
* @provisional This API might change or be removed in a future release.
@@ -1117,7 +1117,7 @@ public class GlobalizationPreferences implements FreezableIt MUST return a 'safe' value,
* one whose modification will not affect this object.
- *
+ *
* @draft ICU 3.6
* @provisional This API might change or be removed in a future release.
*/
@@ -1126,7 +1126,7 @@ public class GlobalizationPreferences implements FreezableIt MUST return a 'safe' value,
* one whose modification will not affect this object.
- *
+ *
* @draft ICU 3.6
* @provisional This API might change or be removed in a future release.
*/
@@ -1162,9 +1162,9 @@ public class GlobalizationPreferences implements Freezable locales;
private String territory;
private Currency currency;
@@ -1175,7 +1175,7 @@ public class GlobalizationPreferences implements Freezable implicitLocales;
-
+
{
reset();
}
@@ -1199,9 +1199,9 @@ public class GlobalizationPreferences implements Freezable language_territory_hack_map = new HashMap();
private static final String[][] language_territory_hack = {
@@ -1467,7 +1467,7 @@ public class GlobalizationPreferences implements Freezable hours
static private final double DEG_RAD = PI / 180; // degrees -> radians
static private final double RAD_DEG = 180 / PI; // radians -> degrees
-
+
//-------------------------------------------------------------------------
// Constructors
//-------------------------------------------------------------------------
@@ -202,7 +202,7 @@ public class CalendarAstronomer {
public CalendarAstronomer() {
this(System.currentTimeMillis());
}
-
+
/**
* Construct a new CalendarAstronomer object that is initialized to
* the specified date and time.
@@ -211,7 +211,7 @@ public class CalendarAstronomer {
public CalendarAstronomer(Date d) {
this(d.getTime());
}
-
+
/**
* Construct a new CalendarAstronomer object that is initialized to
* the specified time. The time is expressed as a number of milliseconds since
@@ -223,7 +223,7 @@ public class CalendarAstronomer {
public CalendarAstronomer(long aTime) {
time = aTime;
}
-
+
/**
* Construct a new CalendarAstronomer object with the given
* latitude and longitude. The object's time is set to the current
@@ -244,12 +244,12 @@ public class CalendarAstronomer {
fLatitude = normPI(latitude * DEG_RAD);
fGmtOffset = (long)(fLongitude * 24 * HOUR_MS / PI2);
}
-
-
+
+
//-------------------------------------------------------------------------
// Time and date getters and setters
//-------------------------------------------------------------------------
-
+
/**
* Set the current date and time of this CalendarAstronomer object. All
* astronomical calculations are performed based on this time setting.
@@ -265,7 +265,7 @@ public class CalendarAstronomer {
time = aTime;
clearCache();
}
-
+
/**
* Set the current date and time of this CalendarAstronomer object. All
* astronomical calculations are performed based on this time setting.
@@ -279,13 +279,13 @@ public class CalendarAstronomer {
public void setDate(Date date) {
setTime(date.getTime());
}
-
+
/**
* Set the current date and time of this CalendarAstronomer object. All
* astronomical calculations are performed based on this time setting.
*
* @param jdn the desired time, expressed as a "julian day number",
- * which is the number of elapsed days since
+ * which is the number of elapsed days since
* 1/1/4713 BC (Julian), 12:00 GMT. Note that julian day
* numbers start at noon. To get the jdn for
* the corresponding midnight, subtract 0.5.
@@ -299,7 +299,7 @@ public class CalendarAstronomer {
clearCache();
julianDay = jdn;
}
-
+
/**
* Get the current time of this CalendarAstronomer object,
* represented as the number of milliseconds since
@@ -312,7 +312,7 @@ public class CalendarAstronomer {
public long getTime() {
return time;
}
-
+
/**
* Get the current time of this CalendarAstronomer object,
* represented as a Date object.
@@ -324,7 +324,7 @@ public class CalendarAstronomer {
public Date getDate() {
return new Date(time);
}
-
+
/**
* Get the current time of this CalendarAstronomer object,
* expressed as a "julian day number", which is the number of elapsed
@@ -340,7 +340,7 @@ public class CalendarAstronomer {
}
return julianDay;
}
-
+
/**
* Return this object's time expressed in julian centuries:
* the number of centuries after 1/1/1900 AD, 12:00 GMT
@@ -363,14 +363,14 @@ public class CalendarAstronomer {
if (siderealTime == INVALID) {
// See page 86 of "Practial Astronomy with your Calculator",
// by Peter Duffet-Smith, for details on the algorithm.
-
+
double UT = normalize((double)time/HOUR_MS, 24);
-
+
siderealTime = normalize(getSiderealOffset() + UT*1.002737909, 24);
}
return siderealTime;
}
-
+
private double getSiderealOffset() {
if (siderealT0 == INVALID) {
double JD = Math.floor(getJulianDay() - 0.5) + 0.5;
@@ -380,7 +380,7 @@ public class CalendarAstronomer {
}
return siderealT0;
}
-
+
/**
* Returns the current local sidereal time, measured in hours
* @internal
@@ -388,7 +388,7 @@ public class CalendarAstronomer {
public double getLocalSidereal() {
return normalize(getGreenwichSidereal() + (double)fGmtOffset/HOUR_MS, 24);
}
-
+
/**
* Converts local sidereal time to Universal Time.
*
@@ -396,22 +396,22 @@ public class CalendarAstronomer {
* on this object's current date.
*
* @return The corresponding Universal Time, in milliseconds since
- * 1 Jan 1970, GMT.
+ * 1 Jan 1970, GMT.
*/
private long lstToUT(double lst) {
// Convert to local mean time
double lt = normalize((lst - getSiderealOffset()) * 0.9972695663, 24);
-
+
// Then find local midnight on this day
long base = DAY_MS * ((time + fGmtOffset)/DAY_MS) - fGmtOffset;
-
+
//out(" lt =" + lt + " hours");
//out(" base=" + new Date(base));
-
+
return base + (long)(lt * HOUR_MS);
}
-
-
+
+
//-------------------------------------------------------------------------
// Coordinate transformations, all based on the current time of this object
//-------------------------------------------------------------------------
@@ -445,14 +445,14 @@ public class CalendarAstronomer {
double obliq = eclipticObliquity();
double sinE = Math.sin(obliq);
double cosE = Math.cos(obliq);
-
+
double sinL = Math.sin(eclipLong);
double cosL = Math.cos(eclipLong);
-
+
double sinB = Math.sin(eclipLat);
double cosB = Math.cos(eclipLat);
double tanB = Math.tan(eclipLat);
-
+
return new Equatorial(Math.atan2(sinL*cosE - tanB*sinE, cosL),
Math.asin(sinB*cosE + cosB*sinE*sinL) );
}
@@ -476,23 +476,23 @@ public class CalendarAstronomer {
public Horizon eclipticToHorizon(double eclipLong)
{
Equatorial equatorial = eclipticToEquatorial(eclipLong);
-
+
double H = getLocalSidereal()*PI/12 - equatorial.ascension; // Hour-angle
-
+
double sinH = Math.sin(H);
double cosH = Math.cos(H);
double sinD = Math.sin(equatorial.declination);
double cosD = Math.cos(equatorial.declination);
double sinL = Math.sin(fLatitude);
double cosL = Math.cos(fLatitude);
-
+
double altitude = Math.asin(sinD*sinL + cosD*cosL*cosH);
double azimuth = Math.atan2(-cosD*cosL*sinH, sinD - sinL * Math.sin(altitude));
return new Horizon(azimuth, altitude);
}
-
+
//-------------------------------------------------------------------------
// The Sun
//-------------------------------------------------------------------------
@@ -569,7 +569,7 @@ public class CalendarAstronomer {
{
// See page 86 of "Practial Astronomy with your Calculator",
// by Peter Duffet-Smith, for details on the algorithm.
-
+
if (sunLongitude == INVALID) {
double[] result = getSunLongitude(getJulianDay());
sunLongitude = result[0];
@@ -577,7 +577,7 @@ public class CalendarAstronomer {
}
return sunLongitude;
}
-
+
/**
* TODO Make this public when the entire class is package-private.
*/
@@ -585,17 +585,17 @@ public class CalendarAstronomer {
{
// See page 86 of "Practial Astronomy with your Calculator",
// by Peter Duffet-Smith, for details on the algorithm.
-
+
double day = julian - JD_EPOCH; // Days since epoch
-
+
// Find the angular distance the sun in a fictitious
// circular orbit has travelled since the epoch.
double epochAngle = norm2PI(PI2/TROPICAL_YEAR*day);
-
+
// The epoch wasn't at the sun's perigee; find the angular distance
// since perigee, which is called the "mean anomaly"
double meanAnomaly = norm2PI(epochAngle + SUN_ETA_G - SUN_OMEGA_G);
-
+
// Now find the "true anomaly", e.g. the real solar longitude
// by solving Kepler's equation for an elliptical orbit
// NOTE: The 3rd ed. of the book lists omega_g and eta_g in different
@@ -614,20 +614,20 @@ public class CalendarAstronomer {
public Equatorial getSunPosition() {
return eclipticToEquatorial(getSunLongitude(), 0);
}
-
+
private static class SolarLongitude {
double value;
SolarLongitude(double val) { value = val; }
}
-
+
/**
* Constant representing the vernal equinox.
- * For use with {@link #getSunTime(SolarLongitude, boolean) getSunTime}.
+ * For use with {@link #getSunTime(SolarLongitude, boolean) getSunTime}.
* Note: In this case, "vernal" refers to the northern hemisphere's seasons.
* @internal
*/
public static final SolarLongitude VERNAL_EQUINOX = new SolarLongitude(0);
-
+
/**
* Constant representing the summer solstice.
* For use with {@link #getSunTime(SolarLongitude, boolean) getSunTime}.
@@ -635,7 +635,7 @@ public class CalendarAstronomer {
* @internal
*/
public static final SolarLongitude SUMMER_SOLSTICE = new SolarLongitude(PI/2);
-
+
/**
* Constant representing the autumnal equinox.
* For use with {@link #getSunTime(SolarLongitude, boolean) getSunTime}.
@@ -643,7 +643,7 @@ public class CalendarAstronomer {
* @internal
*/
public static final SolarLongitude AUTUMN_EQUINOX = new SolarLongitude(PI);
-
+
/**
* Constant representing the winter solstice.
* For use with {@link #getSunTime(SolarLongitude, boolean) getSunTime}.
@@ -651,30 +651,31 @@ public class CalendarAstronomer {
* @internal
*/
public static final SolarLongitude WINTER_SOLSTICE = new SolarLongitude((PI*3)/2);
-
+
/**
* Find the next time at which the sun's ecliptic longitude will have
- * the desired value.
+ * the desired value.
* @internal
*/
public long getSunTime(double desired, boolean next)
{
- return timeOfAngle( new AngleFunc() { public double eval() { return getSunLongitude(); } },
+ return timeOfAngle( new AngleFunc() { @Override
+ public double eval() { return getSunLongitude(); } },
desired,
TROPICAL_YEAR,
MINUTE_MS,
next);
}
-
+
/**
* Find the next time at which the sun's ecliptic longitude will have
- * the desired value.
+ * the desired value.
* @internal
*/
public long getSunTime(SolarLongitude desired, boolean next) {
return getSunTime(desired.value, next);
}
-
+
/**
* Returns the time (GMT) of sunrise or sunset on the local date to which
* this calendar is currently set.
@@ -684,29 +685,29 @@ public class CalendarAstronomer {
* official time zone and the geographic longitude, the
* computation can flop over into an adjacent day if this object
* is set to a time near local midnight.
- *
+ *
* @internal
*/
- public long getSunRiseSet(boolean rise)
- {
+ public long getSunRiseSet(boolean rise) {
long t0 = time;
// Make a rough guess: 6am or 6pm local time on the current day
long noon = ((time + fGmtOffset)/DAY_MS)*DAY_MS - fGmtOffset + 12*HOUR_MS;
-
- setTime(noon + (rise ? -6L : 6L) * HOUR_MS);
-
- long t = riseOrSet(new CoordFunc() {
- public Equatorial eval() { return getSunPosition(); }
- },
- rise,
- .533 * DEG_RAD, // Angular Diameter
- 34 /60.0 * DEG_RAD, // Refraction correction
- MINUTE_MS / 12); // Desired accuracy
- setTime(t0);
- return t;
- }
+ setTime(noon + (rise ? -6L : 6L) * HOUR_MS);
+
+ long t = riseOrSet(new CoordFunc() {
+ @Override
+ public Equatorial eval() { return getSunPosition(); }
+ },
+ rise,
+ .533 * DEG_RAD, // Angular Diameter
+ 34 /60.0 * DEG_RAD, // Refraction correction
+ MINUTE_MS / 12); // Desired accuracy
+
+ setTime(t0);
+ return t;
+ }
// Commented out - currently unused. ICU 2.6, Alan
// //-------------------------------------------------------------------------
@@ -741,7 +742,7 @@ public class CalendarAstronomer {
// if (lst1s > 24) lst1s -= 24;
// if (lst2r > 24) lst2r -= 24;
// if (lst2s > 24) lst2s -= 24;
-//
+//
// // 4. Convert LSTs to GSTs. If GST1 > GST2, add 24 to GST2.
// double gst1r = lstToGst(lst1r);
// double gst1s = lstToGst(lst1s);
@@ -752,12 +753,12 @@ public class CalendarAstronomer {
//
// // 5. Calculate GST at 0h UT of this date
// double t00 = utToGst(0);
-//
+//
// // 6. Calculate GST at 0h on the observer's longitude
// double offset = Math.round(fLongitude*12/PI); // p.95 step 6; he _rounds_ to nearest 15 deg.
// double t00p = t00 - offset*1.002737909;
// if (t00p < 0) t00p += 24; // do NOT normalize
-//
+//
// // 7. Adjust
// if (gst1r < t00p) {
// gst1r += 24;
@@ -801,7 +802,7 @@ public class CalendarAstronomer {
// double delta = fLongitude * 24 / PI2;
// return normalize(lst - delta, 24);
// }
-
+
// Commented out - currently unused. ICU 2.6, Alan
// /**
// * Convert UT to GST on this date.
@@ -845,7 +846,7 @@ public class CalendarAstronomer {
// //-------------------------------------------------------------------------
//
// // Note: This method appears to produce inferior accuracy as
-// // compared to getSunRiseSet().
+// // compared to getSunRiseSet().
//
// /**
// * TODO Make this public when the entire class is package-private.
@@ -856,62 +857,62 @@ public class CalendarAstronomer {
// double d = (double)(time - EPOCH_2000_MS) / DAY_MS;
//
// // Now compute the Local Sidereal Time, LST:
-// //
+// //
// double LST = 98.9818 + 0.985647352 * d + /*UT*15 + long*/
// fLongitude*RAD_DEG;
-// //
+// //
// // (east long. positive). Note that LST is here expressed in degrees,
// // where 15 degrees corresponds to one hour. Since LST really is an angle,
// // it's convenient to use one unit---degrees---throughout.
//
// // COMPUTING THE SUN'S POSITION
// // ----------------------------
-// //
+// //
// // To be able to compute the Sun's rise/set times, you need to be able to
// // compute the Sun's position at any time. First compute the "day
// // number" d as outlined above, for the desired moment. Next compute:
-// //
+// //
// double oblecl = 23.4393 - 3.563E-7 * d;
-// //
+// //
// double w = 282.9404 + 4.70935E-5 * d;
// double M = 356.0470 + 0.9856002585 * d;
// double e = 0.016709 - 1.151E-9 * d;
-// //
+// //
// // This is the obliquity of the ecliptic, plus some of the elements of
// // the Sun's apparent orbit (i.e., really the Earth's orbit): w =
// // argument of perihelion, M = mean anomaly, e = eccentricity.
// // Semi-major axis is here assumed to be exactly 1.0 (while not strictly
// // true, this is still an accurate approximation). Next compute E, the
// // eccentric anomaly:
-// //
+// //
// double E = M + e*(180/PI) * Math.sin(M*DEG_RAD) * ( 1.0 + e*Math.cos(M*DEG_RAD) );
-// //
+// //
// // where E and M are in degrees. This is it---no further iterations are
// // needed because we know e has a sufficiently small value. Next compute
// // the true anomaly, v, and the distance, r:
-// //
+// //
// /* r * cos(v) = */ double A = Math.cos(E*DEG_RAD) - e;
// /* r * sin(v) = */ double B = Math.sqrt(1 - e*e) * Math.sin(E*DEG_RAD);
-// //
+// //
// // and
-// //
+// //
// // r = sqrt( A*A + B*B )
// double v = Math.atan2( B, A )*RAD_DEG;
-// //
+// //
// // The Sun's true longitude, slon, can now be computed:
-// //
+// //
// double slon = v + w;
-// //
+// //
// // Since the Sun is always at the ecliptic (or at least very very close to
// // it), we can use simplified formulae to convert slon (the Sun's ecliptic
// // longitude) to sRA and sDec (the Sun's RA and Dec):
-// //
+// //
// // sin(slon) * cos(oblecl)
// // tan(sRA) = -------------------------
// // cos(slon)
-// //
+// //
// // sin(sDec) = sin(oblecl) * sin(slon)
-// //
+// //
// // As was the case when computing az, the Azimuth, if possible use an
// // atan2() function to compute sRA.
//
@@ -922,38 +923,38 @@ public class CalendarAstronomer {
//
// // COMPUTING RISE AND SET TIMES
// // ----------------------------
-// //
+// //
// // To compute when an object rises or sets, you must compute when it
// // passes the meridian and the HA of rise/set. Then the rise time is
// // the meridian time minus HA for rise/set, and the set time is the
// // meridian time plus the HA for rise/set.
-// //
+// //
// // To find the meridian time, compute the Local Sidereal Time at 0h local
// // time (or 0h UT if you prefer to work in UT) as outlined above---name
// // that quantity LST0. The Meridian Time, MT, will now be:
-// //
+// //
// // MT = RA - LST0
// double MT = normalize(sRA - LST, 360);
-// //
+// //
// // where "RA" is the object's Right Ascension (in degrees!). If negative,
// // add 360 deg to MT. If the object is the Sun, leave the time as it is,
// // but if it's stellar, multiply MT by 365.2422/366.2422, to convert from
// // sidereal to solar time. Now, compute HA for rise/set, name that
// // quantity HA0:
-// //
+// //
// // sin(h0) - sin(lat) * sin(Dec)
// // cos(HA0) = ---------------------------------
// // cos(lat) * cos(Dec)
-// //
+// //
// // where h0 is the altitude selected to represent rise/set. For a purely
// // mathematical horizon, set h0 = 0 and simplify to:
-// //
+// //
// // cos(HA0) = - tan(lat) * tan(Dec)
-// //
+// //
// // If you want to account for refraction on the atmosphere, set h0 = -35/60
// // degrees (-35 arc minutes), and if you want to compute the rise/set times
// // for the Sun's upper limb, set h0 = -50/60 (-50 arc minutes).
-// //
+// //
// double h0 = -50/60 * DEG_RAD;
//
// double HA0 = Math.acos(
@@ -963,12 +964,12 @@ public class CalendarAstronomer {
// // When HA0 has been computed, leave it as it is for the Sun but multiply
// // by 365.2422/366.2422 for stellar objects, to convert from sidereal to
// // solar time. Finally compute:
-// //
+// //
// // Rise time = MT - HA0
// // Set time = MT + HA0
-// //
+// //
// // convert the times from degrees to hours by dividing by 15.
-// //
+// //
// // If you'd like to check that your calculations are accurate or just
// // need a quick result, check the USNO's Sun or Moon Rise/Set Table,
// // .
@@ -984,18 +985,18 @@ public class CalendarAstronomer {
//-------------------------------------------------------------------------
// The Moon
//-------------------------------------------------------------------------
-
+
static final double moonL0 = 318.351648 * PI/180; // Mean long. at epoch
static final double moonP0 = 36.340410 * PI/180; // Mean long. of perigee
static final double moonN0 = 318.510107 * PI/180; // Mean long. of node
static final double moonI = 5.145366 * PI/180; // Inclination of orbit
static final double moonE = 0.054900; // Eccentricity of orbit
-
+
// These aren't used right now
static final double moonA = 3.84401e5; // semi-major axis (km)
static final double moonT0 = 0.5181 * PI/180; // Angular size at distance A
static final double moonPi = 0.9507 * PI/180; // Parallax at distance A
-
+
/**
* The position of the moon at the time set on this
* object, in equatorial coordinates.
@@ -1011,18 +1012,18 @@ public class CalendarAstronomer {
// Calculate the solar longitude. Has the side effect of
// filling in "meanAnomalySun" as well.
double sunLong = getSunLongitude();
-
+
//
// Find the # of days since the epoch of our orbital parameters.
// TODO: Convert the time of day portion into ephemeris time
//
double day = getJulianDay() - JD_EPOCH; // Days since epoch
-
+
// Calculate the mean longitude and anomaly of the moon, based on
// a circular orbit. Similar to the corresponding solar calculation.
double meanLongitude = norm2PI(13.1763966*PI/180*day + moonL0);
double meanAnomalyMoon = norm2PI(meanLongitude - 0.1114041*PI/180 * day - moonP0);
-
+
//
// Calculate the following corrections:
// Evection: the sun's gravity affects the moon's eccentricity
@@ -1035,7 +1036,7 @@ public class CalendarAstronomer {
double a3 = 0.3700*PI/180 * Math.sin(meanAnomalySun);
meanAnomalyMoon += evection - annual - a3;
-
+
//
// More correction factors:
// center equation of the center correction
@@ -1045,7 +1046,7 @@ public class CalendarAstronomer {
//
double center = 6.2886*PI/180 * Math.sin(meanAnomalyMoon);
double a4 = 0.2140*PI/180 * Math.sin(2 * meanAnomalyMoon);
-
+
// Now find the moon's corrected longitude
moonLongitude = meanLongitude + evection + center - annual + a4;
@@ -1055,9 +1056,9 @@ public class CalendarAstronomer {
// the earth the moon is on
//
double variation = 0.6583*PI/180 * Math.sin(2*(moonLongitude - sunLong));
-
+
moonLongitude += variation;
-
+
//
// What we've calculated so far is the moon's longitude in the plane
// of its own orbit. Now map to the ecliptic to get the latitude
@@ -1071,7 +1072,7 @@ public class CalendarAstronomer {
double y = Math.sin(moonLongitude - nodeLongitude);
double x = Math.cos(moonLongitude - nodeLongitude);
-
+
moonEclipLong = Math.atan2(y*Math.cos(moonI), x) + nodeLongitude;
double moonEclipLat = Math.asin(y * Math.sin(moonI));
@@ -1079,7 +1080,7 @@ public class CalendarAstronomer {
}
return moonPosition;
}
-
+
/**
* The "age" of the moon at the time specified in this object.
* This is really the angle between the
@@ -1097,10 +1098,10 @@ public class CalendarAstronomer {
// some the intermediate results cached during that calculation.
//
getMoonPosition();
-
+
return norm2PI(moonEclipLong - sunLongitude);
}
-
+
/**
* Calculate the phase of the moon at the time set in this object.
* The returned phase is a double in the range
@@ -1120,12 +1121,12 @@ public class CalendarAstronomer {
// by Peter Duffet-Smith, for details on the algorithm.
return 0.5 * (1 - Math.cos(getMoonAge()));
}
-
+
private static class MoonAge {
double value;
MoonAge(double val) { value = val; }
}
-
+
/**
* Constant representing a new moon.
* For use with {@link #getMoonTime(MoonAge, boolean) getMoonTime}
@@ -1139,53 +1140,54 @@ public class CalendarAstronomer {
* @internal
*/
public static final MoonAge FIRST_QUARTER = new MoonAge(PI/2);
-
+
/**
* Constant representing a full moon.
* For use with {@link #getMoonTime(MoonAge, boolean) getMoonTime}
* @internal
*/
public static final MoonAge FULL_MOON = new MoonAge(PI);
-
+
/**
* Constant representing the moon's last quarter.
* For use with {@link #getMoonTime(MoonAge, boolean) getMoonTime}
* @internal
*/
public static final MoonAge LAST_QUARTER = new MoonAge((PI*3)/2);
-
+
/**
* Find the next or previous time at which the Moon's ecliptic
- * longitude will have the desired value.
+ * longitude will have the desired value.
*
* @param desired The desired longitude.
* @param next true if the next occurrance of the phase
- * is desired, false for the previous occurrance.
+ * is desired, false for the previous occurrance.
* @internal
*/
public long getMoonTime(double desired, boolean next)
{
return timeOfAngle( new AngleFunc() {
+ @Override
public double eval() { return getMoonAge(); } },
desired,
SYNODIC_MONTH,
MINUTE_MS,
next);
}
-
+
/**
* Find the next or previous time at which the moon will be in the
* desired phase.
*
* @param desired The desired phase of the moon.
* @param next true if the next occurrance of the phase
- * is desired, false for the previous occurrance.
+ * is desired, false for the previous occurrance.
* @internal
*/
public long getMoonTime(MoonAge desired, boolean next) {
return getMoonTime(desired.value, next);
}
-
+
/**
* Returns the time (GMT) of sunrise or sunset on the local date to which
* this calendar is currently set.
@@ -1194,6 +1196,7 @@ public class CalendarAstronomer {
public long getMoonRiseSet(boolean rise)
{
return riseOrSet(new CoordFunc() {
+ @Override
public Equatorial eval() { return getMoonPosition(); }
},
rise,
@@ -1205,27 +1208,27 @@ public class CalendarAstronomer {
//-------------------------------------------------------------------------
// Interpolation methods for finding the time at which a given event occurs
//-------------------------------------------------------------------------
-
+
private interface AngleFunc {
public double eval();
}
-
+
private long timeOfAngle(AngleFunc func, double desired,
double periodDays, long epsilon, boolean next)
{
// Find the value of the function at the current time
double lastAngle = func.eval();
-
+
// Find out how far we are from the desired angle
double deltaAngle = norm2PI(desired - lastAngle) ;
-
+
// Using the average period, estimate the next (or previous) time at
// which the desired angle occurs.
double deltaT = (deltaAngle + (next ? 0 : -PI2)) * (periodDays*DAY_MS) / PI2;
-
+
double lastDeltaT = deltaT; // Liu
long startTime = time; // Liu
-
+
setTime(time + (long)deltaT);
// Now iterate until we get the error below epsilon. Throughout
@@ -1240,17 +1243,17 @@ public class CalendarAstronomer {
// Correct the time estimate based on how far off the angle is
deltaT = normPI(desired - angle) * factor;
-
+
// HACK:
- //
+ //
// If abs(deltaT) begins to diverge we need to quit this loop.
// This only appears to happen when attempting to locate, for
// example, a new moon on the day of the new moon. E.g.:
- //
+ //
// This result is correct:
// newMoon(7508(Mon Jul 23 00:00:00 CST 1990,false))=
// Sun Jul 22 10:57:41 CST 1990
- //
+ //
// But attempting to make the same call a day earlier causes deltaT
// to diverge:
// CalendarAstronomer.timeOfAngle() diverging: 1.348508727575625E9 ->
@@ -1274,23 +1277,23 @@ public class CalendarAstronomer {
setTime(time + (long)deltaT);
}
while (Math.abs(deltaT) > epsilon);
-
+
return time;
}
-
+
private interface CoordFunc {
public Equatorial eval();
}
-
+
private long riseOrSet(CoordFunc func, boolean rise,
- double diameter, double refraction,
+ double diameter, double refraction,
long epsilon)
- {
+ {
Equatorial pos = null;
double tanL = Math.tan(fLatitude);
long deltaT = Long.MAX_VALUE;
int count = 0;
-
+
//
// Calculate the object's position at the current time, then use that
// position to calculate the time of rising or setting. The position
@@ -1301,10 +1304,10 @@ public class CalendarAstronomer {
pos = func.eval();
double angle = Math.acos(-tanL * Math.tan(pos.declination));
double lst = ((rise ? PI2-angle : angle) + pos.ascension ) * 24 / PI2;
-
+
// Convert from LST to Universal Time.
long newTime = lstToUT( lst );
-
+
deltaT = newTime - time;
setTime(newTime);
}
@@ -1316,10 +1319,10 @@ public class CalendarAstronomer {
double x = diameter / 2 + refraction;
double y = Math.asin(Math.sin(x) / Math.sin(psi));
long delta = (long)((240 * y * RAD_DEG / cosD)*SECOND_MS);
-
+
return time + (rise ? -delta : delta);
}
-
+
//-------------------------------------------------------------------------
// Other utility methods
//-------------------------------------------------------------------------
@@ -1331,7 +1334,7 @@ public class CalendarAstronomer {
private static final double normalize(double value, double range) {
return value - range * Math.floor(value / range);
}
-
+
/**
* Normalize an angle so that it's in the range 0 - 2pi.
* For positive angles this is just (angle % 2pi), but the Java
@@ -1340,14 +1343,14 @@ public class CalendarAstronomer {
private static final double norm2PI(double angle) {
return normalize(angle, PI2);
}
-
+
/**
* Normalize an angle into the range -PI - PI
*/
private static final double normPI(double angle) {
return normalize(angle + PI, PI2) - PI;
}
-
+
/**
* Find the "true anomaly" (longitude) of an object from
* its mean anomaly and the eccentricity of its orbit. This uses
@@ -1355,7 +1358,7 @@ public class CalendarAstronomer {
*
* @param meanAnomaly The object's longitude calculated as if it were in
* a regular, circular orbit, measured in radians
- * from the point of perigee.
+ * from the point of perigee.
*
* @param eccentricity The eccentricity of the orbit
*
@@ -1370,13 +1373,13 @@ public class CalendarAstronomer {
do {
delta = E - eccentricity * Math.sin(E) - meanAnomaly;
E = E - delta / (1 - eccentricity * Math.cos(E));
- }
+ }
while (Math.abs(delta) > 1e-5); // epsilon = 1e-5 rad
return 2.0 * Math.atan( Math.tan(E/2) * Math.sqrt( (1+eccentricity)
/(1-eccentricity) ) );
}
-
+
/**
* Return the obliquity of the ecliptic (the angle between the ecliptic
* and the earth's equator) at the current time. This varies due to
@@ -1390,42 +1393,42 @@ public class CalendarAstronomer {
final double epoch = 2451545.0; // 2000 AD, January 1.5
double T = (getJulianDay() - epoch) / 36525;
-
+
eclipObliquity = 23.439292
- 46.815/3600 * T
- 0.0006/3600 * T*T
+ 0.00181/3600 * T*T*T;
-
+
eclipObliquity *= DEG_RAD;
}
return eclipObliquity;
}
-
-
+
+
//-------------------------------------------------------------------------
// Private data
//-------------------------------------------------------------------------
-
+
/**
* Current time in milliseconds since 1/1/1970 AD
* @see java.util.Date#getTime
*/
private long time;
-
+
/* These aren't used yet, but they'll be needed for sunset calculations
* and equatorial to horizon coordinate conversions
*/
private double fLongitude = 0.0;
private double fLatitude = 0.0;
private long fGmtOffset = 0;
-
+
//
// The following fields are used to cache calculated results for improved
// performance. These values all depend on the current time setting
// of this object, so the clearCache method is provided.
//
static final private double INVALID = Double.MIN_VALUE;
-
+
private transient double julianDay = INVALID;
private transient double julianCentury = INVALID;
private transient double sunLongitude = INVALID;
@@ -1436,7 +1439,7 @@ public class CalendarAstronomer {
private transient double eclipObliquity = INVALID;
private transient double siderealT0 = INVALID;
private transient double siderealTime = INVALID;
-
+
private transient Equatorial moonPosition = null;
private void clearCache() {
@@ -1452,15 +1455,15 @@ public class CalendarAstronomer {
siderealT0 = INVALID;
moonPosition = null;
}
-
+
//private static void out(String s) {
// System.out.println(s);
//}
-
+
//private static String deg(double rad) {
// return Double.toString(rad * RAD_DEG);
//}
-
+
//private static String hours(long ms) {
// return Double.toString((double)ms / HOUR_MS) + " hours";
//}
@@ -1471,11 +1474,11 @@ public class CalendarAstronomer {
public String local(long localMillis) {
return new Date(localMillis - TimeZone.getDefault().getRawOffset()).toString();
}
-
-
+
+
/**
* Represents the position of an object in the sky relative to the ecliptic,
- * the plane of the earth's orbit around the Sun.
+ * the plane of the earth's orbit around the Sun.
* This is a spherical coordinate system in which the latitude
* specifies the position north or south of the plane of the ecliptic.
* The longitude specifies the position along the ecliptic plane
@@ -1507,10 +1510,11 @@ public class CalendarAstronomer {
* Return a string representation of this object
* @internal
*/
+ @Override
public String toString() {
return Double.toString(longitude*RAD_DEG) + "," + (latitude*RAD_DEG);
}
-
+
/**
* The ecliptic latitude, in radians. This specifies an object's
* position north or south of the plane of the ecliptic,
@@ -1518,7 +1522,7 @@ public class CalendarAstronomer {
* @internal
*/
public final double latitude;
-
+
/**
* The ecliptic longitude, in radians.
* This specifies an object's position along the ecliptic plane
@@ -1534,8 +1538,8 @@ public class CalendarAstronomer {
}
/**
- * Represents the position of an
- * object in the sky relative to the plane of the earth's equator.
+ * Represents the position of an
+ * object in the sky relative to the plane of the earth's equator.
* The Right Ascension specifies the position east or west
* along the equator, relative to the sun's position at the vernal
* equinox. The Declination is the position north or south
@@ -1567,10 +1571,11 @@ public class CalendarAstronomer {
* angles measured in degrees.
* @internal
*/
+ @Override
public String toString() {
return Double.toString(ascension*RAD_DEG) + "," + (declination*RAD_DEG);
}
-
+
/**
* Return a string representation of this object with the right ascension
* measured in hours, minutes, and seconds.
@@ -1579,16 +1584,16 @@ public class CalendarAstronomer {
public String toHmsString() {
return radToHms(ascension) + "," + radToDms(declination);
}
-
+
/**
- * The right ascension, in radians.
+ * The right ascension, in radians.
* This is the position east or west along the equator
* relative to the sun's position at the vernal equinox,
* with positive angles representing East.
* @internal
*/
public final double ascension;
-
+
/**
* The declination, in radians.
* This is the position north or south of the equatorial plane,
@@ -1599,7 +1604,7 @@ public class CalendarAstronomer {
}
/**
- * Represents the position of an object in the sky relative to
+ * Represents the position of an object in the sky relative to
* the local horizon.
* The Altitude represents the object's elevation above the horizon,
* with objects below the horizon having a negative altitude.
@@ -1633,18 +1638,19 @@ public class CalendarAstronomer {
* angles measured in degrees.
* @internal
*/
+ @Override
public String toString() {
return Double.toString(altitude*RAD_DEG) + "," + (azimuth*RAD_DEG);
}
-
- /**
- * The object's altitude above the horizon, in radians.
+
+ /**
+ * The object's altitude above the horizon, in radians.
* @internal
*/
public final double altitude;
-
- /**
- * The object's direction, in radians clockwise from north.
+
+ /**
+ * The object's direction, in radians clockwise from north.
* @internal
*/
public final double azimuth;
@@ -1654,15 +1660,15 @@ public class CalendarAstronomer {
int hrs = (int) (angle*RAD_HOUR);
int min = (int)((angle*RAD_HOUR - hrs) * 60);
int sec = (int)((angle*RAD_HOUR - hrs - min/60.0) * 3600);
-
+
return Integer.toString(hrs) + "h" + min + "m" + sec + "s";
}
-
+
static private String radToDms(double angle) {
int deg = (int) (angle*RAD_DEG);
int min = (int)((angle*RAD_DEG - deg) * 60);
int sec = (int)((angle*RAD_DEG - deg - min/60.0) * 3600);
-
+
return Integer.toString(deg) + "\u00b0" + min + "'" + sec + "\"";
}
}
diff --git a/icu4j/main/classes/core/src/com/ibm/icu/impl/CharTrie.java b/icu4j/main/classes/core/src/com/ibm/icu/impl/CharTrie.java
index 293ffe9f0c2..688b6207dc5 100644
--- a/icu4j/main/classes/core/src/com/ibm/icu/impl/CharTrie.java
+++ b/icu4j/main/classes/core/src/com/ibm/icu/impl/CharTrie.java
@@ -103,7 +103,7 @@ public class CharTrie extends Trie
}
// public methods --------------------------------------------------
-
+
/**
* Gets the value associated with the codepoint.
* If no value is associated with the codepoint, a default value will be
@@ -118,14 +118,14 @@ public class CharTrie extends Trie
// fastpath for U+0000..U+D7FF
if(0 <= ch && ch < UTF16.LEAD_SURROGATE_MIN_VALUE) {
// copy of getRawOffset()
- offset = (m_index_[ch >> INDEX_STAGE_1_SHIFT_] << INDEX_STAGE_2_SHIFT_)
+ offset = (m_index_[ch >> INDEX_STAGE_1_SHIFT_] << INDEX_STAGE_2_SHIFT_)
+ (ch & INDEX_STAGE_3_MASK_);
return m_data_[offset];
}
// handle U+D800..U+10FFFF
offset = getCodePointOffset(ch);
-
+
// return -1 if there is an error, in this case we return the default
// value: m_initialValue_
return (offset >= 0) ? m_data_[offset] : m_initialValue_;
@@ -174,7 +174,7 @@ public class CharTrie extends Trie
/**
*
Get a value from a folding offset (from the value of a lead surrogate)
* and a trail surrogate.
- *
If the
+ *
If the
* @param leadvalue value associated with the lead surrogate which contains
* the folding offset
* @param trail surrogate
@@ -188,24 +188,24 @@ public class CharTrie extends Trie
}
int offset = m_dataManipulate_.getFoldingOffset(leadvalue);
if (offset > 0) {
- return m_data_[getRawOffset(offset,
+ return m_data_[getRawOffset(offset,
(char)(trail & SURROGATE_MASK_))];
}
return m_initialValue_;
}
-
+
/**
*
Gets the latin 1 fast path value.
- *
Note this only works if latin 1 characters have their own linear
+ *
Note this only works if latin 1 characters have their own linear
* array.
* @param ch latin 1 characters
* @return value associated with latin character
*/
- public final char getLatin1LinearValue(char ch)
+ public final char getLatin1LinearValue(char ch)
{
return m_data_[INDEX_STAGE_3_MASK_ + 1 + m_dataOffset_ + ch];
}
-
+
/**
* Checks if the argument Trie has the same data as this Trie
* @param other Trie to check
@@ -213,7 +213,8 @@ public class CharTrie extends Trie
* otherwise
*/
///CLOVER:OFF
- public boolean equals(Object other)
+ @Override
+ public boolean equals(Object other)
{
boolean result = super.equals(other);
if (result && other instanceof CharTrie) {
@@ -222,7 +223,8 @@ public class CharTrie extends Trie
}
return false;
}
-
+
+ @Override
public int hashCode() {
assert false : "hashCode not designed";
return 42;
@@ -236,6 +238,7 @@ public class CharTrie extends Trie
* data array
* @param bytes buffer containing trie data
*/
+ @Override
protected final void unserialize(ByteBuffer bytes)
{
int indexDataLength = m_dataOffset_ + m_dataLength_;
@@ -250,13 +253,14 @@ public class CharTrie extends Trie
* @param trail trailing surrogate
* @return offset to data
*/
+ @Override
protected final int getSurrogateOffset(char lead, char trail)
{
if (m_dataManipulate_ == null) {
throw new NullPointerException(
"The field DataManipulate in this Trie is null");
}
-
+
// get fold position for the next trail surrogate
int offset = m_dataManipulate_.getFoldingOffset(getLeadValue(lead));
@@ -269,7 +273,7 @@ public class CharTrie extends Trie
// value: m_initialValue_
return -1;
}
-
+
/**
* Gets the value at the argument index.
* For use internally in TrieIterator.
@@ -277,6 +281,7 @@ public class CharTrie extends Trie
* @return 32 bit value
* @see com.ibm.icu.impl.TrieIterator
*/
+ @Override
protected final int getValue(int index)
{
return m_data_[index];
@@ -284,13 +289,14 @@ public class CharTrie extends Trie
/**
* Gets the default initial value
- * @return 32 bit value
+ * @return 32 bit value
*/
+ @Override
protected final int getInitialValue()
{
return m_initialValue_;
}
-
+
// private data members --------------------------------------------
/**
diff --git a/icu4j/main/classes/core/src/com/ibm/icu/impl/CharacterIteratorWrapper.java b/icu4j/main/classes/core/src/com/ibm/icu/impl/CharacterIteratorWrapper.java
index d271c435ab2..d657f771c22 100644
--- a/icu4j/main/classes/core/src/com/ibm/icu/impl/CharacterIteratorWrapper.java
+++ b/icu4j/main/classes/core/src/com/ibm/icu/impl/CharacterIteratorWrapper.java
@@ -13,26 +13,27 @@ import java.text.CharacterIterator;
import com.ibm.icu.text.UCharacterIterator;
/**
- * This class is a wrapper around CharacterIterator and implements the
+ * This class is a wrapper around CharacterIterator and implements the
* UCharacterIterator protocol
* @author ram
*/
public class CharacterIteratorWrapper extends UCharacterIterator {
-
+
private CharacterIterator iterator;
-
-
+
+
public CharacterIteratorWrapper(CharacterIterator iter){
if(iter==null){
throw new IllegalArgumentException();
}
- iterator = iter;
+ iterator = iter;
}
/**
* @see UCharacterIterator#current()
*/
+ @Override
public int current() {
int c = iterator.current();
if(c==CharacterIterator.DONE){
@@ -44,6 +45,7 @@ public class CharacterIteratorWrapper extends UCharacterIterator {
/**
* @see UCharacterIterator#getLength()
*/
+ @Override
public int getLength() {
return (iterator.getEndIndex() - iterator.getBeginIndex());
}
@@ -51,6 +53,7 @@ public class CharacterIteratorWrapper extends UCharacterIterator {
/**
* @see UCharacterIterator#getIndex()
*/
+ @Override
public int getIndex() {
return iterator.getIndex();
}
@@ -58,10 +61,11 @@ public class CharacterIteratorWrapper extends UCharacterIterator {
/**
* @see UCharacterIterator#next()
*/
+ @Override
public int next() {
int i = iterator.current();
iterator.next();
- if(i==CharacterIterator.DONE){
+ if(i==CharacterIterator.DONE){
return DONE;
}
return i;
@@ -70,6 +74,7 @@ public class CharacterIteratorWrapper extends UCharacterIterator {
/**
* @see UCharacterIterator#previous()
*/
+ @Override
public int previous() {
int i = iterator.previous();
if(i==CharacterIterator.DONE){
@@ -81,6 +86,7 @@ public class CharacterIteratorWrapper extends UCharacterIterator {
/**
* @see UCharacterIterator#setIndex(int)
*/
+ @Override
public void setIndex(int index) {
try{
iterator.setIndex(index);
@@ -92,6 +98,7 @@ public class CharacterIteratorWrapper extends UCharacterIterator {
/**
* @see UCharacterIterator#setToLimit()
*/
+ @Override
public void setToLimit() {
iterator.setIndex(iterator.getEndIndex());
}
@@ -99,13 +106,14 @@ public class CharacterIteratorWrapper extends UCharacterIterator {
/**
* @see UCharacterIterator#getText(char[])
*/
+ @Override
public int getText(char[] fillIn, int offset){
- int length =iterator.getEndIndex() - iterator.getBeginIndex();
+ int length =iterator.getEndIndex() - iterator.getBeginIndex();
int currentIndex = iterator.getIndex();
if(offset < 0 || offset + length > fillIn.length){
throw new IndexOutOfBoundsException(Integer.toString(length));
}
-
+
for (char ch = iterator.first(); ch != CharacterIterator.DONE; ch = iterator.next()) {
fillIn[offset++] = ch;
}
@@ -118,21 +126,23 @@ public class CharacterIteratorWrapper extends UCharacterIterator {
* Creates a clone of this iterator. Clones the underlying character iterator.
* @see UCharacterIterator#clone()
*/
+ @Override
public Object clone(){
try {
CharacterIteratorWrapper result = (CharacterIteratorWrapper) super.clone();
result.iterator = (CharacterIterator)this.iterator.clone();
return result;
- } catch (CloneNotSupportedException e) {
+ } catch (CloneNotSupportedException e) {
return null; // only invoked if bad underlying character iterator
}
}
-
+
+ @Override
public int moveIndex(int delta){
- int length = iterator.getEndIndex() - iterator.getBeginIndex();
+ int length = iterator.getEndIndex() - iterator.getBeginIndex();
int idx = iterator.getIndex()+delta;
-
+
if(idx < 0) {
idx = 0;
} else if(idx > length) {
@@ -140,11 +150,12 @@ public class CharacterIteratorWrapper extends UCharacterIterator {
}
return iterator.setIndex(idx);
}
-
+
/**
* @see UCharacterIterator#getCharacterIterator()
*/
+ @Override
public CharacterIterator getCharacterIterator(){
return (CharacterIterator)iterator.clone();
- }
+ }
}
diff --git a/icu4j/main/classes/core/src/com/ibm/icu/impl/ClassLoaderUtil.java b/icu4j/main/classes/core/src/com/ibm/icu/impl/ClassLoaderUtil.java
index 7d6c4438e0e..e7389a1f884 100644
--- a/icu4j/main/classes/core/src/com/ibm/icu/impl/ClassLoaderUtil.java
+++ b/icu4j/main/classes/core/src/com/ibm/icu/impl/ClassLoaderUtil.java
@@ -29,7 +29,7 @@ public class ClassLoaderUtil {
// this constructor on Android, because ClassLoaderUtil.getClassLoader()
// should get non-null ClassLoader before calling
// ClassLoaderUtil.getBootstrapClassLoader().
- //
+ //
// On other common JREs (such as Oracle, OpenJDK),
// Object.class.getClassLoader() returns null, but
// super(null) is commonly used for accessing the bootstrap
@@ -44,7 +44,7 @@ public class ClassLoaderUtil {
* Lazily create a singleton BootstrapClassLoader.
* This class loader might be necessary when ICU4J classes are
* initialized by bootstrap class loader.
- *
+ *
* @return The BootStrapClassLoader singleton instance
*/
private static ClassLoader getBootstrapClassLoader() {
@@ -54,10 +54,11 @@ public class ClassLoaderUtil {
ClassLoader cl = null;
if (System.getSecurityManager() != null) {
cl = AccessController.doPrivileged(new PrivilegedAction() {
- public BootstrapClassLoader run() {
- return new BootstrapClassLoader();
- }
- });
+ @Override
+ public BootstrapClassLoader run() {
+ return new BootstrapClassLoader();
+ }
+ });
} else {
cl = new BootstrapClassLoader();
}
diff --git a/icu4j/main/classes/core/src/com/ibm/icu/impl/DateNumberFormat.java b/icu4j/main/classes/core/src/com/ibm/icu/impl/DateNumberFormat.java
index 6c4d3a9c332..af077d5e899 100644
--- a/icu4j/main/classes/core/src/com/ibm/icu/impl/DateNumberFormat.java
+++ b/icu4j/main/classes/core/src/com/ibm/icu/impl/DateNumberFormat.java
@@ -67,7 +67,7 @@ public final class DateNumberFormat extends NumberFormat {
} catch (MissingResourceException ex) {
if ( !nsName.equals("latn") ) {
try {
- minusString = rb.getStringWithFallback("NumberElements/latn/symbols/minusSign");
+ minusString = rb.getStringWithFallback("NumberElements/latn/symbols/minusSign");
} catch (MissingResourceException ex1) {
minusString = "-";
}
@@ -90,18 +90,22 @@ public final class DateNumberFormat extends NumberFormat {
minusSign = elems[10];
}
+ @Override
public void setMaximumIntegerDigits(int newValue) {
maxIntDigits = newValue;
}
+ @Override
public int getMaximumIntegerDigits() {
return maxIntDigits;
}
+ @Override
public void setMinimumIntegerDigits(int newValue) {
minIntDigits = newValue;
}
+ @Override
public int getMinimumIntegerDigits() {
return minIntDigits;
}
@@ -130,11 +134,13 @@ public final class DateNumberFormat extends NumberFormat {
return digits.clone();
}
+ @Override
public StringBuffer format(double number, StringBuffer toAppendTo,
FieldPosition pos) {
throw new UnsupportedOperationException("StringBuffer format(double, StringBuffer, FieldPostion) is not implemented");
}
+ @Override
public StringBuffer format(long numberL, StringBuffer toAppendTo,
FieldPosition pos) {
@@ -173,17 +179,20 @@ public final class DateNumberFormat extends NumberFormat {
}
return toAppendTo;
}
-
+
+ @Override
public StringBuffer format(BigInteger number, StringBuffer toAppendTo,
FieldPosition pos) {
throw new UnsupportedOperationException("StringBuffer format(BigInteger, StringBuffer, FieldPostion) is not implemented");
}
+ @Override
public StringBuffer format(java.math.BigDecimal number, StringBuffer toAppendTo,
FieldPosition pos) {
throw new UnsupportedOperationException("StringBuffer format(BigDecimal, StringBuffer, FieldPostion) is not implemented");
}
+ @Override
public StringBuffer format(BigDecimal number,
StringBuffer toAppendTo, FieldPosition pos) {
throw new UnsupportedOperationException("StringBuffer format(BigDecimal, StringBuffer, FieldPostion) is not implemented");
@@ -194,6 +203,7 @@ public final class DateNumberFormat extends NumberFormat {
*/
private static final long PARSE_THRESHOLD = 922337203685477579L; // (Long.MAX_VALUE / 10) - 1
+ @Override
public Number parse(String text, ParsePosition parsePosition) {
long num = 0;
boolean sawNumber = false;
@@ -236,6 +246,7 @@ public final class DateNumberFormat extends NumberFormat {
return result;
}
+ @Override
public boolean equals(Object obj) {
if (obj == null || !super.equals(obj) || !(obj instanceof DateNumberFormat)) {
return false;
@@ -247,7 +258,8 @@ public final class DateNumberFormat extends NumberFormat {
&& this.positiveOnly == other.positiveOnly
&& Arrays.equals(this.digits, other.digits));
}
-
+
+ @Override
public int hashCode() {
return super.hashCode();
}
diff --git a/icu4j/main/classes/core/src/com/ibm/icu/impl/ICUBinary.java b/icu4j/main/classes/core/src/com/ibm/icu/impl/ICUBinary.java
index 0b4009062bd..98a1d0bb4e6 100644
--- a/icu4j/main/classes/core/src/com/ibm/icu/impl/ICUBinary.java
+++ b/icu4j/main/classes/core/src/com/ibm/icu/impl/ICUBinary.java
@@ -39,7 +39,7 @@ public final class ICUBinary {
private static final int DATA_FORMAT = 0x436d6e44;
private static final class IsAcceptable implements Authenticate {
- // @Override when we switch to Java 6
+ @Override
public boolean isDataVersionAcceptable(byte version[]) {
return version[0] == 1;
}
@@ -367,7 +367,7 @@ public final class ICUBinary {
} else if (i == key.length()) {
return -1; // key < table key because key is shorter.
}
- int diff = (int)key.charAt(i) - c2;
+ int diff = key.charAt(i) - c2;
if (diff != 0) {
return diff;
}
@@ -386,7 +386,7 @@ public final class ICUBinary {
} else if (i == key.length()) {
return -1; // key < table key because key is shorter.
}
- int diff = (int)key.charAt(i) - c2;
+ int diff = key.charAt(i) - c2;
if (diff != 0) {
return diff;
}
@@ -402,13 +402,13 @@ public final class ICUBinary {
{
/**
* Method used in ICUBinary.readHeader() to provide data format
- * authentication.
+ * authentication.
* @param version version of the current data
* @return true if dataformat is an acceptable version, false otherwise
*/
public boolean isDataVersionAcceptable(byte version[]);
}
-
+
// public methods --------------------------------------------------------
/**
@@ -610,7 +610,7 @@ public final class ICUBinary {
bytes.position(headerSize);
return // dataVersion
- ((int)bytes.get(20) << 24) |
+ (bytes.get(20) << 24) |
((bytes.get(21) & 0xff) << 16) |
((bytes.get(22) & 0xff) << 8) |
(bytes.get(23) & 0xff);
@@ -767,23 +767,23 @@ public final class ICUBinary {
}
// private variables -------------------------------------------------
-
+
/**
* Magic numbers to authenticate the data file
*/
private static final byte MAGIC1 = (byte)0xda;
private static final byte MAGIC2 = (byte)0x27;
-
+
/**
* File format authentication values
*/
private static final byte CHAR_SET_ = 0;
private static final byte CHAR_SIZE_ = 2;
-
+
/**
* Error messages
*/
- private static final String MAGIC_NUMBER_AUTHENTICATION_FAILED_ =
+ private static final String MAGIC_NUMBER_AUTHENTICATION_FAILED_ =
"ICU data file error: Not an ICU data file";
private static final String HEADER_AUTHENTICATION_FAILED_ =
"ICU data file error: Header authentication failed, please check if you have a valid ICU data file";
diff --git a/icu4j/main/classes/core/src/com/ibm/icu/impl/ICUConfig.java b/icu4j/main/classes/core/src/com/ibm/icu/impl/ICUConfig.java
index c4fe481e94b..2989e8501c7 100644
--- a/icu4j/main/classes/core/src/com/ibm/icu/impl/ICUConfig.java
+++ b/icu4j/main/classes/core/src/com/ibm/icu/impl/ICUConfig.java
@@ -63,6 +63,7 @@ public class ICUConfig {
if (System.getSecurityManager() != null) {
try {
val = AccessController.doPrivileged(new PrivilegedAction() {
+ @Override
public String run() {
return System.getProperty(fname);
}
diff --git a/icu4j/main/classes/core/src/com/ibm/icu/impl/ICUData.java b/icu4j/main/classes/core/src/com/ibm/icu/impl/ICUData.java
index fdc7df45de6..cf20dbf497f 100644
--- a/icu4j/main/classes/core/src/com/ibm/icu/impl/ICUData.java
+++ b/icu4j/main/classes/core/src/com/ibm/icu/impl/ICUData.java
@@ -93,6 +93,7 @@ public final class ICUData {
URL i = null;
if (System.getSecurityManager() != null) {
i = AccessController.doPrivileged(new PrivilegedAction() {
+ @Override
public URL run() {
return ICUData.class.getResource(resourceName);
}
@@ -107,6 +108,7 @@ public final class ICUData {
InputStream i = null;
if (System.getSecurityManager() != null) {
i = AccessController.doPrivileged(new PrivilegedAction() {
+ @Override
public InputStream run() {
return root.getResourceAsStream(resourceName);
}
@@ -129,6 +131,7 @@ public final class ICUData {
InputStream i = null;
if (System.getSecurityManager() != null) {
i = AccessController.doPrivileged(new PrivilegedAction() {
+ @Override
public InputStream run() {
return loader.getResourceAsStream(resourceName);
}
diff --git a/icu4j/main/classes/core/src/com/ibm/icu/impl/ICULocaleService.java b/icu4j/main/classes/core/src/com/ibm/icu/impl/ICULocaleService.java
index 9158dda0aa8..9f9ba536e9a 100644
--- a/icu4j/main/classes/core/src/com/ibm/icu/impl/ICULocaleService.java
+++ b/icu4j/main/classes/core/src/com/ibm/icu/impl/ICULocaleService.java
@@ -61,7 +61,7 @@ public class ICULocaleService extends ICUService {
* Convenience override for callers using locales. This uses
* createKey(ULocale.toString(), kind) to create a key, calls getKey, and then
* if actualReturn is not null, returns the actualResult from
- * getKey (stripping any prefix) into a ULocale.
+ * getKey (stripping any prefix) into a ULocale.
*/
public Object get(ULocale locale, int kind, ULocale[] actualReturn) {
Key key = createKey(locale, kind);
@@ -146,7 +146,7 @@ public class ICULocaleService extends ICUService {
}
return locales;
}
-
+
/**
* A subclass of Key that implements a locale fallback mechanism.
* The first locale to search for is the locale provided by the
@@ -157,7 +157,7 @@ public class ICULocaleService extends ICUService {
*
*
Canonicalization adjusts the locale string so that the
* section before the first understore is in lower case, and the rest
- * is in upper case, with no trailing underscores.
+ * is in upper case, with no trailing underscores.
*/
public static class LocaleKey extends ICUService.Key {
private int kind;
@@ -174,7 +174,7 @@ public class ICULocaleService extends ICUService {
public static LocaleKey createWithCanonicalFallback(String primaryID, String canonicalFallbackID) {
return createWithCanonicalFallback(primaryID, canonicalFallbackID, KIND_ANY);
}
-
+
/**
* Create a LocaleKey with canonical primary and fallback IDs.
*/
@@ -185,7 +185,7 @@ public class ICULocaleService extends ICUService {
String canonicalPrimaryID = ULocale.getName(primaryID);
return new LocaleKey(primaryID, canonicalPrimaryID, canonicalFallbackID, kind);
}
-
+
/**
* Create a LocaleKey with canonical primary and fallback IDs.
*/
@@ -196,7 +196,7 @@ public class ICULocaleService extends ICUService {
String canonicalPrimaryID = locale.getName();
return new LocaleKey(canonicalPrimaryID, canonicalPrimaryID, canonicalFallbackID, kind);
}
-
+
/**
* PrimaryID is the user's requested locale string,
* canonicalPrimaryID is this string in canonical form,
@@ -248,6 +248,7 @@ public class ICULocaleService extends ICUService {
/**
* Return the (canonical) original ID.
*/
+ @Override
public String canonicalID() {
return primaryID;
}
@@ -255,6 +256,7 @@ public class ICULocaleService extends ICUService {
/**
* Return the (canonical) current ID, or null if no current id.
*/
+ @Override
public String currentID() {
return currentID;
}
@@ -263,6 +265,7 @@ public class ICULocaleService extends ICUService {
* Return the (canonical) current descriptor, or null if no current id.
* Includes the keywords, whereas the ID does not include keywords.
*/
+ @Override
public String currentDescriptor() {
String result = currentID();
if (result != null) {
@@ -305,8 +308,9 @@ public class ICULocaleService extends ICUService {
*
First falls back through the primary ID, then through
* the fallbackID. The final fallback is "" (root)
* unless the primary id was "" (root), in which case
- * there is no fallback.
+ * there is no fallback.
*/
+ @Override
public boolean fallback() {
int x = currentID.lastIndexOf('_');
if (x != -1) {
@@ -329,9 +333,10 @@ public class ICULocaleService extends ICUService {
}
/**
- * If a key created from id would eventually fallback to match the
+ * If a key created from id would eventually fallback to match the
* canonical ID of this key, return true.
*/
+ @Override
public boolean isFallbackOf(String id) {
return LocaleUtility.isFallbackOf(canonicalID(), id);
}
@@ -369,11 +374,12 @@ public class ICULocaleService extends ICUService {
* the key against the supported IDs, and passes the canonicalLocale and
* kind off to handleCreate (which subclasses must implement).
*/
+ @Override
public Object create(Key key, ICUService service) {
if (handlesKey(key)) {
LocaleKey lkey = (LocaleKey)key;
int kind = lkey.kind();
-
+
ULocale uloc = lkey.currentLocale();
return handleCreate(uloc, kind, service);
} else {
@@ -395,6 +401,7 @@ public class ICULocaleService extends ICUService {
/**
* Override of superclass method.
*/
+ @Override
public void updateVisibleIDs(Map result) {
Set cache = getSupportedIDs();
for (String id : cache) {
@@ -409,6 +416,7 @@ public class ICULocaleService extends ICUService {
/**
* Return a localized name for the locale represented by id.
*/
+ @Override
public String getDisplayName(String id, ULocale locale) {
// assume if the user called this on us, we must have handled some fallback of this id
// if (isSupportedID(id)) {
@@ -432,15 +440,15 @@ public class ICULocaleService extends ICUService {
///CLOVER:ON
/**
- * Return true if this id is one the factory supports (visible or
+ * Return true if this id is one the factory supports (visible or
* otherwise).
*/
protected boolean isSupportedID(String id) {
return getSupportedIDs().contains(id);
}
-
+
/**
- * Return the set of ids that this factory supports (visible or
+ * Return the set of ids that this factory supports (visible or
* otherwise). This can be called often and might need to be
* cached if it is expensive to create.
*/
@@ -451,6 +459,7 @@ public class ICULocaleService extends ICUService {
/**
* For debugging.
*/
+ @Override
public String toString() {
StringBuilder buf = new StringBuilder(super.toString());
if (name != null) {
@@ -478,7 +487,7 @@ public class ICULocaleService extends ICUService {
public SimpleLocaleKeyFactory(Object obj, ULocale locale, int kind, boolean visible, String name) {
super(visible, name);
-
+
this.obj = obj;
this.id = locale.getBaseName();
this.kind = kind;
@@ -487,11 +496,12 @@ public class ICULocaleService extends ICUService {
/**
* Returns the service object if kind/locale match. Service is not used.
*/
+ @Override
public Object create(Key key, ICUService service) {
if (!(key instanceof LocaleKey)) {
return null;
}
-
+
LocaleKey lkey = (LocaleKey)key;
if (kind != LocaleKey.KIND_ANY && kind != lkey.kind()) {
return null;
@@ -499,14 +509,16 @@ public class ICULocaleService extends ICUService {
if (!id.equals(lkey.currentID())) {
return null;
}
-
+
return obj;
}
+ @Override
protected boolean isSupportedID(String idToCheck) {
return this.id.equals(idToCheck);
}
+ @Override
public void updateVisibleIDs(Map result) {
if (visible) {
result.put(id, this);
@@ -515,6 +527,7 @@ public class ICULocaleService extends ICUService {
}
}
+ @Override
public String toString() {
StringBuilder buf = new StringBuilder(super.toString());
buf.append(", id: ");
@@ -555,13 +568,15 @@ public class ICULocaleService extends ICUService {
/**
* Return the supported IDs. This is the set of all locale names for the bundleName.
*/
+ @Override
protected Set getSupportedIDs() {
- return ICUResourceBundle.getFullLocaleNameSet(bundleName, loader());
+ return ICUResourceBundle.getFullLocaleNameSet(bundleName, loader());
}
/**
* Override of superclass method.
*/
+ @Override
public void updateVisibleIDs(Map result) {
Set visibleIDs = ICUResourceBundle.getAvailableLocaleNameSet(bundleName, loader()); // only visible ids
for (String id : visibleIDs) {
@@ -573,6 +588,7 @@ public class ICULocaleService extends ICUService {
* Create the service. The default implementation returns the resource bundle
* for the locale, ignoring kind, and service.
*/
+ @Override
protected Object handleCreate(ULocale loc, int kind, ICUService service) {
return ICUResourceBundle.getBundleInstance(bundleName, loc, loader());
}
@@ -581,6 +597,7 @@ public class ICULocaleService extends ICUService {
return ClassLoaderUtil.getClassLoader(getClass());
}
+ @Override
public String toString() {
return super.toString() + ", bundle: " + bundleName;
}
@@ -604,6 +621,7 @@ public class ICULocaleService extends ICUService {
return fallbackLocaleName;
}
+ @Override
public Key createKey(String id) {
return LocaleKey.createWithCanonicalFallback(id, validateFallbackLocale());
}
diff --git a/icu4j/main/classes/core/src/com/ibm/icu/impl/ICUNotifier.java b/icu4j/main/classes/core/src/com/ibm/icu/impl/ICUNotifier.java
index 72453218d8b..9e833723462 100644
--- a/icu4j/main/classes/core/src/com/ibm/icu/impl/ICUNotifier.java
+++ b/icu4j/main/classes/core/src/com/ibm/icu/impl/ICUNotifier.java
@@ -21,12 +21,12 @@ import java.util.List;
* eventually dequeues the list and calls notifyListener on each
* listener in the list.
*
- *
Subclasses override acceptsListener and notifyListener
+ *
Subclasses override acceptsListener and notifyListener
* to add type-safe notification. AcceptsListener should return
* true if the listener is of the appropriate type; ICUNotifier
* itself will ensure the listener is non-null and that the
* identical listener is not already registered with the Notifier.
- * NotifyListener should cast the listener to the appropriate
+ * NotifyListener should cast the listener to the appropriate
* type and call the appropriate method on the listener.
*/
public abstract class ICUNotifier {
@@ -39,7 +39,7 @@ public abstract class ICUNotifier {
* The listener must not be null. AcceptsListener must return
* true for the listener. Attempts to concurrently
* register the identical listener more than once will be
- * silently ignored.
+ * silently ignored.
*/
public void addListener(EventListener l) {
if (l == null) {
@@ -137,6 +137,7 @@ public abstract class ICUNotifier {
* Wait for a notification to be queued, then notify all
* listeners listed in the notification.
*/
+ @Override
public void run() {
EventListener[] list;
while (true) {
diff --git a/icu4j/main/classes/core/src/com/ibm/icu/impl/ICURWLock.java b/icu4j/main/classes/core/src/com/ibm/icu/impl/ICURWLock.java
index 86e6fcae1bb..6cc93a5cfe9 100644
--- a/icu4j/main/classes/core/src/com/ibm/icu/impl/ICURWLock.java
+++ b/icu4j/main/classes/core/src/com/ibm/icu/impl/ICURWLock.java
@@ -88,9 +88,10 @@ public class ICURWLock {
/**
* Return a string listing all the stats.
*/
+ @Override
public String toString() {
return " rc: " + _rc +
- " mrc: " + _mrc +
+ " mrc: " + _mrc +
" wrc: " + _wrc +
" wc: " + _wc +
" wwc: " + _wwc;
@@ -114,7 +115,7 @@ public class ICURWLock {
stats = null;
return result;
}
-
+
/**
* Return a snapshot of the current stats. This does not reset the stats.
*/
@@ -130,7 +131,7 @@ public class ICURWLock {
*
If there's a writer, or a waiting writer, increment the
* waiting reader count and block on this. Otherwise
* increment the active reader count and return. Caller must call
- * releaseRead when done (for example, in a finally block).
+ * releaseRead when done (for example, in a finally block).
*/
public void acquireRead() {
if (stats != null) { // stats is null by default
@@ -168,7 +169,7 @@ public class ICURWLock {
* having an active writer and return. Otherwise, add a lock to the
* end of the waiting writer list, and block on it. Caller
* must call releaseWrite when done (for example, in a finally
- * block).
+ * block).
*/
public void acquireWrite() {
if (stats != null) { // stats is null by default
@@ -189,7 +190,7 @@ public class ICURWLock {
*
If there are waiting readers, make them all active and
* notify all of them. Otherwise, notify the oldest waiting
* writer, if any. Call when finished with work controlled by
- * acquireWrite.
+ * acquireWrite.
*/
public void releaseWrite() {
rwl.writeLock().unlock();
diff --git a/icu4j/main/classes/core/src/com/ibm/icu/impl/ICUService.java b/icu4j/main/classes/core/src/com/ibm/icu/impl/ICUService.java
index ae5e96dd949..4db16b382b8 100644
--- a/icu4j/main/classes/core/src/com/ibm/icu/impl/ICUService.java
+++ b/icu4j/main/classes/core/src/com/ibm/icu/impl/ICUService.java
@@ -297,6 +297,7 @@ public class ICUService extends ICUNotifier {
* Return the service instance if the factory's id is equal to
* the key's currentID. Service is ignored.
*/
+ @Override
public Object create(Key key, ICUService service) {
if (id.equals(key.currentID())) {
return instance;
@@ -308,6 +309,7 @@ public class ICUService extends ICUNotifier {
* If visible, adds a mapping from id -> this to the result,
* otherwise removes id from result.
*/
+ @Override
public void updateVisibleIDs(Map result) {
if (visible) {
result.put(id, this);
@@ -321,6 +323,7 @@ public class ICUService extends ICUNotifier {
* otherwise returns null. (This default implementation has
* no localized id information.)
*/
+ @Override
public String getDisplayName(String identifier, ULocale locale) {
return (visible && id.equals(identifier)) ? identifier : null;
}
@@ -328,6 +331,7 @@ public class ICUService extends ICUNotifier {
/**
* For debugging.
*/
+ @Override
public String toString() {
StringBuilder buf = new StringBuilder(super.toString());
buf.append(", id: ");
@@ -625,12 +629,12 @@ public class ICUService extends ICUNotifier {
return f.getDisplayName(id, locale);
}
}
-
+
return null;
}
/**
- * Convenience override of getDisplayNames(ULocale, Comparator, String) that
+ * Convenience override of getDisplayNames(ULocale, Comparator, String) that
* uses the current default Locale as the locale, null as
* the comparator, and null for the matchID.
*/
@@ -685,7 +689,7 @@ public class ICUService extends ICUNotifier {
synchronized (this) {
if (ref == dnref || dnref == null) {
dncache = new TreeMap(com); // sorted
-
+
Map m = getVisibleIDMap();
Iterator> ei = m.entrySet().iterator();
while (ei.hasNext()) {
@@ -923,6 +927,7 @@ public class ICUService extends ICUNotifier {
* requires a ServiceListener. Subclasses can override to accept
* different listeners.
*/
+ @Override
protected boolean acceptsListener(EventListener l) {
return l instanceof ServiceListener;
}
@@ -931,6 +936,7 @@ public class ICUService extends ICUNotifier {
* Notify the listener, which by default is a ServiceListener.
* Subclasses can override to use a different listener.
*/
+ @Override
protected void notifyListener(EventListener l) {
((ServiceListener)l).serviceChanged(this);
}
@@ -959,6 +965,7 @@ public class ICUService extends ICUNotifier {
/**
* Returns the result of super.toString, appending the name in curly braces.
*/
+ @Override
public String toString() {
return super.toString() + "{" + name + "}";
}
diff --git a/icu4j/main/classes/core/src/com/ibm/icu/impl/IllegalIcuArgumentException.java b/icu4j/main/classes/core/src/com/ibm/icu/impl/IllegalIcuArgumentException.java
index 257306f0c61..b9902a6b00f 100644
--- a/icu4j/main/classes/core/src/com/ibm/icu/impl/IllegalIcuArgumentException.java
+++ b/icu4j/main/classes/core/src/com/ibm/icu/impl/IllegalIcuArgumentException.java
@@ -18,17 +18,18 @@ public class IllegalIcuArgumentException extends IllegalArgumentException {
public IllegalIcuArgumentException(String errorMessage) {
super(errorMessage);
}
-
+
public IllegalIcuArgumentException(Throwable cause) {
super(cause);
}
-
+
public IllegalIcuArgumentException(String errorMessage, Throwable cause) {
super(errorMessage, cause);
}
-
+
+ @Override
public synchronized IllegalIcuArgumentException initCause(Throwable cause) {
return (IllegalIcuArgumentException) super.initCause(cause);
}
-
+
}
diff --git a/icu4j/main/classes/core/src/com/ibm/icu/impl/IntTrie.java b/icu4j/main/classes/core/src/com/ibm/icu/impl/IntTrie.java
index a08fe684815..ca45dedf7be 100644
--- a/icu4j/main/classes/core/src/com/ibm/icu/impl/IntTrie.java
+++ b/icu4j/main/classes/core/src/com/ibm/icu/impl/IntTrie.java
@@ -30,10 +30,10 @@ public class IntTrie extends Trie
/**
*
Creates a new Trie with the settings for the trie data.
- *
Unserialize the 32-bit-aligned input stream and use the data for the
+ *
Unserialize the 32-bit-aligned input stream and use the data for the
* trie.
* @param bytes file buffer to a ICU data file, containing the trie
- * @param dataManipulate object which provides methods to parse the char
+ * @param dataManipulate object which provides methods to parse the char
* data
* @throws IOException thrown when data reading fails
*/
@@ -122,7 +122,7 @@ public class IntTrie extends Trie
// fastpath for U+0000..U+D7FF
if(0 <= ch && ch < UTF16.LEAD_SURROGATE_MIN_VALUE) {
// copy of getRawOffset()
- offset = (m_index_[ch >> INDEX_STAGE_1_SHIFT_] << INDEX_STAGE_2_SHIFT_)
+ offset = (m_index_[ch >> INDEX_STAGE_1_SHIFT_] << INDEX_STAGE_2_SHIFT_)
+ (ch & INDEX_STAGE_3_MASK_);
return m_data_[offset];
}
@@ -202,15 +202,15 @@ public class IntTrie extends Trie
}
return m_initialValue_;
}
-
+
/**
*
Gets the latin 1 fast path value.
- *
Note this only works if latin 1 characters have their own linear
+ *
Note this only works if latin 1 characters have their own linear
* array.
* @param ch latin 1 characters
* @return value associated with latin character
*/
- public final int getLatin1LinearValue(char ch)
+ public final int getLatin1LinearValue(char ch)
{
return m_data_[INDEX_STAGE_3_MASK_ + 1 + ch];
}
@@ -222,7 +222,8 @@ public class IntTrie extends Trie
* otherwise
*/
///CLOVER:OFF
- public boolean equals(Object other)
+ @Override
+ public boolean equals(Object other)
{
boolean result = super.equals(other);
if (result && other instanceof IntTrie) {
@@ -235,13 +236,14 @@ public class IntTrie extends Trie
}
return false;
}
-
+
+ @Override
public int hashCode() {
assert false : "hashCode not designed";
return 42;
}
///CLOVER:ON
-
+
// protected methods -----------------------------------------------
/**
@@ -249,6 +251,7 @@ public class IntTrie extends Trie
* data array
* @param bytes data buffer containing trie data
*/
+ @Override
protected final void unserialize(ByteBuffer bytes)
{
super.unserialize(bytes);
@@ -263,6 +266,7 @@ public class IntTrie extends Trie
* @param trail trailing surrogate
* @return offset to data
*/
+ @Override
protected final int getSurrogateOffset(char lead, char trail)
{
if (m_dataManipulate_ == null) {
@@ -281,7 +285,7 @@ public class IntTrie extends Trie
// value: m_initialValue_
return -1;
}
-
+
/**
* Gets the value at the argument index.
* For use internally in TrieIterator
@@ -289,22 +293,24 @@ public class IntTrie extends Trie
* @return 32 bit value
* @see com.ibm.icu.impl.TrieIterator
*/
+ @Override
protected final int getValue(int index)
{
return m_data_[index];
}
-
+
/**
* Gets the default initial value
- * @return 32 bit value
+ * @return 32 bit value
*/
+ @Override
protected final int getInitialValue()
{
return m_initialValue_;
}
// package private methods -----------------------------------------
-
+
/**
* Internal constructor for builder use
* @param index the index array to be slotted into this trie
@@ -321,7 +327,7 @@ public class IntTrie extends Trie
m_dataLength_ = m_data_.length;
m_initialValue_ = initialvalue;
}
-
+
// private data members --------------------------------------------
/**
diff --git a/icu4j/main/classes/core/src/com/ibm/icu/impl/IterableComparator.java b/icu4j/main/classes/core/src/com/ibm/icu/impl/IterableComparator.java
index 3e71d938c07..38c1983f20b 100644
--- a/icu4j/main/classes/core/src/com/ibm/icu/impl/IterableComparator.java
+++ b/icu4j/main/classes/core/src/com/ibm/icu/impl/IterableComparator.java
@@ -32,6 +32,7 @@ public class IterableComparator implements Comparator> {
this.shorterFirst = shorterFirst ? 1 : -1;
}
+ @Override
public int compare(Iterable a, Iterable b) {
if (a == null) {
return b == null ? 0 : -shorterFirst;
diff --git a/icu4j/main/classes/core/src/com/ibm/icu/impl/LocaleDisplayNamesImpl.java b/icu4j/main/classes/core/src/com/ibm/icu/impl/LocaleDisplayNamesImpl.java
index 7d05ffe30e2..03ff19efddd 100644
--- a/icu4j/main/classes/core/src/com/ibm/icu/impl/LocaleDisplayNamesImpl.java
+++ b/icu4j/main/classes/core/src/com/ibm/icu/impl/LocaleDisplayNamesImpl.java
@@ -637,10 +637,12 @@ public class LocaleDisplayNamesImpl extends LocaleDisplayNames {
path, locale.getBaseName());
}
+ @Override
public ULocale getLocale() {
return bundle.getULocale();
}
+ @Override
public String get(String tableName, String subTableName, String code) {
return ICUResourceTableAccess.getTableString(bundle, tableName, subTableName,
code, nullIfNotFound ? null : code);
@@ -654,6 +656,7 @@ public class LocaleDisplayNamesImpl extends LocaleDisplayNames {
return (DataTables) Class.forName(className).newInstance();
} catch (Throwable t) {
return new DataTables() {
+ @Override
public DataTable get(ULocale locale, boolean nullIfNotFound) {
return new DataTable(nullIfNotFound);
}
diff --git a/icu4j/main/classes/core/src/com/ibm/icu/impl/LocaleIDParser.java b/icu4j/main/classes/core/src/com/ibm/icu/impl/LocaleIDParser.java
index 1685656bce7..3d1144fce43 100644
--- a/icu4j/main/classes/core/src/com/ibm/icu/impl/LocaleIDParser.java
+++ b/icu4j/main/classes/core/src/com/ibm/icu/impl/LocaleIDParser.java
@@ -21,22 +21,22 @@ import com.ibm.icu.impl.locale.AsciiUtil;
* Utility class to parse and normalize locale ids (including POSIX style)
*/
public final class LocaleIDParser {
-
+
/**
* Char array representing the locale ID.
*/
private char[] id;
-
+
/**
* Current position in {@link #id} (while parsing).
*/
private int index;
-
+
/**
* Temporary buffer for parsed sections of data.
*/
private StringBuilder buffer;
-
+
// um, don't handle POSIX ids unless we request it. why not? well... because.
private boolean canonicalize;
private boolean hadCountry;
@@ -73,14 +73,14 @@ public final class LocaleIDParser {
}
// utilities for working on text in the buffer
-
+
/**
* Append c to the buffer.
*/
private void append(char c) {
buffer.append(c);
}
-
+
private void addSeparator() {
append(UNDERSCORE);
}
@@ -194,7 +194,7 @@ public final class LocaleIDParser {
*/
private int parseLanguage() {
int startLength = buffer.length();
-
+
if (haveExperimentalLanguagePrefix()) {
append(AsciiUtil.toLower(id[0]));
append(HYPHEN);
@@ -280,7 +280,7 @@ public final class LocaleIDParser {
if (!atTerminator()) {
int oldIndex = index;
++index;
-
+
char c;
while (!isTerminatorOrIDSeparator(c = next()) && AsciiUtil.isAlpha(c));
--index;
@@ -397,7 +397,7 @@ public final class LocaleIDParser {
boolean skipping = false;
char c;
boolean firstPass = true;
-
+
while ((c = next()) != DONE) {
if (c == DOT) {
start = false;
@@ -591,6 +591,7 @@ public final class LocaleIDParser {
private Comparator getKeyComparator() {
final Comparator comp = new Comparator() {
+ @Override
public int compare(String lhs, String rhs) {
return lhs.compareTo(rhs);
}
diff --git a/icu4j/main/classes/core/src/com/ibm/icu/impl/Norm2AllModes.java b/icu4j/main/classes/core/src/com/ibm/icu/impl/Norm2AllModes.java
index 80114791bda..a3ac7a3d513 100644
--- a/icu4j/main/classes/core/src/com/ibm/icu/impl/Norm2AllModes.java
+++ b/icu4j/main/classes/core/src/com/ibm/icu/impl/Norm2AllModes.java
@@ -342,6 +342,7 @@ public final class Norm2AllModes {
}
private static CacheBase cache =
new SoftCache() {
+ @Override
protected Norm2AllModes createInstance(String key, ByteBuffer bytes) {
Normalizer2Impl impl;
if(bytes==null) {
diff --git a/icu4j/main/classes/core/src/com/ibm/icu/impl/Normalizer2Impl.java b/icu4j/main/classes/core/src/com/ibm/icu/impl/Normalizer2Impl.java
index 67e06f7ff38..86a02479737 100644
--- a/icu4j/main/classes/core/src/com/ibm/icu/impl/Normalizer2Impl.java
+++ b/icu4j/main/classes/core/src/com/ibm/icu/impl/Normalizer2Impl.java
@@ -206,6 +206,7 @@ public final class Normalizer2Impl {
// They assume that the cc or trailCC of their input is 0.
// Most of them implement Appendable interface methods.
// @Override when we switch to Java 6
+ @Override
public ReorderingBuffer append(char c) {
str.append(c);
lastCC=0;
@@ -218,6 +219,7 @@ public final class Normalizer2Impl {
reorderStart=str.length();
}
// @Override when we switch to Java 6
+ @Override
public ReorderingBuffer append(CharSequence s) {
if(s.length()!=0) {
str.append(s);
@@ -227,6 +229,7 @@ public final class Normalizer2Impl {
return this;
}
// @Override when we switch to Java 6
+ @Override
public ReorderingBuffer append(CharSequence s, int start, int limit) {
if(start!=limit) {
str.append(s, start, limit);
@@ -413,6 +416,7 @@ public final class Normalizer2Impl {
private static final class IsAcceptable implements ICUBinary.Authenticate {
// @Override when we switch to Java 6
+ @Override
public boolean isDataVersionAcceptable(byte version[]) {
return version[0]==2;
}
@@ -560,6 +564,7 @@ public final class Normalizer2Impl {
}
}
private static final Trie2.ValueMapper segmentStarterMapper=new Trie2.ValueMapper() {
+ @Override
public int map(int in) {
return in&CANON_NOT_SEGMENT_STARTER;
}
@@ -1829,7 +1834,7 @@ public final class Normalizer2Impl {
}
if(key1==(firstUnit&COMP_1_TRAIL_MASK)) {
if((firstUnit&COMP_1_TRIPLE)!=0) {
- return ((int)compositions.charAt(list+1)<<16)|compositions.charAt(list+2);
+ return (compositions.charAt(list+1)<<16)|compositions.charAt(list+2);
} else {
return compositions.charAt(list+1);
}
@@ -1874,7 +1879,7 @@ public final class Normalizer2Impl {
compositeAndFwd=maybeYesCompositions.charAt(list+1);
list+=2;
} else {
- compositeAndFwd=(((int)maybeYesCompositions.charAt(list+1)&~COMP_2_TRAIL_MASK)<<16)|
+ compositeAndFwd=((maybeYesCompositions.charAt(list+1)&~COMP_2_TRAIL_MASK)<<16)|
maybeYesCompositions.charAt(list+2);
list+=3;
}
diff --git a/icu4j/main/classes/core/src/com/ibm/icu/impl/OlsonTimeZone.java b/icu4j/main/classes/core/src/com/ibm/icu/impl/OlsonTimeZone.java
index 550681c2f0c..44e97872fe3 100644
--- a/icu4j/main/classes/core/src/com/ibm/icu/impl/OlsonTimeZone.java
+++ b/icu4j/main/classes/core/src/com/ibm/icu/impl/OlsonTimeZone.java
@@ -45,52 +45,52 @@ import com.ibm.icu.util.UResourceBundle;
*
* a. Zone (table). A zone is a table resource contains several
* type of resources below:
- *
+ *
* - typeOffsets:intvector (Required)
- *
+ *
* Sets of UTC raw/dst offset pairs in seconds. Entries at
* 2n represents raw offset and 2n+1 represents dst offset
* paired with the raw offset at 2n. The very first pair represents
* the initial zone offset (before the first transition) always.
*
- * - trans:intvector (Optional)
- *
+ * - trans:intvector (Optional)
+ *
* List of transition times represented by 32bit seconds from the
* epoch (1970-01-01T00:00Z) in ascending order.
- *
+ *
* - transPre32/transPost32:intvector (Optional)
- *
+ *
* List of transition times before/after 32bit minimum seconds.
* Each time is represented by a pair of 32bit integer.
- *
+ *
* - typeMap:bin (Optional)
- *
+ *
* Array of bytes representing the mapping between each transition
* time (transPre32/trans/transPost32) and its corresponding offset
* data (typeOffsets).
- *
+ *
* - finalRule:string (Optional)
- *
+ *
* If a recurrent transition rule is applicable to a zone forever
* after the final transition time, finalRule represents the rule
* in Rules data.
- *
+ *
* - finalRaw:int (Optional)
- *
+ *
* When finalRule is available, finalRaw is required and specifies
* the raw (base) offset of the rule.
- *
+ *
* - finalYear:int (Optional)
- *
+ *
* When finalRule is available, finalYear is required and specifies
* the start year of the rule.
- *
+ *
* - links:intvector (Optional)
- *
+ *
* When this zone data is shared with other zones, links specifies
* all zones including the zone itself. Each zone is referenced by
* integer index.
- *
+ *
* b. Link (int, length 1). A link zone is an int resource. The
* integer is the zone number of the target zone. The key of this
* resource is an alternate name for the target zone. This data
@@ -317,8 +317,8 @@ public class OlsonTimeZone extends BasicTimeZone {
int[] fields = Grego.timeToFields(current, null);
// Find start of this year, and start of next year
- long start = Grego.fieldsToDay(fields[0], 0, 1) * SECONDS_PER_DAY;
- long limit = Grego.fieldsToDay(fields[0] + 1, 0, 1) * SECONDS_PER_DAY;
+ long start = Grego.fieldsToDay(fields[0], 0, 1) * SECONDS_PER_DAY;
+ long limit = Grego.fieldsToDay(fields[0] + 1, 0, 1) * SECONDS_PER_DAY;
// Return TRUE if DST is observed at any time during the current
// year.
@@ -485,7 +485,7 @@ public class OlsonTimeZone extends BasicTimeZone {
}
private void construct(UResourceBundle top, UResourceBundle res){
-
+
if ((top == null || res == null)) {
throw new IllegalArgumentException();
}
@@ -537,21 +537,21 @@ public class OlsonTimeZone extends BasicTimeZone {
int idx = 0;
if (transPre32 != null) {
for (int i = 0; i < transPre32.length / 2; i++, idx++) {
- transitionTimes64[idx] =
- (((long)transPre32[i * 2]) & 0x00000000FFFFFFFFL) << 32
- | (((long)transPre32[i * 2 + 1]) & 0x00000000FFFFFFFFL);
+ transitionTimes64[idx] =
+ ((transPre32[i * 2]) & 0x00000000FFFFFFFFL) << 32
+ | ((transPre32[i * 2 + 1]) & 0x00000000FFFFFFFFL);
}
}
if (trans32 != null) {
for (int i = 0; i < trans32.length; i++, idx++) {
- transitionTimes64[idx] = (long)trans32[i];
+ transitionTimes64[idx] = trans32[i];
}
}
if (transPost32 != null) {
for (int i = 0; i < transPost32.length / 2; i++, idx++) {
- transitionTimes64[idx] =
- (((long)transPost32[i * 2]) & 0x00000000FFFFFFFFL) << 32
- | (((long)transPost32[i * 2 + 1]) & 0x00000000FFFFFFFFL);
+ transitionTimes64[idx] =
+ ((transPost32[i * 2]) & 0x00000000FFFFFFFFL) << 32
+ | ((transPost32[i * 2 + 1]) & 0x00000000FFFFFFFFL);
}
}
} else {
@@ -607,7 +607,7 @@ public class OlsonTimeZone extends BasicTimeZone {
finalStartYear = r.getInt();
// Note: Setting finalStartYear to the finalZone is problematic. When a date is around
- // year boundary, SimpleTimeZone may return false result when DST is observed at the
+ // year boundary, SimpleTimeZone may return false result when DST is observed at the
// beginning of year. We could apply safe margin (day or two), but when one of recurrent
// rules falls around year boundary, it could return false result. Without setting the
// start year, finalZone works fine around the year boundary of the start year.
@@ -747,7 +747,7 @@ public class OlsonTimeZone extends BasicTimeZone {
}
private int getInt(byte val){
- return val & 0xFF;
+ return val & 0xFF;
}
/*
@@ -827,7 +827,7 @@ public class OlsonTimeZone extends BasicTimeZone {
buf.append(",finalStartMillis=" + finalStartMillis);
buf.append(",finalZone=" + finalZone);
buf.append(']');
-
+
return buf.toString();
}
@@ -874,7 +874,7 @@ public class OlsonTimeZone extends BasicTimeZone {
* If and only if finalYear == INT32_MAX then finalZone == 0.
*/
private SimpleTimeZone finalZone = null; // owned, may be NULL
-
+
/**
* The canonical ID of this zone. Initialized when {@link #getCanonicalID()}
* is invoked first time, or {@link #setID(String)} is called.
@@ -885,7 +885,7 @@ public class OlsonTimeZone extends BasicTimeZone {
private static final boolean DEBUG = ICUDebug.enabled("olson");
private static final int SECONDS_PER_DAY = 24*60*60;
-
+
private static UResourceBundle loadRule(UResourceBundle top, String ruleid) {
UResourceBundle r = top.get("Rules");
r = r.get(ruleid);
@@ -919,9 +919,9 @@ public class OlsonTimeZone extends BasicTimeZone {
public int hashCode(){
int ret = (int) (finalStartYear ^ (finalStartYear>>>4) +
transitionCount ^ (transitionCount>>>6) +
- typeCount ^ (typeCount>>>8) +
+ typeCount ^ (typeCount>>>8) +
Double.doubleToLongBits(finalStartMillis)+
- (finalZone == null ? 0 : finalZone.hashCode()) +
+ (finalZone == null ? 0 : finalZone.hashCode()) +
super.hashCode());
if (transitionTimes64 != null) {
for(int i=0; i 0xffff) {
// too many rows for a 16-bit trie
@@ -37,6 +41,6 @@ public class PVecToTrieCompactHandler implements CompactHandler {
} else {
builder = new IntTrieBuilder(null, 100000, initialValue,
initialValue, false);
- }
+ }
}
}
diff --git a/icu4j/main/classes/core/src/com/ibm/icu/impl/PropsVectors.java b/icu4j/main/classes/core/src/com/ibm/icu/impl/PropsVectors.java
index 0db096ef6af..0df6063ddea 100644
--- a/icu4j/main/classes/core/src/com/ibm/icu/impl/PropsVectors.java
+++ b/icu4j/main/classes/core/src/com/ibm/icu/impl/PropsVectors.java
@@ -9,9 +9,9 @@
/**
* Store bits (Unicode character properties) in bit set vectors.
- *
+ *
* This is a port of the C++ class UPropsVectors from ICU4C
- *
+ *
* @author Shaopeng Jia
* @internal
*/
@@ -23,15 +23,15 @@ import java.util.Comparator;
/**
* Unicode Properties Vectors associated with code point ranges.
- *
+ *
* Rows of primitive integers in a contiguous array store the range limits and
* the properties vectors.
- *
+ *
* In each row, row[0] contains the start code point and row[1] contains the
* limit code point, which is the start of the next range.
- *
+ *
* Initially, there is only one range [0..0x110000] with values 0.
- *
+ *
* It would be possible to store only one range boundary per row, but
* self-contained rows allow to later sort them by contents.
*/
@@ -45,10 +45,10 @@ public class PropsVectors {
private boolean isCompacted;
// internal function to compare elements in v and target. Return true iff
- // elements in v starting from index1 to index1 + length - 1
+ // elements in v starting from index1 to index1 + length - 1
// are exactly the same as elements in target
// starting from index2 to index2 + length - 1
- private boolean areElementsSame(int index1, int[] target, int index2,
+ private boolean areElementsSame(int index1, int[] target, int index2,
int length) {
for (int i = 0; i < length; ++i) {
if (v[index1 + i] != target[index2 + i]) {
@@ -57,7 +57,7 @@ public class PropsVectors {
}
return true;
}
-
+
// internal function which given rangeStart, returns
// index where v[index]<=rangeStart() {
+ @Override
public int compare(Integer o1, Integer o2) {
int indexOfRow1 = o1.intValue();
int indexOfRow2 = o2.intValue();
@@ -436,10 +437,10 @@ public class PropsVectors {
compactor.startRealValues(count);
/*
- * Move vector contents up to a contiguous array with only unique
+ * Move vector contents up to a contiguous array with only unique
* vector values, and call the handler function for each vector.
- *
- * This destroys the Properties Vector structure and replaces it
+ *
+ * This destroys the Properties Vector structure and replaces it
* with an array of just vector values.
*/
int[] temp = new int[count];
@@ -450,7 +451,7 @@ public class PropsVectors {
// count a new values vector if it is different
// from the current one
- if (count < 0 || !areElementsSame(indexArray[i].intValue() + 2,
+ if (count < 0 || !areElementsSame(indexArray[i].intValue() + 2,
temp, count, valueColumns)) {
count += valueColumns;
System.arraycopy(v, indexArray[i].intValue() + 2, temp, count,
@@ -462,7 +463,7 @@ public class PropsVectors {
}
}
v = temp;
-
+
// count is at the beginning of the last vector,
// add one to include that last vector
rows = count / valueColumns + 1;
@@ -470,7 +471,7 @@ public class PropsVectors {
/*
* Get the vectors array after calling compact().
- *
+ *
* @throws IllegalStateException
*/
public int[] getCompactedArray() {
@@ -483,7 +484,7 @@ public class PropsVectors {
/*
* Get the number of rows for the compacted array.
- *
+ *
* @throws IllegalStateException
*/
public int getCompactedRows() {
@@ -496,7 +497,7 @@ public class PropsVectors {
/*
* Get the number of columns for the compacted array.
- *
+ *
* @throws IllegalStateException
*/
public int getCompactedColumns() {
@@ -520,6 +521,7 @@ public class PropsVectors {
// inner class implementation of Trie.DataManipulate
private static class DefaultGetFoldingOffset implements Trie.DataManipulate {
+ @Override
public int getFoldingOffset(int value) {
return value;
}
@@ -534,8 +536,9 @@ public class PropsVectors {
builder = inBuilder;
}
+ @Override
public int getFoldedValue(int start, int offset) {
- int initialValue = builder.m_initialValue_;
+ int initialValue = builder.m_initialValue_;
int limit = start + 0x400;
while (start < limit) {
boolean[] inBlockZero = new boolean[1];
@@ -551,7 +554,7 @@ public class PropsVectors {
return 0;
}
}
-
+
public static interface CompactHandler {
public void setRowIndexForRange(int start, int end, int rowIndex);
public void setRowIndexForInitialValue(int rowIndex);
diff --git a/icu4j/main/classes/core/src/com/ibm/icu/impl/Relation.java b/icu4j/main/classes/core/src/com/ibm/icu/impl/Relation.java
index 01531d3e7a1..2f2f184eb3d 100644
--- a/icu4j/main/classes/core/src/com/ibm/icu/impl/Relation.java
+++ b/icu4j/main/classes/core/src/com/ibm/icu/impl/Relation.java
@@ -57,7 +57,7 @@ public class Relation implements Freezable> { // TODO: add ,
this.setCreator.newInstance(setComparatorParam); // check to make sure compiles
} else {
this.setCreator = ((Class extends Set>)setCreator).getConstructor(Comparator.class);
- this.setCreator.newInstance(setComparatorParam); // check to make sure compiles
+ this.setCreator.newInstance(setComparatorParam); // check to make sure compiles
}
data = map == null ? new HashMap>() : map;
} catch (Exception e) {
@@ -85,11 +85,11 @@ public class Relation implements Freezable> { // TODO: add ,
public final Set> entrySet() {
return keyValueSet();
}
-
+
public Set>> keyValuesSet() {
return data.entrySet();
}
-
+
public Set> keyValueSet() {
Set> result = new LinkedHashSet>();
for (K key : data.keySet()) {
@@ -100,6 +100,7 @@ public class Relation implements Freezable> { // TODO: add ,
return result;
}
+ @Override
public boolean equals(Object o) {
if (o == null)
return false;
@@ -123,6 +124,7 @@ public class Relation implements Freezable> { // TODO: add ,
return data.get(key);
}
+ @Override
public int hashCode() {
return data.hashCode();
}
@@ -163,7 +165,7 @@ public class Relation implements Freezable> { // TODO: add ,
private Set newSet() {
try {
- return (Set) setCreator.newInstance(setComparatorParam);
+ return setCreator.newInstance(setComparatorParam);
} catch (Exception e) {
throw (RuntimeException) new IllegalArgumentException("Can't create new set").initCause(e);
}
@@ -222,6 +224,7 @@ public class Relation implements Freezable> { // TODO: add ,
return result;
}
+ @Override
public String toString() {
return data.toString();
}
@@ -241,14 +244,17 @@ public class Relation implements Freezable> { // TODO: add ,
this.value = e.getValue();
}
+ @Override
public K getKey() {
return key;
}
+ @Override
public V getValue() {
return value;
}
+ @Override
public V setValue(V value) {
V oldValue = this.value;
this.value = value;
@@ -274,10 +280,12 @@ public class Relation implements Freezable> { // TODO: add ,
volatile boolean frozen = false;
+ @Override
public boolean isFrozen() {
return frozen;
}
+ @Override
public Relation freeze() {
if (!frozen) {
// does not handle one level down, so we do that on a case-by-case basis
@@ -291,6 +299,7 @@ public class Relation implements Freezable> { // TODO: add ,
return this;
}
+ @Override
public Relation cloneAsThawed() {
// TODO do later
throw new UnsupportedOperationException();
diff --git a/icu4j/main/classes/core/src/com/ibm/icu/impl/ReplaceableUCharacterIterator.java b/icu4j/main/classes/core/src/com/ibm/icu/impl/ReplaceableUCharacterIterator.java
index 695eb8a587b..aa914e0db7f 100644
--- a/icu4j/main/classes/core/src/com/ibm/icu/impl/ReplaceableUCharacterIterator.java
+++ b/icu4j/main/classes/core/src/com/ibm/icu/impl/ReplaceableUCharacterIterator.java
@@ -26,7 +26,7 @@ import com.ibm.icu.text.UTF16;
public class ReplaceableUCharacterIterator extends UCharacterIterator {
// public constructor ------------------------------------------------------
-
+
/**
* Public constructor
* @param replaceable text which the iterator will be based on
@@ -38,7 +38,7 @@ public class ReplaceableUCharacterIterator extends UCharacterIterator {
this.replaceable = replaceable;
this.currentIndex = 0;
}
-
+
/**
* Public constructor
* @param str text which the iterator will be based on
@@ -50,7 +50,7 @@ public class ReplaceableUCharacterIterator extends UCharacterIterator {
this.replaceable = new ReplaceableString(str);
this.currentIndex = 0;
}
-
+
/**
* Public constructor
* @param buf buffer of text on which the iterator will be based
@@ -62,14 +62,15 @@ public class ReplaceableUCharacterIterator extends UCharacterIterator {
this.replaceable = new ReplaceableString(buf);
this.currentIndex = 0;
}
-
+
// public methods ----------------------------------------------------------
-
+
/**
- * Creates a copy of this iterator, does not clone the underlying
+ * Creates a copy of this iterator, does not clone the underlying
* Replaceableobject
* @return copy of this iterator
*/
+ @Override
public Object clone(){
try {
return super.clone();
@@ -77,37 +78,39 @@ public class ReplaceableUCharacterIterator extends UCharacterIterator {
return null; // never invoked
}
}
-
+
/**
* Returns the current UTF16 character.
* @return current UTF16 character
*/
+ @Override
public int current(){
if (currentIndex < replaceable.length()) {
return replaceable.charAt(currentIndex);
}
return DONE;
}
-
+
/**
* Returns the current codepoint
* @return current codepoint
*/
+ @Override
public int currentCodePoint(){
- // cannot use charAt due to it different
+ // cannot use charAt due to it different
// behaviour when index is pointing at a
// trail surrogate, check for surrogates
-
+
int ch = current();
if(UTF16.isLeadSurrogate((char)ch)){
// advance the index to get the next code point
next();
- // due to post increment semantics current() after next()
+ // due to post increment semantics current() after next()
// actually returns the next char which is what we want
int ch2 = current();
// current should never change the current index so back off
previous();
-
+
if(UTF16.isTrailSurrogate((char)ch2)){
// we found a surrogate pair
return Character.toCodePoint((char)ch, (char)ch2);
@@ -115,47 +118,51 @@ public class ReplaceableUCharacterIterator extends UCharacterIterator {
}
return ch;
}
-
+
/**
* Returns the length of the text
* @return length of the text
*/
+ @Override
public int getLength(){
return replaceable.length();
}
-
+
/**
* Gets the current currentIndex in text.
* @return current currentIndex in text.
*/
+ @Override
public int getIndex(){
return currentIndex;
}
-
+
/**
- * Returns next UTF16 character and increments the iterator's currentIndex by 1.
- * If the resulting currentIndex is greater or equal to the text length, the
- * currentIndex is reset to the text length and a value of DONECODEPOINT is
- * returned.
- * @return next UTF16 character in text or DONE if the new currentIndex is off the
+ * Returns next UTF16 character and increments the iterator's currentIndex by 1.
+ * If the resulting currentIndex is greater or equal to the text length, the
+ * currentIndex is reset to the text length and a value of DONECODEPOINT is
+ * returned.
+ * @return next UTF16 character in text or DONE if the new currentIndex is off the
* end of the text range.
*/
+ @Override
public int next(){
if (currentIndex < replaceable.length()) {
return replaceable.charAt(currentIndex++);
}
return DONE;
}
-
-
+
+
/**
- * Returns previous UTF16 character and decrements the iterator's currentIndex by
- * 1.
- * If the resulting currentIndex is less than 0, the currentIndex is reset to 0 and a
- * value of DONECODEPOINT is returned.
- * @return next UTF16 character in text or DONE if the new currentIndex is off the
+ * Returns previous UTF16 character and decrements the iterator's currentIndex by
+ * 1.
+ * If the resulting currentIndex is less than 0, the currentIndex is reset to 0 and a
+ * value of DONECODEPOINT is returned.
+ * @return next UTF16 character in text or DONE if the new currentIndex is off the
* start of the text range.
*/
+ @Override
public int previous(){
if (currentIndex > 0) {
return replaceable.charAt(--currentIndex);
@@ -164,22 +171,24 @@ public class ReplaceableUCharacterIterator extends UCharacterIterator {
}
/**
- *
Sets the currentIndex to the specified currentIndex in the text and returns that
- * single UTF16 character at currentIndex.
+ *
Sets the currentIndex to the specified currentIndex in the text and returns that
+ * single UTF16 character at currentIndex.
* This assumes the text is stored as 16-bit code units.
- * @param currentIndex the currentIndex within the text.
- * @exception IllegalArgumentException is thrown if an invalid currentIndex is
+ * @param currentIndex the currentIndex within the text.
+ * @exception IllegalArgumentException is thrown if an invalid currentIndex is
* supplied. i.e. currentIndex is out of bounds.
- * @returns the character at the specified currentIndex or DONE if the specified
+ * @returns the character at the specified currentIndex or DONE if the specified
* currentIndex is equal to the end of the text.
*/
+ @Override
public void setIndex(int currentIndex) throws IndexOutOfBoundsException{
if (currentIndex < 0 || currentIndex > replaceable.length()) {
throw new IndexOutOfBoundsException();
}
this.currentIndex = currentIndex;
}
-
+
+ @Override
public int getText(char[] fillIn, int offset){
int length = replaceable.length();
if(offset < 0 || offset + length > fillIn.length){
@@ -187,10 +196,10 @@ public class ReplaceableUCharacterIterator extends UCharacterIterator {
}
replaceable.getChars(0,length,fillIn,offset);
return length;
- }
-
+ }
+
// private data members ----------------------------------------------------
-
+
/**
* Replacable object
*/
diff --git a/icu4j/main/classes/core/src/com/ibm/icu/impl/ResourceBundleWrapper.java b/icu4j/main/classes/core/src/com/ibm/icu/impl/ResourceBundleWrapper.java
index 8b290f9a084..50869e78033 100644
--- a/icu4j/main/classes/core/src/com/ibm/icu/impl/ResourceBundleWrapper.java
+++ b/icu4j/main/classes/core/src/com/ibm/icu/impl/ResourceBundleWrapper.java
@@ -22,7 +22,7 @@ import com.ibm.icu.util.ULocale;
import com.ibm.icu.util.UResourceBundle;
/**
- * just a wrapper for Java ListResourceBundles and
+ * just a wrapper for Java ListResourceBundles and
* @author ram
*
*/
@@ -49,6 +49,7 @@ public final class ResourceBundleWrapper extends UResourceBundle {
this.bundle=bundle;
}
+ @Override
protected Object handleGetObject(String aKey){
ResourceBundleWrapper current = this;
Object obj = null;
@@ -69,11 +70,12 @@ public final class ResourceBundleWrapper extends UResourceBundle {
}
return obj;
}
-
+
+ @Override
public Enumeration getKeys(){
return Collections.enumeration(keys);
}
-
+
private void initKeysVector(){
ResourceBundleWrapper current = this;
keys = new ArrayList();
@@ -88,25 +90,29 @@ public final class ResourceBundleWrapper extends UResourceBundle {
current = (ResourceBundleWrapper)current.getParent();
}
}
+ @Override
protected String getLocaleID(){
- return localeID;
+ return localeID;
}
-
+
+ @Override
protected String getBaseName(){
- return bundle.getClass().getName().replace('.','/');
+ return bundle.getClass().getName().replace('.','/');
}
-
+
+ @Override
public ULocale getULocale(){
- return new ULocale(localeID);
+ return new ULocale(localeID);
}
-
+
+ @Override
public UResourceBundle getParent(){
- return (UResourceBundle)parent;
+ return (UResourceBundle)parent;
}
// Flag for enabling/disabling debugging code
private static final boolean DEBUG = ICUDebug.enabled("resourceBundleWrapper");
-
+
// This method is for super class's instantiateBundle method
public static ResourceBundleWrapper getBundleInstance(String baseName, String localeID,
ClassLoader root, boolean disableFallback) {
@@ -182,6 +188,7 @@ public final class ResourceBundleWrapper extends UResourceBundle {
final String resName = name.replace('.', '/') + ".properties";
InputStream stream = java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction() {
+ @Override
public InputStream run() {
return root.getResourceAsStream(resName);
}
diff --git a/icu4j/main/classes/core/src/com/ibm/icu/impl/Row.java b/icu4j/main/classes/core/src/com/ibm/icu/impl/Row.java
index fcec0f56037..55667a8bfbe 100644
--- a/icu4j/main/classes/core/src/com/ibm/icu/impl/Row.java
+++ b/icu4j/main/classes/core/src/com/ibm/icu/impl/Row.java
@@ -95,6 +95,7 @@ public class Row implements java.lang.Comparable, Cloneable,
return this;
}
+ @Override
public int hashCode() {
int sum = items.length;
for (Object item : items) {
@@ -103,6 +104,7 @@ public class Row implements java.lang.Comparable, Cloneable,
return sum;
}
+ @Override
public boolean equals(Object other) {
if (other == null) {
return false;
@@ -127,6 +129,7 @@ public class Row implements java.lang.Comparable, Cloneable,
}
}
+ @Override
public int compareTo(Object other) {
int result;
Row that = (Row)other;
@@ -144,6 +147,7 @@ public class Row implements java.lang.Comparable, Cloneable,
return 0;
}
+ @Override
public String toString() {
StringBuilder result = new StringBuilder("[");
boolean first = true;
@@ -158,15 +162,18 @@ public class Row implements java.lang.Comparable, Cloneable,
return result.append("]").toString();
}
+ @Override
public boolean isFrozen() {
return frozen;
}
+ @Override
public Row freeze() {
frozen = true;
return this;
}
+ @Override
public Object clone() {
if (frozen) return this;
try {
@@ -178,6 +185,7 @@ public class Row implements java.lang.Comparable, Cloneable,
}
}
+ @Override
public Row cloneAsThawed() {
try {
Row result = (Row) super.clone();
diff --git a/icu4j/main/classes/core/src/com/ibm/icu/impl/RuleCharacterIterator.java b/icu4j/main/classes/core/src/com/ibm/icu/impl/RuleCharacterIterator.java
index 8e673e44146..a72261c158c 100644
--- a/icu4j/main/classes/core/src/com/ibm/icu/impl/RuleCharacterIterator.java
+++ b/icu4j/main/classes/core/src/com/ibm/icu/impl/RuleCharacterIterator.java
@@ -36,7 +36,7 @@ public class RuleCharacterIterator {
/**
* Text being iterated.
- */
+ */
private String text;
/**
@@ -81,7 +81,7 @@ public class RuleCharacterIterator {
* PARSE_ESCAPES) != 0, then an embedded escape sequence will be expanded
* to its value. Escapes are parsed using Utility.unescapeAt().
*/
- public static final int PARSE_ESCAPES = 2;
+ public static final int PARSE_ESCAPES = 2;
/**
* Bitmask option to enable skipping of whitespace. If (options &
@@ -111,7 +111,7 @@ public class RuleCharacterIterator {
this.pos = pos;
buf = null;
}
-
+
/**
* Returns true if this iterator has no more characters to return.
*/
@@ -308,6 +308,7 @@ public class RuleCharacterIterator {
* Position within an expanded variable is not indicated.
* @return a string representation of this object
*/
+ @Override
public String toString() {
int b = pos.getIndex();
return text.substring(0, b) + '|' + text.substring(b);
@@ -326,7 +327,7 @@ public class RuleCharacterIterator {
return (i < text.length()) ? UTF16.charAt(text, i) : DONE;
}
}
-
+
/**
* Advances the position by the given amount.
* @param count the number of 16-bit code units to advance past
diff --git a/icu4j/main/classes/core/src/com/ibm/icu/impl/SimpleCache.java b/icu4j/main/classes/core/src/com/ibm/icu/impl/SimpleCache.java
index 36d0cdce49a..d0a1264757e 100644
--- a/icu4j/main/classes/core/src/com/ibm/icu/impl/SimpleCache.java
+++ b/icu4j/main/classes/core/src/com/ibm/icu/impl/SimpleCache.java
@@ -39,6 +39,7 @@ public class SimpleCache implements ICUCache {
}
}
+ @Override
public V get(Object key) {
Reference