Re: [Fwd: Re: [cp-patches] Comparable in java.util.Calendar]

2005-12-02 Thread Mark Wielaard
Hi Kendall,
 On Tue, 2005-11-22 at 09:55 -0600, Kendall Bell wrote:
  2005-11-21  Kendall Bell  [EMAIL PROTECTED]
  
  * java/util/Calendar.java:
  Implemented Comparable.
  (compareTo) Method added.
 
 Thanks. Could you also email that to the classpath-patches list so
 others can review? Also Tom said that there was another implementation
 on the generics branch (he is in Brazil and can apparently not sent
 email). Could you compare that implementation with your implementation?
 http://savannah.gnu.org/cgi-bin/viewcvs/classpath/classpath/java/util/Calendar.java?only_with_tag=generics-branch

I see your paperwork has gone through and the mailinglist seems to
function again. Have you had time to compare the two implementations?

Thanks,

Mark


signature.asc
Description: This is a digitally signed message part
___
Classpath-patches mailing list
Classpath-patches@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath-patches


[Fwd: Re: [cp-patches] Comparable in java.util.Calendar]

2005-11-25 Thread Kendall Bell






 Original Message 

  

  From: 
  - Thu Nov 24 10:35:50 2005


  X-Account-Key:
  
  account2


  X-UIDL: 
  20051124083124F859


  X-Mozilla-Status:
  
  0011


  X-Mozilla-Status2:
  
  1000


  Received: 
  from gnu.wildebeest.org ([83.160.152.237]) by
mx252d.mysite4now.com (Webhost4life Mail Server v8.0) with ESMTP id
BBC96819 for [EMAIL PROTECTED]; Thu, 24 Nov 2005 08:30:19
-0800


  Received: 
  from elsschot.wildebeest.org ([192.168.1.26]) by
gnu.wildebeest.org with esmtp (Exim 3.36 #1 (Debian)) id
1EfJyb-0002VD-00 for [EMAIL PROTECTED]; Thu, 24 Nov 2005
17:29:37 +0100


  Subject: 
  Re: [cp-patches] Comparable in java.util.Calendar


  From: 
  Mark Wielaard [EMAIL PROTECTED]


  To: 
  Kendall Bell [EMAIL PROTECTED]


  In-Reply-To: 
  [EMAIL PROTECTED]


  References: 
  [EMAIL PROTECTED]
[EMAIL PROTECTED]
[EMAIL PROTECTED]


  Content-Type:
  
  multipart/signed; micalg=pgp-sha1;
protocol="application/pgp-signature"; boundary="=-O8UYY/78d1eZpP5OV/tk"


  Date: 
  Thu, 24 Nov 2005 17:29:37 +0100


  Message-Id: 
  [EMAIL PROTECTED]


  Mime-Version:
  
  1.0


  X-Mailer: 
  Evolution 2.2.3


  X-Spam-Status:
  
  No, hits=0.01 required=3.00 tests=NO_RDNS2 version=3.1


  X-Spam-Level:
  
  
  


  X-Spam-Checker-Version:
  
  SpamAssassin 3.1 (1.5) on mx252d.mysite4now.com

  



Hi Kendall,

On Tue, 2005-11-22 at 09:55 -0600, Kendall Bell wrote:
 2005-11-21  Kendall Bell  [EMAIL PROTECTED]
 
 	* java/util/Calendar.java:
 	Implemented Comparable.
 	(compareTo) Method added.

Thanks. Could you also email that to the classpath-patches list so
others can review? Also Tom said that there was another implementation
on the generics branch (he is in Brazil and can apparently not sent
email). Could you compare that implementation with your implementation?
http://www.gnu.org/philosophy/java-trap.html

Join the community at http://planet.classpath.org/


signature.asc
Description: This is a digitally signed message part
---End Message---


signature.asc
Description: PGP signature
Index: classpath/java/util/Calendar.java
===
RCS file: /cvsroot/classpath/classpath/java/util/Calendar.java,v
retrieving revision 1.47
diff -u -r1.47 Calendar.java
--- classpath/java/util/Calendar.java   1 Oct 2005 19:45:23 -   1.47
+++ classpath/java/util/Calendar.java   22 Nov 2005 15:40:58 -
@@ -103,7 +103,7 @@
  * @see TimeZone
  * @see java.text.DateFormat
  */
-public abstract class Calendar implements Serializable, Cloneable
+public abstract class Calendar implements Serializable, Cloneable, Comparable
 {
   /**
* Constant representing the era time field.
@@ -1290,5 +1290,18 @@
isSet = new boolean[FIELD_COUNT];
areFieldsSet = false;
   }
+  }
+
+  /**
+   *Compares the time values (in millisecond offsets) represented by two Calendar objects.
+   * @param c the calendar to that we should compare.
+   * @return 0, if the given calendar is equal, -1 if it is less then, or 1 if greater then.
+   */
+  public int compareTo(Calendar c)
+  {
+if (getTimeInMillis() == c.getTimeInMillis())
+  return 0;
+// Returns just -1 or 1 on inequality;
+return getTimeInMillis()  c.getTimeInMillis() ? 1 : -1;
   }
 }
begin:vcard
fn:Kendall Bell
n:Bell;Kendall
email;internet:[EMAIL PROTECTED]
x-mozilla-html:FALSE
version:2.1
end:vcard

___
Classpath-patches mailing list
Classpath-patches@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath-patches


Re: Comparable in java.util.Calendar

2005-11-25 Thread Tom Tromey
 Kendall == Kendall Bell [EMAIL PROTECTED] writes:

Kendall I would like to implement Comparable in
Kendall java.util.Calendar.java. I fell that this is necessary for
Kendall compatibility with other JRE's.

Note that this is already done on the generics branch.
But I think it wouldn't hurt anything to also do it on the trunk.

Tom



___
Classpath mailing list
Classpath@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath


Re: [cp-patches] Comparable in java.util.Calendar

2005-11-22 Thread Mark Wielaard
Hi Kendall,

On Mon, 2005-11-21 at 21:35 -0600, Kendall Bell wrote:
 2005-11-21  Kendall Bell  [EMAIL PROTECTED]
 
 * java/util/Calendar.java: Implemented Comparable.

Seems you accidentally attached the original source file, not the diff
-u patch.

Please do include all method names you added/changed in the ChangeLog
entry.

Cheers,

Mark


signature.asc
Description: This is a digitally signed message part
___
Classpath-patches mailing list
Classpath-patches@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath-patches


[cp-patches] Comparable in java.util.Calendar

2005-11-21 Thread Kendall Bell

2005-11-21  Kendall Bell  [EMAIL PROTECTED]

   * java/util/Calendar.java: Implemented Comparable.
 
/* Calendar.java --
   Copyright (C) 1998, 1999, 2000, 2001, 2002, 2004, 2005  Free Software Foundation, Inc.

This file is part of GNU Classpath.

GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.

GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
General Public License for more details.

You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING.  If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.

Linking this library statically or dynamically with other modules is
making a combined work based on this library.  Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.

As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module.  An independent module is a module which is not derived from
or based on this library.  If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so.  If you do not wish to do so, delete this
exception statement from your version. */


package java.util;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

/**
 * This class is an abstract base class for Calendars, which can be
 * used to convert between codeDate/code objects and a set of
 * integer fields which represent codeYEAR/code,
 * codeMONTH/code, codeDAY/code, etc.  The codeDate/code
 * object represents a time in milliseconds since the Epoch. br
 *
 * This class is locale sensitive.  To get the Object matching the
 * current locale you can use codegetInstance/code.  You can even provide
 * a locale or a timezone.  codegetInstance/code returns currently
 * a codeGregorianCalendar/code for the current date. br
 *
 * If you want to convert a date from the Year, Month, Day, DayOfWeek,
 * etc.  Representation to a codeDate/code-Object, you can create
 * a new Calendar with codegetInstance()/code,
 * codeclear()/code all fields, codeset(int,int)/code the
 * fields you need and convert it with codegetTime()/code. br
 *
 * If you want to convert a codeDate/code-object to the Calendar
 * representation, create a new Calendar, assign the
 * codeDate/code-Object with codesetTime()/code, and read the
 * fields with codeget(int)/code. br
 *
 * When computing the date from time fields, it may happen, that there
 * are either two few fields set, or some fields are inconsistent.  This
 * cases will handled in a calendar specific way.  Missing fields are
 * replaced by the fields of the epoch: 1970 January 1 00:00. br
 *
 * To understand, how the day of year is computed out of the fields
 * look at the following table.  It is traversed from top to bottom,
 * and for the first line all fields are set, that line is used to
 * compute the day. br
 *
 *
premonth + day_of_month
month + week_of_month + day_of_week
month + day_of_week_of_month + day_of_week
day_of_year
day_of_week + week_of_year/pre
 *
 * The hour_of_day-field takes precedence over the ampm and
 * hour_of_ampm fields. br
 *
 * STRONGNote:/STRONG This can differ for non-Gregorian calendar. br
 *
 * To convert a calendar to a human readable form and vice versa,  use
 * the codejava.text.DateFormat/code class. br
 *
 * Other useful things you can do with an calendar, is
 * coderoll/codeing fields (that means increase/decrease a
 * specific field by one, propagating overflows), or
 * codeadd/codeing/substracting a fixed amount to a field.
 *
 * @see Date
 * @see GregorianCalendar
 * @see TimeZone
 * @see java.text.DateFormat
 */
public abstract class Calendar implements Serializable, Cloneable
{
  /**
   * Constant representing the era time field.
   */
  public static final int ERA = 0;

  /**
   * Constant representing the year time field.
   */
  public static final int YEAR = 1;

  /**
   * Constant representing the month time field.  This field
   * should contain one of the JANUARY,...,DECEMBER constants below.
   */
  public static final int MONTH = 2;

  /**
   * Constant representing the week of the year field.
   * @see 

Comparable in java.util.Calendar

2005-11-21 Thread Kendall Bell
I would like to implement Comparable in java.util.Calendar.java. I fell 
that this is necessary for compatibility with other JRE's.

Kendall Bell
begin:vcard
fn:Kendall Bell
n:Bell;Kendall
email;internet:[EMAIL PROTECTED]
x-mozilla-html:FALSE
version:2.1
end:vcard

___
Classpath mailing list
Classpath@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath


Re: Comparable in java.util.Calendar

2005-11-21 Thread Stephen Crawley

Kendall Bell wrote:

I would like to implement Comparable in java.util.Calendar.java. I 
fell that this is necessary for compatibility with other JRE's.

Kendall Bell


Which other JRE's are you talking about?

For the record, java.util.Calendar does NOT implement Comparable in the 
JDK 1.4.2.


-- Steve



___
Classpath mailing list
Classpath@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath


Re: Comparable in java.util.Calendar

2005-11-21 Thread Mark Wielaard
Hi Kendall,

On Mon, 2005-11-21 at 17:15 -0600, Kendall Bell wrote:
 I would like to implement Comparable in java.util.Calendar.

That seems like a nice start for a 1.5 addition. Please follow the
Hacking Guide for some general instructions and post a patch to
classpath-patches plus ChangeLog entry when you have something for
review. http://www.gnu.org/software/classpath/docs/hacking.html

I see you already sent the paperwork request forms. Thanks for that.

Happy hacking,

Mark

-- 
Escape the Java Trap with GNU Classpath!
http://www.gnu.org/philosophy/java-trap.html

Join the community at http://planet.classpath.org/


signature.asc
Description: This is a digitally signed message part
___
Classpath mailing list
Classpath@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath