ICU-5533 Merging eclipse3.3 jse4 fragment related changes

X-SVN-Rev: 21133
This commit is contained in:
Yoshito Umaoka 2007-02-27 04:24:02 +00:00
parent 6087cfe0bb
commit 932556b6a5
2 changed files with 132 additions and 29 deletions

View file

@ -1,7 +1,7 @@
//##header
/**
*******************************************************************************
* Copyright (C) 1996-2006, International Business Machines Corporation and *
* Copyright (C) 1996-2007, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
@ -5376,11 +5376,24 @@ public final class UCharacter implements ECharacterCategory, ECharacterDirection
* @return the code point at the index
* @stable ICU 3.0
*/
//#ifndef FOUNDATION
public static final int codePointAt(CharSequence seq, int index) {
//#else
//#ifdef FOUNDATION
//## public static final int codePointAt(String seq, int index) {
//#endif
//## char c1 = seq.charAt(index++);
//## if (isHighSurrogate(c1)) {
//## if (index < seq.length()) {
//## char c2 = seq.charAt(index);
//## if (isLowSurrogate(c2)) {
//## return toCodePoint(c1, c2);
//## }
//## }
//## }
//## return c1;
//## }
//## public static final int codePointAt(StringBuffer seq, int index) {
//## return codePointAt(seq.toString(), index);
//## }
//#else
public static final int codePointAt(CharSequence seq, int index) {
char c1 = seq.charAt(index++);
if (isHighSurrogate(c1)) {
if (index < seq.length()) {
@ -5392,9 +5405,13 @@ public final class UCharacter implements ECharacterCategory, ECharacterDirection
}
return c1;
}
//#ifdef FOUNDATION
//#endif
//#ifdef ECLIPSE_FRAGMENT
//## public static final int codePointAt(String seq, int index) {
//## return codePointAt((CharSequence)seq, index);
//## }
//## public static final int codePointAt(StringBuffer seq, int index) {
//## return codePointAt(seq.toString(), index);
//## return codePointAt((CharSequence)seq, index);
//## }
//#endif
@ -5455,11 +5472,24 @@ public final class UCharacter implements ECharacterCategory, ECharacterDirection
* @return the code point before the index
* @stable ICU 3.0
*/
//#ifndef FOUNDATION
public static final int codePointBefore(CharSequence seq, int index) {
//#else
//#ifdef FOUNDATION
//## public static final int codePointBefore(StringBuffer seq, int index) {
//## return codePointBefore(seq.toString(), index);
//## }
//## public static final int codePointBefore(String seq, int index) {
//#endif
//## char c2 = seq.charAt(--index);
//## if (isLowSurrogate(c2)) {
//## if (index > 0) {
//## char c1 = seq.charAt(--index);
//## if (isHighSurrogate(c1)) {
//## return toCodePoint(c1, c2);
//## }
//## }
//## }
//## return c2;
//## }
//#else
public static final int codePointBefore(CharSequence seq, int index) {
char c2 = seq.charAt(--index);
if (isLowSurrogate(c2)) {
if (index > 0) {
@ -5471,9 +5501,13 @@ public final class UCharacter implements ECharacterCategory, ECharacterDirection
}
return c2;
}
//#ifdef FOUNDATION
//#endif
//#ifdef ECLIPSE_FRAGMENT
//## public static final int codePointBefore(String seq, int index) {
//## return codePointBefore((CharSequence)seq, index);
//## }
//## public static final int codePointBefore(StringBuffer seq, int index) {
//## return codePointBefore(seq.toString(), index);
//## return codePointBefore((CharSequence)seq, index);
//## }
//#endif
@ -5598,11 +5632,29 @@ public final class UCharacter implements ECharacterCategory, ECharacterDirection
* @return the number of code points in the range
* @stable ICU 3.0
*/
//#ifndef FOUNDATION
public static int codePointCount(CharSequence text, int start, int limit) {
//#else
//#ifdef FOUNDATION
//## public static int codePointCount(String text, int start, int limit) {
//#endif
//## if (start < 0 || limit < start || limit > text.length()) {
//## throw new IndexOutOfBoundsException("start (" + start +
//## ") or limit (" + limit +
//## ") invalid or out of range 0, " + text.length());
//## }
//##
//## int len = limit - start;
//## while (limit > start) {
//## char ch = text.charAt(--limit);
//## while (ch >= MIN_LOW_SURROGATE && ch <= MAX_LOW_SURROGATE && limit > start) {
//## ch = text.charAt(--limit);
//## if (ch >= MIN_HIGH_SURROGATE && ch <= MAX_HIGH_SURROGATE) {
//## --len;
//## break;
//## }
//## }
//## }
//## return len;
//## }
//#else
public static int codePointCount(CharSequence text, int start, int limit) {
if (start < 0 || limit < start || limit > text.length()) {
throw new IndexOutOfBoundsException("start (" + start +
") or limit (" + limit +
@ -5622,6 +5674,12 @@ public final class UCharacter implements ECharacterCategory, ECharacterDirection
}
return len;
}
//#endif
//#ifdef ECLIPSE_FRAGMENT
//## public static int codePointCount(String text, int start, int limit) {
//## return codePointCount((CharSequence)text, start, limit);
//## }
//#endif
/**
* Cover the JDK API, for convenience. Count the number of code points in the range of text.
@ -5660,11 +5718,44 @@ public final class UCharacter implements ECharacterCategory, ECharacterDirection
* @return the adjusted index
* @stable ICU 3.0
*/
//#ifndef FOUNDATION
public static int offsetByCodePoints(CharSequence text, int index, int codePointOffset) {
//#else
//#ifdef FOUNDATION
//## public static int offsetByCodePoints(String text, int index, int codePointOffset) {
//#endif
//## if (index < 0 || index > text.length()) {
//## throw new IndexOutOfBoundsException("index ( " + index +
//## ") out of range 0, " + text.length());
//## }
//##
//## if (codePointOffset < 0) {
//## while (++codePointOffset <= 0) {
//## char ch = text.charAt(--index);
//## while (ch >= MIN_LOW_SURROGATE && ch <= MAX_LOW_SURROGATE && index > 0) {
//## ch = text.charAt(--index);
//## if (ch < MIN_HIGH_SURROGATE || ch > MAX_HIGH_SURROGATE) {
//## if (++codePointOffset > 0) {
//## return index+1;
//## }
//## }
//## }
//## }
//## } else {
//## int limit = text.length();
//## while (--codePointOffset >= 0) {
//## char ch = text.charAt(index++);
//## while (ch >= MIN_HIGH_SURROGATE && ch <= MAX_HIGH_SURROGATE && index < limit) {
//## ch = text.charAt(index++);
//## if (ch < MIN_LOW_SURROGATE || ch > MAX_LOW_SURROGATE) {
//## if (--codePointOffset < 0) {
//## return index-1;
//## }
//## }
//## }
//## }
//## }
//##
//## return index;
//## }
//#else
public static int offsetByCodePoints(CharSequence text, int index, int codePointOffset) {
if (index < 0 || index > text.length()) {
throw new IndexOutOfBoundsException("index ( " + index +
") out of range 0, " + text.length());
@ -5699,7 +5790,12 @@ public final class UCharacter implements ECharacterCategory, ECharacterDirection
return index;
}
//#endif
//#ifdef ECLIPSE_FRAGMENT
//## public static int offsetByCodePoints(String text, int index, int codePointOffset) {
//## return offsetByCodePoints((CharSequence)text, index, codePointOffset);
//## }
//#endif
/**
* Cover the JDK API, for convenience. Adjust the char index by a code point offset.
* @param text the characters to check

View file

@ -1,7 +1,7 @@
//##header
/*
*******************************************************************************
* Copyright (C) 1996-2006, International Business Machines Corporation and *
* Copyright (C) 1996-2007, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
@ -2506,16 +2506,23 @@ public class DecimalFormat extends NumberFormat {
* @see #setRoundingMode
* @stable ICU 2.0
*/
//#ifndef FOUNDATION
//#ifdef FOUNDATION
//## public BigDecimal getRoundingIncrement() {
//## if (roundingIncrementICU == null) return null;
//## return new BigDecimal(roundingIncrementICU.toString());
//## }
//#else
//#ifdef ECLIPSE_FRAGMENT
//## public BigDecimal getRoundingIncrement() {
//## if (roundingIncrementICU == null) return null;
//## return new BigDecimal(roundingIncrementICU.toString());
//## }
//#else
public java.math.BigDecimal getRoundingIncrement() {
if (roundingIncrementICU == null) return null;
return roundingIncrementICU.toBigDecimal();
}
//#else
//## public BigDecimal getRoundingIncrement() {
//## if (roundingIncrementICU == null) return null;
//## return new BigDecimal(roundingIncrementICU.toString());
//## }
//#endif
//#endif
//#ifndef FOUNDATION