summaryrefslogtreecommitdiff
path: root/java/util/SimpleTimeZone.java
diff options
context:
space:
mode:
authorMark Wielaard <mark@klomp.org>2006-05-15 09:45:33 +0000
committerMark Wielaard <mark@klomp.org>2006-05-15 09:45:33 +0000
commit5e8704b0f93bf54154dac38e3cbef50436127424 (patch)
tree2d2be2e65703cccfba1a2b9fd7b289f98ea46983 /java/util/SimpleTimeZone.java
parent940e4db75683240c9a097b812e973e1009ab56c4 (diff)
downloadclasspath-5e8704b0f93bf54154dac38e3cbef50436127424.tar.gz
2006-05-15 Mark Wielaard <mark@klomp.org>generics-0_91-release
* configure.ac (VERSION): Set to 0.91-generics. 2006-05-15 Mark Wielaard <mark@klomp.org> * NEWS: Add release date and VMClassLoader.getBootPackages() changes. 2006-05-15 Christian Thalinger <twisti@complang.tuwien.ac.at> * README: Added CACAO to list of VMs. 2006-05-14 Mark Wielaard <mark@klomp.org> * native/jni/java-net/javanet.c (_javanet_accept): Don't use C++ comments. 2006-05-14 Chris Burdess <dog@gnu.org> * gnu/xml/dom/DomNode.java: Permit comments and PIs in doctype nodes to be preserved during cloneNode. 2006-05-14 Mark Wielaard <mark@klomp.org> PR 27459 * native/jni/java-net/javanet.c (_javanet_accept): Reset the inherited timeout on socket. 2006-05-14 Lillian Angel <langel@redhat.com> * java/util/SimpleTimeZone.java: Reverted patch. (SimpleTimeZone): Throw exception if startMonth == endMonth. (SimpleTimeZone): Likewise. (checkRule): Rewritten to properly check all values (more efficently). This code is now more stable, at least less buggy than before. Fixed API documentation. (setStartRule): Moved checkRule call to end. (setStartRule): Likewise. (setEndRule): Likewise. (setEndRule): Likewise. 2006-05-14 Audrius Meskauskas <AudriusA@Bioinformatics.org> * javax/swing/tree/DefaultTreeSelectionModel.java (leadRow): Initialise to -1. 2006-05-14 Robert Schuster <robertschuster@fsfe.org> PR classpath/27595 * javax/swing/text/AbstractDocument.java: (insertString): Flipped if-expression and its blocks. (remove): Dito. (replace): Flipped if-expression and its blocks, added note, invoke insertString and remove instead of insertStringImpl and removeImpl. 2006-05-13 Tom Tromey <tromey@redhat.com> * java/nio/ByteBufferImpl.java (compact): Always set position. 2006-05-11 Mark Wielaard <mark@klomp.org> * java/util/logging/Logger.java (global): Initialize inside static PrivilegedAction. 2006-05-11 Mark Wielaard <mark@klomp.org> * java/awt/geom/GeneralPath.java (WIND_EVEN_ODD, WIND_NON_ZERO): Fully qualify PathIterator constants 2006-05-10 Roman Kennke <kennke@aicas.com> PR classpath/27481 * javax/swing/plaf/basic/BasicInternalFrameUI.java (installDefaults): Set background of content pane to null, if no custom color has been installed by the application yet. 2006-05-10 Roman Kennke <kennke@aicas.com> PR classpath/27481 * javax/swing/JRootPane.java (createContentPane): Don't set background to null. 2006-05-09 Robert Schuster <robertschuster@fsfe.org> PR classpath/24216 * javax/swing/text/AbstractDocument.java: (insertString): Added more documentation, added argument check. (remove): Added more documentation. (removeImpl): Added argument check. (replace): Added more documentation, added argument check. 2006-05-08 Lillian Angel <langel@redhat.com> * java/net/URLClassLoader.java (JarURLLoader): Added check to make sure the INDEX.LIST file exists. 2006-05-08 Roman Kennke <kennke@aicas.com> PR classpath/27481 * javax/swing/JRootPane.java (createContentPane): Set background of the content pane to null, so that the content pane inherits its background from the root pane. 2006-05-08 Roman Kennke <kennke@aicas.com> PR classpath/27480 * javax/swing/ButtonGroup.java (add): Check if new button is selected and if so, deselect other buttons in the group. 2006-05-08 Lillian Angel <langel@redhat.com> PR 27444 * java/net/URLClassLoader.java (JarURLLoader): Added code to go through META-INF/INDEX.LIST file to load all jars listed. 2006-05-08 Roman Kennke <kennke@aicas.com> PR classpath/27461 * javax/swing/ImageIcon.java (ImageIcon(URL)): Set description to URL.toString(). 2006-05-08 Roman Kennke <kennke@aicas.com> PR classpath/27482 * javax/swing/JTable.java (IconCellRenderer.getTableCellRendererComponent): Set icon to null when cell value is null. 2006-05-08 Roman Kennke <kennke@aicas.com> PR classpath/27484 * javax/swing/DefaultDesktopManager.java (closeFrame): Don't perform default close action on the frame to prevent endless loop. 2006-05-08 Roman Kennke <kennke@aicas.com> PR classpath/27485 * javax/swing/table/DefaultTableModel.java (addExtraRows): New helper method. (checkSize): New helper method. (setRowCount): Use addExtraRows helper method. (addColumn): Use addExtraRows helper method. (getColumnName): Check and adjust size if necessary using checkSize(). 2006-05-08 Roman Kennke <kennke@aicas.com> PR classpath/27486 * javax/swing/JTable.java (setValueAt): Allow setting values even when table is editable. 2006-05-07 Andrew John Hughes <gnu_andrew@member.fsf.org> PR classpath/27435: * java/util/zip/DeflaterEngine.java: (deflateFast(boolean,boolean)): Empty buffer when full. 2006-05-07 Sven de Marothy <sven@physto.se> Fixed PR27343 * java/util/Calendar.java (setTimeZone): Force recalculation. 2006-05-07 Sven de Marothy <sven@physto.se> Fixed PR27463 * javax/swing/plaf/metal/MetalInternalFrameTitlePane.java (propertyChange): Handle FRAME_ICON_PROPERTY property. 2006-05-06 Sven de Marothy <sven@physto.se> Fixed PR27454 * gnu/java/awt/peer/gtk/GtkImage: (drawPixels,drawPixelsScaled): Check for zero image sizes. 2006-05-07 Andrew John Hughes <gnu_andrew@member.fsf.org> PR classpath/27311: * gnu/java/text/StringFormatBuffer.java: (toString()): Implemented so we can see the contents. * java/text/DecimalFormat.java: (formatInternal(double,StringFormatBuffer,FieldPosition)): Don't calculate the exponent when the number is 0 or less. Also, use log10 instead of log now it's available. 2006-05-07 Sven de Marothy <sven@physto.se> Fixed PR27455 * gnu/java/awt/peer/GLightweightPeer.java (mouseEntered): Remove. * java/awt/Component.java (processMouseEvent): Do lightweight cursor handling. * javax/swing/plaf/basic/BasicTableHeaderUI.java (endResizing,mouseMoved): Save and reset original cursor, not the default one. 2006-05-07 Roman Kennke <kennke@aicas.com> * gnu/java/awt/java2d/RasterGraphics.java: New file. 2006-05-07 Roman Kennke <kennke@aicas.com> * gnu/java/awt/java2d/AbstractGraphics2D.java (fillShape): Determine user space bounds of shape and feed them into the actual rendering pipeline. (rawSetPixel): Made non-abstract for now. Maybe remove later. (rawSetForeground): Likewise. (getDestinationColorModel): Removed. (getDeviceBounds): Made non-abstract. Provide useful default impl. (rawFillShape): Handle paint context. (fillScanline): Implement painting and compositing. (fillShapeAntialias): Handle paint context. (fillScanlineAA): Implemented preliminary antialiasing based on composite context. Not working yet. (fillScanlineAlpha): Removed. (init): Fetch destination raster. (getDestinationRaster): New abstract method. (updateRaster): New backend method. 2006-05-07 Roman Kennke <kennke@aicas.com> * gnu/java/awt/java2d/AlphaCompositeContext.java (compose): Fixed loops, conditions and logic to make compositing work correctly. 2006-05-05 Roman Kennke <kennke@aicas.com> * java/awt/image/ColorModel.java (getNormalizedComponents): Implemented. 2006-05-05 Roman Kennke <kennke@aicas.com> * javax/swing/plaf/basic/BasicRadioButtonUI.java (paint): Query the button model for it's state, not the button itself. 2006-05-05 Roman Kennke <kennke@aicas.com> * javax/swing/JTable.java (tableChanged): Sync selection model with table model changes. 2006-05-04 Roman Kennke <kennke@aicas.com> * javax/swing/plaf/basic/BasicButtonListener.java (mouseEntered): Fixed conditions for changing states. 2006-05-04 Roman Kennke <kennke@aicas.com> * javax/swing/JOptionPane.java (AccessibleJOptionPane.getAccessibleRole): Implemented method. 2006-05-04 Roman Kennke <kennke@aicas.com> * javax/swing/JLabel.java (AccessibleJLabel.getSelectedText): Return null instead of "". (AccessibleJLabel.getSelectionStart): Added comment why return -1 is correct here. (AccessibleJLabel.getSelectionEnd): Added comment why return -1 is correct here. (AccessibleJLabel.getCharacterAttribute): Added comment about what to do here. (AccessibleJLabel.getCharCount): Added comment about what to do here. (AccessibleJLabel.getCharacterBounds): Tagged as not implemented. (AccessibleJLabel.getIndexAtPoint): Tagged as not implemented. (paramString): Return super.paramString() here, this provides a more meaningful output. 2006-05-04 Roman Kennke <kennke@aicas.com> * javax/swing/JComponent.java (paint): Added null check to avoid NPE when clip == null. 2006-05-04 Roman Kennke <kennke@aicas.com> * javax/swing/AbstractButton.java (addImpl): New method. Installs an OverlayLayout if no other layout has been installed before. (setLayout): New method. Detect if a client app installs a custom layout. 2006-05-04 Roman Kennke <kennke@aicas.com> * javax/swing/table/DefaultTableCellModel.java (noFocusBorder): Fixed width of empty border to 1. (getTableCellRendererComponent): Don't change the colors for focuses cells. Fixed border for focused cells. 2006-05-04 Roman Kennke <kennke@aicas.com> * javax/swing/JTable.java (moveToCellBeingEdited): Adjust bounding box of editing component to exactly cover the grid. * javax/swing/plaf/basic/BasicTableUI.java (paint): Paint grid to the bottom and right of the cells instead of left and top. Adjust bounding box of cells accordingly. * javax/swing/plaf/metal/MetalLookAndFeel.java (initComponentDefaults): Fixed color of JTable selection border. * javax/swing/plaf/metal/OceanTheme.java (addCustomEntriesToTable): Fixed color of JTable selection border. 2006-05-04 Raif S. Naffah <raif@swiftdsl.com.au> * tools/gnu/classpath/tools/keytool/ExportCmd.java (setup): Use _alias instead of alias. 2006-05-04 Lillian Angel <langel@redhat.com> * javax/swing/JLabel.java (JLabel): Pass in an empty string for the text parameter. (JLabel): Likewise. (JLabel): Likewise. 2006-05-05 Audrius Meskauskas <AudriusA@Bioinformatics.org> * javax/swing/plaf/basic/BasicTreeUI.java (paint): Return early if there are no visible nodes to paint.
Diffstat (limited to 'java/util/SimpleTimeZone.java')
-rw-r--r--java/util/SimpleTimeZone.java102
1 files changed, 53 insertions, 49 deletions
diff --git a/java/util/SimpleTimeZone.java b/java/util/SimpleTimeZone.java
index 72d61ff19..d94f89ad3 100644
--- a/java/util/SimpleTimeZone.java
+++ b/java/util/SimpleTimeZone.java
@@ -333,6 +333,8 @@ public class SimpleTimeZone extends TimeZone
setStartRule(startMonth, startDayOfWeekInMonth, startDayOfWeek, startTime);
setEndRule(endMonth, endDayOfWeekInMonth, endDayOfWeek, endTime);
+ if (startMonth == endMonth)
+ throw new IllegalArgumentException("startMonth and endMonth must be different");
this.startYear = 0;
}
@@ -391,6 +393,8 @@ public class SimpleTimeZone extends TimeZone
setStartRule(startMonth, startDayOfWeekInMonth, startDayOfWeek, startTime);
setEndRule(endMonth, endDayOfWeekInMonth, endDayOfWeek, endTime);
+ if (startMonth == endMonth)
+ throw new IllegalArgumentException("startMonth and endMonth must be different");
this.startYear = 0;
this.dstSavings = dstSavings;
@@ -409,66 +413,67 @@ public class SimpleTimeZone extends TimeZone
}
/**
- * Checks if the values are in range and
+ * Checks if the month, day, dayOfWeek arguments are in range and
* returns the mode of the rule.
* @param month the month parameter as in the constructor
+ * @param day the day parameter as in the constructor
+ * @param dayOfWeek the day of week parameter as in the constructor
* @return the mode of this rule see startMode.
* @exception IllegalArgumentException if parameters are out of range.
* @see #SimpleTimeZone(int, String, int, int, int, int, int, int, int, int)
* @see #startMode
*/
- private int checkRule(int month)
+ private int checkRule(int month, int day, int dayOfWeek)
{
- if (startDay != 0)
+ if (month < 0 || month > 11)
+ throw new IllegalArgumentException("month out of range");
+
+ int daysInMonth = getDaysInMonth(month, 1);
+ if (dayOfWeek == 0)
+ {
+ if (day <= 0 || day > daysInMonth)
+ throw new IllegalArgumentException("day out of range");
+ return DOM_MODE;
+ }
+ else if (dayOfWeek > 0)
{
- if (startMonth < 0 || startMonth > 11)
- throw new IllegalArgumentException("month out of range");
-
- if (startDayOfWeek == 0)
- startMode = DOM_MODE;
- else
- {
- if (startDayOfWeek > 0)
- startMode = DOW_IN_MONTH_MODE;
- else
- {
- startDayOfWeek = -startDayOfWeek;
- if (startDay < 0)
- {
- startDay = - startDay;
- startMode = DOW_LE_DOM_MODE;
- }
- else
- startMode = DOW_GE_DOM_MODE;
- }
-
- if (startDayOfWeek > Calendar.SATURDAY)
- throw new IllegalArgumentException("day of week out of range");
- }
-
- if (startMode != DOW_IN_MONTH_MODE
- && (startDay <= 0 || startDay > getDaysInMonth(month, 1)))
- throw new IllegalArgumentException("day out of range");
+ if (Math.abs(day) > (daysInMonth + 6) / 7)
+ throw new IllegalArgumentException("dayOfWeekInMonth out of range");
+ if (dayOfWeek > Calendar.SATURDAY)
+ throw new IllegalArgumentException("dayOfWeek out of range");
+ return DOW_IN_MONTH_MODE;
+ }
+ else
+ {
+ if (day == 0 || Math.abs(day) > daysInMonth)
+ throw new IllegalArgumentException("day out of range");
+ if (dayOfWeek < -Calendar.SATURDAY)
+ throw new IllegalArgumentException("dayOfWeek out of range");
+ if (day < 0)
+ return DOW_LE_DOM_MODE;
+ else
+ return DOW_GE_DOM_MODE;
}
- return startMode;
}
/**
- * Sets the daylight savings start rule. You must also set the end rule with
- * <code>setEndRule</code> or the result of getOffset is undefined. For the
- * parameters see the ten-argument constructor above.
- *
- * @param month The month where daylight savings start, zero based. You should
- * use the constants in Calendar.
+ * Sets the daylight savings start rule. You must also set the
+ * end rule with <code>setEndRule</code> or the result of
+ * getOffset is undefined. For the parameters see the ten-argument
+ * constructor above.
+ *
+ * @param month The month where daylight savings start, zero
+ * based. You should use the constants in Calendar.
* @param day A day of month or day of week in month.
* @param dayOfWeek The day of week where daylight savings start.
- * @param time The time in milliseconds standard time where daylight savings
- * start.
+ * @param time The time in milliseconds standard time where daylight
+ * savings start.
* @exception IllegalArgumentException if parameters are out of range.
* @see SimpleTimeZone
*/
public void setStartRule(int month, int day, int dayOfWeek, int time)
{
+ this.startMode = checkRule(month, day, dayOfWeek);
this.startMonth = month;
this.startDay = day;
this.startDayOfWeek = Math.abs(dayOfWeek);
@@ -478,7 +483,6 @@ public class SimpleTimeZone extends TimeZone
// Convert from UTC to STANDARD
this.startTime = time + this.rawOffset;
useDaylight = true;
- this.startMode = checkRule(month);
}
/**
@@ -513,6 +517,9 @@ public class SimpleTimeZone extends TimeZone
// 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.startDay = Math.abs(this.startDay);
this.startDayOfWeek = Math.abs(this.startDayOfWeek);
@@ -524,9 +531,6 @@ public class SimpleTimeZone extends TimeZone
// Convert from UTC to STANDARD
this.startTime = time + this.rawOffset;
useDaylight = true;
- this.startMode = (dayOfWeek != 0)
- ? (after ? DOW_GE_DOM_MODE : DOW_LE_DOM_MODE)
- : checkRule(month);
}
/**
@@ -562,6 +566,7 @@ public class SimpleTimeZone extends TimeZone
*/
public void setEndRule(int month, int day, int dayOfWeek, int time)
{
+ this.endMode = checkRule(month, day, dayOfWeek);
this.endMonth = month;
this.endDay = day;
this.endDayOfWeek = Math.abs(dayOfWeek);
@@ -574,7 +579,6 @@ public class SimpleTimeZone extends TimeZone
// Convert from UTC to DST
this.endTime = time + this.rawOffset + this.dstSavings;
useDaylight = true;
- this.endMode = checkRule(month);
}
/**
@@ -607,6 +611,9 @@ public class SimpleTimeZone extends TimeZone
// 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.endDay = Math.abs(this.endDay);
this.endDayOfWeek = Math.abs(endDayOfWeek);
@@ -621,9 +628,6 @@ public class SimpleTimeZone extends TimeZone
// Convert from UTC to DST
this.endTime = time + this.rawOffset + this.dstSavings;
useDaylight = true;
- this.endMode = (dayOfWeek != 0)
- ? (after ? DOW_GE_DOM_MODE : DOW_LE_DOM_MODE)
- : checkRule(month);
}
/**
@@ -770,7 +774,7 @@ public class SimpleTimeZone extends TimeZone
* @param year The year.
*/
private int getDaysInMonth(int month, int year)
- {
+ {
if (month == Calendar.FEBRUARY)
{
if ((year & 3) != 0)