Index: ChangeLog =================================================================== RCS file: /cvsroot/classpath/classpath/ChangeLog,v retrieving revision 1.2386.2.63 diff -u -3 -p -u -r1.2386.2.63 ChangeLog --- ChangeLog 21 Jan 2005 02:16:34 -0000 1.2386.2.63 +++ ChangeLog 22 Jan 2005 02:16:24 -0000 @@ -1,3 +1,60 @@ +2005-01-22 Andrew John Hughes
+ + * java/awt/Checkbox.java: + (AccessibleAWTCheckbox()): Added public constructor + to call superclass. + * java/awt/Choice.java: + (AccessibleAWTChoice): Added class documentation. + (AccessibleAWTChoice()): Added public constructor + to call superclass. + (AccessibleAWTChoice.getAccessibleAction()): Documented. + (AccessibleAWTChoice.getAccessibleRole()): Documented, + and changed role to COMBO_BOX. + (AccessibleAWTChoice.getAccessibleActionCount()): Documented. + (AccessibleAWTChoice.getAccessibleActionDescription(int)): Documented. + (AccessibleAWTChoice.doAccessibleAction(int)): Documented. + +2005-01-21 Andrew John Hughes + + * java/text/SimpleDateFormat.java: + (parse(String, java.text.ParsePosition)): + Changed 'E' and 'M' cases to use both + short and long names. Extended 'z' + case to also handle 'Z', and deal + with simple GMT offsets such as +0100. + (computeOffset(String)): New private method, + which converts a GMT offset specification, + such as GMT-0500 to a numeric offset in + milliseconds. + * java/util/TimeZone.java: + (timezones()): Added "CEST", the daylight + savings time version of "CET", or Central + European Time. + +2005-01-21 Sven de Marothy + + * java/util/Calendar.java: Reformatted. + * java/util/GregorianCalendar.java: Reformatted. + * java/util/SimpleTimeZon.java: Reformatted. + +2005-01-21 Michael Koch + + * javax/swing/DebugGraphics.java: Mostly implemented. + +2005-01-21 Michael Koch + + * javax/swing/SwingUtilities.java + (findFocusOwner): New method. + +2005-01-21 Michael Koch + + * javax/swing/text/DefaultEditorKit.java + (read): Added '\n' after each line. + * javax/swing/text/PlainView.java + (modelToView): Update metrics. + (drawLine): Use offsets from element. + (paint): Update metrics. Draw all lines. + 2005-01-20 Michael Koch * java/awt/print/PrinterJob.java Index: java/awt/Checkbox.java =================================================================== RCS file: /cvsroot/classpath/classpath/java/awt/Checkbox.java,v retrieving revision 1.10.2.3 diff -u -3 -p -u -r1.10.2.3 Checkbox.java --- java/awt/Checkbox.java 21 Jan 2005 02:16:35 -0000 1.10.2.3 +++ java/awt/Checkbox.java 22 Jan 2005 02:16:24 -0000 @@ -113,6 +113,16 @@ protected class AccessibleAWTCheckbox private static final long serialVersionUID = 7881579233144754107L; /** + * Default constructor which simply calls the + * super class for generic component accessibility + * handling. + */ + public AccessibleAWTCheckbox() + { + super(); + } + + /** * Captures changes to the state of the checkbox and * fires appropriate accessible property change events. * Index: java/awt/Choice.java =================================================================== RCS file: /cvsroot/classpath/classpath/java/awt/Choice.java,v retrieving revision 1.15.2.3 diff -u -3 -p -u -r1.15.2.3 Choice.java --- java/awt/Choice.java 16 Jan 2005 15:15:11 -0000 1.15.2.3 +++ java/awt/Choice.java 22 Jan 2005 02:16:24 -0000 @@ -85,23 +85,65 @@ private int selectedIndex = -1; // Listener chain private ItemListener item_listeners; +/** + * This class provides accessibility support for the + * combo box. + * + * @author Jerry Quinn (address@hidden) + * @author Andrew John Hughes (address@hidden) + */ protected class AccessibleAWTChoice - extends Component.AccessibleAWTComponent - implements AccessibleAction + extends AccessibleAWTComponent + implements AccessibleAction { + + /** + * Serialization constant to match JDK 1.5 + */ + private static final long serialVersionUID = 7175603582428509322L; + + /** + * Default constructor which simply calls the + * super class for generic component accessibility + * handling. + */ + public AccessibleAWTChoice() + { + super(); + } + + /** + * Returns an implementation of theAccessibleAction
+ * interface for this accessible object. In this case, the
+ * current instance is simply returned (with a more appropriate
+ * type), as it also implements the accessible action as well as
+ * the context.
+ *
+ * @return the accessible action associated with this context.
+ * @see javax.accessibility.AccessibleAction
+ */
public AccessibleAction getAccessibleAction()
{
return this;
}
- // FIXME: I think this is right, but should be checked by someone who
- // knows better.
+ /**
+ * Returns the role of this accessible object.
+ *
+ * @return the instance of AccessibleRole
,
+ * which describes this object.
+ * @see javax.accessibility.AccessibleRole
+ */
public AccessibleRole getAccessibleRole()
{
- return AccessibleRole.POPUP_MENU;
+ return AccessibleRole.COMBO_BOX;
}
- /* (non-Javadoc)
+ /**
+ * Returns the number of actions associated with this accessible
+ * object. In this case, it is the number of choices available.
+ *
+ * @return the number of choices available.
* @see javax.accessibility.AccessibleAction#getAccessibleActionCount()
*/
public int getAccessibleActionCount()
@@ -109,7 +151,14 @@ private ItemListener item_listeners;
return pItems.size();
}
- /* (non-Javadoc)
+ /**
+ * Returns a description of the action with the supplied id.
+ * In this case, it is the text used in displaying the particular
+ * choice on-screen.
+ *
+ * @param i the id of the choice whose description should be
+ * retrieved.
+ * @return the String
used to describe the choice.
* @see javax.accessibility.AccessibleAction#getAccessibleActionDescription(int)
*/
public String getAccessibleActionDescription(int i)
@@ -117,7 +166,13 @@ private ItemListener item_listeners;
return (String) pItems.get(i);
}
- /* (non-Javadoc)
+ /**
+ * Executes the action with the specified id. In this case,
+ * calling this method provides the same behaviour as would
+ * choosing a choice from the list in a visual manner.
+ *
+ * @param i the id of the choice to select.
+ * @return true if a valid choice was specified.
* @see javax.accessibility.AccessibleAction#doAccessibleAction(int)
*/
public boolean doAccessibleAction(int i)
Index: java/text/SimpleDateFormat.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/text/SimpleDateFormat.java,v
retrieving revision 1.28.2.2
diff -u -3 -p -u -r1.28.2.2 SimpleDateFormat.java
--- java/text/SimpleDateFormat.java 16 Jan 2005 15:15:12 -0000 1.28.2.2
+++ java/text/SimpleDateFormat.java 22 Jan 2005 02:16:25 -0000
@@ -55,6 +55,8 @@ import java.util.Iterator;
import java.util.Locale;
import java.util.SimpleTimeZone;
import java.util.TimeZone;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
/**
* SimpleDateFormat provides convenient methods for parsing and formatting
@@ -673,9 +675,11 @@ public class SimpleDateFormat extends Da
// initial index into the string array.
int calendar_field;
boolean is_numeric = true;
- String[] match = null;
int offset = 0;
boolean maybe2DigitYear = false;
+ Integer simpleOffset;
+ String[] set1 = null;
+ String[] set2 = null;
switch (ch)
{
case 'd':
@@ -691,9 +695,8 @@ public class SimpleDateFormat extends Da
is_numeric = false;
offset = 1;
calendar_field = Calendar.DAY_OF_WEEK;
- match = (fmt_count <= 3
- ? formatData.getShortWeekdays()
- : formatData.getWeekdays());
+ set1 = formatData.getWeekdays();
+ set2 = formatData.getShortWeekdays();
break;
case 'w':
calendar_field = Calendar.WEEK_OF_YEAR;
@@ -708,9 +711,8 @@ public class SimpleDateFormat extends Da
else
{
is_numeric = false;
- match = (fmt_count == 3
- ? formatData.getShortMonths()
- : formatData.getMonths());
+ set1 = formatData.getMonths();
+ set2 = formatData.getShortMonths();
}
break;
case 'y':
@@ -742,9 +744,10 @@ public class SimpleDateFormat extends Da
case 'a':
is_numeric = false;
calendar_field = Calendar.AM_PM;
- match = formatData.getAmPmStrings();
+ set1 = formatData.getAmPmStrings();
break;
case 'z':
+ case 'Z':
// We need a special case for the timezone, because it
// uses a different data structure than the other cases.
is_numeric = false;
@@ -753,42 +756,47 @@ public class SimpleDateFormat extends Da
int zoneCount = zoneStrings.length;
int index = pos.getIndex();
boolean found_zone = false;
- for (int j = 0; j < zoneCount; j++)
+ simpleOffset = computeOffset(dateStr.substring(index));
+ if (simpleOffset != null)
{
- String[] strings = zoneStrings[j];
- int k;
- for (k = 1; k < strings.length; ++k)
- {
- if (dateStr.startsWith(strings[k], index))
- break;
- }
- if (k != strings.length)
+ found_zone = true;
+ saw_timezone = true;
+ offset = simpleOffset.intValue();
+ }
+ else
+ {
+ for (int j = 0; j < zoneCount; j++)
{
- found_zone = true;
- saw_timezone = true;
- TimeZone tz = TimeZone.getTimeZone (strings[0]);
- calendar.set (Calendar.ZONE_OFFSET, tz.getRawOffset ());
- offset = 0;
- if (k > 2 && tz instanceof SimpleTimeZone)
+ String[] strings = zoneStrings[j];
+ int k;
+ for (k = 0; k < strings.length; ++k)
+ {
+ if (dateStr.startsWith(strings[k], index))
+ break;
+ }
+ if (k != strings.length)
{
- SimpleTimeZone stz = (SimpleTimeZone) tz;
- offset = stz.getDSTSavings ();
+ found_zone = true;
+ saw_timezone = true;
+ TimeZone tz = TimeZone.getTimeZone (strings[0]);
+ calendar.set (Calendar.ZONE_OFFSET, tz.getRawOffset ());
+ offset = tz.getDSTSavings();
+ pos.setIndex(index + strings[k].length());
+ break;
}
- pos.setIndex(index + strings[k].length());
- break;
}
}
if (! found_zone)
{
- pos.setErrorIndex(pos.getIndex());
- return null;
+ pos.setErrorIndex(pos.getIndex());
+ return null;
}
break;
default:
pos.setErrorIndex(pos.getIndex());
return null;
}
-
+
// Compute the value we should assign to the field.
int value;
int index = -1;
@@ -804,23 +812,41 @@ public class SimpleDateFormat extends Da
return null;
value = n.intValue() + offset;
}
- else if (match != null)
+ else if (set1 != null)
{
index = pos.getIndex();
int i;
- for (i = offset; i < match.length; ++i)
+ boolean found = false;
+ for (i = offset; i < set1.length; ++i)
{
- if (match[i] != null)
- if (dateStr.toUpperCase().startsWith(match[i].toUpperCase(),
+ if (set1[i] != null)
+ if (dateStr.toUpperCase().startsWith(set1[i].toUpperCase(),
index))
- break;
+ {
+ found = true;
+ pos.setIndex(index + set1[i].length());
+ break;
+ }
+ }
+ if (!found && set2 != null)
+ {
+ for (i = offset; i < set2.length; ++i)
+ {
+ if (set2[i] != null)
+ if (dateStr.toUpperCase().startsWith(set2[i].toUpperCase(),
+ index))
+ {
+ found = true;
+ pos.setIndex(index + set2[i].length());
+ break;
+ }
+ }
}
- if (i == match.length)
+ if (!found)
{
pos.setErrorIndex(index);
return null;
}
- pos.setIndex(index + match[i].length());
value = i;
}
else
@@ -862,6 +888,69 @@ public class SimpleDateFormat extends Da
pos.setErrorIndex(pos.getIndex());
return null;
}
+ }
+
+ /**
+ *
+ * Computes the time zone offset in milliseconds
+ * relative to GMT, based on the supplied
+ * String
representation.
+ *
+ * The supplied String
must be a three
+ * or four digit signed number, with an optional 'GMT'
+ * prefix. The first one or two digits represents the hours,
+ * while the last two represent the minutes. The
+ * two sets of digits can optionally be separated by
+ * ':'. The mandatory sign prefix (either '+' or '-')
+ * indicates the direction of the offset from GMT.
+ *
+ * For example, 'GMT+0200' specifies 2 hours after + * GMT, while '-05:00' specifies 5 hours prior to + * GMT. The special case of 'GMT' alone can be used + * to represent the offset, 0. + *
+ *
+ * If the String
can not be parsed,
+ * the result will be null. The resulting offset
+ * is wrapped in an Integer
object, in
+ * order to allow such failure to be represented.
+ *
YEAR
,
* MONTH
, DAY
, etc. The Date
* object represents a time in milliseconds since the Epoch. getInstance
. You can even provide
* a locale or a timezone. getInstance
returns currently
@@ -78,13 +78,13 @@ import java.lang.reflect.InvocationTarge
* and for the first line all fields are set, that line is used to
* compute the day. month + 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- * + * * The hour_of_day-field takes precedence over the ampm and * hour_of_ampm fields.
java.text.DateFormat
class. roll
ing fields (that means increase/decrease a
* specific field by one, propagating overflows), or
@@ -101,7 +101,7 @@ day_of_week + week_of_year
* @see Date
* @see GregorianCalendar
* @see TimeZone
- * @see java.text.DateFormat
+ * @see java.text.DateFormat
*/
public abstract class Calendar
implements Serializable, Cloneable, Comparabletime
) to time fields
* (fields
). Override this method if you write your
- * own Calendar.
+ * own Calendar.
*/
protected abstract void computeFields();
@@ -549,7 +592,7 @@ public abstract class Calendar
*/
public final Date getTime()
{
- if (!isTimeSet)
+ if (! isTimeSet)
computeTime();
return new Date(time);
}
@@ -570,7 +613,7 @@ public abstract class Calendar
*/
public long getTimeInMillis()
{
- if (!isTimeSet)
+ if (! isTimeSet)
computeTime();
return time;
}
@@ -601,14 +644,14 @@ public abstract class Calendar
public int get(int field)
{
// If the requested field is invalid, force all fields to be recomputed.
- if (!isSet[field])
+ if (! isSet[field])
areFieldsSet = false;
complete();
return fields[field];
}
/**
- * Gets the value of the specified field. This method doesn't
+ * Gets the value of the specified field. This method doesn't
* recompute the fields, if they are invalid.
* @param field the time field. One of the time field constants.
* @return the value of the specified field, undefined if
@@ -659,11 +702,11 @@ public abstract class Calendar
isSet[HOUR_OF_DAY] = false;
break;
case DST_OFFSET:
- explicitDSTOffset = true;
+ explicitDSTOffset = true;
}
// May have crossed over a DST boundary.
- if (!explicitDSTOffset && (field != DST_OFFSET && field != ZONE_OFFSET))
+ if (! explicitDSTOffset && (field != DST_OFFSET && field != ZONE_OFFSET))
isSet[DST_OFFSET] = false;
}
@@ -686,8 +729,8 @@ public abstract class Calendar
isSet[DAY_OF_WEEK] = false;
isSet[DAY_OF_WEEK_IN_MONTH] = false;
- if (!explicitDSTOffset)
- isSet[DST_OFFSET] = false; // May have crossed a DST boundary.
+ if (! explicitDSTOffset)
+ isSet[DST_OFFSET] = false; // May have crossed a DST boundary.
}
/**
@@ -717,8 +760,8 @@ public abstract class Calendar
* @param minute the minute.
* @param second the second.
*/
- public final void set(int year, int month, int date,
- int hour, int minute, int second)
+ public final void set(int year, int month, int date, int hour, int minute,
+ int second)
{
set(year, month, date, hour, minute);
fields[SECOND] = second;
@@ -768,18 +811,18 @@ public abstract class Calendar
/**
* Fills any unset fields in the time field list
- * @return true if the specified field has a value.
+ * @return true if the specified field has a value.
*/
protected void complete()
{
- if (!isTimeSet)
+ if (! isTimeSet)
computeTime();
- if (!areFieldsSet)
+ if (! areFieldsSet)
computeFields();
}
/**
- * Compares the given calendar with this.
+ * Compares the given calendar with this.
* @param o the object to that we should compare.
* @return true, if the given object is a calendar, that represents
* the same time (but doesn't necessary have the same fields).
@@ -787,12 +830,12 @@ public abstract class Calendar
public boolean equals(Object o)
{
return (o instanceof Calendar)
- && getTimeInMillis() == ((Calendar) o).getTimeInMillis();
+ && getTimeInMillis() == ((Calendar) o).getTimeInMillis();
}
/**
* Returns a hash code for this calendar.
- * @return a hash code, which fullfits the general contract of
+ * @return a hash code, which fullfits the general contract of
* hashCode()
*/
public int hashCode()
@@ -802,7 +845,7 @@ public abstract class Calendar
}
/**
- * Compares the given calendar with this.
+ * Compares the given calendar with this.
* @param o the object to that we should compare.
* @return true, if the given object is a calendar, and this calendar
* represents a smaller time than the calendar o.
@@ -815,7 +858,7 @@ public abstract class Calendar
}
/**
- * Compares the given calendar with this.
+ * Compares the given calendar with this.
* @param o the object to that we should compare.
* @return true, if the given object is a calendar, and this calendar
* represents a bigger time than the calendar o.
@@ -842,11 +885,11 @@ public abstract class Calendar
/**
* Rolls the specified time field up or down. This means add one
* to the specified field, but don't change the other fields. If
- * the maximum for this field is reached, start over with the
+ * the maximum for this field is reached, start over with the
* minimum value. FIELD_COUNT
.
@@ -885,7 +928,6 @@ public abstract class Calendar
}
}
-
/**
* Sets the time zone to the specified value.
* @param zone the new time zone
@@ -929,7 +971,7 @@ public abstract class Calendar
/**
* Sets what the first day of week is. This is used for
- * WEEK_OF_MONTH and WEEK_OF_YEAR fields.
+ * WEEK_OF_MONTH and WEEK_OF_YEAR fields.
* @param value the first day of week. One of SUNDAY to SATURDAY.
*/
public void setFirstDayOfWeek(int value)
@@ -939,7 +981,7 @@ public abstract class Calendar
/**
* Gets what the first day of week is. This is used for
- * WEEK_OF_MONTH and WEEK_OF_YEAR fields.
+ * WEEK_OF_MONTH and WEEK_OF_YEAR fields.
* @return the first day of week. One of SUNDAY to SATURDAY.
*/
public int getFirstDayOfWeek()
@@ -983,7 +1025,6 @@ public abstract class Calendar
*/
public abstract int getMaximum(int field);
-
/**
* Gets the greatest minimum value that is allowed for the specified field.
* @param field the time field. One of the time field constants.
@@ -995,7 +1036,7 @@ public abstract class Calendar
* Gets the smallest maximum value that is allowed for the
* specified field. For example this is 28 for DAY_OF_MONTH.
* @param field the time field. One of the time field constants.
- * @return the least maximum value.
+ * @return the least maximum value.
*/
public abstract int getLeastMaximum(int field);
@@ -1011,16 +1052,15 @@ public abstract class Calendar
*/
public int getActualMinimum(int field)
{
- Calendar tmp = (Calendar)clone(); // To avoid restoring state
+ Calendar tmp = (Calendar) 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
+ tmp.add(field, -1); // Try to get smaller
if (tmp.get(field) != min - 1)
- break; // Done if not successful
-
+ break; // Done if not successful
}
return min;
}
@@ -1029,7 +1069,7 @@ public abstract class Calendar
* Gets the actual maximum value that is allowed for the specified field.
* This value is dependent on the values of the other fields.
* @param field the time field. One of the time field constants.
- * @return the actual maximum value.
+ * @return the actual maximum value.
* @throws ArrayIndexOutOfBoundsException if the field is outside
* the valid range. The value of field must be >= 0 and
* <= FIELD_COUNT
.
@@ -1037,7 +1077,7 @@ public abstract class Calendar
*/
public int getActualMaximum(int field)
{
- Calendar tmp = (Calendar)clone(); // To avoid restoring state
+ Calendar tmp = (Calendar) clone(); // To avoid restoring state
int max = tmp.getLeastMaximum(field);
int end = tmp.getMaximum(field);
tmp.set(field, max);
@@ -1066,7 +1106,7 @@ public abstract class Calendar
{
Calendar cal = (Calendar) super.clone();
cal.fields = (int[]) fields.clone();
- cal.isSet = (boolean[])isSet.clone();
+ cal.isSet = (boolean[]) isSet.clone();
return cal;
}
catch (CloneNotSupportedException ex)
@@ -1075,16 +1115,19 @@ public abstract class Calendar
}
}
- private static final String[] fieldNames = {
- ",ERA=", ",YEAR=", ",MONTH=",
- ",WEEK_OF_YEAR=", ",WEEK_OF_MONTH=",
- ",DAY_OF_MONTH=", ",DAY_OF_YEAR=", ",DAY_OF_WEEK=",
- ",DAY_OF_WEEK_IN_MONTH=",
- ",AM_PM=", ",HOUR=", ",HOUR_OF_DAY=",
- ",MINUTE=", ",SECOND=", ",MILLISECOND=",
- ",ZONE_OFFSET=", ",DST_OFFSET="
- };
-
+ private static final String[] fieldNames =
+ {
+ ",ERA=", ",YEAR=", ",MONTH=",
+ ",WEEK_OF_YEAR=",
+ ",WEEK_OF_MONTH=",
+ ",DAY_OF_MONTH=",
+ ",DAY_OF_YEAR=", ",DAY_OF_WEEK=",
+ ",DAY_OF_WEEK_IN_MONTH=",
+ ",AM_PM=", ",HOUR=",
+ ",HOUR_OF_DAY=", ",MINUTE=",
+ ",SECOND=", ",MILLISECOND=",
+ ",ZONE_OFFSET=", ",DST_OFFSET="
+ };
/**
* Returns a string representation of this object. It is mainly
@@ -1127,7 +1170,7 @@ public abstract class Calendar
* says, that it could be omitted. */
private void writeObject(ObjectOutputStream stream) throws IOException
{
- if (!isTimeSet)
+ if (! isTimeSet)
computeTime();
stream.defaultWriteObject();
}
@@ -1139,7 +1182,7 @@ public abstract class Calendar
throws IOException, ClassNotFoundException
{
stream.defaultReadObject();
- if (!isTimeSet)
+ if (! isTimeSet)
computeTime();
if (serialVersionOnStream > 1)
@@ -1148,7 +1191,6 @@ public abstract class Calendar
// Sun wants to remove all fields from the stream someday
// and will then increase the serialVersion number again.
// We prepare to be compatible.
-
fields = new int[FIELD_COUNT];
isSet = new boolean[FIELD_COUNT];
areFieldsSet = false;
Index: java/util/GregorianCalendar.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/util/GregorianCalendar.java,v
retrieving revision 1.26.2.3
diff -u -3 -p -u -r1.26.2.3 GregorianCalendar.java
--- java/util/GregorianCalendar.java 16 Jan 2005 15:15:12 -0000 1.26.2.3
+++ java/util/GregorianCalendar.java 22 Jan 2005 02:16:25 -0000
@@ -39,6 +39,7 @@ exception statement from your version. *
package java.util;
+
/**
* * This class represents the Gregorian calendar, that is used in most @@ -46,7 +47,7 @@ package java.util; * for dates smaller than the date of the change to the Gregorian calendar. * The Gregorian calendar differs from the Julian calendar by a different * leap year rule (no leap year every 100 years, except if year is divisible - * by 400). + * by 400). *
** This change date is different from country to country, and can be changed with @@ -136,7 +137,7 @@ public class GregorianCalendar extends C * Constant representing the era BC (Before Christ). */ public static final int BC = 0; - + /** * Constant representing the era AD (Anno Domini). */ @@ -171,36 +172,36 @@ public class GregorianCalendar extends C * @param locale the locale in use for this calendar. * @return A resource bundle for the calendar for the specified locale. */ - private static ResourceBundle getBundle(Locale locale) + private static ResourceBundle getBundle(Locale locale) { return ResourceBundle.getBundle(bundleName, locale, - ClassLoader.getSystemClassLoader()); + ClassLoader.getSystemClassLoader()); } /** * Constructs a new GregorianCalender representing the current - * time, using the default time zone and the default locale. + * time, using the default time zone and the default locale. */ public GregorianCalendar() { this(TimeZone.getDefault(), Locale.getDefault()); } - + /** * Constructs a new GregorianCalender representing the current - * time, using the specified time zone and the default locale. - * + * time, using the specified time zone and the default locale. + * * @param zone a time zone. */ public GregorianCalendar(TimeZone zone) { this(zone, Locale.getDefault()); } - + /** * Constructs a new GregorianCalender representing the current * time, using the default time zone and the specified locale. - * + * * @param locale a locale. */ public GregorianCalendar(Locale locale) @@ -212,8 +213,8 @@ public class GregorianCalendar extends C * Constructs a new GregorianCalender representing the current * time with the given time zone and the given locale. * - * @param zone a time zone. - * @param locale a locale. + * @param zone a time zone. + * @param locale a locale. */ public GregorianCalendar(TimeZone zone, Locale locale) { @@ -224,8 +225,8 @@ public class GregorianCalendar extends C /** * Common constructor that all constructors should call. - * @param zone a time zone. - * @param locale a locale. + * @param zone a time zone. + * @param locale a locale. * @param unused unused parameter to make the signature differ from * the public constructor (TimeZone, Locale). */ @@ -277,8 +278,8 @@ public class GregorianCalendar extends C * @param minute corresponds to the MINUTE time field. * @param second corresponds to the SECOND time field. */ - public GregorianCalendar(int year, int month, int day, - int hour, int minute, int second) + public GregorianCalendar(int year, int month, int day, int hour, int minute, + int second) { this(TimeZone.getDefault(), Locale.getDefault(), false); set(year, month, day, hour, minute, second); @@ -321,7 +322,7 @@ public class GregorianCalendar extends C *
* * @param year a year (use a negative value for BC). - * @return true, if the given year is a leap year, false otherwise. + * @return true, if the given year is a leap year, false otherwise. */ public boolean isLeapYear(int year) { @@ -332,9 +333,9 @@ public class GregorianCalendar extends C // compute the linear day of the 29. February of that year. // The 13 is the number of days, that were omitted in the Gregorian // Calender until the epoch. - int julianDay = (((year-1) * (365*4+1)) >> 2) + (31+29 - - (((1970-1) * (365*4+1)) / 4 + 1 - 13)); - + int julianDay = (((year - 1) * (365 * 4 + 1)) >> 2) + + (31 + 29 - (((1970 - 1) * (365 * 4 + 1)) / 4 + 1 - 13)); + // If that day is smaller than the gregorianChange the julian // rule applies: This is a leap year since it is divisible by 4. if (julianDay * (24 * 60 * 60 * 1000L) < gregorianCutover) @@ -352,7 +353,7 @@ public class GregorianCalendar extends C * @param year the year of the date. * @param dayOfYear the day of year of the date; 1 based. * @param millis the millisecond in that day. - * @return the days since the epoch, may be negative. + * @return the days since the epoch, may be negative. */ private long getLinearTime(int year, int dayOfYear, int millis) { @@ -360,8 +361,8 @@ public class GregorianCalendar extends C // Calendar until the epoch. // We shift right by 2 instead of dividing by 4, to get correct // results for negative years (and this is even more efficient). - int julianDay = ((year * (365 * 4 + 1)) >> 2) + dayOfYear - - ((1970 * (365 * 4 + 1)) / 4 + 1 - 13); + int julianDay = ((year * (365 * 4 + 1)) >> 2) + dayOfYear + - ((1970 * (365 * 4 + 1)) / 4 + 1 - 13); long time = julianDay * (24 * 60 * 60 * 1000L) + millis; if (time >= gregorianCutover) @@ -378,7 +379,7 @@ public class GregorianCalendar extends C // And on and after the leap day, the leap day has already been // included in dayOfYear. int gregOffset = (year / 400) - (year / 100) + 2; - if (isLeapYear (year, true)) + if (isLeapYear(year, true)) --gregOffset; time += gregOffset * (24 * 60 * 60 * 1000L); } @@ -395,8 +396,7 @@ public class GregorianCalendar extends C */ private int getWeekDay(int year, int dayOfYear) { - int day = - (int) (getLinearTime(year, dayOfYear, 0) / (24 * 60 * 60 * 1000L)); + int day = (int) (getLinearTime(year, dayOfYear, 0) / (24 * 60 * 60 * 1000L)); // The epoch was a thursday. int weekday = (day + THURSDAY) % 7; @@ -407,7 +407,7 @@ public class GregorianCalendar extends C /** *- * Calculate the dayOfYear from the fields array. + * Calculate the dayOfYear from the fields array. * The relativeDays is used, to account for weeks that begin before * the Gregorian change and end after it. *
@@ -416,13 +416,13 @@ public class GregorianCalendar extends C * should use the Gregorian calendar or the Julian calendar, in order * to handle the change year. The second is a relative day after the given * day. This is necessary for week calculation in the year in - * which the Gregorian change occurs. + * which the Gregorian change occurs. * - * + * * @param year the year, negative for BC. * @return an array of two integer values, the first containing a reference * day in the current year, the second a relative count since this reference - * day. + * day. */ private int[] getDayOfYear(int year) { @@ -431,7 +431,6 @@ public class GregorianCalendar extends C int dayOfYear; if (fields[MONTH] > FEBRUARY) { - // The months after February are regular: // 9 is an offset found by try and error. dayOfYear = (fields[MONTH] * (31 + 30 + 31 + 30 + 31) - 9) / 5; @@ -439,75 +438,76 @@ public class GregorianCalendar extends C dayOfYear++; } else - dayOfYear = 31 * fields[MONTH]; + dayOfYear = 31 * fields[MONTH]; if (isSet[DAY_OF_MONTH]) - { - return new int[] - { - dayOfYear + fields[DAY_OF_MONTH], 0}; - } + return new int[] { dayOfYear + fields[DAY_OF_MONTH], 0 }; if (isSet[WEEK_OF_MONTH] && isSet[DAY_OF_WEEK]) { // the weekday of the first day in that month is: int weekday = getWeekDay(year, ++dayOfYear); return new int[] - { - dayOfYear, - // the day of week in the first week - // (weeks starting on sunday) is: - fields[DAY_OF_WEEK] - weekday + - // Now jump to the right week and correct the possible - // error made by assuming sunday is the first week day. - 7 * (fields[WEEK_OF_MONTH] - + (fields[DAY_OF_WEEK] < getFirstDayOfWeek()? 0 : -1) - + (weekday < getFirstDayOfWeek()? -1 : 0))}; + { + dayOfYear, + // the day of week in the first week + // (weeks starting on sunday) is: + fields[DAY_OF_WEEK] - weekday + + // Now jump to the right week and correct the possible + // error made by assuming sunday is the first week day. + 7 * (fields[WEEK_OF_MONTH] + + (fields[DAY_OF_WEEK] < getFirstDayOfWeek() ? 0 : -1) + + (weekday < getFirstDayOfWeek() ? -1 : 0)) + }; } if (isSet[DAY_OF_WEEK] && isSet[DAY_OF_WEEK_IN_MONTH]) { // the weekday of the first day in that month is: int weekday = getWeekDay(year, ++dayOfYear); - return new int[] { - dayOfYear, - fields[DAY_OF_WEEK] - weekday + - 7 * (fields[DAY_OF_WEEK_IN_MONTH] - + (fields[DAY_OF_WEEK] < weekday ? 0 : -1))}; + return new int[] + { + dayOfYear, + fields[DAY_OF_WEEK] - weekday + + 7 * (fields[DAY_OF_WEEK_IN_MONTH] + + (fields[DAY_OF_WEEK] < weekday ? 0 : -1)) + }; } } // MONTH + something did not succeed. if (isSet[DAY_OF_YEAR]) - { - return new int[] {0, fields[DAY_OF_YEAR]}; - } - + return new int[] { 0, fields[DAY_OF_YEAR] }; + if (isSet[DAY_OF_WEEK] && isSet[WEEK_OF_YEAR]) { int dayOfYear = getMinimalDaysInFirstWeek(); + // the weekday of the day, that begins the first week // in that year is: int weekday = getWeekDay(year, dayOfYear); - return new int[] { - dayOfYear, - // the day of week in the first week - // (weeks starting on sunday) is: - fields[DAY_OF_WEEK] - weekday - // Now jump to the right week and correct the possible - // error made by assuming sunday is the first week day. - + 7 * (fields[WEEK_OF_YEAR] - + (fields[DAY_OF_WEEK] < getFirstDayOfWeek()? 0 : -1) - + (weekday < getFirstDayOfWeek()? -1 : 0))}; + return new int[] + { + dayOfYear, + + // the day of week in the first week + // (weeks starting on sunday) is: + fields[DAY_OF_WEEK] - weekday + // Now jump to the right week and correct the possible + // error made by assuming sunday is the first week day. + + 7 * (fields[WEEK_OF_YEAR] + + (fields[DAY_OF_WEEK] < getFirstDayOfWeek() ? 0 : -1) + + (weekday < getFirstDayOfWeek() ? -1 : 0)) + }; } // As last resort return Jan, 1st. - return new int[] {1, 0}; + return new int[] { 1, 0 }; } /** * Converts the time field values (fields
) to
- * milliseconds since the epoch UTC (time
).
+ * milliseconds since the epoch UTC (time
).
*
* @throws IllegalArgumentException if any calendar fields
* are invalid.
@@ -542,9 +542,9 @@ public class GregorianCalendar extends C
else if (isSet[HOUR])
{
hour = fields[HOUR];
- if (isSet[AM_PM] && fields[AM_PM] == PM)
+ if (isSet[AM_PM] && fields[AM_PM] == PM)
if (hour != 12) /* not Noon */
- hour += 12;
+ hour += 12;
/* Fix the problem of the status of 12:00 AM (midnight). */
if (isSet[AM_PM] && fields[AM_PM] == AM && hour == 12)
hour = 0;
@@ -559,14 +559,14 @@ public class GregorianCalendar extends C
{
// prevent overflow
long allMillis = (((hour * 60L) + minute) * 60L + second) * 1000L
- + millis;
+ + millis;
daysOfYear[1] += allMillis / (24 * 60 * 60 * 1000L);
millisInDay = (int) (allMillis % (24 * 60 * 60 * 1000L));
}
else
{
- if (hour < 0 || hour >= 24 || minute < 0 || minute > 59
- || second < 0 || second > 59 || millis < 0 || millis >= 1000)
+ if (hour < 0 || hour >= 24 || minute < 0 || minute > 59 || second < 0
+ || second > 59 || millis < 0 || millis >= 1000)
throw new IllegalArgumentException();
millisInDay = (((hour * 60) + minute) * 60 + second) * 1000 + millis;
}
@@ -576,10 +576,9 @@ public class GregorianCalendar extends C
// get right behaviour when jumping over the gregorianCutover.
time += daysOfYear[1] * (24 * 60 * 60 * 1000L);
-
TimeZone zone = getTimeZone();
- int rawOffset = isSet[ZONE_OFFSET]
- ? fields[ZONE_OFFSET] : zone.getRawOffset();
+ int rawOffset = isSet[ZONE_OFFSET] ? fields[ZONE_OFFSET]
+ : zone.getRawOffset();
int day = (int) (time / (24 * 60 * 60 * 1000L));
millisInDay = (int) (time % (24 * 60 * 60 * 1000L));
@@ -595,18 +594,20 @@ public class GregorianCalendar extends C
int month = f[MONTH];
day = f[DAY_OF_MONTH];
int weekday = f[DAY_OF_WEEK];
- int dstOffset = isSet[DST_OFFSET]
- ? fields[DST_OFFSET] : (zone.getOffset((year < 0) ? BC : AD,
- (year < 0) ? 1 - year : year,
- month, day, weekday, millisInDay)
- - zone.getRawOffset());
+ int dstOffset = isSet[DST_OFFSET] ? fields[DST_OFFSET]
+ : (zone.getOffset((year < 0) ? BC : AD,
+ (year < 0) ? 1 - year
+ : year,
+ month, day, weekday,
+ millisInDay)
+ - zone.getRawOffset());
time -= rawOffset + dstOffset;
isTimeSet = true;
}
/**
* - * Determines if the given year is a leap year. + * Determines if the given year is a leap year. *
*
* To specify a year in the BC era, use a negative value calculated
@@ -616,7 +617,7 @@ public class GregorianCalendar extends C
*
* @param year a year (use a negative value for BC).
* @param gregorian if true, use the gregorian leap year rule.
- * @return true, if the given year is a leap year, false otherwise.
+ * @return true, if the given year is a leap year, false otherwise.
*/
private boolean isLeapYear(int year, boolean gregorian)
{
@@ -624,7 +625,7 @@ public class GregorianCalendar extends C
// Only years divisible by 4 can be leap years
return false;
- if (!gregorian)
+ if (! gregorian)
return true;
// We rely on AD area here.
@@ -635,12 +636,12 @@ public class GregorianCalendar extends C
* Get the linear day in days since the epoch, using the
* Julian or Gregorian calendar as specified. If you specify a
* nonpositive year it is interpreted as BC as following: 0 is 1
- * BC, -1 is 2 BC and so on.
+ * BC, -1 is 2 BC and so on.
*
* @param year the year of the date.
* @param dayOfYear the day of year of the date; 1 based.
* @param gregorian true
, if we should use the Gregorian rules.
- * @return the days since the epoch, may be negative.
+ * @return the days since the epoch, may be negative.
*/
private long getLinearDay(int year, int dayOfYear, boolean gregorian)
{
@@ -648,8 +649,8 @@ public class GregorianCalendar extends C
// Calender until the epoch.
// We shift right by 2 instead of dividing by 4, to get correct
// results for negative years (and this is even more efficient).
- long julianDay = ((year * (365L * 4 + 1)) >> 2) + dayOfYear -
- ((1970 * (365 * 4 + 1)) / 4 + 1 - 13);
+ long julianDay = ((year * (365L * 4 + 1)) >> 2) + dayOfYear
+ - ((1970 * (365 * 4 + 1)) / 4 + 1 - 13);
if (gregorian)
{
@@ -663,7 +664,7 @@ public class GregorianCalendar extends C
// The additional leap year factor accounts for the fact that
// a leap day is not seen on Jan 1 of the leap year.
int gregOffset = (year / 400) - (year / 100) + 2;
- if (isLeapYear (year, true) && dayOfYear < 31 + 29)
+ if (isLeapYear(year, true) && dayOfYear < 31 + 29)
--gregOffset;
julianDay += gregOffset;
}
@@ -675,22 +676,23 @@ public class GregorianCalendar extends C
* day_of_year, day_of_month, day_of_week, and writes the result
* into the fields array.
*
- * @param day the linear day.
+ * @param day the linear day.
* @param gregorian true, if we should use Gregorian rules.
*/
private void calculateDay(int[] fields, long day, boolean gregorian)
{
// the epoch is a Thursday.
- int weekday = (int)(day + THURSDAY) % 7;
+ int weekday = (int) (day + THURSDAY) % 7;
if (weekday <= 0)
weekday += 7;
fields[DAY_OF_WEEK] = weekday;
// get a first approximation of the year. This may be one
// year too big.
- int year = 1970 + (int)(gregorian
- ? ((day - 100) * 400) / (365 * 400 + 100 - 4 + 1)
- : ((day - 100) * 4) / (365 * 4 + 1));
+ int year = 1970
+ + (int) (gregorian
+ ? ((day - 100) * 400) / (365 * 400 + 100 - 4 + 1)
+ : ((day - 100) * 4) / (365 * 4 + 1));
if (day >= 0)
year++;
@@ -703,9 +705,9 @@ public class GregorianCalendar extends C
firstDayOfYear = getLinearDay(year, 1, gregorian);
}
- day -= firstDayOfYear - 1; // day of year, one based.
+ day -= firstDayOfYear - 1; // day of year, one based.
- fields[DAY_OF_YEAR] = (int)day;
+ fields[DAY_OF_YEAR] = (int) day;
if (year <= 0)
{
fields[ERA] = BC;
@@ -720,13 +722,13 @@ public class GregorianCalendar extends C
int leapday = isLeapYear(year, gregorian) ? 1 : 0;
if (day <= 31 + 28 + leapday)
{
- fields[MONTH] = (int)day / 32; // 31->JANUARY, 32->FEBRUARY
- fields[DAY_OF_MONTH] = (int)day - 31 * fields[MONTH];
+ fields[MONTH] = (int) day / 32; // 31->JANUARY, 32->FEBRUARY
+ fields[DAY_OF_MONTH] = (int) day - 31 * fields[MONTH];
}
else
{
// A few more magic formulas
- int scaledDay = ((int)day - leapday) * 5 + 8;
+ int scaledDay = ((int) day - leapday) * 5 + 8;
fields[MONTH] = scaledDay / (31 + 30 + 31 + 30 + 31);
fields[DAY_OF_MONTH] = (scaledDay % (31 + 30 + 31 + 30 + 31)) / 5 + 1;
}
@@ -754,10 +756,10 @@ public class GregorianCalendar extends C
}
calculateDay(fields, day, gregorian);
- fields[DST_OFFSET] =
- zone.getOffset(fields[ERA], fields[YEAR], fields[MONTH],
- fields[DAY_OF_MONTH], fields[DAY_OF_WEEK],
- millisInDay) - fields[ZONE_OFFSET];
+ fields[DST_OFFSET] = zone.getOffset(fields[ERA], fields[YEAR],
+ fields[MONTH], fields[DAY_OF_MONTH],
+ fields[DAY_OF_WEEK], millisInDay)
+ - fields[ZONE_OFFSET];
millisInDay += fields[DST_OFFSET];
if (millisInDay >= 24 * 60 * 60 * 1000)
@@ -778,13 +780,12 @@ public class GregorianCalendar extends C
// Do the Correction: getMinimalDaysInFirstWeek() is always in the
// first week.
int minDays = getMinimalDaysInFirstWeek();
- int firstWeekday =
- (7 + getWeekDay(fields[YEAR], minDays) - getFirstDayOfWeek()) % 7;
+ int firstWeekday = (7 + getWeekDay(fields[YEAR], minDays)
+ - getFirstDayOfWeek()) % 7;
if (minDays - firstWeekday < 1)
weekOfYear++;
fields[WEEK_OF_YEAR] = weekOfYear;
-
int hourOfDay = millisInDay / (60 * 60 * 1000);
fields[AM_PM] = (hourOfDay < 12) ? AM : PM;
int hour = hourOfDay % 12;
@@ -796,14 +797,7 @@ public class GregorianCalendar extends C
fields[SECOND] = millisInDay / (1000);
fields[MILLISECOND] = millisInDay % 1000;
-
- areFieldsSet = isSet[ERA] = isSet[YEAR] = isSet[MONTH] =
- isSet[WEEK_OF_YEAR] = isSet[WEEK_OF_MONTH] =
- isSet[DAY_OF_MONTH] = isSet[DAY_OF_YEAR] = isSet[DAY_OF_WEEK] =
- isSet[DAY_OF_WEEK_IN_MONTH] = isSet[AM_PM] = isSet[HOUR] =
- isSet[HOUR_OF_DAY] = isSet[MINUTE] = isSet[SECOND] =
- isSet[MILLISECOND] = isSet[ZONE_OFFSET] = isSet[DST_OFFSET] = true;
-
+ areFieldsSet = isSet[ERA] = isSet[YEAR] = isSet[MONTH] = isSet[WEEK_OF_YEAR] = isSet[WEEK_OF_MONTH] = isSet[DAY_OF_MONTH] = isSet[DAY_OF_YEAR] = isSet[DAY_OF_WEEK] = isSet[DAY_OF_WEEK_IN_MONTH] = isSet[AM_PM] = isSet[HOUR] = isSet[HOUR_OF_DAY] = isSet[MINUTE] = isSet[SECOND] = isSet[MILLISECOND] = isSet[ZONE_OFFSET] = isSet[DST_OFFSET] = true;
}
/**
@@ -811,7 +805,7 @@ public class GregorianCalendar extends C
* equivalent to this if it is also a GregorianCalendar
* with the same time since the epoch under the same conditions
* (same change date and same time zone).
- *
+ *
* @param o the object to that we should compare.
* @return true, if the given object is a calendar, that represents
* the same time (but doesn't necessarily have the same fields).
@@ -823,7 +817,7 @@ public class GregorianCalendar extends C
*/
public boolean equals(Object o)
{
- if (!(o instanceof GregorianCalendar))
+ if (! (o instanceof GregorianCalendar))
return false;
GregorianCalendar cal = (GregorianCalendar) o;
@@ -839,11 +833,9 @@ public class GregorianCalendar extends C
// public boolean before(Object o) {
// if (!(o instanceof GregorianCalendar))
// return false;
-
// GregorianCalendar cal = (GregorianCalendar) o;
// return (cal.getTimeInMillis() < getTimeInMillis());
// }
-
// /**
// * Compares the given calender with this.
// * @param o the object to that we should compare.
@@ -853,7 +845,6 @@ public class GregorianCalendar extends C
// public boolean after(Object o) {
// if (!(o instanceof GregorianCalendar))
// return false;
-
// GregorianCalendar cal = (GregorianCalendar) o;
// return (cal.getTimeInMillis() > getTimeInMillis());
// }
@@ -864,7 +855,7 @@ public class GregorianCalendar extends C
* it does what you expect: Jan, 25 + 10 Days is Feb, 4.
* @param field one of the time field constants.
* @param amount the amount of time to add.
- * @exception IllegalArgumentException if field
is
+ * @exception IllegalArgumentException if field
is
* ZONE_OFFSET
, DST_OFFSET
, or invalid; or
* if amount
contains an out-of-range value and the calendar
* is not in lenient mode.
@@ -899,7 +890,7 @@ public class GregorianCalendar extends C
case DAY_OF_MONTH:
case DAY_OF_YEAR:
case DAY_OF_WEEK:
- if (!isTimeSet)
+ if (! isTimeSet)
computeTime();
time += amount * (24 * 60 * 60 * 1000L);
areFieldsSet = false;
@@ -907,59 +898,57 @@ public class GregorianCalendar extends C
case WEEK_OF_YEAR:
case WEEK_OF_MONTH:
case DAY_OF_WEEK_IN_MONTH:
- if (!isTimeSet)
+ if (! isTimeSet)
computeTime();
time += amount * (7 * 24 * 60 * 60 * 1000L);
areFieldsSet = false;
break;
case AM_PM:
- if (!isTimeSet)
+ if (! isTimeSet)
computeTime();
time += amount * (12 * 60 * 60 * 1000L);
areFieldsSet = false;
break;
case HOUR:
case HOUR_OF_DAY:
- if (!isTimeSet)
+ if (! isTimeSet)
computeTime();
time += amount * (60 * 60 * 1000L);
areFieldsSet = false;
break;
case MINUTE:
- if (!isTimeSet)
+ if (! isTimeSet)
computeTime();
time += amount * (60 * 1000L);
areFieldsSet = false;
break;
case SECOND:
- if (!isTimeSet)
+ if (! isTimeSet)
computeTime();
time += amount * (1000L);
areFieldsSet = false;
break;
case MILLISECOND:
- if (!isTimeSet)
+ if (! isTimeSet)
computeTime();
time += amount;
areFieldsSet = false;
break;
case ZONE_OFFSET:
- case DST_OFFSET:
- default:
+ case DST_OFFSET:default:
throw new IllegalArgumentException("Invalid or unknown field");
}
}
-
/**
* Rolls the specified time field up or down. This means add one
* to the specified field, but don't change the other fields. If
- * the maximum for this field is reached, start over with the
- * minimum value.
+ * the maximum for this field is reached, start over with the
+ * minimum value.
*
* Note: There may be situation, where the other
- * fields must be changed, e.g rolling the month on May, 31.
- * The date June, 31 is automatically converted to July, 1.
+ * fields must be changed, e.g rolling the month on May, 31.
+ * The date June, 31 is automatically converted to July, 1.
* This requires lenient settings.
*
* @param field the time field. One of the time field constants.
@@ -1001,7 +990,6 @@ public class GregorianCalendar extends C
isSet[DAY_OF_YEAR] = false;
isSet[WEEK_OF_YEAR] = false;
break;
-
case DAY_OF_MONTH:
isSet[WEEK_OF_MONTH] = false;
isSet[DAY_OF_WEEK] = false;
@@ -1010,7 +998,6 @@ public class GregorianCalendar extends C
isSet[WEEK_OF_YEAR] = false;
time += delta * (24 * 60 * 60 * 1000L);
break;
-
case WEEK_OF_MONTH:
isSet[DAY_OF_MONTH] = false;
isSet[DAY_OF_WEEK_IN_MONTH] = false;
@@ -1042,7 +1029,6 @@ public class GregorianCalendar extends C
isSet[DAY_OF_YEAR] = false;
time += delta * (7 * 24 * 60 * 60 * 1000L);
break;
-
case AM_PM:
isSet[HOUR_OF_DAY] = false;
time += delta * (12 * 60 * 60 * 1000L);
@@ -1056,7 +1042,6 @@ public class GregorianCalendar extends C
isSet[AM_PM] = false;
time += delta * (60 * 60 * 1000L);
break;
-
case MINUTE:
time += delta * (60 * 1000L);
break;
@@ -1076,7 +1061,7 @@ public class GregorianCalendar extends C
* with the minimum value and vice versa for negative amounts.
*
* Note: There may be situation, where the other
- * fields must be changed, e.g rolling the month on May, 31.
+ * fields must be changed, e.g rolling the month on May, 31.
* The date June, 31 is automatically corrected to June, 30.
*
* @param field the time field. One of the time field constants.
@@ -1113,16 +1098,23 @@ public class GregorianCalendar extends C
/**
* The minimum values for the calendar fields.
*/
- private static final int[] minimums =
- { BC, 1, 0, 0, 1, 1, 1, SUNDAY, 1,
- AM, 1, 0, 1, 1, 1, -(12*60*60*1000), 0 };
+ private static final int[] minimums =
+ {
+ BC, 1, 0, 0, 1, 1, 1, SUNDAY, 1, AM,
+ 1, 0, 1, 1, 1, -(12 * 60 * 60 * 1000),
+ 0
+ };
/**
* The maximum values for the calendar fields.
*/
- private static final int[] maximums =
- { AD, 5000000, 11, 53, 5, 31, 366, SATURDAY, 5,
- PM, 12, 23, 59, 59, 999, +(12*60*60*1000), (12*60*60*1000) };
+ private static final int[] maximums =
+ {
+ AD, 5000000, 11, 53, 5, 31, 366,
+ SATURDAY, 5, PM, 12, 23, 59, 59, 999,
+ +(12 * 60 * 60 * 1000),
+ (12 * 60 * 60 * 1000)
+ };
/**
* Gets the smallest value that is allowed for the specified field.
@@ -1146,7 +1138,6 @@ public class GregorianCalendar extends C
return maximums[field];
}
-
/**
* Gets the greatest minimum value that is allowed for the specified field.
* This is the largest value returned by the getActualMinimum(int)
@@ -1171,7 +1162,7 @@ public class GregorianCalendar extends C
* 28 days).
*
* @param field the time field. One of the time field constants.
- * @return the least maximum value.
+ * @return the least maximum value.
* @see #getActualMaximum(int)
* @since 1.2
*/
@@ -1211,7 +1202,7 @@ public class GregorianCalendar extends C
int min = getMinimalDaysInFirstWeek();
if (min == 0)
return 1;
- if (!areFieldsSet || !isSet[ERA] || !isSet[YEAR])
+ if (! areFieldsSet || ! isSet[ERA] || ! isSet[YEAR])
complete();
int year = fields[ERA] == AD ? fields[YEAR] : 1 - fields[YEAR];
@@ -1232,45 +1223,46 @@ public class GregorianCalendar extends C
* 29, rather than 28.
*
* @param field the time field. One of the time field constants.
- * @return the actual maximum value.
+ * @return the actual maximum value.
*/
public int getActualMaximum(int field)
{
switch (field)
{
case WEEK_OF_YEAR:
- {
- if (!areFieldsSet || !isSet[ERA] || !isSet[YEAR])
+ {
+ if (! areFieldsSet || ! isSet[ERA] || ! isSet[YEAR])
complete();
+
// This is wrong for the year that contains the gregorian change.
// I.e it gives the weeks in the julian year or in the gregorian
// year in that case.
int year = fields[ERA] == AD ? fields[YEAR] : 1 - fields[YEAR];
int lastDay = isLeapYear(year) ? 366 : 365;
int weekday = getWeekDay(year, lastDay);
- int week = (lastDay + 6
- - (7 + weekday - getFirstDayOfWeek()) % 7) / 7;
+ int week = (lastDay + 6 - (7 + weekday - getFirstDayOfWeek()) % 7) / 7;
int minimalDays = getMinimalDaysInFirstWeek();
int firstWeekday = getWeekDay(year, minimalDays);
- /*
+ /*
* Is there a set of days at the beginning of the year, before the
* first day of the week, equal to or greater than the minimum number
* of days required in the first week?
*/
if (minimalDays - (7 + firstWeekday - getFirstDayOfWeek()) % 7 < 1)
return week + 1; /* Add week 1: firstWeekday through to firstDayOfWeek */
- }
- case DAY_OF_MONTH:
- {
- if (!areFieldsSet || !isSet[MONTH])
+ }
+ case DAY_OF_MONTH:
+ {
+ if (! areFieldsSet || ! isSet[MONTH])
complete();
int month = fields[MONTH];
+
// If you change this, you should also change
// SimpleTimeZone.getDaysInMonth();
if (month == FEBRUARY)
{
- if (!isSet[YEAR] || !isSet[ERA])
+ if (! isSet[YEAR] || ! isSet[ERA])
complete();
int year = fields[ERA] == AD ? fields[YEAR] : 1 - fields[YEAR];
return isLeapYear(year) ? 29 : 28;
@@ -1279,33 +1271,31 @@ public class GregorianCalendar extends C
return 31 - (month & 1);
else
return 30 + (month & 1);
- }
+ }
case DAY_OF_YEAR:
- {
- if (!areFieldsSet || !isSet[ERA] || !isSet[YEAR])
+ {
+ if (! areFieldsSet || ! isSet[ERA] || ! isSet[YEAR])
complete();
int year = fields[ERA] == AD ? fields[YEAR] : 1 - fields[YEAR];
return isLeapYear(year) ? 366 : 365;
- }
+ }
case DAY_OF_WEEK_IN_MONTH:
- {
+ {
// This is wrong for the month that contains the gregorian change.
int daysInMonth = getActualMaximum(DAY_OF_MONTH);
+
// That's black magic, I know
return (daysInMonth - (fields[DAY_OF_MONTH] - 1) % 7 + 6) / 7;
- }
+ }
case WEEK_OF_MONTH:
- {
+ {
int daysInMonth = getActualMaximum(DAY_OF_MONTH);
int weekday = (daysInMonth - fields[DAY_OF_MONTH]
- + fields[DAY_OF_WEEK] - SUNDAY) % 7 + SUNDAY;
- return (daysInMonth + 6
- - (7 + weekday - getFirstDayOfWeek()) % 7) / 7;
- }
+ + fields[DAY_OF_WEEK] - SUNDAY) % 7 + SUNDAY;
+ return (daysInMonth + 6 - (7 + weekday - getFirstDayOfWeek()) % 7) / 7;
+ }
default:
return maximums[field];
}
}
-
-
}
Index: java/util/SimpleTimeZone.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/util/SimpleTimeZone.java,v
retrieving revision 1.18.2.1
diff -u -3 -p -u -r1.18.2.1 SimpleTimeZone.java
--- java/util/SimpleTimeZone.java 16 Jan 2005 15:15:12 -0000 1.18.2.1
+++ java/util/SimpleTimeZone.java 22 Jan 2005 02:16:26 -0000
@@ -38,6 +38,7 @@ exception statement from your version. *
package java.util;
+
/**
* This class represents a simple time zone offset and handles
* daylight savings. It can only handle one daylight savings rule, so
@@ -49,14 +50,14 @@ package java.util;
* lying in the AD era.
*
* @see Calendar
- * @see GregorianCalender
+ * @see GregorianCalender
* @author Jochen Hoenicke
*/
public class SimpleTimeZone extends TimeZone
{
/**
* The raw time zone offset in milliseconds to GMT, ignoring
- * daylight savings.
+ * daylight savings.
* @serial
*/
private int rawOffset;
@@ -77,16 +78,15 @@ public class SimpleTimeZone extends Time
private int dstSavings = 60 * 60 * 1000;
/**
- * The first year, in which daylight savings rules applies.
+ * The first year, in which daylight savings rules applies.
* @serial
*/
private int startYear;
-
private static final int DOM_MODE = 1;
private static final int DOW_IN_MONTH_MODE = 2;
private static final int DOW_GE_DOM_MODE = 3;
private static final int DOW_LE_DOM_MODE = 4;
-
+
/**
* The mode of the start rule. This takes one of the following values:
*
SimpleTimeZone
with the given time offset
- * from GMT and without daylight savings.
+ * from GMT and without daylight savings.
* @param rawOffset the time offset from GMT in milliseconds.
- * @param id The identifier of this time zone.
+ * @param id The identifier of this time zone.
*/
public SimpleTimeZone(int rawOffset, String id)
{
@@ -273,7 +275,7 @@ public class SimpleTimeZone extends Time
* Create a SimpleTimeZone
with the given time offset
* from GMT and with daylight savings. The start/end parameters
* can have different meaning (replace WEEKDAY with a real day of
- * week). Only the first two meanings were supported by earlier
+ * week). Only the first two meanings were supported by earlier
* versions of jdk.
*
* setEndRule
or the result of
@@ -514,14 +507,16 @@ public class SimpleTimeZone extends Time
* @since 1.2
* @see SimpleTimeZone
*/
- public void setStartRule(int month, int day, int dayOfWeek, int time, boolean after)
+ public void setStartRule(int month, int day, int dayOfWeek, int time,
+ boolean after)
{
// FIXME: XXX: Validate that checkRule and offset processing work with on
// or before mode.
this.startDay = after ? Math.abs(day) : -Math.abs(day);
this.startDayOfWeek = after ? Math.abs(dayOfWeek) : -Math.abs(dayOfWeek);
- this.startMode = (dayOfWeek != 0) ? (after ? DOW_GE_DOM_MODE : DOW_LE_DOM_MODE)
- : checkRule(month, day, dayOfWeek);
+ this.startMode = (dayOfWeek != 0)
+ ? (after ? DOW_GE_DOM_MODE : DOW_LE_DOM_MODE)
+ : checkRule(month, day, dayOfWeek);
this.startDay = Math.abs(this.startDay);
this.startDayOfWeek = Math.abs(this.startDayOfWeek);
@@ -606,14 +601,16 @@ public class SimpleTimeZone extends Time
* @since 1.2
* @see #setStartRule
*/
- public void setEndRule(int month, int day, int dayOfWeek, int time, boolean after)
+ public void setEndRule(int month, int day, int dayOfWeek, int time,
+ boolean after)
{
// FIXME: XXX: Validate that checkRule and offset processing work with on
// or before mode.
this.endDay = after ? Math.abs(day) : -Math.abs(day);
this.endDayOfWeek = after ? Math.abs(dayOfWeek) : -Math.abs(dayOfWeek);
- this.endMode = (dayOfWeek != 0) ? (after ? DOW_GE_DOM_MODE : DOW_LE_DOM_MODE)
- : checkRule(month, day, dayOfWeek);
+ this.endMode = (dayOfWeek != 0)
+ ? (after ? DOW_GE_DOM_MODE : DOW_LE_DOM_MODE)
+ : checkRule(month, day, dayOfWeek);
this.endDay = Math.abs(this.endDay);
this.endDayOfWeek = Math.abs(endDayOfWeek);
@@ -648,7 +645,7 @@ public class SimpleTimeZone extends Time
}
/**
- * Gets the time zone offset, for current date, modified in case of
+ * Gets the time zone offset, for current date, modified in case of
* daylight savings. This is the offset to add to UTC to get the local
* time.
*
@@ -674,8 +671,8 @@ public class SimpleTimeZone extends Time
* @return the time zone offset in milliseconds.
* @throws IllegalArgumentException if arguments are incorrect.
*/
- public int getOffset(int era, int year, int month,
- int day, int dayOfWeek, int millis)
+ public int getOffset(int era, int year, int month, int day, int dayOfWeek,
+ int millis)
{
int daysInMonth = getDaysInMonth(month, year);
if (day < 1 || day > daysInMonth)
@@ -691,27 +688,21 @@ public class SimpleTimeZone extends Time
{
// This does only work for Gregorian calendars :-(
// This is mainly because setStartYear doesn't take an era.
-
- boolean afterStart = !isBefore(year, month, day, dayOfWeek, millis,
- startMode, startMonth,
- startDay, startDayOfWeek, startTime);
+ boolean afterStart = ! isBefore(year, month, day, dayOfWeek, millis,
+ startMode, startMonth, startDay,
+ startDayOfWeek, startTime);
boolean beforeEnd = isBefore(year, month, day, dayOfWeek,
- millis + dstSavings,
- endMode, endMonth,
- endDay, endDayOfWeek, endTime);
+ millis + dstSavings, endMode, endMonth,
+ endDay, endDayOfWeek, endTime);
if (startMonth < endMonth)
- {
- // use daylight savings, if the date is after the start of
- // savings, and before the end of savings.
- daylightSavings = afterStart && beforeEnd ? dstSavings : 0;
- }
+ // use daylight savings, if the date is after the start of
+ // savings, and before the end of savings.
+ daylightSavings = afterStart && beforeEnd ? dstSavings : 0;
else
- {
- // use daylight savings, if the date is before the end of
- // savings, or after the start of savings.
- daylightSavings = beforeEnd || afterStart ? dstSavings : 0;
- }
+ // use daylight savings, if the date is before the end of
+ // savings, or after the start of savings.
+ daylightSavings = beforeEnd || afterStart ? dstSavings : 0;
}
return rawOffset + daylightSavings;
}
@@ -740,7 +731,7 @@ public class SimpleTimeZone extends Time
* milliseconds with respect to standard time. Typically this
* is one hour, but for some time zones this may be half an our.
* @return the daylight savings offset in milliseconds.
- *
+ *
* @since 1.2
*/
public int getDSTSavings()
@@ -760,7 +751,7 @@ public class SimpleTimeZone extends Time
{
if (dstSavings <= 0)
throw new IllegalArgumentException("illegal value for dstSavings");
-
+
this.dstSavings = dstSavings;
}
@@ -775,7 +766,7 @@ public class SimpleTimeZone extends Time
/**
* Returns the number of days in the given month. It does always
- * use the Gregorian leap year rule.
+ * use the Gregorian leap year rule.
* @param month The month, zero based; use one of the Calendar constants.
* @param year The year.
*/
@@ -783,12 +774,9 @@ public class SimpleTimeZone extends Time
{
// Most of this is copied from GregorianCalendar.getActualMaximum()
if (month == Calendar.FEBRUARY)
- {
- return ((year & 3) == 0 && (year % 100 != 0 || year % 400 == 0))
- ? 29 : 28;
- }
+ return ((year & 3) == 0 && (year % 100 != 0 || year % 400 == 0)) ? 29 : 28;
else if (month < Calendar.AUGUST)
- return 31 - (month & 1);
+ return 31 - (month & 1);
else
return 30 + (month & 1);
}
@@ -804,23 +792,19 @@ public class SimpleTimeZone extends Time
* @param mode the change mode; same semantic as startMode.
* @param month the change month; same semantic as startMonth.
* @param day the change day; same semantic as startDay.
- * @param dayOfWeek the change day of week;
+ * @param dayOfWeek the change day of week;
* @param millis the change time in millis since midnight standard time.
* same semantic as startDayOfWeek.
* @return true, if cal is before the change, false if cal is on
* or after the change.
*/
- private boolean isBefore(int calYear,
- int calMonth, int calDayOfMonth, int calDayOfWeek,
- int calMillis, int mode, int month,
- int day, int dayOfWeek, int millis)
+ private boolean isBefore(int calYear, int calMonth, int calDayOfMonth,
+ int calDayOfWeek, int calMillis, int mode,
+ int month, int day, int dayOfWeek, int millis)
{
-
// This method is called by Calendar, so we mustn't use that class.
// We have to do all calculations by hand.
-
// check the months:
-
// XXX - this is not correct:
// for the DOW_GE_DOM and DOW_LE_DOM modes the change date may
// be in a different month.
@@ -835,7 +819,7 @@ public class SimpleTimeZone extends Time
return calDayOfMonth < day;
break;
case DOW_IN_MONTH_MODE:
- {
+ {
// This computes the day of month of the day of type
// "dayOfWeek" that lies in the same (sunday based) week as cal.
calDayOfMonth += (dayOfWeek - calDayOfWeek);
@@ -844,7 +828,6 @@ public class SimpleTimeZone extends Time
// after dividing by 7). If we count from the end of the
// month, we get want a -7 based number counting the days from
// the end:
-
if (day < 0)
calDayOfMonth -= getDaysInMonth(calMonth, calYear) + 7;
else
@@ -857,9 +840,9 @@ public class SimpleTimeZone extends Time
// 20 21 22 23 24 25 26 -23-22-21-20-19-18-17
// 27 28 29 30 31 32 33 -16-15-14-13-12-11-10
// 34 35 36 -9 -8 -7
-
// Now we calculate the day of week in month:
int week = calDayOfMonth / 7;
+
// day > 0 day < 0
// S M T W T F S S M T W T F S
// 1 1 1 1 1 1 -5 -5 -4 -4 -4 -4
@@ -867,7 +850,6 @@ public class SimpleTimeZone extends Time
// 2 3 3 3 3 3 3 -3 -3 -3 -2 -2 -2 -2
// 3 4 4 4 4 4 4 -2 -2 -2 -1 -1 -1 -1
// 4 5 5 -1 -1 -1
-
if (week != day)
return week < day;
@@ -876,26 +858,25 @@ public class SimpleTimeZone extends Time
// daylight savings starts/ends on the given day.
break;
- }
-
+ }
case DOW_LE_DOM_MODE:
// The greatest sunday before or equal December, 12
// is the same as smallest sunday after or equal December, 6.
day = Math.abs(day) - 6;
-
case DOW_GE_DOM_MODE:
-
// Calculate the day of month of the day of type
// "dayOfWeek" that lies before (or on) the given date.
- calDayOfMonth -= (calDayOfWeek < dayOfWeek ? 7 : 0)
- + calDayOfWeek - dayOfWeek;
+ calDayOfMonth -= (calDayOfWeek < dayOfWeek ? 7 : 0) + calDayOfWeek
+ - dayOfWeek;
if (calDayOfMonth < day)
return true;
if (calDayOfWeek != dayOfWeek || calDayOfMonth >= day + 7)
return false;
+
// now we have the same day
break;
}
+
// the millis decides:
return (calMillis < millis);
}
@@ -914,40 +895,35 @@ public class SimpleTimeZone extends Time
/**
* Generates the hashCode for the SimpleDateFormat object. It is
* the rawOffset, possibly, if useDaylightSavings is true, xored
- * with startYear, startMonth, startDayOfWeekInMonth, ..., endTime.
+ * with startYear, startMonth, startDayOfWeekInMonth, ..., endTime.
*/
public synchronized int hashCode()
{
- return rawOffset ^
- (useDaylight ?
- startMonth ^ startDay ^ startDayOfWeek ^ startTime
- ^ endMonth ^ endDay ^ endDayOfWeek ^ endTime : 0);
+ return rawOffset
+ ^ (useDaylight
+ ? startMonth ^ startDay ^ startDayOfWeek ^ startTime ^ endMonth
+ ^ endDay ^ endDayOfWeek ^ endTime : 0);
}
public synchronized boolean equals(Object o)
{
if (this == o)
return true;
- if (!(o instanceof SimpleTimeZone))
+ if (! (o instanceof SimpleTimeZone))
return false;
SimpleTimeZone zone = (SimpleTimeZone) o;
- if (zone.hashCode() != hashCode()
- || !getID().equals(zone.getID())
- || rawOffset != zone.rawOffset || useDaylight != zone.useDaylight)
+ if (zone.hashCode() != hashCode() || ! getID().equals(zone.getID())
+ || rawOffset != zone.rawOffset || useDaylight != zone.useDaylight)
return false;
- if (!useDaylight)
+ if (! useDaylight)
return true;
- return (startYear == zone.startYear
- && startMonth == zone.startMonth
- && startDay == zone.startDay
- && startDayOfWeek == zone.startDayOfWeek
- && startTime == zone.startTime
- && startTimeMode == zone.startTimeMode
- && endMonth == zone.endMonth
- && endDay == zone.endDay
- && endDayOfWeek == zone.endDayOfWeek
- && endTime == zone.endTime
- && endTimeMode == zone.endTimeMode);
+ return (startYear == zone.startYear && startMonth == zone.startMonth
+ && startDay == zone.startDay
+ && startDayOfWeek == zone.startDayOfWeek
+ && startTime == zone.startTime
+ && startTimeMode == zone.startTimeMode && endMonth == zone.endMonth
+ && endDay == zone.endDay && endDayOfWeek == zone.endDayOfWeek
+ && endTime == zone.endTime && endTimeMode == zone.endTimeMode);
}
/**
@@ -962,25 +938,21 @@ public class SimpleTimeZone extends Time
{
if (this == other)
return true;
- if (!(other instanceof SimpleTimeZone))
+ if (! (other instanceof SimpleTimeZone))
return false;
SimpleTimeZone zone = (SimpleTimeZone) other;
- if (zone.hashCode() != hashCode()
- || rawOffset != zone.rawOffset || useDaylight != zone.useDaylight)
+ if (zone.hashCode() != hashCode() || rawOffset != zone.rawOffset
+ || useDaylight != zone.useDaylight)
return false;
- if (!useDaylight)
+ if (! useDaylight)
return true;
- return (startYear == zone.startYear
- && startMonth == zone.startMonth
- && startDay == zone.startDay
- && startDayOfWeek == zone.startDayOfWeek
- && startTime == zone.startTime
- && startTimeMode == zone.startTimeMode
- && endMonth == zone.endMonth
- && endDay == zone.endDay
- && endDayOfWeek == zone.endDayOfWeek
- && endTime == zone.endTime
- && endTimeMode == zone.endTimeMode);
+ return (startYear == zone.startYear && startMonth == zone.startMonth
+ && startDay == zone.startDay
+ && startDayOfWeek == zone.startDayOfWeek
+ && startTime == zone.startTime
+ && startTimeMode == zone.startTimeMode && endMonth == zone.endMonth
+ && endDay == zone.endDay && endDayOfWeek == zone.endDayOfWeek
+ && endTime == zone.endTime && endTimeMode == zone.endTimeMode);
}
/**
@@ -991,26 +963,17 @@ public class SimpleTimeZone extends Time
{
// the test for useDaylight is an incompatibility to jdk1.2, but
// I think this shouldn't hurt.
- return getClass().getName() + "["
- + "id=" + getID()
- + ",offset=" + rawOffset
- + ",dstSavings=" + dstSavings
- + ",useDaylight=" + useDaylight
- + (useDaylight ?
- ",startYear=" + startYear
- + ",startMode=" + startMode
- + ",startMonth=" + startMonth
- + ",startDay=" + startDay
- + ",startDayOfWeek=" + startDayOfWeek
- + ",startTime=" + startTime
- + ",startTimeMode=" + startTimeMode
- + ",endMode=" + endMode
- + ",endMonth=" + endMonth
- + ",endDay=" + endDay
- + ",endDayOfWeek=" + endDayOfWeek
- + ",endTime=" + endTime
- + ",endTimeMode=" + endTimeMode
- : "") + "]";
+ return getClass().getName() + "[" + "id=" + getID() + ",offset="
+ + rawOffset + ",dstSavings=" + dstSavings + ",useDaylight="
+ + useDaylight
+ + (useDaylight
+ ? ",startYear=" + startYear + ",startMode=" + startMode
+ + ",startMonth=" + startMonth + ",startDay=" + startDay
+ + ",startDayOfWeek=" + startDayOfWeek + ",startTime="
+ + startTime + ",startTimeMode=" + startTimeMode + ",endMode="
+ + endMode + ",endMonth=" + endMonth + ",endDay=" + endDay
+ + ",endDayOfWeek=" + endDayOfWeek + ",endTime=" + endTime
+ + ",endTimeMode=" + endTimeMode : "") + "]";
}
/**
@@ -1029,7 +992,8 @@ public class SimpleTimeZone extends Time
startMode = DOW_IN_MONTH_MODE;
startTimeMode = WALL_TIME;
endTimeMode = WALL_TIME;
- serialVersionOnStream = 2; }
+ serialVersionOnStream = 2;
+ }
else
{
int length = input.readInt();
@@ -1054,29 +1018,31 @@ public class SimpleTimeZone extends Time
* start/endDay(OfWeek)
-Fields are written in the
* DOW_IN_MONTH_MODE rule, since this was the only supported rule
* in 1.1.
- *
+ *
* In the optional section, we write first the length of an byte
* array as int and afterwards the byte array itself. The byte
* array contains in this release four elements, namely the real
* startDay, startDayOfWeek endDay, endDayOfWeek in that Order.
* These fields are needed, because for compatibility reasons only
* approximative values are written to the required section, as
- * described above.
+ * described above.
*/
private void writeObject(java.io.ObjectOutputStream output)
throws java.io.IOException
{
byte[] byteArray = new byte[]
- {
- (byte) startDay, (byte) startDayOfWeek,
- (byte) endDay, (byte) endDayOfWeek};
+ {
+ (byte) startDay, (byte) startDayOfWeek, (byte) endDay,
+ (byte) endDayOfWeek
+ };
/* calculate the approximation for JDK 1.1 */
switch (startMode)
{
case DOM_MODE:
- startDayOfWeek = Calendar.SUNDAY; // random day of week
- // fall through
+ startDayOfWeek = Calendar.SUNDAY; // random day of week
+
+ // fall through
case DOW_GE_DOM_MODE:
case DOW_LE_DOM_MODE:
startDay = (startDay + 6) / 7;
@@ -1085,7 +1051,8 @@ public class SimpleTimeZone extends Time
{
case DOM_MODE:
endDayOfWeek = Calendar.SUNDAY;
- // fall through
+
+ // fall through
case DOW_GE_DOM_MODE:
case DOW_LE_DOM_MODE:
endDay = (endDay + 6) / 7;
Index: java/util/TimeZone.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/util/TimeZone.java,v
retrieving revision 1.23.2.4
diff -u -3 -p -u -r1.23.2.4 TimeZone.java
--- java/util/TimeZone.java 16 Jan 2005 15:15:12 -0000 1.23.2.4
+++ java/util/TimeZone.java 22 Jan 2005 02:16:26 -0000
@@ -447,6 +447,7 @@ public abstract class TimeZone implement
Calendar.MARCH, -1, Calendar.SUNDAY, 2000 * 3600,
Calendar.OCTOBER, -1, Calendar.SUNDAY, 2000 * 3600);
timezones0.put("CET", tz);
+ timezones0.put("CEST", tz);
timezones0.put("ECT", tz);
timezones0.put("MET", tz);
timezones0.put("Africa/Ceuta", tz);
Index: javax/swing/DebugGraphics.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/DebugGraphics.java,v
retrieving revision 1.2.2.1
diff -u -3 -p -u -r1.2.2.1 DebugGraphics.java
--- javax/swing/DebugGraphics.java 14 Jan 2005 10:24:16 -0000 1.2.2.1
+++ javax/swing/DebugGraphics.java 22 Jan 2005 02:16:26 -0000
@@ -1,5 +1,5 @@
/* DebugGraphics.java --
- Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -56,6 +56,30 @@ import java.text.AttributedCharacterIter
*/
public class DebugGraphics extends Graphics
{
+ /**
+ * LOG_OPTION
+ */
+ public static final int LOG_OPTION = 1;
+
+ /**
+ * FLASH_OPTION
+ */
+ public static final int FLASH_OPTION = 2;
+
+ /**
+ * BUFFERED_OPTION
+ */
+ public static final int BUFFERED_OPTION = 4;
+
+ /**
+ * NONE_OPTION
+ */
+ public static final int NONE_OPTION = -1;
+
+ static Color debugFlashColor = Color.RED;
+ static int debugFlashCount = 10;
+ static int debugFlashTime = 1000;
+ static PrintStream debugLogStream = System.out;
/**
* graphics
@@ -63,6 +87,11 @@ public class DebugGraphics extends Graph
Graphics graphics;
/**
+ * color
+ */
+ Color color = Color.BLACK;
+
+ /**
* buffer
*/
Image buffer;
@@ -88,26 +117,6 @@ public class DebugGraphics extends Graph
int yOffset;
/**
- * LOG_OPTION
- */
- public static final int LOG_OPTION = 1;
-
- /**
- * FLASH_OPTION
- */
- public static final int FLASH_OPTION = 2;
-
- /**
- * BUFFERED_OPTION
- */
- public static final int BUFFERED_OPTION = 4;
-
- /**
- * NONE_OPTION
- */
- public static final int NONE_OPTION = -1;
-
- /**
* Creates a DebugGraphics
object.
*/
public DebugGraphics()
@@ -116,55 +125,62 @@ public class DebugGraphics extends Graph
}
/**
- * Constructor DebugGraphics
- * @param graphics TODO
+ * Creates a DebugGraphics
object.
+ *
+ * @param graphics The Graphics
object to wrap
* @param component TODO
*/
public DebugGraphics(Graphics graphics, JComponent component)
{
- // TODO
+ this.graphics = graphics;
+ // FIXME: What shall we do with component ?
}
/**
- * Constructor DebugGraphics
- * @param graphics TODO
+ * Creates a DebugGraphics
object.
+ *
+ * @param graphics The Graphics
object to wrap
*/
public DebugGraphics(Graphics graphics)
{
- // TODO
+ this.graphics = graphics;
}
/**
- * setColor
- * @param value0 TODO
+ * Sets the color to draw stuff with.
+ *
+ * @param color The color
*/
public void setColor(Color color)
{
- // TODO
+ this.color = color;
}
/**
- * create
+ * Creates a overrides Graphics.create
to create a
+ * DebugGraphics
object.
*
- * @return Graphics
+ * @return a new DebugGraphics
object.
*/
public Graphics create()
{
- return null; // TODO
+ return new DebugGraphics(graphics.create());
}
/**
- * create
+ * Creates a overrides Graphics.create
to create a
+ * DebugGraphics
object.
+ *
+ * @param x the x coordinate
+ * @param y the y coordinate
+ * @param width the width
+ * @param height the height
*
- * @param x TODO
- * @param y TODO
- * @param w TODO
- * @param h TODO
- * @returns Graphics
+ * @return a new DebugGraphics
object.
*/
- public Graphics create(int valx, int y, int w, int h)
+ public Graphics create(int x, int y, int width, int height)
{
- return null; // TODO
+ return new DebugGraphics(graphics.create(x, y, width, height));
}
/**
@@ -174,7 +190,7 @@ public class DebugGraphics extends Graph
*/
public static Color flashColor()
{
- return null; // TODO
+ return debugFlashColor;
}
/**
@@ -184,7 +200,7 @@ public class DebugGraphics extends Graph
*/
public static void setFlashColor(Color color)
{
- // TODO
+ debugFlashColor = color;
}
/**
@@ -194,7 +210,7 @@ public class DebugGraphics extends Graph
*/
public static int flashTime()
{
- return 0; // TODO
+ return debugFlashTime;
}
/**
@@ -204,16 +220,17 @@ public class DebugGraphics extends Graph
*/
public static void setFlashTime(int time)
{
- // TODO
+ debugFlashTime = time;
}
/**
* flashCount
- * @returns int
+ *
+ * @return The number of flashes
*/
public static int flashCount()
{
- return 0; // TODO
+ return debugFlashCount;
}
/**
@@ -223,7 +240,7 @@ public class DebugGraphics extends Graph
*/
public static void setFlashCount(int count)
{
- // TODO
+ debugFlashCount = count;
}
/**
@@ -233,7 +250,7 @@ public class DebugGraphics extends Graph
*/
public static PrintStream logStream()
{
- return null; // TODO
+ return debugLogStream;
}
/**
@@ -243,16 +260,17 @@ public class DebugGraphics extends Graph
*/
public static void setLogStream(PrintStream stream)
{
- // TODO
+ debugLogStream = stream;
}
/**
* getFont
- * @returns Font
+ *
+ * @return The font
*/
public Font getFont()
{
- return null; // TODO
+ return graphics.getFont();
}
/**
@@ -262,46 +280,50 @@ public class DebugGraphics extends Graph
*/
public void setFont(Font font)
{
- // TODO
+ graphics.setFont(font);
}
/**
- * getColor
- * @returns Color
+ * Returns the color used for drawing.
+ *
+ * @return The color.
*/
public Color getColor()
{
- return null; // TODO
+ return color;
}
/**
- * getFontMetrics
- * @returns FontMetrics
+ * Returns the font metrics of the current font.
+ *
+ * @return a FontMetrics
object
*/
public FontMetrics getFontMetrics()
{
- return null; // TODO
+ return graphics.getFontMetrics();
}
/**
- * getFontMetrics
- * @param font TODO
- * @returns FontMetrics
+ * Returns the font metrics for a given font.
+ *
+ * @param font the font to get the metrics for
+ *
+ * @return a FontMetrics
object
*/
public FontMetrics getFontMetrics(Font font)
{
- return null; // TODO
+ return graphics.getFontMetrics(font);
}
/**
* translate
*
- * @param x TODO
- * @param y TODO
+ * @param x the x coordinate
+ * @param y the y coordinate
*/
public void translate(int x, int y)
{
- // TODO
+ graphics.translate(x, y);
}
/**
@@ -309,237 +331,291 @@ public class DebugGraphics extends Graph
*/
public void setPaintMode()
{
- // TODO
+ graphics.setPaintMode();
}
/**
* setXORMode
*
- * @param color TODO
+ * @param color the color
*/
public void setXORMode(Color color)
{
- // TODO
+ graphics.setXORMode(color);
}
/**
* getClipBounds
- * @returns Rectangle
+ *
+ * @return Rectangle
*/
public Rectangle getClipBounds()
{
- return null; // TODO
+ return graphics.getClipBounds();
}
/**
- * clipRect
- * @param value0 TODO
- * @param value1 TODO
- * @param value2 TODO
- * @param value3 TODO
+ * Intersects the current clip region with the given region.
+ *
+ * @param x The x-position of the region
+ * @param y The y-position of the region
+ * @param width The width of the region
+ * @param height The height of the region
*/
- public void clipRect(int value0, int value1, int value2, int value3)
+ public void clipRect(int x, int y, int width, int height)
{
- // TODO
+ graphics.clipRect(x, y, width, height);
}
/**
- * setClip
- * @param x TODO
- * @param y TODO
- * @param w TODO
- * @param h TODO
+ * Sets the clipping region.
+ *
+ * @param x The x-position of the region
+ * @param y The y-position of the region
+ * @param width The width of the region
+ * @param height The height of the region
*/
- public void setClip(int x, int y, int w, int h)
+ public void setClip(int x, int y, int width, int height)
{
- // TODO
+ graphics.setClip(x, y, width, height);
}
/**
- * getClip
- * @returns Shape
+ * Returns the current clipping region.
+ *
+ * @return Shape
*/
public Shape getClip()
{
- return null; // TODO
+ return graphics.getClip();
}
/**
- * setClip
- * @param shape TODO
+ * Sets the current clipping region
+ *
+ * @param shape The clippin region
*/
public void setClip(Shape shape)
{
- // TODO
+ graphics.setClip(shape);
}
+ private void sleep(int milliseconds)
+ {
+ try
+ {
+ Thread.sleep(milliseconds);
+ }
+ catch (InterruptedException e)
+ {
+ // Ignore this.
+ }
+ }
+
/**
- * drawRect
- * @param x TODO
- * @param y TODO
- * @param w TODO
- * @param valh TODO
+ * Draws a rectangle.
+ *
+ * @param x The x-position of the rectangle
+ * @param y The y-position of the rectangle
+ * @param width The width of the rectangle
+ * @param height The height of the rectangle
*/
- public void drawRect(int x, int y, int w, int h)
+ public void drawRect(int x, int y, int width, int height)
{
- // TODO
- } // drawRect()
+ for (int index = 0; index < (debugFlashCount - 1); ++index)
+ {
+ graphics.setColor(color);
+ graphics.drawRect(x, y, width, height);
+ sleep(debugFlashTime);
+
+ graphics.setColor(debugFlashColor);
+ graphics.drawRect(x, y, width, height);
+ sleep(debugFlashTime);
+ }
+
+ graphics.setColor(color);
+ graphics.drawRect(x, y, width, height);
+ }
/**
- * fillRect
- * @param x TODO
- * @param y TODO
- * @param w TODO
- * @param h TODO
+ * Draws a filled rectangle.
+ *
+ * @param x The x-position of the rectangle
+ * @param y The y-position of the rectangle
+ * @param width The width of the rectangle
+ * @param height The height of the rectangle
*/
- public void fillRect(int x, int y, int w, int h)
+ public void fillRect(int x, int y, int width, int height)
{
- // TODO
- } // fillRect()
+ for (int index = 0; index < (debugFlashCount - 1); ++index)
+ {
+ graphics.setColor(color);
+ graphics.fillRect(x, y, width, height);
+ sleep(debugFlashTime);
+
+ graphics.setColor(debugFlashColor);
+ graphics.fillRect(x, y, width, height);
+ sleep(debugFlashTime);
+ }
+
+ graphics.setColor(color);
+ graphics.fillRect(x, y, width, height);
+ }
/**
* clearRect
- * @param x TODO
- * @param y TODO
- * @param w TODO
- * @param h TODO
+ *
+ * @param x The x-position of the rectangle
+ * @param y The y-position of the rectangle
+ * @param width The width of the rectangle
+ * @param height The height of the rectangle
*/
- public void clearRect(int x, int y, int w, int h)
+ public void clearRect(int x, int y, int width, int height)
{
- // TODO
+ graphics.clearRect(x, y, width, height);
}
/**
* drawRoundRect
- * @param x TODO
- * @param y TODO
- * @param w TODO
- * @param h TODO
+ *
+ * @param x The x-position of the rectangle
+ * @param y The y-position of the rectangle
+ * @param width The width of the rectangle
+ * @param height The height of the rectangle
* @param arcWidth TODO
* @param arcHeight TODO
*/
- public void drawRoundRect(int x, int y, int w, int h, int arcWidth,
- int arcHeight)
+ public void drawRoundRect(int x, int y, int width, int height,
+ int arcWidth, int arcHeight)
{
- // TODO
+ graphics.drawRoundRect(x, y, width, height, arcWidth, arcHeight);
}
/**
* fillRoundRect
- * @param x TODO
- * @param y TODO
- * @param w TODO
- * @param h TODO
+ *
+ * @param x The x-position of the rectangle
+ * @param y The y-position of the rectangle
+ * @param width The width of the rectangle
+ * @param height The height of the rectangle
* @param arcWidth TODO
* @param arcHeight TODO
*/
- public void fillRoundRect(int x, int y, int w, int h, int arcWidth,
- int arcHeight)
+ public void fillRoundRect(int x, int y, int width, int height,
+ int arcWidth, int arcHeight)
{
- // TODO
+ graphics.fillRoundRect(x, y, width, height, arcWidth, arcHeight);
}
/**
* drawLine
- * @param x1 TODO
- * @param y1 TODO
- * @param x2 TODO
- * @param y2 TODO
+ *
+ * @param x1 The x-position of the start
+ * @param y1 The y-position of the start
+ * @param x2 The x-position of the end
+ * @param y2 The y-position of the end
*/
public void drawLine(int x1, int y1, int x2, int y2)
{
- // TODO
+ graphics.drawLine(x1, y1, x2, y2);
}
/**
* draw3DRect
- * @param x TODO
- * @param y TODO
- * @param w TODO
- * @param h TODO
+ *
+ * @param x The x-position of the rectangle
+ * @param y The y-position of the rectangle
+ * @param width The width of the rectangle
+ * @param height The height of the rectangle
* @param raised TODO
*/
- public void draw3DRect(int x, int y, int w, int h, boolean raised)
+ public void draw3DRect(int x, int y, int width, int height, boolean raised)
{
- // TODO
+ graphics.draw3DRect(x, y, width, height, raised);
}
/**
* fill3DRect
- * @param x TODO
- * @param y TODO
- * @param w TODO
- * @param h TODO
+ *
+ * @param x The x-position of the rectangle
+ * @param y The y-position of the rectangle
+ * @param width The width of the rectangle
+ * @param height The height of the rectangle
* @param raised TODO
*/
- public void fill3DRect(int x, int y, int w, int h, boolean raised)
+ public void fill3DRect(int x, int y, int width, int height, boolean raised)
{
- // TODO
+ graphics.fill3DRect(x, y, width, height, raised);
}
/**
* drawOval
- * @param x TODO
- * @param y TODO
- * @param w TODO
- * @param h TODO
+ *
+ * @param x the x coordinate
+ * @param y the y coordiante
+ * @param width the width
+ * @param height the height
*/
- public void drawOval(int x, int y, int w, int h)
+ public void drawOval(int x, int y, int width, int height)
{
- // TODO
+ graphics.drawOval(x, y, width, height);
}
/**
* fillOval
- * @param x TODO
- * @param y TODO
- * @param w TODO
- * @param h TODO
+ *
+ * @param x the x coordinate
+ * @param y the y coordinate
+ * @param width the width
+ * @param height the height
*/
- public void fillOval(int x, int y, int w, int h)
+ public void fillOval(int x, int y, int width, int height)
{
- // TODO
+ graphics.fillOval(x, y, width, height);
}
/**
* drawArc
*
- * @param x TODO
- * @param y TODO
- * @param w TODO
- * @param h TODO
+ * @param x the x coordinate
+ * @param y the y coordinate
+ * @param width the width
+ * @param height the height
* @param startAngle TODO
* @param arcAngle TODO
*/
- public void drawArc(int x, int y, int w, int h, int startAngle, int arcAngle)
+ public void drawArc(int x, int y, int width, int height,
+ int startAngle, int arcAngle)
{
- // TODO
+ graphics.drawArc(x, y, width, height, startAngle, arcAngle);
}
/**
* fillArc
*
- * @param x TODO
- * @param y TODO
- * @param w TODO
- * @param h TODO
+ * @param x the coordinate
+ * @param y the y coordinate
+ * @param width the width
+ * @param height the height
* @param startAngle TODO
* @param arcAngle TODO
*/
- public void fillArc(int x, int y, int w, int h, int startAngle, int arcAngle)
+ public void fillArc(int x, int y, int width, int height,
+ int startAngle, int arcAngle)
{
- // TODO
+ graphics.fillArc(x, y, width, height, startAngle, arcAngle);
}
/**
* drawPolyline
+ *
* @param xpoints TODO
* @param ypoints TODO
* @param npoints TODO
*/
public void drawPolyline(int[] xpoints, int[] ypoints, int npoints)
{
- // TODO
+ graphics.drawPolyline(xpoints, ypoints, npoints);
}
/**
@@ -551,7 +627,7 @@ public class DebugGraphics extends Graph
*/
public void drawPolygon(int[] xpoints, int[] ypoints, int npoints)
{
- // TODO
+ graphics.drawPolygon(xpoints, ypoints, npoints);
}
/**
@@ -563,31 +639,32 @@ public class DebugGraphics extends Graph
*/
public void fillPolygon(int[] xpoints, int[] ypoints, int npoints)
{
- // TODO
+ graphics.fillPolygon(xpoints, ypoints, npoints);
}
/**
* drawString
*
- * @param string TODO
- * @param x TODO
- * @param y TODO
+ * @param string the string
+ * @param x the x coordinate
+ * @param y the y coordinate
*/
- public void drawString(String string, int s, int y)
+ public void drawString(String string, int x, int y)
{
- // TODO
+ graphics.drawString(string, x, y);
}
/**
* drawString
*
* @param iterator TODO
- * @param x TODO
- * @param y TODO
+ * @param x the x coordinate
+ * @param y the y coordinate
*/
- public void drawString(AttributedCharacterIterator iterator, int x, int y)
+ public void drawString(AttributedCharacterIterator iterator,
+ int x, int y)
{
- // TODO
+ graphics.drawString(iterator, x, y);
}
/**
@@ -596,86 +673,111 @@ public class DebugGraphics extends Graph
* @param data TODO
* @param offset TODO
* @param length TODO
- * @param x TODO
- * @param y TODO
+ * @param x the x coordinate
+ * @param y the y coordinate
*/
- public void drawBytes(byte[] data, int offset, int length, int x, int y)
+ public void drawBytes(byte[] data, int offset, int length,
+ int x, int y)
{
- // TODO
+ graphics.drawBytes(data, offset, length, x, y);
}
/**
* drawChars
- * @param data TODO
- * @param offset TODO
- * @param length TODO
- * @param value3 TODO
- * @param value4 TODO
- */
- public void drawChars(char[] data, int offset, int value2, int x, int y)
- {
- // TODO
- } // drawChars()
+ *
+ * @param data array of characters to draw
+ * @param offset offset in array
+ * @param length number of characters in array to draw
+ * @param x x-position
+ * @param y y-position
+ */
+ public void drawChars(char[] data, int offset, int length,
+ int x, int y)
+ {
+ for (int index = 0; index < (debugFlashCount - 1); ++index)
+ {
+ graphics.setColor(color);
+ graphics.drawChars(data, offset, length, x, y);
+ sleep(debugFlashTime);
+
+ graphics.setColor(debugFlashColor);
+ graphics.drawChars(data, offset, length, x, y);
+ sleep(debugFlashTime);
+ }
+
+ graphics.setColor(color);
+ graphics.drawChars(data, offset, length, x, y);
+ }
/**
* drawImage
- * @param image TODO
- * @param x TODO
- * @param y TODO
- * @param observer TODO
- * @returns boolean
+ *
+ * @param image The image to draw
+ * @param x The x position
+ * @param y The y position
+ * @param observer The image observer
+ * @return boolean
*/
- public boolean drawImage(Image image, int x, int y, ImageObserver observer)
+ public boolean drawImage(Image image, int x, int y,
+ ImageObserver observer)
{
- return false; // TODO
+ return graphics.drawImage(image, x, y, observer);
}
/**
* drawImage
- * @param image TODO
- * @param x TODO
- * @param y TODO
- * @param w TODO
- * @param h TODO
- * @param observer TODO
- * @returns boolean
+ *
+ * @param image The image to draw
+ * @param x The x position
+ * @param y The y position
+ * @param width The width of the area to draw the image
+ * @param height The height of the area to draw the image
+ * @param observer The image observer
+ *
+ * @return boolean
*/
- public boolean drawImage(Image image, int x, int y, int w, int h,
- ImageObserver observer)
+ public boolean drawImage(Image image, int x, int y, int width,
+ int height, ImageObserver observer)
{
- return false; // TODO
+ return graphics.drawImage(image, x, y, width, height, observer);
}
/**
* drawImage
- * @param image TODO
- * @param x TODO
- * @param y TODO
- * @param background TODO
- * @param observer TODO
- * @returns boolean
+ *
+ * @param image The image to draw
+ * @param x The x position
+ * @param y The y position
+ * @param background The color for the background in the opaque regions
+ * of the image
+ * @param observer The image observer
+ *
+ * @return boolean
*/
- public boolean drawImage(Image image, int x, int y, Color background,
- ImageObserver observer)
+ public boolean drawImage(Image image, int x, int y,
+ Color background, ImageObserver observer)
{
- return false; // TODO
+ return graphics.drawImage(image, x, y, background, observer);
}
/**
* drawImage
- * @param image TODO
- * @param x TODO
- * @param y TODO
- * @param w TODO
- * @param h TODO
- * @param background TODO
- * @param observer TODO
- * @returns boolean
+ *
+ * @param image The image to draw
+ * @param x The x position
+ * @param y The y position
+ * @param width The width of the area to draw the image
+ * @param height The height of the area to draw the image
+ * @param background The color for the background in the opaque regions
+ * of the image
+ * @param observer The image observer
+ *
+ * @return boolean
*/
- public boolean drawImage(Image image, int x, int y, int w, int h,
- Color background, ImageObserver observer)
+ public boolean drawImage(Image image, int x, int y, int width, int height,
+ Color background, ImageObserver observer)
{
- return false; // TODO
+ return graphics.drawImage(image, x, y, width, height, background, observer);
}
/**
@@ -690,14 +792,15 @@ public class DebugGraphics extends Graph
* @param sy1 TODO
* @param sx2 TODO
* @param sy2 TODO
- * @param observer TODO
- * @returns boolean
+ * @param observer The image observer
+ *
+ * @return boolean
*/
- public boolean drawImage(Image image, int dx1, int dy1, int dx2, int dy2,
- int sx1, int sy1, int sx2, int sy2,
- ImageObserver observer)
+ public boolean drawImage(Image image, int dx1, int dy1,
+ int dx2, int dy2, int sx1, int sy1, int sx2, int sy2,
+ ImageObserver observer)
{
- return false; // TODO
+ return graphics.drawImage(image, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2, observer);
}
/**
@@ -712,15 +815,17 @@ public class DebugGraphics extends Graph
* @param sy1 TODO
* @param sx2 TODO
* @param sy2 TODO
- * @param background TODO
- * @param observer TODO
- * @returns boolean
- */
- public boolean drawImage(Image image, int dx1, int dy1, int dx2, int dy2,
- int sx1, int sy1, int sx2, int sy2,
- Color background, ImageObserver observer)
+ * @param background The color for the background in the opaque regions
+ * of the image
+ * @param observer The image observer
+ *
+ * @return boolean
+ */
+ public boolean drawImage(Image image, int dx1, int dy1,
+ int dx2, int dy2, int sx1, int sy1, int sx2, int sy2,
+ Color background, ImageObserver observer)
{
- return false; // TODO
+ return graphics.drawImage(image, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2, background, observer);
}
/**
@@ -733,9 +838,10 @@ public class DebugGraphics extends Graph
* @param destx The x position of the destination area
* @param desty The y posiiton of the destination area
*/
- public void copyArea(int x, int y, int w, int h, int destx, int desty)
+ public void copyArea(int x, int y, int width, int height,
+ int destx, int desty)
{
- // TODO
+ graphics.copyArea(x, y, width, height, destx, desty);
}
/**
@@ -743,7 +849,8 @@ public class DebugGraphics extends Graph
*/
public void dispose()
{
- // TODO
+ graphics.dispose();
+ graphics = null;
}
/**
@@ -757,22 +864,13 @@ public class DebugGraphics extends Graph
}
/**
- * toShortString
- * @returns String
- */
- String toShortString()
- {
- return null; // TODO
- } // toShortString()
-
- /**
* setDebugOptions
*
* @param options the debug options
*/
public void setDebugOptions(int options)
{
- // TODO
+ debugOptions = options;
}
/**
@@ -782,6 +880,6 @@ public class DebugGraphics extends Graph
*/
public int getDebugOptions()
{
- return 0; // TODO
+ return debugOptions;
}
}
Index: javax/swing/SwingUtilities.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/SwingUtilities.java,v
retrieving revision 1.15.2.3
diff -u -3 -p -u -r1.15.2.3 SwingUtilities.java
--- javax/swing/SwingUtilities.java 16 Jan 2005 02:14:49 -0000 1.15.2.3
+++ javax/swing/SwingUtilities.java 22 Jan 2005 02:16:27 -0000
@@ -47,6 +47,7 @@ import java.awt.FontMetrics;
import java.awt.Frame;
import java.awt.Graphics;
import java.awt.Insets;
+import java.awt.KeyboardFocusManager;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.Shape;
@@ -129,6 +130,37 @@ public class SwingUtilities implements S
}
/**
+ * Returns the focus owner or null
if comp
is not
+ * the focus owner or a parent of it.
+ *
+ * @param comp the focus owner or a parent of it
+ *
+ * @return the focus owner, or null
+ *
+ * @deprecated 1.4 Replaced by
+ * KeyboardFocusManager.getFocusOwner()
.
+ */
+ public static Component findFocusOwner(Component comp)
+ {
+ // Get real focus owner.
+ Component focusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager()
+ .getFocusOwner();
+
+ // Check if comp is the focus owner or a parent of it.
+ Component tmp = focusOwner;
+
+ while (tmp != null)
+ {
+ if (tmp == comp)
+ return focusOwner;
+
+ tmp = tmp.getParent();
+ }
+
+ return null;
+ }
+
+ /**
* Calculates the bounds of a component in the component's own coordinate
* space. The result has the same height and width as the component's
* bounds, but its location is set to (0,0).
Index: javax/swing/text/DefaultEditorKit.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/text/DefaultEditorKit.java,v
retrieving revision 1.7.2.3
diff -u -3 -p -u -r1.7.2.3 DefaultEditorKit.java
--- javax/swing/text/DefaultEditorKit.java 16 Jan 2005 15:15:13 -0000 1.7.2.3
+++ javax/swing/text/DefaultEditorKit.java 22 Jan 2005 02:16:27 -0000
@@ -375,7 +375,10 @@ public class DefaultEditorKit extends Ed
StringBuffer content = new StringBuffer();
while ((line = reader.readLine()) != null)
- content.append(line);
+ {
+ content.append(line);
+ content.append("\n");
+ }
document.insertString(offset, content.toString(),
SimpleAttributeSet.EMPTY);
Index: javax/swing/text/PlainView.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/text/PlainView.java,v
retrieving revision 1.1.2.1
diff -u -3 -p -u -r1.1.2.1 PlainView.java
--- javax/swing/text/PlainView.java 14 Jan 2005 10:24:17 -0000 1.1.2.1
+++ javax/swing/text/PlainView.java 22 Jan 2005 02:16:27 -0000
@@ -1,5 +1,5 @@
/* PlainView.java --
- Copyright (C) 2004 Free Software Foundation, Inc.
+ Copyright (C) 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -46,7 +46,6 @@ import java.awt.Graphics;
import java.awt.Rectangle;
import java.awt.Shape;
-
public class PlainView extends View
implements TabExpander
{
@@ -93,6 +92,9 @@ public class PlainView extends View
public Shape modelToView(int position, Shape a, Position.Bias b)
throws BadLocationException
{
+ // Ensure metrics are up-to-date.
+ updateMetrics();
+
Document document = getDocument();
// Get rectangle of the line containing position.
@@ -121,7 +123,8 @@ public class PlainView extends View
{
metrics = g.getFontMetrics();
// FIXME: Selected text are not drawn yet.
- drawUnselectedText(g, x, y, 0, getDocument().getLength());
+ Element line = getDocument().getDefaultRootElement().getElement(lineIndex);
+ drawUnselectedText(g, x, y, line.getStartOffset(), line.getEndOffset());
//drawSelectedText(g, , , , );
}
catch (BadLocationException e)
@@ -150,6 +153,9 @@ public class PlainView extends View
public void paint(Graphics g, Shape s)
{
+ // Ensure metrics are up-to-date.
+ updateMetrics();
+
JTextComponent textComponent = (JTextComponent) getContainer();
g.setFont(textComponent.getFont());
@@ -159,7 +165,15 @@ public class PlainView extends View
Rectangle rect = s.getBounds();
// FIXME: Text may be scrolled.
- drawLine(0, g, rect.x, rect.y);
+ Document document = textComponent.getDocument();
+ Element root = document.getDefaultRootElement();
+ int y = rect.y;
+
+ for (int i = 0; i < root.getElementCount(); i++)
+ {
+ drawLine(i, g, rect.x, y);
+ y += metrics.getHeight();
+ }
}
public int getTabSize()