mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-14 17:24:01 +00:00
ICU-3462 icu4j coverage for calendar and date format
some changes due to clover tool limitations: "if ((a = b) == c)..." is not traced properly by clover X-SVN-Rev: 14121
This commit is contained in:
parent
5b04614ac5
commit
b096c973ab
19 changed files with 595 additions and 164 deletions
|
@ -6,8 +6,8 @@
|
|||
*******************************************************************************
|
||||
*
|
||||
* $Source: /xsrl/Nsvn/icu/icu4j/build.xml,v $
|
||||
* $Date: 2003/12/02 03:08:38 $
|
||||
* $Revision: 1.84 $
|
||||
* $Date: 2003/12/13 00:30:58 $
|
||||
* $Revision: 1.85 $
|
||||
*
|
||||
*******************************************************************************
|
||||
* This is the ant build file for ICU4J. See readme.html for more information.
|
||||
|
@ -312,7 +312,7 @@
|
|||
<java classname="com.ibm.icu.dev.test.TestAll" fork="yes">
|
||||
<classpath>
|
||||
<pathelement path="${java.class.path}/"/>
|
||||
<!-- pathelement location="clover.jar"-->
|
||||
<pathelement location="clover.jar"/>
|
||||
<pathelement path="${build.dir}"/>
|
||||
</classpath>
|
||||
</java>
|
||||
|
@ -326,7 +326,7 @@
|
|||
<arg value="-w"/>
|
||||
<classpath>
|
||||
<pathelement path="${java.class.path}/"/>
|
||||
<!-- pathelement location="clover.jar"-->
|
||||
<pathelement location="clover.jar"/>
|
||||
<pathelement path="${build.dir}"/>
|
||||
</classpath>
|
||||
</java>
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
* others. All Rights Reserved.
|
||||
*********************************************************************
|
||||
* $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/icu/dev/test/calendar/ChineseTest.java,v $
|
||||
* $Date: 2003/06/03 18:49:28 $
|
||||
* $Revision: 1.12 $
|
||||
* $Date: 2003/12/13 00:30:57 $
|
||||
* $Revision: 1.13 $
|
||||
*/
|
||||
package com.ibm.icu.dev.test.calendar;
|
||||
import com.ibm.icu.util.*;
|
||||
|
@ -522,4 +522,18 @@ public class ChineseTest extends CalendarTest {
|
|||
// cal.add(Calendar.DAY_OF_YEAR, 25);
|
||||
// }
|
||||
// }
|
||||
|
||||
public void TestCoverage() {
|
||||
ChineseCalendar cal = new ChineseCalendar();
|
||||
ChineseDateFormat fmt = (ChineseDateFormat)DateFormat.getInstance(cal);
|
||||
fmt.applyPattern("llyyll");
|
||||
Date time = new Date(2100-1900, Calendar.JANUARY, 1);
|
||||
String str = fmt.format(time);
|
||||
try {
|
||||
Date e = fmt.parse(str);
|
||||
logln("chinese calendar time: " + time + " result: " + str + " --> " + e);
|
||||
} catch (java.text.ParseException ex) {
|
||||
logln(ex.getMessage()); // chinese calendar can't parse this, no error for now
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
*******************************************************************************
|
||||
*
|
||||
* $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/icu/dev/test/calendar/HolidayTest.java,v $
|
||||
* $Date: 2003/12/01 21:56:21 $
|
||||
* $Revision: 1.6 $
|
||||
* $Date: 2003/12/13 00:30:57 $
|
||||
* $Revision: 1.7 $
|
||||
*
|
||||
*****************************************************************************************
|
||||
*/
|
||||
|
@ -22,8 +22,8 @@ import com.ibm.icu.util.Calendar;
|
|||
import com.ibm.icu.util.EasterHoliday;
|
||||
import com.ibm.icu.util.GregorianCalendar;
|
||||
import com.ibm.icu.util.Holiday;
|
||||
//import com.ibm.icu.util.RangeDateRule;
|
||||
//import com.ibm.icu.util.SimpleDateRule;
|
||||
import com.ibm.icu.util.RangeDateRule;
|
||||
import com.ibm.icu.util.SimpleDateRule;
|
||||
import com.ibm.icu.util.SimpleHoliday;
|
||||
|
||||
/**
|
||||
|
@ -132,8 +132,27 @@ public class HolidayTest extends TestFmwk {
|
|||
new SimpleHoliday(2, 29, 0, "Leap year", 1900, 2100)};
|
||||
exerciseHolidays(h, Locale.getDefault());
|
||||
|
||||
// RangeDateRule rdr = new RangeDateRule();
|
||||
// rdr.add(new SimpleDateRule(7, 15));
|
||||
RangeDateRule rdr = new RangeDateRule();
|
||||
rdr.add(new SimpleDateRule(7, 10));
|
||||
Date mbd = new Date(1953, Calendar.JULY, 10);
|
||||
Date dbd = new Date(1958, Calendar.AUGUST, 15);
|
||||
Date nbd = new Date(1990, Calendar.DECEMBER, 17);
|
||||
Date abd = new Date(1992, Calendar.SEPTEMBER, 16);
|
||||
Date xbd = new Date(1976, Calendar.JULY, 4);
|
||||
Date ybd = new Date(2003, Calendar.DECEMBER, 8);
|
||||
rdr.add(new SimpleDateRule(Calendar.JULY, 10, Calendar.MONDAY, false));
|
||||
rdr.add(dbd, new SimpleDateRule(Calendar.AUGUST, 15, Calendar.WEDNESDAY, true));
|
||||
rdr.add(xbd, null);
|
||||
rdr.add(nbd, new SimpleDateRule(Calendar.DECEMBER, 17, Calendar.MONDAY, false));
|
||||
rdr.add(ybd, null);
|
||||
|
||||
logln("first after " + mbd + " is " + rdr.firstAfter(mbd));
|
||||
logln("first between " + mbd + " and " + dbd + " is " + rdr.firstBetween(mbd, dbd));
|
||||
logln("first between " + dbd + " and " + nbd + " is " + rdr.firstBetween(dbd, nbd));
|
||||
logln("first between " + nbd + " and " + abd + " is " + rdr.firstBetween(nbd, abd));
|
||||
logln("first between " + abd + " and " + xbd + " is " + rdr.firstBetween(abd, xbd));
|
||||
logln("first between " + abd + " and " + null + " is " + rdr.firstBetween(abd, null));
|
||||
logln("first between " + xbd + " and " + null + " is " + rdr.firstBetween(xbd, null));
|
||||
}
|
||||
|
||||
public void TestIsOn() {
|
||||
|
@ -142,27 +161,27 @@ public class HolidayTest extends TestFmwk {
|
|||
|
||||
Calendar cal = new GregorianCalendar();
|
||||
cal.clear();
|
||||
cal.set(cal.YEAR, 2000);
|
||||
cal.set(cal.MONTH, cal.AUGUST);
|
||||
cal.set(cal.DAY_OF_MONTH, 15);
|
||||
cal.set(Calendar.YEAR, 2000);
|
||||
cal.set(Calendar.MONTH, Calendar.AUGUST);
|
||||
cal.set(Calendar.DAY_OF_MONTH, 15);
|
||||
|
||||
Date d0 = cal.getTime();
|
||||
cal.add(cal.SECOND, 1);
|
||||
cal.add(Calendar.SECOND, 1);
|
||||
Date d1 = cal.getTime();
|
||||
cal.add(cal.SECOND, -2);
|
||||
cal.add(Calendar.SECOND, -2);
|
||||
Date d2 = cal.getTime();
|
||||
cal.add(cal.DAY_OF_MONTH, 1);
|
||||
cal.add(Calendar.DAY_OF_MONTH, 1);
|
||||
Date d3 = cal.getTime();
|
||||
cal.add(cal.SECOND, 1);
|
||||
cal.add(Calendar.SECOND, 1);
|
||||
Date d4 = cal.getTime();
|
||||
cal.add(cal.SECOND, -2);
|
||||
cal.set(cal.YEAR, 1957);
|
||||
cal.add(Calendar.SECOND, -2);
|
||||
cal.set(Calendar.YEAR, 1957);
|
||||
Date d5 = cal.getTime();
|
||||
cal.set(cal.YEAR, 1958);
|
||||
cal.set(Calendar.YEAR, 1958);
|
||||
Date d6 = cal.getTime();
|
||||
cal.set(cal.YEAR, 2058);
|
||||
cal.set(Calendar.YEAR, 2058);
|
||||
Date d7 = cal.getTime();
|
||||
cal.set(cal.YEAR, 2059);
|
||||
cal.set(Calendar.YEAR, 2059);
|
||||
Date d8 = cal.getTime();
|
||||
|
||||
Date[] dates = { d0, d1, d2, d3, d4, d5, d6, d7, d8 };
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
* $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/icu/dev/test/format/DateFormatTest.java,v $
|
||||
* $Date: 2003/10/16 00:52:18 $
|
||||
* $Revision: 1.21 $
|
||||
* $Date: 2003/12/13 00:30:57 $
|
||||
* $Revision: 1.22 $
|
||||
*
|
||||
*****************************************************************************************
|
||||
*/
|
||||
|
@ -913,6 +913,46 @@ public class DateFormatTest extends com.ibm.icu.dev.test.TestFmwk {
|
|||
}
|
||||
}
|
||||
|
||||
public void testErrorChecking() {
|
||||
try {
|
||||
DateFormat sdf = DateFormat.getDateTimeInstance(-1, -1, Locale.US);
|
||||
errln("Expected exception for getDateTimeInstance(-1, -1, Locale)");
|
||||
}
|
||||
catch(IllegalArgumentException e) {
|
||||
logln("one ok");
|
||||
}
|
||||
catch(Exception e) {
|
||||
errln("Expected IllegalArgumentException, got: " + e);
|
||||
}
|
||||
|
||||
try {
|
||||
DateFormat df = new SimpleDateFormat("aabbccc");
|
||||
df.format(new Date());
|
||||
errln("Expected exception for format with bad pattern");
|
||||
}
|
||||
catch(IllegalArgumentException ex) {
|
||||
logln("two ok");
|
||||
}
|
||||
catch(Exception e) {
|
||||
errln("Expected IllegalArgumentException, got: " + e);
|
||||
}
|
||||
|
||||
{
|
||||
SimpleDateFormat fmt = new SimpleDateFormat("dd/MM/yy"); // opposite of text
|
||||
fmt.set2DigitYearStart(new Date(2003, Calendar.DECEMBER, 25));
|
||||
String text = "12/25/03";
|
||||
Calendar xcal = new GregorianCalendar();
|
||||
xcal.setLenient(false);
|
||||
ParsePosition pp = new ParsePosition(0);
|
||||
fmt.parse(text, xcal, pp); // should get parse error on second field, not lenient
|
||||
if (pp.getErrorIndex() == -1) {
|
||||
errln("Expected parse error");
|
||||
} else {
|
||||
logln("three ok");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void TestCoverage() {
|
||||
Date now = new Date();
|
||||
Calendar cal = new GregorianCalendar();
|
||||
|
@ -930,6 +970,9 @@ public class DateFormatTest extends com.ibm.icu.dev.test.TestFmwk {
|
|||
f = DateFormat.getTimeInstance(cal, DateFormat.FULL);
|
||||
logln("time yet again: " + f.format(now));
|
||||
|
||||
f = DateFormat.getDateInstance();
|
||||
logln("time yet again: " + f.format(now));
|
||||
|
||||
ResourceBundle rb = ICULocaleData.getLocaleElements("de_DE");
|
||||
DateFormatSymbols sym = new DateFormatSymbols(rb, Locale.GERMANY);
|
||||
DateFormatSymbols sym2 = (DateFormatSymbols)sym.clone();
|
||||
|
@ -939,6 +982,304 @@ public class DateFormatTest extends com.ibm.icu.dev.test.TestFmwk {
|
|||
if (!sym.equals(sym2)) {
|
||||
errln("fail, date format symbols not equal");
|
||||
}
|
||||
|
||||
Locale foo = new Locale("fu", "FU", "BAR");
|
||||
rb = null;
|
||||
sym = new DateFormatSymbols(rb, foo);
|
||||
sym = new DateFormatSymbols(GregorianCalendar.class, foo);
|
||||
sym = new DateFormatSymbols((Class)null, foo);
|
||||
sym = new DateFormatSymbols((Calendar)null, foo);
|
||||
sym.equals(null);
|
||||
|
||||
sym = new ChineseDateFormatSymbols();
|
||||
sym = new ChineseDateFormatSymbols(cal, foo);
|
||||
sym = new ChineseDateFormatSymbols(null, foo);
|
||||
|
||||
StringBuffer buf = new StringBuffer();
|
||||
FieldPosition pos = new FieldPosition(0);
|
||||
|
||||
f.format((Object)cal, buf, pos);
|
||||
f.format((Object)now, buf, pos);
|
||||
f.format((Object)new Long(now.getTime()), buf, pos);
|
||||
try {
|
||||
f.format((Object)"Howdy", buf, pos);
|
||||
}
|
||||
catch (Exception e) {
|
||||
}
|
||||
|
||||
NumberFormat nf = f.getNumberFormat();
|
||||
f.setNumberFormat(nf);
|
||||
|
||||
boolean lenient = f.isLenient();
|
||||
f.setLenient(lenient);
|
||||
|
||||
ULocale uloc = f.getLocale(ULocale.ACTUAL_LOCALE);
|
||||
|
||||
int hashCode = f.hashCode();
|
||||
|
||||
boolean eq = f.equals(f);
|
||||
eq = f.equals(null);
|
||||
eq = f.equals(new SimpleDateFormat());
|
||||
|
||||
{
|
||||
ChineseDateFormat fmt = new ChineseDateFormat("yymm", Locale.US);
|
||||
try {
|
||||
Date d = fmt.parse("2"); // fewer symbols than required 2
|
||||
errln("whoops");
|
||||
}
|
||||
catch (ParseException e) {
|
||||
logln("ok");
|
||||
}
|
||||
|
||||
try {
|
||||
Date d = fmt.parse("2255"); // should succeed with obeycount
|
||||
logln("ok");
|
||||
}
|
||||
catch (ParseException e) {
|
||||
logln("whoops");
|
||||
}
|
||||
|
||||
try {
|
||||
Date d = fmt.parse("ni hao"); // not a number, should fail
|
||||
errln("whoops ni hao");
|
||||
}
|
||||
catch (ParseException e) {
|
||||
logln("ok ni hao");
|
||||
}
|
||||
}
|
||||
{
|
||||
Calendar xcal = new GregorianCalendar();
|
||||
xcal.set(Calendar.HOUR_OF_DAY, 0);
|
||||
DateFormat fmt = new SimpleDateFormat("k");
|
||||
StringBuffer xbuf = new StringBuffer();
|
||||
FieldPosition fpos = new FieldPosition(Calendar.HOUR_OF_DAY);
|
||||
fmt.format(xcal, xbuf, fpos);
|
||||
try {
|
||||
Date d = fmt.parse(xbuf.toString());
|
||||
logln("ok");
|
||||
|
||||
xbuf.setLength(0);
|
||||
xcal.set(Calendar.HOUR_OF_DAY, 25);
|
||||
fmt.format(xcal, xbuf, fpos);
|
||||
Date d2 = fmt.parse(xbuf.toString());
|
||||
logln("ok again");
|
||||
}
|
||||
catch (ParseException e) {
|
||||
errln("whoops");
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
// cover gmt+hh:mm
|
||||
DateFormat fmt = new SimpleDateFormat("MM/dd/yy z");
|
||||
try {
|
||||
Date d = fmt.parse("07/10/53 GMT+10:00");
|
||||
logln("ok");
|
||||
}
|
||||
catch (ParseException e) {
|
||||
errln("whoops");
|
||||
}
|
||||
|
||||
// cover invalid separator after GMT
|
||||
try {
|
||||
Date d = fmt.parse("07/10/53 GMT=10:00");
|
||||
logln("whoops");
|
||||
}
|
||||
catch (ParseException e) {
|
||||
errln("ok");
|
||||
}
|
||||
|
||||
// cover bad text after GMT+.
|
||||
try {
|
||||
Date d = fmt.parse("07/10/53 GMT+blecch");
|
||||
errln("whoops GMT+blecch");
|
||||
}
|
||||
catch (ParseException e) {
|
||||
logln("ok GMT+blecch");
|
||||
}
|
||||
|
||||
// cover bad text after GMT+hh:.
|
||||
try {
|
||||
Date d = fmt.parse("07/10/53 GMT+07:blecch");
|
||||
errln("whoops GMT+xx:blecch");
|
||||
}
|
||||
catch (ParseException e) {
|
||||
logln("ok GMT+xx:blecch");
|
||||
}
|
||||
|
||||
// cover no ':' GMT+#, # < 24 (hh)
|
||||
try {
|
||||
Date d = fmt.parse("07/10/53 GMT+07");
|
||||
logln("ok");
|
||||
}
|
||||
catch (ParseException e) {
|
||||
errln("whoops");
|
||||
}
|
||||
|
||||
// cover no ':' GMT+#, # > 24 (hhmm)
|
||||
try {
|
||||
Date d = fmt.parse("07/10/53 GMT+0730");
|
||||
logln("ok");
|
||||
}
|
||||
catch (ParseException e) {
|
||||
errln("whoops");
|
||||
}
|
||||
|
||||
// cover no ':' GMT+#, # > 2400 (this should fail, i suspect, but doesn't)
|
||||
try {
|
||||
Date d = fmt.parse("07/10/53 GMT+07300");
|
||||
logln("should GMT+9999 fail?");
|
||||
}
|
||||
catch (ParseException e) {
|
||||
logln("ok, I guess");
|
||||
}
|
||||
|
||||
// cover raw digits with no leading sign (bad RFC822)
|
||||
try {
|
||||
Date d = fmt.parse("07/10/53 07");
|
||||
errln("whoops");
|
||||
}
|
||||
catch (ParseException e) {
|
||||
logln("ok");
|
||||
}
|
||||
|
||||
// cover raw digits (RFC822)
|
||||
try {
|
||||
Date d = fmt.parse("07/10/53 +07");
|
||||
logln("ok");
|
||||
}
|
||||
catch (ParseException e) {
|
||||
errln("whoops");
|
||||
}
|
||||
|
||||
// cover raw digits (RFC822)
|
||||
try {
|
||||
Date d = fmt.parse("07/10/53 -0730");
|
||||
logln("ok");
|
||||
}
|
||||
catch (ParseException e) {
|
||||
errln("whoops");
|
||||
}
|
||||
|
||||
// cover raw digits (RFC822) in DST
|
||||
try {
|
||||
fmt.setTimeZone(TimeZone.getTimeZone("PDT"));
|
||||
Date d = fmt.parse("07/10/53 -0730");
|
||||
logln("ok");
|
||||
}
|
||||
catch (ParseException e) {
|
||||
errln("whoops");
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
SimpleDateFormat fmt = new SimpleDateFormat("aabbcc");
|
||||
try {
|
||||
String pat = fmt.toLocalizedPattern();
|
||||
errln("whoops, shouldn't have been able to localize aabbcc");
|
||||
}
|
||||
catch (IllegalArgumentException e) {
|
||||
logln("aabbcc localize ok");
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
SimpleDateFormat fmt = new SimpleDateFormat("'aabbcc");
|
||||
try {
|
||||
String pat = fmt.toLocalizedPattern();
|
||||
errln("whoops, localize unclosed quote");
|
||||
}
|
||||
catch (IllegalArgumentException e) {
|
||||
logln("localize unclosed quote ok");
|
||||
}
|
||||
}
|
||||
{
|
||||
SimpleDateFormat fmt = new SimpleDateFormat("MM/dd/yy z");
|
||||
String text = "08/15/58 DBDY"; // bogus time zone
|
||||
try {
|
||||
fmt.parse(text);
|
||||
errln("recognized bogus time zone DBDY");
|
||||
}
|
||||
catch (ParseException e) {
|
||||
logln("time zone ex ok");
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
// force fallback to default timezone when fmt timezone
|
||||
// is not named
|
||||
SimpleDateFormat fmt = new SimpleDateFormat("MM/dd/yy z");
|
||||
// force fallback to default time zone, still fails
|
||||
fmt.setTimeZone(TimeZone.getTimeZone("GMT+0147")); // not in equivalency group
|
||||
String text = "08/15/58 DBDY";
|
||||
try {
|
||||
fmt.parse(text);
|
||||
errln("whoops");
|
||||
}
|
||||
catch (ParseException e) {
|
||||
logln("time zone ex2 ok");
|
||||
}
|
||||
|
||||
// force success on fallback
|
||||
text = "08/15/58 " + TimeZone.getDefault().getID();
|
||||
try {
|
||||
fmt.parse(text);
|
||||
logln("found default tz");
|
||||
}
|
||||
catch (ParseException e) {
|
||||
errln("whoops, got parse exception");
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
// force fallback to symbols list of timezones when neither
|
||||
// fmt and default timezone is named
|
||||
SimpleDateFormat fmt = new SimpleDateFormat("MM/dd/yy z");
|
||||
TimeZone oldtz = TimeZone.getDefault();
|
||||
TimeZone newtz = TimeZone.getTimeZone("GMT+0137"); // nonstandard tz
|
||||
fmt.setTimeZone(newtz);
|
||||
TimeZone.setDefault(newtz); // todo: fix security issue
|
||||
|
||||
// fallback to symbol list, but fail
|
||||
String text = "08/15/58 DBDY"; // try to parse the bogus time zone
|
||||
try {
|
||||
fmt.parse(text);
|
||||
errln("whoops again");
|
||||
}
|
||||
catch (ParseException e) {
|
||||
logln("time zone ex3 ok");
|
||||
}
|
||||
catch (Exception e) {
|
||||
// hmmm... this shouldn't happen. don't want to exit this
|
||||
// fn with timezone improperly set, so just in case
|
||||
TimeZone.setDefault(oldtz);
|
||||
throw new InternalError(e.getMessage());
|
||||
}
|
||||
|
||||
// create DFS that recognizes our bogus time zone, sortof
|
||||
DateFormatSymbols xsym = new DateFormatSymbols();
|
||||
String[][] tzids = xsym.getZoneStrings();
|
||||
for (int i = 0; i < tzids.length; ++i) {
|
||||
if (tzids[i][0].equals("GMT")) {
|
||||
tzids[i][1] = "DBDY"; // change a local name
|
||||
break;
|
||||
}
|
||||
}
|
||||
xsym.setZoneStrings(tzids);
|
||||
fmt.setDateFormatSymbols(xsym);
|
||||
|
||||
try {
|
||||
fmt.parse(text);
|
||||
logln("we parsed DBDY (as GMT, but still...)");
|
||||
}
|
||||
catch (ParseException e) {
|
||||
errln("hey, still didn't recognize DBDY");
|
||||
}
|
||||
finally {
|
||||
TimeZone.setDefault(oldtz);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*****************************************************************************************
|
||||
* $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/icu/dev/test/format/IntlTestDecimalFormatSymbols.java,v $
|
||||
* $Date: 2003/06/03 18:49:29 $
|
||||
* $Revision: 1.6 $
|
||||
* $Date: 2003/12/13 00:30:57 $
|
||||
* $Revision: 1.7 $
|
||||
*
|
||||
*****************************************************************************************
|
||||
**/
|
||||
|
@ -109,11 +109,23 @@ public class IntlTestDecimalFormatSymbols extends com.ibm.icu.dev.test.TestFmwk
|
|||
errln("ERROR: get/set MinusSign failed");
|
||||
}
|
||||
|
||||
// char exponential = en.getExponentialSymbol();
|
||||
// fr.setExponentialSymbol(exponential);
|
||||
// if(fr.getExponentialSymbol() != en.getExponentialSymbol()) {
|
||||
// errln("ERROR: get/set Exponential failed");
|
||||
// }
|
||||
char plusSign = en.getPlusSign();
|
||||
fr.setPlusSign(plusSign);
|
||||
if(fr.getPlusSign() != en.getPlusSign()) {
|
||||
errln("ERROR: get/set PlusSign failed");
|
||||
}
|
||||
|
||||
char padEscape = en.getPadEscape();
|
||||
fr.setPadEscape(padEscape);
|
||||
if(fr.getPadEscape() != en.getPadEscape()) {
|
||||
errln("ERROR: get/set PadEscape failed");
|
||||
}
|
||||
|
||||
String exponential = en.getExponentSeparator();
|
||||
fr.setExponentSeparator(exponential);
|
||||
if(fr.getExponentSeparator() != en.getExponentSeparator()) {
|
||||
errln("ERROR: get/set Exponential failed");
|
||||
}
|
||||
|
||||
//DecimalFormatSymbols foo = new DecimalFormatSymbols(); //The variable is never used
|
||||
|
||||
|
@ -123,4 +135,12 @@ public class IntlTestDecimalFormatSymbols extends com.ibm.icu.dev.test.TestFmwk
|
|||
errln("ERROR: Clone failed");
|
||||
}
|
||||
}
|
||||
|
||||
public void testCoverage() {
|
||||
DecimalFormatSymbols df = new DecimalFormatSymbols();
|
||||
DecimalFormatSymbols df2 = (DecimalFormatSymbols)df.clone();
|
||||
if (!df.equals(df2) || df.hashCode() != df2.hashCode()) {
|
||||
errln("decimal format symbols clone, equals, or hashCode failed");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
*******************************************************************************
|
||||
*
|
||||
* $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/icu/dev/test/normalizer/BasicTest.java,v $
|
||||
* $Date: 2003/11/14 00:07:07 $
|
||||
* $Revision: 1.34 $
|
||||
* $Date: 2003/12/13 00:30:50 $
|
||||
* $Revision: 1.35 $
|
||||
*
|
||||
*****************************************************************************************
|
||||
*/
|
||||
|
@ -1372,10 +1372,10 @@ public class BasicTest extends TestFmwk {
|
|||
}
|
||||
|
||||
// test setIndex()
|
||||
ch=norm.setIndex(3);
|
||||
if(ch!=0x4e3d) {
|
||||
errln("error in Normalizer(CharacterIterator).setIndex(3)");
|
||||
}
|
||||
// ch=norm.setIndex(3);
|
||||
// if(ch!=0x4e3d) {
|
||||
// errln("error in Normalizer(CharacterIterator).setIndex(3)");
|
||||
// }
|
||||
|
||||
// test setText(CharacterIterator) and getText()
|
||||
String out, out2;
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
*******************************************************************************
|
||||
*
|
||||
* $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/icu/dev/test/normalizer/ConformanceTest.java,v $
|
||||
* $Date: 2003/11/14 00:07:08 $
|
||||
* $Revision: 1.15 $
|
||||
* $Date: 2003/12/13 00:30:50 $
|
||||
* $Revision: 1.16 $
|
||||
*
|
||||
*****************************************************************************************
|
||||
*/
|
||||
|
@ -380,12 +380,12 @@ public class ConformanceTest extends TestFmwk {
|
|||
if (dir > 0) {
|
||||
for (ch = normalizer.first(); ch != Normalizer.DONE;
|
||||
ch = normalizer.next()) {
|
||||
buf.append(UTF16.toString(ch));
|
||||
buf.append(UTF16.valueOf(ch));
|
||||
}
|
||||
} else {
|
||||
for (ch = normalizer.last(); ch != Normalizer.DONE;
|
||||
ch = normalizer.previous()) {
|
||||
buf.insert(0, UTF16.toString(ch));
|
||||
buf.insert(0, UTF16.valueOf(ch));
|
||||
}
|
||||
}
|
||||
return buf.toString();
|
||||
|
@ -409,12 +409,12 @@ public class ConformanceTest extends TestFmwk {
|
|||
if (dir > 0) {
|
||||
for (ch = normalizer.first(); ch != Normalizer.DONE;
|
||||
ch = normalizer.next()) {
|
||||
buf.append(UTF16.toString(ch));
|
||||
buf.append(UTF16.valueOf(ch));
|
||||
}
|
||||
} else {
|
||||
for (ch = normalizer.last(); ch != Normalizer.DONE;
|
||||
ch = normalizer.previous()) {
|
||||
buf.insert(0, UTF16.toString(ch));
|
||||
buf.insert(0, UTF16.valueOf(ch));
|
||||
}
|
||||
}
|
||||
return buf.toString();
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
* others. All Rights Reserved.
|
||||
*********************************************************************
|
||||
* $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/icu/text/ChineseDateFormat.java,v $
|
||||
* $Date: 2003/06/03 18:49:33 $
|
||||
* $Revision: 1.9 $
|
||||
* $Date: 2003/12/13 00:30:56 $
|
||||
* $Revision: 1.10 $
|
||||
*/
|
||||
package com.ibm.icu.text;
|
||||
import com.ibm.icu.util.*;
|
||||
|
@ -125,7 +125,9 @@ public class ChineseDateFormat extends SimpleDateFormat {
|
|||
return result;
|
||||
}
|
||||
default:
|
||||
///CLOVER:OFF
|
||||
return 0; // This can never happen
|
||||
///CLOVER:ON
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1486,7 +1486,7 @@ public final class CollationElementIterator
|
|||
if (m_bufferOffset_ < 0) {
|
||||
// decompose into writable buffer
|
||||
m_buffer_.replace(0, m_buffer_.length(),
|
||||
Normalizer.decompose(UTF16.toString(cp),
|
||||
Normalizer.decompose(UTF16.valueOf(cp),
|
||||
false));
|
||||
// reorder Thai and the character after it
|
||||
if (m_buffer_.length() >= 2
|
||||
|
@ -2430,7 +2430,7 @@ public final class CollationElementIterator
|
|||
// in the normalization buffer
|
||||
}
|
||||
else {
|
||||
String decomp = Normalizer.decompose(UTF16.toString(ch), false);
|
||||
String decomp = Normalizer.decompose(UTF16.valueOf(ch), false);
|
||||
// we need to check if we will hit a contraction trigger because of
|
||||
// decomposition
|
||||
for (int i = decomp.length() - 1; i >= 0; i --) {
|
||||
|
|
|
@ -744,6 +744,7 @@ public abstract class DateFormat extends UFormat {
|
|||
* @stable ICU 2.0
|
||||
*/
|
||||
///CLOVER:OFF
|
||||
// turn off code coverage since all subclasses override this
|
||||
public int hashCode() {
|
||||
return numberFormat.hashCode();
|
||||
// just enough fields for a reasonable distribution
|
||||
|
@ -793,7 +794,10 @@ public abstract class DateFormat extends UFormat {
|
|||
try {
|
||||
return new SimpleDateFormat(timeStyle, dateStyle, loc);
|
||||
} catch (MissingResourceException e) {
|
||||
///CLOVER:OFF
|
||||
// coverage requires separate run with no data, so skip
|
||||
return new SimpleDateFormat("M/d/yy h:mm a");
|
||||
///CLOVER:ON
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
*******************************************************************************
|
||||
*
|
||||
* $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/icu/text/DateFormatSymbols.java,v $
|
||||
* $Date: 2003/11/21 22:52:05 $
|
||||
* $Revision: 1.21 $
|
||||
* $Date: 2003/12/13 00:30:56 $
|
||||
* $Revision: 1.22 $
|
||||
*
|
||||
*****************************************************************************************
|
||||
*/
|
||||
|
@ -365,7 +365,9 @@ public class DateFormatSymbols implements Serializable, Cloneable {
|
|||
copyMembers(this, other);
|
||||
return other;
|
||||
} catch (CloneNotSupportedException e) {
|
||||
///CLOVER:OFF
|
||||
throw new InternalError();
|
||||
///CLOVER:ON
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -618,12 +620,15 @@ public class DateFormatSymbols implements Serializable, Cloneable {
|
|||
try {
|
||||
bundle = getDateFormatBundle(calendarClass, locale);
|
||||
} catch (MissingResourceException e) {
|
||||
///CLOVER:OFF
|
||||
// coverage requires test without data, so skip
|
||||
//if (!(cal instanceof GregorianCalendar)) {
|
||||
if (!(GregorianCalendar.class.isAssignableFrom(calendarClass))) {
|
||||
// Ok for symbols to be missing for a Gregorian calendar, but
|
||||
// not for any other type.
|
||||
throw e;
|
||||
}
|
||||
///CLOVER:ON
|
||||
}
|
||||
constructCalendarSpecific(bundle);
|
||||
}
|
||||
|
@ -715,12 +720,15 @@ public class DateFormatSymbols implements Serializable, Cloneable {
|
|||
result = ICULocaleData.getResourceBundle(bundleName, locale);
|
||||
}
|
||||
catch (MissingResourceException e) {
|
||||
///CLOVER:OFF
|
||||
// coverage requires test without data, so skip
|
||||
//if (!(cal instanceof GregorianCalendar)) {
|
||||
if (!(GregorianCalendar.class.isAssignableFrom(calendarClass))) {
|
||||
// Ok for symbols to be missing for a Gregorian calendar, but
|
||||
// not for any other type.
|
||||
throw e;
|
||||
}
|
||||
///CLOVER:ON
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -731,8 +739,8 @@ public class DateFormatSymbols implements Serializable, Cloneable {
|
|||
* @see #getDateFormatBundle(java.lang.Class, java.util.Locale)
|
||||
* @stable ICU 2.2
|
||||
*/
|
||||
static public ResourceBundle getDateFormatBundle(Calendar cal, Locale locale)
|
||||
public static ResourceBundle getDateFormatBundle(Calendar cal, Locale locale)
|
||||
throws MissingResourceException {
|
||||
return getDateFormatBundle(cal==null?null:cal.getClass(), locale);
|
||||
return getDateFormatBundle(cal.getClass(), locale);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
*******************************************************************************
|
||||
*
|
||||
* $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/icu/text/DecimalFormatSymbols.java,v $
|
||||
* $Date: 2003/11/21 22:52:05 $
|
||||
* $Revision: 1.13 $
|
||||
* $Date: 2003/12/13 00:30:56 $
|
||||
* $Revision: 1.14 $
|
||||
*
|
||||
*****************************************************************************************
|
||||
*/
|
||||
|
@ -424,7 +424,9 @@ final public class DecimalFormatSymbols implements Cloneable, Serializable {
|
|||
return (DecimalFormatSymbols)super.clone();
|
||||
// other fields are bit-copied
|
||||
} catch (CloneNotSupportedException e) {
|
||||
///CLOVER:OFF
|
||||
throw new InternalError();
|
||||
///CLOVER:ON
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -435,7 +437,6 @@ final public class DecimalFormatSymbols implements Cloneable, Serializable {
|
|||
public boolean equals(Object obj) {
|
||||
if (obj == null) return false;
|
||||
if (this == obj) return true;
|
||||
if (getClass() != obj.getClass()) return false;
|
||||
DecimalFormatSymbols other = (DecimalFormatSymbols) obj;
|
||||
return (zeroDigit == other.zeroDigit &&
|
||||
groupingSeparator == other.groupingSeparator &&
|
||||
|
@ -491,24 +492,28 @@ final public class DecimalFormatSymbols implements Cloneable, Serializable {
|
|||
// {dlf} clean up below now that we have our own resource data
|
||||
decimalSeparator = numberElements[0].charAt(0);
|
||||
groupingSeparator = numberElements[1].charAt(0);
|
||||
// [NEW] Temporary hack to support old JDK 1.1 resources
|
||||
patternSeparator = numberElements[2].length() > 0 ?
|
||||
numberElements[2].charAt(0) : ';';
|
||||
// patternSeparator = numberElements[2].charAt(0);
|
||||
// Temporary hack to support old JDK 1.1 resources
|
||||
// patternSeparator = numberElements[2].length() > 0 ?
|
||||
// numberElements[2].charAt(0) : ';';
|
||||
patternSeparator = numberElements[2].charAt(0);
|
||||
percent = numberElements[3].charAt(0);
|
||||
zeroDigit = numberElements[4].charAt(0); //different for Arabic,etc.
|
||||
digit = numberElements[5].charAt(0);
|
||||
minusSign = numberElements[6].charAt(0);
|
||||
|
||||
// [NEW] Temporary hack to support JDK versions before 1.1.6 (?)
|
||||
exponentSeparator = numberElements.length >= 9 ?
|
||||
numberElements[7] : DecimalFormat.PATTERN_EXPONENT;
|
||||
perMill = numberElements.length >= 9 ?
|
||||
numberElements[8].charAt(0) : '\u2030';
|
||||
infinity = numberElements.length >= 10 ?
|
||||
numberElements[9] : "\u221e";
|
||||
NaN = numberElements.length >= 11 ?
|
||||
numberElements[10] : "\ufffd";
|
||||
// Temporary hack to support JDK versions before 1.1.6 (?)
|
||||
// exponentSeparator = numberElements.length >= 9 ?
|
||||
// numberElements[7] : DecimalFormat.PATTERN_EXPONENT;
|
||||
// perMill = numberElements.length >= 9 ?
|
||||
// numberElements[8].charAt(0) : '\u2030';
|
||||
// infinity = numberElements.length >= 10 ?
|
||||
// numberElements[9] : "\u221e";
|
||||
// NaN = numberElements.length >= 11 ?
|
||||
// numberElements[10] : "\ufffd";
|
||||
exponentSeparator = numberElements[7];
|
||||
perMill = numberElements[8].charAt(0);
|
||||
infinity = numberElements[9];
|
||||
NaN = numberElements[10];
|
||||
|
||||
// [NEW] Temporarily hard code; retrieve from resource later
|
||||
plusSign = DecimalFormat.PATTERN_PLUS_SIGN;
|
||||
|
@ -535,8 +540,9 @@ final public class DecimalFormatSymbols implements Cloneable, Serializable {
|
|||
currencySymbol = "\u00A4"; // 'OX' currency symbol
|
||||
}
|
||||
// If there is a currency decimal, use it.
|
||||
monetarySeparator =
|
||||
numberElements[numberElements.length >= 12 ? 11 : 0].charAt(0);
|
||||
// monetarySeparator =
|
||||
// numberElements[numberElements.length >= 12 ? 11 : 0].charAt(0);
|
||||
monetarySeparator = numberElements[11].charAt(0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -551,13 +557,15 @@ final public class DecimalFormatSymbols implements Cloneable, Serializable {
|
|||
private void readObject(ObjectInputStream stream)
|
||||
throws IOException, ClassNotFoundException {
|
||||
stream.defaultReadObject();
|
||||
///CLOVER:OFF
|
||||
// we don't have data for these old serialized forms any more
|
||||
if (serialVersionOnStream < 1) {
|
||||
// Didn't have monetarySeparator or exponential field;
|
||||
// use defaults.
|
||||
monetarySeparator = decimalSeparator;
|
||||
exponential = 'E';
|
||||
}
|
||||
if (serialVersionOnStream < 2) { // [NEW]
|
||||
if (serialVersionOnStream < 2) {
|
||||
padEscape = DecimalFormat.PATTERN_PAD_ESCAPE;
|
||||
plusSign = DecimalFormat.PATTERN_PLUS_SIGN;
|
||||
exponentSeparator = String.valueOf(exponential);
|
||||
|
@ -566,6 +574,7 @@ final public class DecimalFormatSymbols implements Cloneable, Serializable {
|
|||
// notation isn't supported by the old classes, even though the
|
||||
// symbol is there.
|
||||
}
|
||||
///CLOVER:ON
|
||||
if (serialVersionOnStream < 3) {
|
||||
// Resurrected objects from old streams will have no
|
||||
// locale. There is no 100% fix for this. A
|
||||
|
@ -759,8 +768,11 @@ final public class DecimalFormatSymbols implements Cloneable, Serializable {
|
|||
|
||||
private ULocale validLocale;
|
||||
|
||||
///CLOVER:OFF
|
||||
// temporarily off (2.8d1) until tests are completed
|
||||
ULocale getLocale(ULocale.ULocaleDataType type) {
|
||||
return validLocale;
|
||||
}
|
||||
|
||||
///CLOVER:ON
|
||||
///CLOVER:ON
|
||||
}
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
*******************************************************************************
|
||||
*
|
||||
* $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/icu/text/Normalizer.java,v $
|
||||
* $Date: 2003/12/02 01:34:31 $
|
||||
* $Revision: 1.38 $
|
||||
* $Date: 2003/12/13 00:30:50 $
|
||||
* $Revision: 1.39 $
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
@ -537,7 +537,7 @@ public final class Normalizer implements Cloneable{
|
|||
* altogether.
|
||||
* <p>
|
||||
* @see #setMode
|
||||
* @obsolete ICU 2.8. To be removed after 2004-Aug-31. Use Nomalizer.NONE
|
||||
* @deprecated ICU 2.8. Use Nomalizer.NONE
|
||||
* @see #NONE
|
||||
*/
|
||||
public static final Mode NO_OP = NONE;
|
||||
|
@ -555,7 +555,7 @@ public final class Normalizer implements Cloneable{
|
|||
* <b>C</b>.
|
||||
* <p>
|
||||
* @see #setMode
|
||||
* @obsolete ICU 2.8. To be removed after 2004-Aug-31. Use Normalier.NFC
|
||||
* @deprecated ICU 2.8. Use Normalier.NFC
|
||||
* @see #NFC
|
||||
*/
|
||||
public static final Mode COMPOSE = NFC;
|
||||
|
@ -573,7 +573,7 @@ public final class Normalizer implements Cloneable{
|
|||
* <b>KC</b>.
|
||||
* <p>
|
||||
* @see #setMode
|
||||
* @obsolete ICU 2.8. To be removed after 2004-Aug-31. Use Normalizer.NFKC
|
||||
* @deprecated ICU 2.8. Use Normalizer.NFKC
|
||||
* @see #NFKC
|
||||
*/
|
||||
public static final Mode COMPOSE_COMPAT = NFKC;
|
||||
|
@ -591,7 +591,7 @@ public final class Normalizer implements Cloneable{
|
|||
* <b>D</b>.
|
||||
* <p>
|
||||
* @see #setMode
|
||||
* @obsolete ICU 2.8. To be removed after 2004-Aug-31.Use Normalizer.NFD
|
||||
* @deprecated ICU 2.8. Use Normalizer.NFD
|
||||
* @see #NFD
|
||||
*/
|
||||
public static final Mode DECOMP = NFD;
|
||||
|
@ -609,7 +609,7 @@ public final class Normalizer implements Cloneable{
|
|||
* <b>KD</b>.
|
||||
* <p>
|
||||
* @see #setMode
|
||||
* @obsolete ICU 2.8. To be removed after 2004-Aug-31. Use Normalizer.NFKD
|
||||
* @deprecated ICU 2.8. Use Normalizer.NFKD
|
||||
* @see #NFKD
|
||||
*/
|
||||
public static final Mode DECOMP_COMPAT = NFKD;
|
||||
|
@ -630,7 +630,7 @@ public final class Normalizer implements Cloneable{
|
|||
* Unicode Normalization Forms</a>.
|
||||
* <p>
|
||||
* @see #setOption
|
||||
* @obsolete ICU 2.8. To be removed after 2004-Aug-31.
|
||||
* @deprecated ICU 2.8. This option is no longer supported. TODO: check with Ram
|
||||
*/
|
||||
public static final int IGNORE_HANGUL = 0x0001;
|
||||
|
||||
|
@ -1843,18 +1843,17 @@ public final class Normalizer implements Cloneable{
|
|||
* @throws IllegalArgumentException if the given index is less than
|
||||
* {@link #getBeginIndex} or greater than {@link #getEndIndex}.
|
||||
* @return The codepoint as an int
|
||||
* @obsolete ICU 2.8. To be removed after 2004-Aug-31
|
||||
*/
|
||||
public int setIndex(int index) {
|
||||
setIndexOnly(index);
|
||||
return current();
|
||||
}
|
||||
// public int setIndex(int index) {
|
||||
// setIndexOnly(index);
|
||||
// return current();
|
||||
// }
|
||||
|
||||
/**
|
||||
* Retrieve the index of the start of the input text. This is the begin
|
||||
* index of the <tt>CharacterIterator</tt> or the start (i.e. 0) of the
|
||||
* <tt>String</tt> over which this <tt>Normalizer</tt> is iterating
|
||||
* @deprecated ICU 2.2. To be removed after 2003-aug-31. Use startIndex() instead.
|
||||
* @deprecated ICU 2.2. Use startIndex() instead.
|
||||
* @return The codepoint as an int
|
||||
* @see #startIndex
|
||||
*/
|
||||
|
@ -1866,7 +1865,7 @@ public final class Normalizer implements Cloneable{
|
|||
* Retrieve the index of the end of the input text. This is the end index
|
||||
* of the <tt>CharacterIterator</tt> or the length of the <tt>String</tt>
|
||||
* over which this <tt>Normalizer</tt> is iterating
|
||||
* @obsolete ICU 2.2. To be removed after 2003-aug-31. Use endIndex() instead.
|
||||
* @deprecated ICU 2.2. Use endIndex() instead.
|
||||
* @return The codepoint as an int
|
||||
* @see #endIndex
|
||||
*/
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
*******************************************************************************
|
||||
*
|
||||
* $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/icu/text/NumberFormat.java,v $
|
||||
* $Date: 2003/11/21 22:52:05 $
|
||||
* $Revision: 1.33 $
|
||||
* $Date: 2003/12/13 00:30:56 $
|
||||
* $Revision: 1.34 $
|
||||
*
|
||||
*****************************************************************************************
|
||||
*/
|
||||
|
@ -1040,6 +1040,8 @@ public abstract class NumberFormat extends UFormat {
|
|||
throws IOException, ClassNotFoundException
|
||||
{
|
||||
stream.defaultReadObject();
|
||||
///CLOVER:OFF
|
||||
// we don't have serialization data for this format
|
||||
if (serialVersionOnStream < 1) {
|
||||
// Didn't have additional int fields, reassign to use them.
|
||||
maximumIntegerDigits = maxIntegerDigits;
|
||||
|
@ -1047,6 +1049,7 @@ public abstract class NumberFormat extends UFormat {
|
|||
maximumFractionDigits = maxFractionDigits;
|
||||
minimumFractionDigits = minFractionDigits;
|
||||
}
|
||||
///CLOVER:ON
|
||||
/*Bug 4185761
|
||||
Validate the min and max fields [Richard/GCL]
|
||||
*/
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
*******************************************************************************
|
||||
*
|
||||
* $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/icu/text/SimpleDateFormat.java,v $
|
||||
* $Date: 2003/12/02 01:34:31 $
|
||||
* $Revision: 1.25 $
|
||||
* $Date: 2003/12/13 00:30:55 $
|
||||
* $Revision: 1.26 $
|
||||
*
|
||||
*****************************************************************************************
|
||||
*/
|
||||
|
@ -353,8 +353,12 @@ public class SimpleDateFormat extends DateFormat {
|
|||
calendar = Calendar.getInstance(TimeZone.getDefault(), loc);
|
||||
numberFormat = NumberFormat.getInstance(loc);
|
||||
numberFormat.setGroupingUsed(false);
|
||||
///CLOVER:OFF
|
||||
// difficult to test for case where NumberFormat.getInstance does not
|
||||
// return a DecimalFormat
|
||||
if (numberFormat instanceof DecimalFormat)
|
||||
((DecimalFormat)numberFormat).setDecimalSeparatorAlwaysShown(false);
|
||||
///CLOVER:ON
|
||||
numberFormat.setParseIntegerOnly(true); /* So that dd.MM.yy can be parsed */
|
||||
numberFormat.setMinimumFractionDigits(0); // To prevent "Jan 1.00, 1997.00"
|
||||
|
||||
|
@ -505,11 +509,11 @@ public class SimpleDateFormat extends DateFormat {
|
|||
Calendar cal)
|
||||
throws IllegalArgumentException
|
||||
{
|
||||
int patternCharIndex = -1;
|
||||
int maxIntCount = Integer.MAX_VALUE;
|
||||
String current = "";
|
||||
|
||||
if ((patternCharIndex=DateFormatSymbols.patternChars.indexOf(ch)) == -1) {
|
||||
int patternCharIndex = DateFormatSymbols.patternChars.indexOf(ch);
|
||||
if (patternCharIndex == -1) {
|
||||
throw new IllegalArgumentException("Illegal pattern character " +
|
||||
"'" + ch + "'");
|
||||
}
|
||||
|
@ -964,27 +968,36 @@ public class SimpleDateFormat extends DateFormat {
|
|||
formatData.getZoneIndex (getTimeZone().getID());
|
||||
TimeZone tz = null;
|
||||
int j = 0, i = 0;
|
||||
if ((zoneIndex != -1) && ((j = matchZoneString(text, start, zoneIndex)) > 0)) {
|
||||
tz = TimeZone.getTimeZone(formatData.zoneStrings[zoneIndex][0]);
|
||||
i = zoneIndex;
|
||||
if (zoneIndex != -1) {
|
||||
j = matchZoneString(text, start, zoneIndex);
|
||||
if (j > 0) {
|
||||
tz = TimeZone.getTimeZone(formatData.zoneStrings[zoneIndex][0]);
|
||||
i = zoneIndex;
|
||||
}
|
||||
}
|
||||
|
||||
if (tz == null) {
|
||||
zoneIndex =
|
||||
formatData.getZoneIndex (TimeZone.getDefault().getID());
|
||||
if ((zoneIndex != -1) && ((j = matchZoneString(text, start, zoneIndex)) > 0)) {
|
||||
tz = TimeZone.getTimeZone(formatData.zoneStrings[zoneIndex][0]);
|
||||
i = zoneIndex;
|
||||
if (zoneIndex != -1) {
|
||||
j = matchZoneString(text, start, zoneIndex);
|
||||
if (j > 0) {
|
||||
tz = TimeZone.getTimeZone(formatData.zoneStrings[zoneIndex][0]);
|
||||
i = zoneIndex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (tz == null) {
|
||||
for (i = 0; i < formatData.zoneStrings.length; i++) {
|
||||
if ((j = matchZoneString(text, start, i)) > 0) {
|
||||
tz = TimeZone.getTimeZone(formatData.zoneStrings[i][0]);
|
||||
break;
|
||||
}
|
||||
j = matchZoneString(text, start, i);
|
||||
if (j > 0) {
|
||||
tz = TimeZone.getTimeZone(formatData.zoneStrings[i][0]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (tz != null) { // Matched any ?
|
||||
cal.set(Calendar.ZONE_OFFSET, tz.getRawOffset());
|
||||
int savings = 0;
|
||||
|
@ -1002,7 +1015,9 @@ public class SimpleDateFormat extends DateFormat {
|
|||
// TimeZone (JDK 1.4) or SimpleTimeZone (JDK 1.3).
|
||||
Method m = tz.getClass().getMethod("getDSTSavings", new Class[0]);
|
||||
savings = ((Integer) m.invoke(tz, new Object[0])).intValue();
|
||||
} catch (Exception e1) {}
|
||||
} catch (Exception e1) {
|
||||
// todo: fix bug 3458, this code shold be on JDKTimeZone
|
||||
}
|
||||
}
|
||||
cal.set(Calendar.DST_OFFSET, savings);
|
||||
return (start + formatData.zoneStrings[i][j].length());
|
||||
|
@ -1037,9 +1052,9 @@ public class SimpleDateFormat extends DateFormat {
|
|||
int value = 0;
|
||||
int i;
|
||||
ParsePosition pos = new ParsePosition(0);
|
||||
int patternCharIndex = -1;
|
||||
int patternCharIndex = DateFormatSymbols.patternChars.indexOf(ch);
|
||||
|
||||
if ((patternCharIndex=DateFormatSymbols.patternChars.indexOf(ch)) == -1) {
|
||||
if (patternCharIndex == -1) {
|
||||
return -start;
|
||||
}
|
||||
|
||||
|
@ -1126,13 +1141,14 @@ public class SimpleDateFormat extends DateFormat {
|
|||
// count >= 3 // i.e., MMM or MMMM
|
||||
// Want to be able to parse both short and long forms.
|
||||
// Try count == 4 first:
|
||||
int newStart = 0;
|
||||
if ((newStart=matchString(text, start, Calendar.MONTH,
|
||||
formatData.months, cal)) > 0)
|
||||
int newStart = matchString(text, start, Calendar.MONTH,
|
||||
formatData.months, cal);
|
||||
if (newStart > 0) {
|
||||
return newStart;
|
||||
else // count == 4 failed, now try count == 3
|
||||
} else { // count == 4 failed, now try count == 3
|
||||
return matchString(text, start, Calendar.MONTH,
|
||||
formatData.shortMonths, cal);
|
||||
}
|
||||
}
|
||||
case 4: // 'k' - HOUR_OF_DAY: 1-based. eg, 23:59 + 1 hour =>> 24:59
|
||||
// [We computed 'value' above.]
|
||||
|
@ -1142,13 +1158,14 @@ public class SimpleDateFormat extends DateFormat {
|
|||
case 9: { // 'E' - DAY_OF_WEEK
|
||||
// Want to be able to parse both short and long forms.
|
||||
// Try count == 4 (DDDD) first:
|
||||
int newStart = 0;
|
||||
if ((newStart=matchString(text, start, Calendar.DAY_OF_WEEK,
|
||||
formatData.weekdays, cal)) > 0)
|
||||
int newStart = matchString(text, start, Calendar.DAY_OF_WEEK,
|
||||
formatData.weekdays, cal);
|
||||
if (newStart > 0) {
|
||||
return newStart;
|
||||
else // DDDD failed, now try DDD
|
||||
} else { // DDDD failed, now try DDD
|
||||
return matchString(text, start, Calendar.DAY_OF_WEEK,
|
||||
formatData.shortWeekdays, cal);
|
||||
}
|
||||
}
|
||||
case 14: // 'a' - AM_PM
|
||||
return matchString(text, start, Calendar.AM_PM, formatData.ampms, cal);
|
||||
|
@ -1197,7 +1214,9 @@ public class SimpleDateFormat extends DateFormat {
|
|||
if( tzNumber == null) {
|
||||
return -start;
|
||||
}
|
||||
if( text.charAt(pos.getIndex()) == ':' ) {
|
||||
if( pos.getIndex() < text.length() &&
|
||||
text.charAt(pos.getIndex()) == ':' ) {
|
||||
|
||||
// This is the hours:minutes case
|
||||
offset = tzNumber.intValue() * 60;
|
||||
pos.setIndex(pos.getIndex() + 1);
|
||||
|
@ -1213,6 +1232,7 @@ public class SimpleDateFormat extends DateFormat {
|
|||
if( offset < 24 )
|
||||
offset *= 60;
|
||||
else
|
||||
// todo: this looks questionable, should have more error checking
|
||||
offset = offset % 100 + offset / 100 * 60;
|
||||
}
|
||||
|
||||
|
@ -1251,9 +1271,10 @@ public class SimpleDateFormat extends DateFormat {
|
|||
}
|
||||
|
||||
// Do the final processing for both of the above cases. We only
|
||||
// arrive here if the form GMT+/-... or an RFC 822 form was seen.
|
||||
if (sign != 0)
|
||||
{
|
||||
// arrive here if the form GMT+/-... or an RFC 822 form was seen. ///CLOVER:OFF
|
||||
// as it turns out, sign is never 0 if we get here
|
||||
// if (sign != 0)
|
||||
// {
|
||||
offset *= millisPerMinute * sign;
|
||||
|
||||
if (cal.getTimeZone().useDaylightTime())
|
||||
|
@ -1264,11 +1285,12 @@ public class SimpleDateFormat extends DateFormat {
|
|||
cal.set(Calendar.ZONE_OFFSET, offset);
|
||||
|
||||
return pos.getIndex();
|
||||
}
|
||||
// }
|
||||
}
|
||||
|
||||
// All efforts to parse a zone failed.
|
||||
return -start;
|
||||
// since sign != 0 is always true (see above), we never get here // todo: clover bug, if I clover comment this, default gets lost
|
||||
// return -start;
|
||||
|
||||
default:
|
||||
// case 3: // 'd' - DATE
|
||||
|
@ -1458,10 +1480,13 @@ public class SimpleDateFormat extends DateFormat {
|
|||
private void readObject(ObjectInputStream stream)
|
||||
throws IOException, ClassNotFoundException {
|
||||
stream.defaultReadObject();
|
||||
///CLOVER:OFF
|
||||
// don't have old serial data to test with
|
||||
if (serialVersionOnStream < 1) {
|
||||
// didn't have defaultCenturyStart field
|
||||
initializeDefaultCentury();
|
||||
}
|
||||
///CLOVER:ON
|
||||
else {
|
||||
// fill in dependent transient field
|
||||
parseAmbiguousDatesAsAfter(defaultCenturyStart);
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
*******************************************************************************
|
||||
*
|
||||
* $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/icu/text/UTF16.java,v $
|
||||
* $Date: 2003/12/02 01:34:31 $
|
||||
* $Revision: 1.33 $
|
||||
* $Date: 2003/12/13 00:30:54 $
|
||||
* $Revision: 1.34 $
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
@ -2643,10 +2643,8 @@ public final class UTF16
|
|||
* points, 2 otherwise.</p>
|
||||
* @param ch code point
|
||||
* @return string representation of the code point
|
||||
* @obsolete ICU 2.4. Use UCharacter.toString(int) instead since it will be
|
||||
* removed in that release.
|
||||
*/
|
||||
public static String toString(int ch)
|
||||
private static String toString(int ch)
|
||||
{
|
||||
if (ch < SUPPLEMENTARY_MIN_VALUE) {
|
||||
return String.valueOf((char)ch);
|
||||
|
|
|
@ -1512,10 +1512,13 @@ public abstract class Calendar implements Serializable, Cloneable {
|
|||
// Allocate fields through the framework method. Subclasses
|
||||
// may override this to define additional fields.
|
||||
fields = handleCreateFields();
|
||||
///CLOVER:OFF
|
||||
// todo: fix, difficult to test without subclassing
|
||||
if (fields == null || fields.length < BASE_FIELD_COUNT ||
|
||||
fields.length > MAX_FIELD_COUNT) {
|
||||
throw new InternalError("Invalid fields[]");
|
||||
}
|
||||
///CLOVER:ON
|
||||
stamp = new int[fields.length];
|
||||
int mask = (1 << ERA) |
|
||||
(1 << YEAR) |
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
*******************************************************************************
|
||||
*
|
||||
* $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/icu/util/RangeDateRule.java,v $
|
||||
* $Date: 2003/12/01 21:29:33 $
|
||||
* $Revision: 1.8 $
|
||||
* $Date: 2003/12/13 00:30:57 $
|
||||
* $Revision: 1.9 $
|
||||
*
|
||||
*****************************************************************************************
|
||||
*/
|
||||
|
@ -33,12 +33,12 @@ public class RangeDateRule implements DateRule
|
|||
* @internal
|
||||
*/
|
||||
// Range is a package-private class so this should be package-private too, probably
|
||||
public RangeDateRule(Range[] ranges)
|
||||
{
|
||||
for (int i = 0; i < ranges.length; i++) {
|
||||
this.ranges.addElement(ranges[i]);
|
||||
}
|
||||
}
|
||||
// public RangeDateRule(Range[] ranges)
|
||||
// {
|
||||
// for (int i = 0; i < ranges.length; i++) {
|
||||
// this.ranges.addElement(ranges[i]);
|
||||
// }
|
||||
// }
|
||||
|
||||
/**
|
||||
* @draft ICU 2.8
|
||||
|
@ -91,19 +91,23 @@ public class RangeDateRule implements DateRule
|
|||
*/
|
||||
public Date firstBetween(Date start, Date end)
|
||||
{
|
||||
if (end == null) {
|
||||
return firstAfter(start);
|
||||
}
|
||||
|
||||
// Find the range that I should look at
|
||||
int index = startIndex(start);
|
||||
Date result = null;
|
||||
|
||||
Range next = rangeAt(index);
|
||||
|
||||
while (result == null && next != null && ! next.start.after(end))
|
||||
while (result == null && next != null && !next.start.after(end))
|
||||
{
|
||||
Range r = next;
|
||||
next = rangeAt(index+1);
|
||||
|
||||
if (r.rule != null) {
|
||||
Date e = (next != null && next.start.before(end)) ? next.start
|
||||
Date e = (next != null && !next.start.after(end)) ? next.start
|
||||
: end;
|
||||
result = r.rule.firstBetween(start, e);
|
||||
}
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
*******************************************************************************
|
||||
*
|
||||
* $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/icu/util/SimpleDateRule.java,v $
|
||||
* $Date: 2003/12/01 21:33:37 $
|
||||
* $Revision: 1.11 $
|
||||
* $Date: 2003/12/13 00:30:57 $
|
||||
* $Revision: 1.12 $
|
||||
*
|
||||
*****************************************************************************************
|
||||
*/
|
||||
|
@ -76,10 +76,7 @@ public class SimpleDateRule implements DateRule
|
|||
*/
|
||||
public Date firstAfter(Date start)
|
||||
{
|
||||
if (startDate != null && start.before(startDate)) {
|
||||
start = startDate;
|
||||
}
|
||||
return doFirstBetween(start, endDate);
|
||||
return doFirstBetween(start, null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -99,12 +96,6 @@ public class SimpleDateRule implements DateRule
|
|||
public Date firstBetween(Date start, Date end)
|
||||
{
|
||||
// Pin to the min/max dates for this rule
|
||||
if (startDate != null && start.before(startDate)) {
|
||||
start = startDate;
|
||||
}
|
||||
if (endDate != null && end.after(endDate)) {
|
||||
end = endDate;
|
||||
}
|
||||
return doFirstBetween(start, end);
|
||||
}
|
||||
|
||||
|
@ -122,13 +113,6 @@ public class SimpleDateRule implements DateRule
|
|||
*/
|
||||
public boolean isOn(Date date)
|
||||
{
|
||||
if (startDate != null && date.before(startDate)) {
|
||||
return false;
|
||||
}
|
||||
if (endDate != null && date.after(endDate)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Calendar c = calendar;
|
||||
|
||||
synchronized(c) {
|
||||
|
@ -189,8 +173,6 @@ public class SimpleDateRule implements DateRule
|
|||
|
||||
private Date computeInYear(int year, Calendar c)
|
||||
{
|
||||
if (c == null) c = calendar;
|
||||
|
||||
synchronized(c) {
|
||||
c.clear();
|
||||
c.set(Calendar.ERA, c.getMaximum(Calendar.ERA));
|
||||
|
@ -213,7 +195,7 @@ public class SimpleDateRule implements DateRule
|
|||
// on or after the specified date in the month.
|
||||
delta = (dayOfWeek - weekday + 7) % 7;
|
||||
}
|
||||
else if (dayOfWeek < 0) {
|
||||
else {
|
||||
// We want the first occurrance of the (-dayOfWeek)
|
||||
// on or before the specified date in the month.
|
||||
delta = -((dayOfWeek + weekday + 7) % 7);
|
||||
|
@ -229,9 +211,9 @@ public class SimpleDateRule implements DateRule
|
|||
/**
|
||||
* @draft ICU 2.8
|
||||
*/
|
||||
public void setCalendar(Calendar c) {
|
||||
calendar = c;
|
||||
}
|
||||
// public void setCalendar(Calendar c) {
|
||||
// calendar = c;
|
||||
// }
|
||||
|
||||
private static GregorianCalendar gCalendar = new GregorianCalendar();
|
||||
|
||||
|
@ -240,7 +222,4 @@ public class SimpleDateRule implements DateRule
|
|||
private int month;
|
||||
private int dayOfMonth;
|
||||
private int dayOfWeek;
|
||||
|
||||
private Date startDate = null;
|
||||
private Date endDate = null;
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue