From fe03e3ea5afb6758b6ef2f16d34dbfec30426fdf Mon Sep 17 00:00:00 2001 From: tromey Date: Thu, 3 Feb 2000 18:26:51 +0000 Subject: [PATCH] * java/util/Calendar.java (toString): New method. * java/util/SimpleTimeZone.java (clone): New method. (toString): New method. * java/util/TimeZone.java (clone): New method. * java/text/SimpleDateFormat.java (clone): New method. * java/text/NumberFormat.java (clone): New method. (equals): New method. * java/text/Format.java (clone): New method. * java/text/DateFormatSymbols.java (DateFormatSymbols): New constructor. (clone): New method. * java/text/DateFormat.java (clone): New method. * java/text/Collator.java (clone): New method. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@31775 138bc75d-0d04-0410-961f-82ee72b054a4 --- libjava/ChangeLog | 16 ++++++++++++++++ libjava/java/text/Collator.java | 7 ++++++- libjava/java/text/DateFormat.java | 8 +++++++- libjava/java/text/DateFormatSymbols.java | 20 +++++++++++++++++++- libjava/java/text/Format.java | 7 ++++++- libjava/java/text/NumberFormat.java | 23 ++++++++++++++++++++++- libjava/java/text/SimpleDateFormat.java | 8 +++++++- libjava/java/util/Calendar.java | 17 ++++++++++++++++- libjava/java/util/SimpleTimeZone.java | 28 +++++++++++++++++++++++++++- libjava/java/util/TimeZone.java | 8 ++++++-- 10 files changed, 132 insertions(+), 10 deletions(-) diff --git a/libjava/ChangeLog b/libjava/ChangeLog index 655ea87ce18..48cf22dc1f8 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,5 +1,21 @@ 2000-02-03 Tom Tromey + * java/util/Calendar.java (toString): New method. + * java/util/SimpleTimeZone.java (clone): New method. + (toString): New method. + * java/util/TimeZone.java (clone): New method. + * java/text/SimpleDateFormat.java (clone): New method. + * java/text/NumberFormat.java (clone): New method. + (equals): New method. + * java/text/Format.java (clone): New method. + * java/text/DateFormatSymbols.java (DateFormatSymbols): New + constructor. + (clone): New method. + * java/text/DateFormat.java (clone): New method. + * java/text/Collator.java (clone): New method. + +2000-02-03 Tom Tromey + * java/io/PipedOutputStream.java (write(byte[], int, int)): New method. diff --git a/libjava/java/text/Collator.java b/libjava/java/text/Collator.java index 76fc08da73f..5453372c5bc 100644 --- a/libjava/java/text/Collator.java +++ b/libjava/java/text/Collator.java @@ -1,6 +1,6 @@ // Collator.java - Locale-sensitive string comparison. -/* Copyright (C) 1999 Red Hat, Inc. +/* Copyright (C) 1999, 2000 Red Hat, Inc. This file is part of libgcj. @@ -56,6 +56,11 @@ public abstract class Collator implements Cloneable, Serializable return compare (source, target) == 0; } + public Object clone () + { + return super.clone (); + } + public static synchronized Locale[] getAvailableLocales () { // FIXME. diff --git a/libjava/java/text/DateFormat.java b/libjava/java/text/DateFormat.java index e7bbe0cf734..fe20b049302 100644 --- a/libjava/java/text/DateFormat.java +++ b/libjava/java/text/DateFormat.java @@ -1,4 +1,4 @@ -/* Copyright (C) 1998, 1999 Red Hat, Inc. +/* Copyright (C) 1998, 1999, 2000 Red Hat, Inc. This file is part of libgcj. @@ -62,6 +62,12 @@ public abstract class DateFormat extends Format implements Cloneable return calendar.equals(d.calendar) && numberFormat.equals(d.numberFormat); } + public Object clone () + { + // We know the superclass just call's Object's generic cloner. + return super.clone (); + } + public final StringBuffer format (Object obj, StringBuffer buf, FieldPosition pos) { diff --git a/libjava/java/text/DateFormatSymbols.java b/libjava/java/text/DateFormatSymbols.java index 75067225f00..99a053e507d 100644 --- a/libjava/java/text/DateFormatSymbols.java +++ b/libjava/java/text/DateFormatSymbols.java @@ -1,4 +1,4 @@ -/* Copyright (C) 1998, 1999 Red Hat, Inc. +/* Copyright (C) 1998, 1999, 2000 Red Hat, Inc. This file is part of libgcj. @@ -121,6 +121,19 @@ public class DateFormatSymbols extends Object this (Locale.getDefault()); } + // Copy constructor. + private DateFormatSymbols (DateFormatSymbols old) + { + ampms = old.ampms; + eras = old.eras; + localPatternChars = old.localPatternChars; + months = old.months; + shortMonths = old.shortMonths; + shortWeekdays = old.shortWeekdays; + weekdays = old.weekdays; + zoneStrings = old.zoneStrings; + } + public String[] getAmPmStrings() { return ampms; @@ -251,6 +264,11 @@ public class DateFormatSymbols extends Object && equals(zoneStrings, other.zoneStrings)); } + public Object clone () + { + return new DateFormatSymbols (this); + } + public int hashCode () { return (hashCode(ampms) diff --git a/libjava/java/text/Format.java b/libjava/java/text/Format.java index bd3943ad41c..fda14bc755c 100644 --- a/libjava/java/text/Format.java +++ b/libjava/java/text/Format.java @@ -1,4 +1,4 @@ -/* Copyright (C) 1998, 1999 Red Hat, Inc. +/* Copyright (C) 1998, 1999, 2000 Red Hat, Inc. This file is part of libgcj. @@ -48,4 +48,9 @@ public abstract class Format implements java.io.Serializable, Cloneable } return result; } + + public Object clone () + { + return super.clone (); + } } diff --git a/libjava/java/text/NumberFormat.java b/libjava/java/text/NumberFormat.java index 56615915efa..bc96cbc9452 100644 --- a/libjava/java/text/NumberFormat.java +++ b/libjava/java/text/NumberFormat.java @@ -1,4 +1,4 @@ -/* Copyright (C) 1998, 1999 Red Hat, Inc. +/* Copyright (C) 1998, 1999, 2000 Red Hat, Inc. This file is part of libgcj. @@ -50,6 +50,27 @@ public abstract class NumberFormat extends Format implements Cloneable public abstract StringBuffer format (long number, StringBuffer sbuf, FieldPosition pos); + public Object clone () + { + // We know the superclass just uses Object's generic cloner. + // Why not just inherit? Because the online docs specify that + // this method exists for this class. + return super.clone (); + } + + public boolean equals (Object obj) + { + if (! (obj instanceof NumberFormat)) + return false; + NumberFormat nf = (NumberFormat) obj; + return (groupingUsed == nf.groupingUsed + && maximumFractionDigits == nf.maximumFractionDigits + && maximumIntegerDigits == nf.maximumIntegerDigits + && minimumFractionDigits == nf.minimumFractionDigits + && minimumIntegerDigits == nf.minimumIntegerDigits + && parseIntegerOnly == nf.parseIntegerOnly); + } + public static Locale[] getAvailableLocales () { // FIXME. diff --git a/libjava/java/text/SimpleDateFormat.java b/libjava/java/text/SimpleDateFormat.java index 7e237f79dfa..f9bee8eb906 100644 --- a/libjava/java/text/SimpleDateFormat.java +++ b/libjava/java/text/SimpleDateFormat.java @@ -1,4 +1,4 @@ -/* Copyright (C) 1998, 1999 Red Hat, Inc. +/* Copyright (C) 1998, 1999, 2000 Red Hat, Inc. This file is part of libgcj. @@ -512,6 +512,12 @@ public class SimpleDateFormat extends DateFormat other.defaultCenturyStart)); } + public Object clone () + { + // We know the superclass just call's Object's generic cloner. + return super.clone (); + } + public int hashCode () { int hash = super.hashCode(); diff --git a/libjava/java/util/Calendar.java b/libjava/java/util/Calendar.java index 406ccd42ee0..34921d0e062 100644 --- a/libjava/java/util/Calendar.java +++ b/libjava/java/util/Calendar.java @@ -1,4 +1,4 @@ -/* Copyright (C) 1998, 1999 Red Hat, Inc. +/* Copyright (C) 1998, 1999, 2000 Red Hat, Inc. This file is part of libgcj. @@ -108,6 +108,21 @@ public abstract class Calendar implements java.io.Serializable, Cloneable } } + public String toString () + { + // We have much latitude in how we implement this. + return ("areFieldsSet " + areFieldsSet + + "; fields " + fields + + "; firstDayOfWeek " + firstDayOfWeek + + "; isSet " + isSet + + "; isTimeSet " + isTimeSet + + "; lenient " + lenient + + "; minimalDaysInFirstWeek " + minimalDaysInFirstWeek + + "; nextStamp " + nextStamp + + "; time " + time + + "; zone " + zone); + } + public static Calendar getInstance () { return new GregorianCalendar (); diff --git a/libjava/java/util/SimpleTimeZone.java b/libjava/java/util/SimpleTimeZone.java index f8c831569c8..84d43d67f64 100644 --- a/libjava/java/util/SimpleTimeZone.java +++ b/libjava/java/util/SimpleTimeZone.java @@ -1,4 +1,4 @@ -/* Copyright (C) 1998, 1999 Red Hat, Inc. +/* Copyright (C) 1998, 1999, 2000 Red Hat, Inc. This file is part of libgcj. @@ -169,6 +169,32 @@ public class SimpleTimeZone extends TimeZone return getID() == other.getID() && hasSameRules(other); } + public Object clone () + { + // We know the superclass just call's Object's generic cloner. + return super.clone (); + } + + public String toString () + { + // The docs don't say much about how we might implement this. + // We choose a debugging implementation. + return ("dstSavings " + dstSavings + + "; rawOffset " + rawOffset + + "; startDay " + startDay + + "; startDayOfWeek " + startDayOfWeek + + "; startMode " + startMode + + "; startMonth " + startMonth + + "; startTime " + startTime + + "; startYear " + startYear + + "; endDay " + endDay + + "; endDayOfWeek " + endDayOfWeek + + "; endMode " + endMode + + "; endMonth " + endMonth + + "; endTime " + endTime + + "; useDaylight " + useDaylight); + } + public int hashCode () { // FIXME - this does not folow any spec (since none is public)! diff --git a/libjava/java/util/TimeZone.java b/libjava/java/util/TimeZone.java index 37e16237ce8..16772adcdf3 100644 --- a/libjava/java/util/TimeZone.java +++ b/libjava/java/util/TimeZone.java @@ -1,4 +1,4 @@ -/* Copyright (C) 1998, 1999 Red Hat, Inc. +/* Copyright (C) 1998, 1999, 2000 Red Hat, Inc. This file is part of libgcj. @@ -152,7 +152,11 @@ public abstract class TimeZone implements java.io.Serializable, Cloneable return this == other; } - // public Object clone (); + public Object clone () + { + // Just use Object's generic cloner. + return super.clone (); + } // Names of timezones. This array is kept in parallel with // rawOffsets. This list comes from the JCL 1.1 book. -- 2.11.0