This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] Implement getActualMinimum and Maximum


This patch implements the Calendar methods that are no longer abstract
in 1.2 and newer.

2004-04-24  Jerry Quinn  <jlquinn@optonline.net>

        * java/util/Calendar.java (getActualMinimum,
        getActualMaximum):  Remove abstract.  Implement.


*** Calendar.java.~1.18.~	Fri Apr 23 16:14:05 2004
--- Calendar.java	Sat Apr 24 01:04:56 2004
***************
*** 926,933 ****
     * @return the actual minimum value.
     * @since jdk1.2
     */
!   // FIXME: XXX: Not abstract in JDK 1.2.
!   public abstract int getActualMinimum(int field);
  
    /**
     * Gets the actual maximum value that is allowed for the specified field.
--- 926,946 ----
     * @return the actual minimum value.
     * @since jdk1.2
     */
!   public int getActualMinimum(int field)
!   {
!     Calendar tmp = clone();	// To avoid restoring state
!     int min = tmp.getGreatestMinimum(field);
!     int end = tmp.getMinimum(field);
!     tmp.set(field, min);
!     for (; min > end; min--)
!       {
! 	tmp.add(field, -1);	// Try to get smaller
! 	if (tmp.get(field) != min - 1)
! 	  break;		// Done if not successful
! 
!       }
!     return min;
!   }
  
    /**
     * Gets the actual maximum value that is allowed for the specified field.
***************
*** 936,943 ****
     * @return the actual maximum value.  
     * @since jdk1.2
     */
!   // FIXME: XXX: Not abstract in JDK 1.2.
!   public abstract int getActualMaximum(int field);
  
    /**
     * Return a clone of this object.
--- 949,968 ----
     * @return the actual maximum value.  
     * @since jdk1.2
     */
!   public int getActualMaximum(int field)
!   {
!     Calendar tmp = clone();	// To avoid restoring state
!     int max = tmp.getLeastMaximum(field);
!     int end = tmp.getMaximum(field);
!     tmp.set(field, max);
!     for (; max < end; max++)
!       {
! 	tmp.add(field, 1);
! 	if (tmp.get(field) != max + 1)
! 	  break;
!       }
!     return max;
!   }
  
    /**
     * Return a clone of this object.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]