aboutsummaryrefslogtreecommitdiff
path: root/libjava/classpath/java
diff options
context:
space:
mode:
Diffstat (limited to 'libjava/classpath/java')
-rw-r--r--libjava/classpath/java/awt/AWTKeyStroke.java20
-rw-r--r--libjava/classpath/java/awt/BorderLayout.java974
-rw-r--r--libjava/classpath/java/awt/Component.java179
-rw-r--r--libjava/classpath/java/awt/Container.java323
-rw-r--r--libjava/classpath/java/awt/EventQueue.java75
-rw-r--r--libjava/classpath/java/awt/FlowLayout.java14
-rw-r--r--libjava/classpath/java/awt/Font.java8
-rw-r--r--libjava/classpath/java/awt/FontMetrics.java6
-rw-r--r--libjava/classpath/java/awt/Frame.java25
-rw-r--r--libjava/classpath/java/awt/GraphicsConfiguration.java16
-rw-r--r--libjava/classpath/java/awt/GridBagLayout.java10
-rw-r--r--libjava/classpath/java/awt/Label.java15
-rw-r--r--libjava/classpath/java/awt/List.java1
-rw-r--r--libjava/classpath/java/awt/MenuItem.java13
-rw-r--r--libjava/classpath/java/awt/TextComponent.java2
-rw-r--r--libjava/classpath/java/awt/Toolkit.java6
-rw-r--r--libjava/classpath/java/awt/Window.java63
-rw-r--r--libjava/classpath/java/awt/datatransfer/Clipboard.java123
-rw-r--r--libjava/classpath/java/awt/datatransfer/DataFlavor.java55
-rw-r--r--libjava/classpath/java/awt/event/MouseWheelEvent.java2
-rw-r--r--libjava/classpath/java/awt/image/AreaAveragingScaleFilter.java3
-rw-r--r--libjava/classpath/java/awt/image/ConvolveOp.java10
-rw-r--r--libjava/classpath/java/awt/image/CropImageFilter.java18
-rw-r--r--libjava/classpath/java/awt/image/DirectColorModel.java18
-rw-r--r--libjava/classpath/java/awt/image/ImageFilter.java9
-rw-r--r--libjava/classpath/java/awt/image/PixelGrabber.java20
-rw-r--r--libjava/classpath/java/awt/image/RGBImageFilter.java14
-rw-r--r--libjava/classpath/java/awt/image/ReplicateScaleFilter.java20
-rw-r--r--libjava/classpath/java/awt/peer/ComponentPeer.java45
-rw-r--r--libjava/classpath/java/awt/peer/ContainerPeer.java27
-rw-r--r--libjava/classpath/java/awt/peer/FramePeer.java20
-rw-r--r--libjava/classpath/java/awt/peer/MenuBarPeer.java1
-rw-r--r--libjava/classpath/java/awt/peer/MenuComponentPeer.java10
-rw-r--r--libjava/classpath/java/awt/peer/MenuPeer.java1
-rw-r--r--libjava/classpath/java/awt/peer/TextComponentPeer.java9
-rw-r--r--libjava/classpath/java/awt/peer/WindowPeer.java14
-rw-r--r--libjava/classpath/java/beans/Expression.java10
-rw-r--r--libjava/classpath/java/beans/Statement.java83
-rw-r--r--libjava/classpath/java/io/ObjectInputStream.java106
-rw-r--r--libjava/classpath/java/lang/Character.java165
-rw-r--r--libjava/classpath/java/lang/Class.java24
-rw-r--r--libjava/classpath/java/lang/ClassLoader.java36
-rw-r--r--libjava/classpath/java/lang/IllegalArgumentException.java56
-rw-r--r--libjava/classpath/java/lang/IllegalStateException.java57
-rw-r--r--libjava/classpath/java/lang/Integer.java10
-rw-r--r--libjava/classpath/java/lang/SecurityException.java56
-rw-r--r--libjava/classpath/java/lang/UnsupportedOperationException.java56
-rw-r--r--libjava/classpath/java/lang/reflect/Proxy.java133
-rw-r--r--libjava/classpath/java/net/DatagramSocket.java6
-rw-r--r--libjava/classpath/java/net/Inet4Address.java4
-rw-r--r--libjava/classpath/java/net/JarURLConnection.java5
-rw-r--r--libjava/classpath/java/net/NetworkInterface.java52
-rw-r--r--libjava/classpath/java/net/URLClassLoader.java32
-rw-r--r--libjava/classpath/java/nio/Buffer.java4
-rw-r--r--libjava/classpath/java/nio/DirectByteBufferImpl.java94
-rw-r--r--libjava/classpath/java/nio/MappedByteBufferImpl.java6
-rw-r--r--libjava/classpath/java/nio/channels/FileLock.java8
-rw-r--r--libjava/classpath/java/nio/charset/Charset.java30
-rw-r--r--libjava/classpath/java/rmi/server/RMIClassLoader.java4
-rw-r--r--libjava/classpath/java/security/KeyPairGenerator.java3
-rw-r--r--libjava/classpath/java/security/cert/X509CertSelector.java4
-rw-r--r--libjava/classpath/java/sql/Date.java6
-rw-r--r--libjava/classpath/java/sql/Time.java6
-rw-r--r--libjava/classpath/java/text/AttributedCharacterIterator.java58
-rw-r--r--libjava/classpath/java/text/AttributedString.java687
-rw-r--r--libjava/classpath/java/text/AttributedStringIterator.java501
-rw-r--r--libjava/classpath/java/text/BreakIterator.java31
-rw-r--r--libjava/classpath/java/text/CharacterIterator.java18
-rw-r--r--libjava/classpath/java/text/ChoiceFormat.java19
-rw-r--r--libjava/classpath/java/text/CollationElementIterator.java20
-rw-r--r--libjava/classpath/java/text/CollationKey.java6
-rw-r--r--libjava/classpath/java/text/Collator.java18
-rw-r--r--libjava/classpath/java/text/DateFormat.java52
-rw-r--r--libjava/classpath/java/text/DateFormatSymbols.java47
-rw-r--r--libjava/classpath/java/text/DecimalFormatSymbols.java15
-rw-r--r--libjava/classpath/java/text/MessageFormat.java17
-rw-r--r--libjava/classpath/java/text/NumberFormat.java50
-rw-r--r--libjava/classpath/java/text/ParseException.java2
-rw-r--r--libjava/classpath/java/text/SimpleDateFormat.java117
-rw-r--r--libjava/classpath/java/text/StringCharacterIterator.java7
-rw-r--r--libjava/classpath/java/util/Observable.java2
-rw-r--r--libjava/classpath/java/util/Properties.java33
-rw-r--r--libjava/classpath/java/util/TimeZone.java260
-rw-r--r--libjava/classpath/java/util/Vector.java8
-rw-r--r--libjava/classpath/java/util/jar/JarFile.java6
-rw-r--r--libjava/classpath/java/util/logging/Logger.java48
-rw-r--r--libjava/classpath/java/util/zip/DeflaterHuffman.java4
-rw-r--r--libjava/classpath/java/util/zip/DeflaterOutputStream.java6
-rw-r--r--libjava/classpath/java/util/zip/ZipEntry.java13
-rw-r--r--libjava/classpath/java/util/zip/ZipFile.java24
-rw-r--r--libjava/classpath/java/util/zip/ZipInputStream.java13
-rw-r--r--libjava/classpath/java/util/zip/ZipOutputStream.java45
92 files changed, 3054 insertions, 2298 deletions
diff --git a/libjava/classpath/java/awt/AWTKeyStroke.java b/libjava/classpath/java/awt/AWTKeyStroke.java
index c10d53e..0e06225 100644
--- a/libjava/classpath/java/awt/AWTKeyStroke.java
+++ b/libjava/classpath/java/awt/AWTKeyStroke.java
@@ -412,13 +412,25 @@ public class AWTKeyStroke implements Serializable
{
token = t.nextToken();
if ("shift".equals(token))
- modifiers |= KeyEvent.SHIFT_DOWN_MASK;
+ {
+ modifiers |= KeyEvent.SHIFT_MASK;
+ modifiers |= KeyEvent.SHIFT_DOWN_MASK;
+ }
else if ("ctrl".equals(token) || "control".equals(token))
- modifiers |= KeyEvent.CTRL_DOWN_MASK;
+ {
+ modifiers |= KeyEvent.CTRL_MASK;
+ modifiers |= KeyEvent.CTRL_DOWN_MASK;
+ }
else if ("meta".equals(token))
- modifiers |= KeyEvent.META_DOWN_MASK;
+ {
+ modifiers |= KeyEvent.META_MASK;
+ modifiers |= KeyEvent.META_DOWN_MASK;
+ }
else if ("alt".equals(token))
- modifiers |= KeyEvent.ALT_DOWN_MASK;
+ {
+ modifiers |= KeyEvent.ALT_MASK;
+ modifiers |= KeyEvent.ALT_DOWN_MASK;
+ }
else if ("button1".equals(token))
modifiers |= KeyEvent.BUTTON1_DOWN_MASK;
else if ("button2".equals(token))
diff --git a/libjava/classpath/java/awt/BorderLayout.java b/libjava/classpath/java/awt/BorderLayout.java
index c9eb5dd..adf2ebf 100644
--- a/libjava/classpath/java/awt/BorderLayout.java
+++ b/libjava/classpath/java/awt/BorderLayout.java
@@ -48,34 +48,30 @@ package java.awt;
public class BorderLayout implements LayoutManager2, java.io.Serializable
{
-/*
- * Static Variables
- */
-
-/**
- * Constant indicating the top of the container
- */
-public static final String NORTH = "North";
+ /**
+ * Constant indicating the top of the container
+ */
+ public static final String NORTH = "North";
-/**
- * Constant indicating the bottom of the container
- */
-public static final String SOUTH = "South";
+ /**
+ * Constant indicating the bottom of the container
+ */
+ public static final String SOUTH = "South";
-/**
- * Constant indicating the right side of the container
- */
-public static final String EAST = "East";
+ /**
+ * Constant indicating the right side of the container
+ */
+ public static final String EAST = "East";
-/**
- * Constant indicating the left side of the container
- */
-public static final String WEST = "West";
+ /**
+ * Constant indicating the left side of the container
+ */
+ public static final String WEST = "West";
-/**
- * Constant indicating the center of the container
- */
-public static final String CENTER = "Center";
+ /**
+ * Constant indicating the center of the container
+ */
+ public static final String CENTER = "Center";
/**
@@ -91,7 +87,6 @@ public static final String CENTER = "Center";
*/
public static final String BEFORE_FIRST_LINE = "First";
-
/**
* The constant indicating the position after the last line of the
* layout. The exact position depends on the writing system: For a
@@ -105,7 +100,6 @@ public static final String CENTER = "Center";
*/
public static final String AFTER_LAST_LINE = "Last";
-
/**
* The constant indicating the position before the first item of the
* layout. The exact position depends on the writing system: For a
@@ -119,7 +113,6 @@ public static final String CENTER = "Center";
*/
public static final String BEFORE_LINE_BEGINS = "Before";
-
/**
* The constant indicating the position after the last item of the
* layout. The exact position depends on the writing system: For a
@@ -133,7 +126,6 @@ public static final String CENTER = "Center";
*/
public static final String AFTER_LINE_ENDS = "After";
-
/**
* The constant indicating the position before the first line of the
* layout. The exact position depends on the writing system: For a
@@ -144,7 +136,6 @@ public static final String CENTER = "Center";
*/
public static final String PAGE_START = BEFORE_FIRST_LINE;
-
/**
* The constant indicating the position after the last line of the
* layout. The exact position depends on the writing system: For a
@@ -155,7 +146,6 @@ public static final String CENTER = "Center";
*/
public static final String PAGE_END = AFTER_LAST_LINE;
-
/**
* The constant indicating the position before the first item of the
* layout. The exact position depends on the writing system: For a
@@ -166,7 +156,6 @@ public static final String CENTER = "Center";
*/
public static final String LINE_START = BEFORE_LINE_BEGINS;
-
/**
* The constant indicating the position after the last item of the
* layout. The exact position depends on the writing system: For a
@@ -178,398 +167,341 @@ public static final String CENTER = "Center";
public static final String LINE_END = AFTER_LINE_ENDS;
+ /**
+ * Serialization constant.
+ */
+ private static final long serialVersionUID = -8658291919501921765L;
-// Serialization constant
-private static final long serialVersionUID = -8658291919501921765L;
-
-/*************************************************************************/
-
-/*
- * Instance Variables
- */
-
-/**
- * @serial
- */
-private Component north;
-
-/**
- * @serial
- */
-private Component south;
-
-/**
- * @serial
- */
-private Component east;
-
-/**
- * @serial
- */
-private Component west;
-
-/**
- * @serial
- */
-private Component center;
-
-/**
- * @serial
- */
-private Component firstLine;
-
-/**
- * @serial
- */
-private Component lastLine;
-
-/**
- * @serial
- */
-private Component firstItem;
-
-/**
- * @serial
- */
-private Component lastItem;
-
-/**
- * @serial The horizontal gap between components
- */
-private int hgap;
-
-/**
- * @serial The vertical gap between components
- */
-private int vgap;
-
-/*************************************************************************/
-
-/*
- * Constructors
- */
-
-/**
- * Initializes a new instance of <code>BorderLayout</code> with no
- * horiztonal or vertical gaps between components.
- */
-public
-BorderLayout()
-{
- this(0,0);
-}
-/*************************************************************************/
+ /**
+ * @serial
+ */
+ private Component north;
-/**
- * Initializes a new instance of <code>BorderLayout</code> with the
- * specified horiztonal and vertical gaps between components.
- *
- * @param hgap The horizontal gap between components.
- * @param vgap The vertical gap between components.
- */
-public
-BorderLayout(int hgap, int vgap)
-{
- this.hgap = hgap;
- this.vgap = vgap;
-}
+ /**
+ * @serial
+ */
+ private Component south;
-/*************************************************************************/
+ /**
+ * @serial
+ */
+ private Component east;
-/*
- * Instance Variables
- */
+ /**
+ * @serial
+ */
+ private Component west;
-/**
- * Returns the horitzontal gap value.
- *
- * @return The horitzontal gap value.
+ /**
+ * @serial
*/
-public int
-getHgap()
-{
- return(hgap);
-}
+ private Component center;
-/*************************************************************************/
-
-/**
- * Sets the horizontal gap to the specified value.
- *
- * @param hgap The new horizontal gap.
- */
-public void
-setHgap(int hgap)
-{
- this.hgap = hgap;
-}
-
-/*************************************************************************/
-
-/**
- * Returns the vertical gap value.
- *
- * @return The vertical gap value.
- */
-public int
-getVgap()
-{
- return(vgap);
-}
+ /**
+ * @serial
+ */
+ private Component firstLine;
-/*************************************************************************/
+ /**
+ * @serial
+ */
+ private Component lastLine;
-/**
- * Sets the vertical gap to the specified value.
- *
- * @param vgap The new vertical gap value.
- */
-public void
-setVgap(int vgap)
-{
- this.vgap = vgap;
-}
+ /**
+ * @serial
+ */
+ private Component firstItem;
-/*************************************************************************/
+ /**
+ * @serial
+ */
+ private Component lastItem;
-/**
- * Adds a component to the layout in the specified constraint position,
- * which must be one of the string constants defined in this class.
- *
- * @param component The component to add.
- * @param constraints The constraint string.
- *
- * @exception IllegalArgumentException If the constraint object is not
- * a string, or is not one of the specified constants in this class.
- */
-public void
-addLayoutComponent(Component component, Object constraints)
-{
- if (constraints != null && ! (constraints instanceof String))
- throw new IllegalArgumentException("Constraint must be a string");
+ /**
+ * @serial The horizontal gap between components
+ */
+ private int hgap;
- addLayoutComponent((String) constraints, component);
-}
+ /**
+ * @serial The vertical gap between components
+ */
+ private int vgap;
-/*************************************************************************/
-/**
- * Adds a component to the layout in the specified constraint position,
- * which must be one of the string constants defined in this class.
- *
- * @param constraints The constraint string.
- * @param component The component to add.
- *
- * @exception IllegalArgumentException If the constraint object is not
- * one of the specified constants in this class.
- *
- * @deprecated This method is deprecated in favor of
- * <code>addLayoutComponent(Component, Object)</code>.
- */
-public void
-addLayoutComponent(String constraints, Component component)
-{
- String str = constraints;
-
- if (str == null || str.equals(CENTER))
- center = component;
- else if (str.equals(NORTH))
- north = component;
- else if (str.equals(SOUTH))
- south = component;
- else if (str.equals(EAST))
- east = component;
- else if (str.equals(WEST))
- west = component;
- else if (str.equals(BEFORE_FIRST_LINE))
- firstLine = component;
- else if (str.equals(AFTER_LAST_LINE))
- lastLine = component;
- else if (str.equals(BEFORE_LINE_BEGINS))
- firstItem = component;
- else if (str.equals(AFTER_LINE_ENDS))
- lastItem = component;
- else
- throw new IllegalArgumentException("Constraint value not valid: " + str);
-}
+ /**
+ * Initializes a new instance of <code>BorderLayout</code> with no
+ * horiztonal or vertical gaps between components.
+ */
+ public BorderLayout()
+ {
+ this(0,0);
+ }
-/*************************************************************************/
+ /**
+ * Initializes a new instance of <code>BorderLayout</code> with the
+ * specified horiztonal and vertical gaps between components.
+ *
+ * @param hgap The horizontal gap between components.
+ * @param vgap The vertical gap between components.
+ */
+ public BorderLayout(int hgap, int vgap)
+ {
+ this.hgap = hgap;
+ this.vgap = vgap;
+ }
-/**
- * Removes the specified component from the layout.
- *
- * @param component The component to remove from the layout.
- */
-public void
-removeLayoutComponent(Component component)
-{
- if (north == component)
- north = null;
- if (south == component)
- south = null;
- if (east == component)
- east = null;
- if (west == component)
- west = null;
- if (center == component)
- center = null;
- if (firstItem == component)
- firstItem = null;
- if (lastItem == component)
- lastItem = null;
- if (firstLine == component)
- firstLine = null;
- if (lastLine == component)
- lastLine = null;
-}
+ /**
+ * Returns the horitzontal gap value.
+ *
+ * @return The horitzontal gap value.
+ */
+ public int getHgap()
+ {
+ return(hgap);
+ }
-/*************************************************************************/
+ /**
+ * Sets the horizontal gap to the specified value.
+ *
+ * @param hgap The new horizontal gap.
+ */
+ public void setHgap(int hgap)
+ {
+ this.hgap = hgap;
+ }
-/**
- * Returns the minimum size of the specified container using this layout.
- *
- * @param target The container to calculate the minimum size for.
- *
- * @return The minimum size of the container
- */
-public Dimension
-minimumLayoutSize(Container target)
-{
- return calcSize(target, MIN);
-}
+ /**
+ * Returns the vertical gap value.
+ *
+ * @return The vertical gap value.
+ */
+ public int getVgap()
+ {
+ return(vgap);
+ }
-/*************************************************************************/
+ /**
+ * Sets the vertical gap to the specified value.
+ *
+ * @param vgap The new vertical gap value.
+ */
+ public void setVgap(int vgap)
+ {
+ this.vgap = vgap;
+ }
-/**
- * Returns the preferred size of the specified container using this layout.
- *
- * @param target The container to calculate the preferred size for.
- *
- * @return The preferred size of the container
- */
-public Dimension
-preferredLayoutSize(Container target)
-{
- return calcSize(target, PREF);
-}
+ /**
+ * Adds a component to the layout in the specified constraint position,
+ * which must be one of the string constants defined in this class.
+ *
+ * @param component The component to add.
+ * @param constraints The constraint string.
+ *
+ * @exception IllegalArgumentException If the constraint object is not
+ * a string, or is not one of the specified constants in this class.
+ */
+ public void addLayoutComponent(Component component, Object constraints)
+ {
+ if (constraints != null && ! (constraints instanceof String))
+ throw new IllegalArgumentException("Constraint must be a string");
-/*************************************************************************/
+ addLayoutComponent((String) constraints, component);
+ }
-/**
- * Returns the maximum size of the specified container using this layout.
- *
- * @param target The container to calculate the maximum size for.
- *
- * @return The maximum size of the container
- */
-public Dimension
-maximumLayoutSize(Container target)
-{
- return calcSize(target, MAX);
-}
+ /**
+ * Adds a component to the layout in the specified constraint position,
+ * which must be one of the string constants defined in this class.
+ *
+ * @param constraints The constraint string.
+ * @param component The component to add.
+ *
+ * @exception IllegalArgumentException If the constraint object is not
+ * one of the specified constants in this class.
+ *
+ * @deprecated This method is deprecated in favor of
+ * <code>addLayoutComponent(Component, Object)</code>.
+ */
+ public void addLayoutComponent(String constraints, Component component)
+ {
+ String str = constraints;
+
+ if (str == null || str.equals(CENTER))
+ center = component;
+ else if (str.equals(NORTH))
+ north = component;
+ else if (str.equals(SOUTH))
+ south = component;
+ else if (str.equals(EAST))
+ east = component;
+ else if (str.equals(WEST))
+ west = component;
+ else if (str.equals(BEFORE_FIRST_LINE))
+ firstLine = component;
+ else if (str.equals(AFTER_LAST_LINE))
+ lastLine = component;
+ else if (str.equals(BEFORE_LINE_BEGINS))
+ firstItem = component;
+ else if (str.equals(AFTER_LINE_ENDS))
+ lastItem = component;
+ else
+ throw new IllegalArgumentException("Constraint value not valid: " + str);
+ }
-/*************************************************************************/
+ /**
+ * Removes the specified component from the layout.
+ *
+ * @param component The component to remove from the layout.
+ */
+ public void removeLayoutComponent(Component component)
+ {
+ if (north == component)
+ north = null;
+ if (south == component)
+ south = null;
+ if (east == component)
+ east = null;
+ if (west == component)
+ west = null;
+ if (center == component)
+ center = null;
+ if (firstItem == component)
+ firstItem = null;
+ if (lastItem == component)
+ lastItem = null;
+ if (firstLine == component)
+ firstLine = null;
+ if (lastLine == component)
+ lastLine = null;
+ }
-/**
- * Returns the X axis alignment, which is a <code>float</code> indicating
- * where along the X axis this container wishs to position its layout.
- * 0 indicates align to the left, 1 indicates align to the right, and 0.5
- * indicates align to the center.
- *
- * @param parent The parent container.
- *
- * @return The X alignment value.
- */
-public float
-getLayoutAlignmentX(Container parent)
-{
- return(parent.getAlignmentX());
-}
+ /**
+ * Returns the minimum size of the specified container using this layout.
+ *
+ * @param target The container to calculate the minimum size for.
+ *
+ * @return The minimum size of the container
+ */
+ public Dimension minimumLayoutSize(Container target)
+ {
+ return calcSize(target, MIN);
+ }
-/*************************************************************************/
+ /**
+ * Returns the preferred size of the specified container using this layout.
+ *
+ * @param target The container to calculate the preferred size for.
+ *
+ * @return The preferred size of the container
+ */
+ public Dimension preferredLayoutSize(Container target)
+ {
+ return calcSize(target, PREF);
+ }
-/**
- * Returns the Y axis alignment, which is a <code>float</code> indicating
- * where along the Y axis this container wishs to position its layout.
- * 0 indicates align to the top, 1 indicates align to the bottom, and 0.5
- * indicates align to the center.
- *
- * @param parent The parent container.
- *
- * @return The Y alignment value.
- */
-public float
-getLayoutAlignmentY(Container parent)
-{
- return(parent.getAlignmentY());
-}
+ /**
+ * Returns the maximum size of the specified container using this layout.
+ *
+ * @param target The container to calculate the maximum size for.
+ *
+ * @return The maximum size of the container
+ */
+ public Dimension maximumLayoutSize(Container target)
+ {
+ return calcSize(target, MAX);
+ }
-/*************************************************************************/
+ /**
+ * Returns the X axis alignment, which is a <code>float</code> indicating
+ * where along the X axis this container wishs to position its layout.
+ * 0 indicates align to the left, 1 indicates align to the right, and 0.5
+ * indicates align to the center.
+ *
+ * @param parent The parent container.
+ *
+ * @return The X alignment value.
+ */
+ public float getLayoutAlignmentX(Container parent)
+ {
+ return(parent.getAlignmentX());
+ }
-/**
- * Instructs this object to discard any layout information it might
- * have cached.
- *
- * @param parent The parent container.
- */
-public void
-invalidateLayout(Container parent)
-{
-}
+ /**
+ * Returns the Y axis alignment, which is a <code>float</code> indicating
+ * where along the Y axis this container wishs to position its layout.
+ * 0 indicates align to the top, 1 indicates align to the bottom, and 0.5
+ * indicates align to the center.
+ *
+ * @param parent The parent container.
+ *
+ * @return The Y alignment value.
+ */
+ public float getLayoutAlignmentY(Container parent)
+ {
+ return(parent.getAlignmentY());
+ }
-/*************************************************************************/
+ /**
+ * Instructs this object to discard any layout information it might
+ * have cached.
+ *
+ * @param parent The parent container.
+ */
+ public void invalidateLayout(Container parent)
+ {
+ // FIXME: Implement this properly!
+ }
-/**
- * Lays out the specified container according to the constraints
- * in this object.
- *
- * @param target The container to lay out.
- */
-public void
-layoutContainer(Container target)
-{
- synchronized (target.getTreeLock ())
- {
- Insets i = target.getInsets();
-
- ComponentOrientation orient = target.getComponentOrientation ();
- boolean left_to_right = orient.isLeftToRight ();
-
- Component my_north = north;
- Component my_east = east;
- Component my_south = south;
- Component my_west = west;
-
- // Note that we currently don't handle vertical layouts. Neither
- // does JDK 1.3.
- if (firstLine != null)
- my_north = firstLine;
- if (lastLine != null)
- my_south = lastLine;
- if (firstItem != null)
- {
- if (left_to_right)
- my_west = firstItem;
- else
- my_east = firstItem;
- }
- if (lastItem != null)
- {
- if (left_to_right)
- my_east = lastItem;
- else
- my_west = lastItem;
- }
-
- Dimension c = calcCompSize(center, PREF);
- Dimension n = calcCompSize(my_north, PREF);
- Dimension s = calcCompSize(my_south, PREF);
- Dimension e = calcCompSize(my_east, PREF);
- Dimension w = calcCompSize(my_west, PREF);
- Dimension t = target.getSize();
-
- /*
+ /**
+ * Lays out the specified container according to the constraints
+ * in this object.
+ *
+ * @param target The container to lay out.
+ */
+ public void layoutContainer(Container target)
+ {
+ synchronized (target.getTreeLock ())
+ {
+ Insets i = target.getInsets();
+
+ ComponentOrientation orient = target.getComponentOrientation ();
+ boolean left_to_right = orient.isLeftToRight ();
+
+ Component my_north = north;
+ Component my_east = east;
+ Component my_south = south;
+ Component my_west = west;
+
+ // Note that we currently don't handle vertical layouts. Neither
+ // does JDK 1.3.
+ if (firstLine != null)
+ my_north = firstLine;
+ if (lastLine != null)
+ my_south = lastLine;
+ if (firstItem != null)
+ {
+ if (left_to_right)
+ my_west = firstItem;
+ else
+ my_east = firstItem;
+ }
+ if (lastItem != null)
+ {
+ if (left_to_right)
+ my_east = lastItem;
+ else
+ my_west = lastItem;
+ }
+
+ Dimension c = calcCompSize(center, PREF);
+ Dimension n = calcCompSize(my_north, PREF);
+ Dimension s = calcCompSize(my_south, PREF);
+ Dimension e = calcCompSize(my_east, PREF);
+ Dimension w = calcCompSize(my_west, PREF);
+ int targetWidth = target.getWidth();
+ int targetHeight = target.getHeight();
+
+ /*
<-> hgap <-> hgap
+----------------------------+ }
|t | } i.top
@@ -588,144 +520,144 @@ layoutContainer(Container target)
<---------------------->
<--> ww <-->
i.left i.right
- */
-
- int x1 = i.left;
- int x2 = x1 + w.width + hgap;
- int x3;
- if (t.width <= i.right + e.width)
- x3 = x2 + w.width + hgap;
- else
- x3 = t.width - i.right - e.width;
- int ww = t.width - i.right - i.left;
-
- int y1 = i.top;
- int y2 = y1 + n.height + vgap;
- int midh = Math.max(e.height, Math.max(w.height, c.height));
- int y3;
- if (t.height <= i.bottom + s.height)
- y3 = y2 + midh + vgap;
- else
- y3 = t.height - i.bottom - s.height;
- int hh = y3-y2-vgap;
-
- setBounds(center, x2, y2, x3-x2-hgap, hh);
- setBounds(my_north, x1, y1, ww, n.height);
- setBounds(my_south, x1, y3, ww, s.height);
- setBounds(my_west, x1, y2, w.width, hh);
- setBounds(my_east, x3, y2, e.width, hh);
- }
-}
-
-/*************************************************************************/
+ */
+
+ int x1 = i.left;
+ int x2 = x1 + w.width + (w.width == 0 ? 0 : hgap);
+ int x3;
+ if (targetWidth <= i.right + e.width)
+ x3 = x2 + w.width + (w.width == 0 ? 0 : hgap);
+ else
+ x3 = targetWidth - i.right - e.width;
+ int ww = targetWidth - i.right - i.left;
+
+ int y1 = i.top;
+ int y2 = y1 + n.height + (n.height == 0 ? 0 : vgap);
+ int midh = Math.max(e.height, Math.max(w.height, c.height));
+ int y3;
+ if (targetHeight <= i.bottom + s.height)
+ y3 = y2 + midh + vgap;
+ else
+ y3 = targetHeight - i.bottom - s.height;
+ int hh = y3-y2-(s.height == 0 ? 0 : vgap);
+
+ setBounds(center, x2, y2, x3-x2-(w.width == 0 ? 0 : hgap), hh);
+ setBounds(my_north, x1, y1, ww, n.height);
+ setBounds(my_south, x1, y3, ww, s.height);
+ setBounds(my_west, x1, y2, w.width, hh);
+ setBounds(my_east, x3, y2, e.width, hh);
+ }
+ }
-/**
- * Returns a string representation of this layout manager.
- *
- * @return A string representation of this object.
- */
-public String
-toString()
-{
- return getClass().getName() + "[hgap=" + hgap + ",vgap=" + vgap + "]";
-}
-
-private void
-setBounds(Component comp, int x, int y, int w, int h)
-{
- if (comp == null)
- return;
- comp.setBounds(x, y, w, h);
-}
-
-// Some constants for use with calcSize().
-private static final int MIN = 0;
-private static final int MAX = 1;
-private static final int PREF = 2;
+ /**
+ * Returns a string representation of this layout manager.
+ *
+ * @return A string representation of this object.
+ */
+ public String toString()
+ {
+ return getClass().getName() + "[hgap=" + hgap + ",vgap=" + vgap + "]";
+ }
-private Dimension
-calcCompSize(Component comp, int what)
-{
- if (comp == null || !comp.isVisible())
- return new Dimension(0, 0);
- if (what == MIN)
- return comp.getMinimumSize();
- else if (what == MAX)
- return comp.getMaximumSize();
- return comp.getPreferredSize();
-}
+ /**
+ * FIXME: Document me!
+ */
+ private void setBounds(Component comp, int x, int y, int w, int h)
+ {
+ if (comp == null)
+ return;
+ comp.setBounds(x, y, w, h);
+ }
+
+ // FIXME: Maybe move to top of file.
+ // Some constants for use with calcSize().
+ private static final int MIN = 0;
+ private static final int MAX = 1;
+ private static final int PREF = 2;
+
+ private Dimension calcCompSize(Component comp, int what)
+ {
+ if (comp == null || !comp.isVisible())
+ return new Dimension(0, 0);
+ if (what == MIN)
+ return comp.getMinimumSize();
+ else if (what == MAX)
+ return comp.getMaximumSize();
+ return comp.getPreferredSize();
+ }
-// This is a helper function used to compute the various sizes for
-// this layout.
-private Dimension
-calcSize(Container target, int what)
-{
- synchronized (target.getTreeLock ())
- {
- Insets ins = target.getInsets();
-
- ComponentOrientation orient = target.getComponentOrientation ();
- boolean left_to_right = orient.isLeftToRight ();
-
- Component my_north = north;
- Component my_east = east;
- Component my_south = south;
- Component my_west = west;
-
- // Note that we currently don't handle vertical layouts. Neither
- // does JDK 1.3.
- if (firstLine != null)
- my_north = firstLine;
- if (lastLine != null)
- my_south = lastLine;
- if (firstItem != null)
- {
- if (left_to_right)
- my_west = firstItem;
- else
- my_east = firstItem;
- }
- if (lastItem != null)
- {
- if (left_to_right)
- my_east = lastItem;
- else
- my_west = lastItem;
- }
-
- Dimension ndim = calcCompSize(my_north, what);
- Dimension sdim = calcCompSize(my_south, what);
- Dimension edim = calcCompSize(my_east, what);
- Dimension wdim = calcCompSize(my_west, what);
- Dimension cdim = calcCompSize(center, what);
-
- int width = edim.width + cdim.width + wdim.width + (hgap * 2);
- // check for overflow
- if (width < edim.width || width < cdim.width || width < cdim.width)
+ /**
+ * This is a helper function used to compute the various sizes for
+ * this layout.
+ */
+ private Dimension calcSize(Container target, int what)
+ {
+ synchronized (target.getTreeLock ())
+ {
+ Insets ins = target.getInsets();
+
+ ComponentOrientation orient = target.getComponentOrientation ();
+ boolean left_to_right = orient.isLeftToRight ();
+
+ Component my_north = north;
+ Component my_east = east;
+ Component my_south = south;
+ Component my_west = west;
+
+ // Note that we currently don't handle vertical layouts. Neither
+ // does JDK 1.3.
+ if (firstLine != null)
+ my_north = firstLine;
+ if (lastLine != null)
+ my_south = lastLine;
+ if (firstItem != null)
+ {
+ if (left_to_right)
+ my_west = firstItem;
+ else
+ my_east = firstItem;
+ }
+ if (lastItem != null)
+ {
+ if (left_to_right)
+ my_east = lastItem;
+ else
+ my_west = lastItem;
+ }
+
+ Dimension ndim = calcCompSize(my_north, what);
+ Dimension sdim = calcCompSize(my_south, what);
+ Dimension edim = calcCompSize(my_east, what);
+ Dimension wdim = calcCompSize(my_west, what);
+ Dimension cdim = calcCompSize(center, what);
+
+ int width = edim.width + cdim.width + wdim.width + (hgap * 2);
+ // Check for overflow.
+ if (width < edim.width || width < cdim.width || width < cdim.width)
width = Integer.MAX_VALUE;
- if (ndim.width > width)
- width = ndim.width;
- if (sdim.width > width)
- width = sdim.width;
+ if (ndim.width > width)
+ width = ndim.width;
+ if (sdim.width > width)
+ width = sdim.width;
- width += (ins.left + ins.right);
+ width += (ins.left + ins.right);
- int height = edim.height;
- if (cdim.height > height)
- height = cdim.height;
- if (wdim.height > height)
- height = wdim.height;
+ int height = edim.height;
+ if (cdim.height > height)
+ height = cdim.height;
+ if (wdim.height > height)
+ height = wdim.height;
- int addedHeight = height + (ndim.height + sdim.height + (vgap * 2)
- + ins.top + ins.bottom);
- // check for overflow
- if (addedHeight < height)
+ int addedHeight = height + (ndim.height + sdim.height + (vgap * 2)
+ + ins.top + ins.bottom);
+ // Check for overflow.
+ if (addedHeight < height)
height = Integer.MAX_VALUE;
- else
+ else
height = addedHeight;
- return(new Dimension(width, height));
- }
+ return(new Dimension(width, height));
+ }
+ }
}
-} // class BorderLayout
diff --git a/libjava/classpath/java/awt/Component.java b/libjava/classpath/java/awt/Component.java
index 4491904..0ae1ffa 100644
--- a/libjava/classpath/java/awt/Component.java
+++ b/libjava/classpath/java/awt/Component.java
@@ -897,9 +897,21 @@ public abstract class Component
if(!isVisible())
{
this.visible = true;
- if (peer != null)
- peer.setVisible(true);
- invalidate();
+ // Avoid NullPointerExceptions by creating a local reference.
+ ComponentPeer currentPeer=peer;
+ if (currentPeer != null)
+ currentPeer.setVisible(true);
+
+ // Invalidate the parent if we have one. The component itself must
+ // not be invalidated. We also avoid NullPointerException with
+ // a local reference here.
+ Container currentParent = parent;
+ if (currentParent != null)
+ {
+ currentParent.invalidate();
+ currentParent.repaint();
+ }
+
ComponentEvent ce =
new ComponentEvent(this,ComponentEvent.COMPONENT_SHOWN);
getToolkit().getSystemEventQueue().postEvent(ce);
@@ -930,10 +942,23 @@ public abstract class Component
{
if (isVisible())
{
- if (peer != null)
- peer.setVisible(false);
+ // Avoid NullPointerExceptions by creating a local reference.
+ ComponentPeer currentPeer=peer;
+ if (currentPeer != null)
+ currentPeer.setVisible(false);
+
this.visible = false;
- invalidate();
+
+ // Invalidate the parent if we have one. The component itself must
+ // not be invalidated. We also avoid NullPointerException with
+ // a local reference here.
+ Container currentParent = parent;
+ if (currentParent != null)
+ {
+ currentParent.invalidate();
+ currentParent.repaint();
+ }
+
ComponentEvent ce =
new ComponentEvent(this,ComponentEvent.COMPONENT_HIDDEN);
getToolkit().getSystemEventQueue().postEvent(ce);
@@ -963,10 +988,12 @@ public abstract class Component
*/
public void setForeground(Color c)
{
- firePropertyChange("foreground", foreground, c);
if (peer != null)
peer.setForeground(c);
+
+ Color previous = foreground;
foreground = c;
+ firePropertyChange("foreground", previous, c);
}
/**
@@ -992,7 +1019,7 @@ public abstract class Component
{
if (background != null)
return background;
- return parent == null ? SystemColor.window : parent.getBackground();
+ return parent == null ? null : parent.getBackground();
}
/**
@@ -1006,16 +1033,18 @@ public abstract class Component
public void setBackground(Color c)
{
// return if the background is already set to that color.
- if (background != null && c != null)
- if (background.equals(c))
- return;
+ if ((c != null) && c.equals(background))
+ return;
+
// If c is null, inherit from closest ancestor whose bg is set.
if (c == null && parent != null)
c = parent.getBackground();
- firePropertyChange("background", background, c);
if (peer != null && c != null)
peer.setBackground(c);
+
+ Color previous = background;
background = c;
+ firePropertyChange("background", previous, c);
}
/**
@@ -1039,13 +1068,15 @@ public abstract class Component
*/
public Font getFont()
{
- if (font != null)
- return font;
+ Font f = font;
+ if (f != null)
+ return f;
- if (parent != null)
- return parent.getFont ();
+ Component p = parent;
+ if (p != null)
+ return p.getFont();
else
- return new Font ("Dialog", Font.PLAIN, 12);
+ return new Font("Dialog", Font.PLAIN, 12);
}
/**
@@ -1058,15 +1089,16 @@ public abstract class Component
*/
public void setFont(Font newFont)
{
- if (font == newFont)
- return;
-
- Font oldFont = font;
- font = newFont;
- if (peer != null)
- peer.setFont(font);
- firePropertyChange("font", oldFont, newFont);
- invalidate();
+ if((newFont != null && (font == null || !font.equals(newFont)))
+ || newFont == null)
+ {
+ Font oldFont = font;
+ font = newFont;
+ if (peer != null)
+ peer.setFont(font);
+ firePropertyChange("font", oldFont, newFont);
+ invalidate();
+ }
}
/**
@@ -1372,9 +1404,6 @@ public abstract class Component
// Erase old bounds and repaint new bounds for lightweights.
if (isLightweight() && isShowing ())
{
- boolean shouldRepaintParent = false;
- boolean shouldRepaintSelf = false;
-
if (parent != null)
{
Rectangle parentBounds = parent.getBounds();
@@ -1384,14 +1413,11 @@ public abstract class Component
Rectangle newBounds = new Rectangle(parent.getX() + x,
parent.getY() + y,
width, height);
- shouldRepaintParent = parentBounds.intersects(oldBounds);
- shouldRepaintSelf = parentBounds.intersects(newBounds);
+ Rectangle destroyed = oldBounds.union(newBounds);
+ if (!destroyed.isEmpty())
+ parent.repaint(0, destroyed.x, destroyed.y, destroyed.width,
+ destroyed.height);
}
-
- if (shouldRepaintParent && parent != null)
- parent.repaint(oldx, oldy, oldwidth, oldheight);
- if (shouldRepaintSelf)
- repaint();
}
// Only post event if this component is visible and has changed size.
@@ -1798,9 +1824,8 @@ public abstract class Component
*/
public void paint(Graphics g)
{
- // Paint the heavyweight peer
- if (!isLightweight() && peer != null)
- peer.paint(g);
+ // This is a callback method and is meant to be overridden by subclasses
+ // that want to perform custom painting.
}
/**
@@ -1816,10 +1841,20 @@ public abstract class Component
*
* @see #paint(Graphics)
* @see #repaint()
+ *
+ * @specnote In contrast to what the spec says, tests show that the exact
+ * behaviour is to clear the background on lightweight and
+ * top-level components only. Heavyweight components are not
+ * affected by this method and only call paint().
*/
public void update(Graphics g)
{
- if (!isLightweight())
+ // Tests show that the clearing of the background is only done in
+ // two cases:
+ // - If the component is lightweight (yes this is in contrast to the spec).
+ // or
+ // - If the component is a toplevel container.
+ if (isLightweight() || getParent() == null)
{
Rectangle clip = g.getClipBounds();
if (clip == null)
@@ -1827,7 +1862,6 @@ public abstract class Component
else
g.clearRect(clip.x, clip.y, clip.width, clip.height);
}
-
paint(g);
}
@@ -1854,7 +1888,14 @@ public abstract class Component
*/
public void repaint()
{
- repaint(0, 0, 0, width, height);
+ if(!isShowing())
+ {
+ Component p = parent;
+ if (p != null)
+ p.repaint(0, getX(), getY(), width, height);
+ }
+ else
+ repaint(0, 0, 0, width, height);
}
/**
@@ -1868,7 +1909,14 @@ public abstract class Component
*/
public void repaint(long tm)
{
- repaint(tm, 0, 0, width, height);
+ if(!isShowing())
+ {
+ Component p = parent;
+ if (p != null)
+ p.repaint(tm, getX(), getY(), width, height);
+ }
+ else
+ repaint(tm, 0, 0, width, height);
}
/**
@@ -1885,7 +1933,14 @@ public abstract class Component
*/
public void repaint(int x, int y, int w, int h)
{
- repaint(0, x, y, w, h);
+ if(!isShowing())
+ {
+ Component p = parent;
+ if (p != null)
+ p.repaint(0, x + getX(), y + getY(), width, height);
+ }
+ else
+ repaint(0, x, y, w, h);
}
/**
@@ -1903,14 +1958,18 @@ public abstract class Component
*/
public void repaint(long tm, int x, int y, int width, int height)
{
- // Handle lightweight repainting by forwarding to native parent
- if (isLightweight() && parent != null)
+ if(!isShowing())
{
- if (parent != null)
- parent.repaint(tm, x + getX(), y + getY(), width, height);
+ Component p = parent;
+ if (p != null)
+ p.repaint(tm, x + getX(), y + getY(), width, height);
+ }
+ else
+ {
+ ComponentPeer p = peer;
+ if (p != null)
+ p.repaint(tm, x, y, width, height);
}
- else if (peer != null)
- peer.repaint(tm, x, y, width, height);
}
/**
@@ -1971,7 +2030,7 @@ public abstract class Component
public boolean imageUpdate(Image img, int flags, int x, int y, int w, int h)
{
if ((flags & (FRAMEBITS | ALLBITS)) != 0)
- repaint ();
+ repaint();
else if ((flags & SOMEBITS) != 0)
{
if (incrementalDraw)
@@ -1981,10 +2040,10 @@ public abstract class Component
long tm = redrawRate.longValue();
if (tm < 0)
tm = 0;
- repaint (tm);
+ repaint(tm);
}
else
- repaint (100);
+ repaint(100);
}
}
return (flags & (ALLBITS | ABORT | ERROR)) == 0;
@@ -2282,8 +2341,6 @@ public abstract class Component
// Some subclasses in the AWT package need to override this behavior,
// hence the use of dispatchEventImpl().
dispatchEventImpl(e);
- if (peer != null && ! e.consumed)
- peer.handleEvent(e);
}
/**
@@ -4183,6 +4240,10 @@ public abstract class Component
param.append(",translucent");
if (isDoubleBuffered())
param.append(",doublebuffered");
+ if (parent == null)
+ param.append(",parent==null");
+ else
+ param.append(",parent==").append(parent.getName());
return param.toString();
}
@@ -4742,7 +4803,7 @@ p * <li>the set of backward traversal keys
* @param e the event to dispatch
*/
- void dispatchEventImpl (AWTEvent e)
+ void dispatchEventImpl(AWTEvent e)
{
Event oldEvent = translateEvent (e);
@@ -4776,8 +4837,12 @@ p * <li>the set of backward traversal keys
break;
}
}
- processEvent (e);
+ if (e.id != PaintEvent.PAINT && e.id != PaintEvent.UPDATE)
+ processEvent(e);
}
+
+ if (peer != null)
+ peer.handleEvent(e);
}
/**
diff --git a/libjava/classpath/java/awt/Container.java b/libjava/classpath/java/awt/Container.java
index 303d13b..13d32f8 100644
--- a/libjava/classpath/java/awt/Container.java
+++ b/libjava/classpath/java/awt/Container.java
@@ -42,6 +42,7 @@ import java.awt.event.ContainerEvent;
import java.awt.event.ContainerListener;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
+import java.awt.peer.ComponentPeer;
import java.awt.peer.ContainerPeer;
import java.awt.peer.LightweightPeer;
import java.beans.PropertyChangeListener;
@@ -59,7 +60,8 @@ import java.util.Iterator;
import java.util.Set;
import javax.accessibility.Accessible;
-import javax.swing.SwingUtilities;
+
+import gnu.java.awt.AWTUtilities;
/**
* A generic window toolkit object that acts as a container for other objects.
@@ -338,8 +340,12 @@ public class Container extends Component
if (comp.parent != null)
comp.parent.remove(comp);
comp.parent = this;
+
if (peer != null)
{
+ // Notify the component that it has a new parent.
+ comp.addNotify();
+
if (comp.isLightweight ())
{
enableEvents (comp.eventMask);
@@ -348,7 +354,8 @@ public class Container extends Component
}
}
- invalidate();
+ // Invalidate the layout of the added component and its ancestors.
+ comp.invalidate();
if (component == null)
component = new Component[4]; // FIXME, better initial size?
@@ -394,6 +401,9 @@ public class Container extends Component
ContainerEvent.COMPONENT_ADDED,
comp);
getToolkit().getSystemEventQueue().postEvent(ce);
+
+ // Repaint this container.
+ repaint();
}
}
}
@@ -429,6 +439,9 @@ public class Container extends Component
ContainerEvent.COMPONENT_REMOVED,
r);
getToolkit().getSystemEventQueue().postEvent(ce);
+
+ // Repaint this container.
+ repaint();
}
}
}
@@ -513,6 +526,11 @@ public class Container extends Component
public void invalidate()
{
super.invalidate();
+ if (layoutMgr != null && layoutMgr instanceof LayoutManager2)
+ {
+ LayoutManager2 lm2 = (LayoutManager2) layoutMgr;
+ lm2.invalidateLayout(this);
+ }
}
/**
@@ -534,6 +552,7 @@ public class Container extends Component
*/
void invalidateTree()
{
+ super.invalidate(); // Clean cached layout state.
for (int i = 0; i < ncomponents; i++)
{
Component comp = component[i];
@@ -541,6 +560,12 @@ public class Container extends Component
if (comp instanceof Container)
((Container) comp).invalidateTree();
}
+
+ if (layoutMgr != null && layoutMgr instanceof LayoutManager2)
+ {
+ LayoutManager2 lm2 = (LayoutManager2) layoutMgr;
+ lm2.invalidateLayout(this);
+ }
}
/**
@@ -596,11 +621,15 @@ public class Container extends Component
public void setFont(Font f)
{
- super.setFont(f);
- // FIXME: Although it might make more sense to invalidate only
- // those children whose font == null, Sun invalidates all children.
- // So we'll do the same.
- invalidateTree();
+ if( (f != null && (font == null || !font.equals(f)))
+ || f == null)
+ {
+ super.setFont(f);
+ // FIXME: Although it might make more sense to invalidate only
+ // those children whose font == null, Sun invalidates all children.
+ // So we'll do the same.
+ invalidateTree();
+ }
}
/**
@@ -622,10 +651,21 @@ public class Container extends Component
*/
public Dimension preferredSize()
{
- if (layoutMgr != null)
- return layoutMgr.preferredLayoutSize (this);
- else
- return super.preferredSize ();
+ synchronized(treeLock)
+ {
+ if(valid && prefSize != null)
+ return new Dimension(prefSize);
+ LayoutManager layout = getLayout();
+ if (layout != null)
+ {
+ Dimension layoutSize = layout.preferredLayoutSize(this);
+ if(valid)
+ prefSize = layoutSize;
+ return new Dimension(layoutSize);
+ }
+ else
+ return super.preferredSize ();
+ }
}
/**
@@ -647,8 +687,15 @@ public class Container extends Component
*/
public Dimension minimumSize()
{
- if (layoutMgr != null)
- return layoutMgr.minimumLayoutSize (this);
+ if(valid && minSize != null)
+ return new Dimension(minSize);
+
+ LayoutManager layout = getLayout();
+ if (layout != null)
+ {
+ minSize = layout.minimumLayoutSize (this);
+ return minSize;
+ }
else
return super.minimumSize ();
}
@@ -660,10 +707,15 @@ public class Container extends Component
*/
public Dimension getMaximumSize()
{
- if (layoutMgr != null && layoutMgr instanceof LayoutManager2)
+ if (valid && maxSize != null)
+ return new Dimension(maxSize);
+
+ LayoutManager layout = getLayout();
+ if (layout != null && layout instanceof LayoutManager2)
{
- LayoutManager2 lm2 = (LayoutManager2) layoutMgr;
- return lm2.maximumLayoutSize(this);
+ LayoutManager2 lm2 = (LayoutManager2) layout;
+ maxSize = lm2.maximumLayoutSize(this);
+ return maxSize;
}
else
return super.getMaximumSize();
@@ -678,13 +730,7 @@ public class Container extends Component
*/
public float getAlignmentX()
{
- if (layoutMgr instanceof LayoutManager2)
- {
- LayoutManager2 lm2 = (LayoutManager2) layoutMgr;
- return lm2.getLayoutAlignmentX(this);
- }
- else
- return super.getAlignmentX();
+ return super.getAlignmentX();
}
/**
@@ -696,13 +742,7 @@ public class Container extends Component
*/
public float getAlignmentY()
{
- if (layoutMgr instanceof LayoutManager2)
- {
- LayoutManager2 lm2 = (LayoutManager2) layoutMgr;
- return lm2.getLayoutAlignmentY(this);
- }
- else
- return super.getAlignmentY();
+ return super.getAlignmentY();
}
/**
@@ -718,8 +758,7 @@ public class Container extends Component
{
if (!isShowing())
return;
- // Paint self first.
- super.paint(g);
+
// Visit heavyweights as well, in case they were
// erased when we cleared the background for this container.
visitChildren(g, GfxPaintVisitor.INSTANCE, false);
@@ -733,10 +772,30 @@ public class Container extends Component
* drawn.
*
* @param g The graphics context for this update.
+ *
+ * @specnote The specification suggests that this method forwards the
+ * update() call to all its lightweight children. Tests show
+ * that this is not done either in the JDK. The exact behaviour
+ * seems to be that the background is cleared in heavyweight
+ * Containers, and all other containers
+ * directly call paint(), causing the (lightweight) children to
+ * be painted.
*/
public void update(Graphics g)
{
- super.update(g);
+ // It seems that the JDK clears the background of containers like Panel
+ // and Window (within this method) but not of 'plain' Containers or
+ // JComponents. This could
+ // lead to the assumption that it only clears heavyweight containers.
+ // However that is not quite true. In a test with a custom Container
+ // that overrides isLightweight() to return false, the background is
+ // also not cleared. So we do a check on !(peer instanceof LightweightPeer)
+ // instead.
+ ComponentPeer p = peer;
+ if (p != null && !(p instanceof LightweightPeer))
+ g.clearRect(0, 0, getWidth(), getHeight());
+
+ paint(g);
}
/**
@@ -1198,7 +1257,7 @@ public class Container extends Component
}
if (focusTraversalKeys == null)
- focusTraversalKeys = new Set[3];
+ focusTraversalKeys = new Set[4];
keystrokes = Collections.unmodifiableSet (new HashSet (keystrokes));
firePropertyChange (name, focusTraversalKeys[id], keystrokes);
@@ -1465,12 +1524,8 @@ public class Container extends Component
for (int i = ncomponents - 1; i >= 0; --i)
{
Component comp = component[i];
- // If we're visiting heavyweights as well,
- // don't recurse into Containers here. This avoids
- // painting the same nested child multiple times.
boolean applicable = comp.isVisible()
- && (comp.isLightweight()
- || !lightweightOnly && ! (comp instanceof Container));
+ && (comp.isLightweight() || !lightweightOnly);
if (applicable)
visitChild(gfx, visitor, comp);
@@ -1525,11 +1580,9 @@ public class Container extends Component
void dispatchEventImpl(AWTEvent e)
{
// Give lightweight dispatcher a chance to handle it.
- if (eventTypeEnabled (e.id)
- && dispatcher != null
- && dispatcher.handleEvent (e))
+ if (dispatcher != null && dispatcher.handleEvent (e))
return;
-
+
if ((e.id <= ContainerEvent.CONTAINER_LAST
&& e.id >= ContainerEvent.CONTAINER_FIRST)
&& (containerListener != null
@@ -1539,6 +1592,26 @@ public class Container extends Component
super.dispatchEventImpl(e);
}
+ /**
+ * Tests if this container has an interest in the given event id.
+ *
+ * @param eventId The event id to check.
+ *
+ * @return <code>true</code> if a listener for the event id exists or
+ * if the eventMask is set for the event id.
+ *
+ * @see java.awt.Component#eventTypeEnabled(int)
+ */
+ boolean eventTypeEnabled(int eventId)
+ {
+ if(eventId <= ContainerEvent.CONTAINER_LAST
+ && eventId >= ContainerEvent.CONTAINER_FIRST)
+ return containerListener != null
+ || (eventMask & AWTEvent.CONTAINER_EVENT_MASK) != 0;
+ else
+ return super.eventTypeEnabled(eventId);
+ }
+
// This is used to implement Component.transferFocus.
Component findNextFocusComponent(Component child)
{
@@ -1603,12 +1676,11 @@ public class Container extends Component
// If we're not lightweight, and we just got a lightweight
// child, we need a lightweight dispatcher to feed it events.
- if (! this.isLightweight())
- {
- if (dispatcher == null)
- dispatcher = new LightweightDispatcher (this);
- }
-
+ if (!this.isLightweight() && dispatcher == null)
+ dispatcher = new LightweightDispatcher (this);
+
+ if (dispatcher != null)
+ dispatcher.enableEvents(component[i].eventMask);
enableEvents(component[i].eventMask);
if (peer != null && !isLightweight ())
@@ -1862,7 +1934,6 @@ public class Container extends Component
* rather than mimic it exactly we write something which does "roughly
* the same thing".
*/
-
class LightweightDispatcher implements Serializable
{
private static final long serialVersionUID = 5184291520170872969L;
@@ -1870,10 +1941,8 @@ class LightweightDispatcher implements Serializable
private Cursor nativeCursor;
private long eventMask;
- private transient Component mouseEventTarget;
private transient Component pressedComponent;
private transient Component lastComponentEntered;
- private transient Component tempComponent;
private transient int pressCount;
LightweightDispatcher(Container c)
@@ -1881,11 +1950,17 @@ class LightweightDispatcher implements Serializable
nativeContainer = c;
}
- void acquireComponentForMouseEvent(MouseEvent me)
+ void enableEvents(long l)
+ {
+ eventMask |= l;
+ }
+
+ Component acquireComponentForMouseEvent(MouseEvent me)
{
int x = me.getX ();
int y = me.getY ();
+ Component mouseEventTarget = null;
// Find the candidate which should receive this event.
Component parent = nativeContainer;
Component candidate = null;
@@ -1893,13 +1968,13 @@ class LightweightDispatcher implements Serializable
while (candidate == null && parent != null)
{
candidate =
- SwingUtilities.getDeepestComponentAt(parent, p.x, p.y);
+ AWTUtilities.getDeepestComponentAt(parent, p.x, p.y);
if (candidate == null || (candidate.eventMask & me.getID()) == 0)
- {
- candidate = null;
- p = SwingUtilities.convertPoint(parent, p.x, p.y, parent.parent);
- parent = parent.parent;
- }
+ {
+ candidate = null;
+ p = AWTUtilities.convertPoint(parent, p.x, p.y, parent.parent);
+ parent = parent.parent;
+ }
}
// If the only candidate we found was the native container itself,
@@ -1915,25 +1990,24 @@ class LightweightDispatcher implements Serializable
{
// Old candidate could have been removed from
// the nativeContainer so we check first.
- if (SwingUtilities.isDescendingFrom(lastComponentEntered, nativeContainer))
- {
- Point tp =
- SwingUtilities.convertPoint(nativeContainer,
- x, y, lastComponentEntered);
- MouseEvent exited = new MouseEvent (lastComponentEntered,
- MouseEvent.MOUSE_EXITED,
- me.getWhen (),
- me.getModifiersEx (),
- tp.x, tp.y,
- me.getClickCount (),
- me.isPopupTrigger (),
- me.getButton ());
- tempComponent = lastComponentEntered;
- lastComponentEntered = null;
- tempComponent.dispatchEvent(exited);
- }
+ if (AWTUtilities.isDescendingFrom(lastComponentEntered,
+ nativeContainer))
+ {
+ Point tp = AWTUtilities.convertPoint(nativeContainer,
+ x, y, lastComponentEntered);
+ MouseEvent exited = new MouseEvent (lastComponentEntered,
+ MouseEvent.MOUSE_EXITED,
+ me.getWhen (),
+ me.getModifiersEx (),
+ tp.x, tp.y,
+ me.getClickCount (),
+ me.isPopupTrigger (),
+ me.getButton ());
+ lastComponentEntered.dispatchEvent (exited);
+ }
lastComponentEntered = null;
}
+
// If we have a candidate, maybe enter it.
if (candidate != null)
{
@@ -1942,10 +2016,10 @@ class LightweightDispatcher implements Serializable
&& candidate.isShowing()
&& candidate != nativeContainer
&& candidate != lastComponentEntered)
- {
+ {
lastComponentEntered = mouseEventTarget;
- Point cp = SwingUtilities.convertPoint(nativeContainer,
- x, y, lastComponentEntered);
+ Point cp = AWTUtilities.convertPoint(nativeContainer,
+ x, y, lastComponentEntered);
MouseEvent entered = new MouseEvent (lastComponentEntered,
MouseEvent.MOUSE_ENTERED,
me.getWhen (),
@@ -1958,17 +2032,38 @@ class LightweightDispatcher implements Serializable
}
}
+ // Check which buttons where pressed except the last button that
+ // changed state.
+ int modifiers = me.getModifiersEx() & (MouseEvent.BUTTON1_DOWN_MASK
+ | MouseEvent.BUTTON2_DOWN_MASK
+ | MouseEvent.BUTTON3_DOWN_MASK);
+ switch(me.getButton())
+ {
+ case MouseEvent.BUTTON1:
+ modifiers &= ~MouseEvent.BUTTON1_DOWN_MASK;
+ break;
+ case MouseEvent.BUTTON2:
+ modifiers &= ~MouseEvent.BUTTON2_DOWN_MASK;
+ break;
+ case MouseEvent.BUTTON3:
+ modifiers &= ~MouseEvent.BUTTON3_DOWN_MASK;
+ break;
+ }
+
if (me.getID() == MouseEvent.MOUSE_RELEASED
- || me.getID() == MouseEvent.MOUSE_PRESSED && pressCount > 0
+ || me.getID() == MouseEvent.MOUSE_PRESSED && modifiers > 0
|| me.getID() == MouseEvent.MOUSE_DRAGGED)
- // If any of the following events occur while a button is held down,
- // they should be dispatched to the same component to which the
- // original MOUSE_PRESSED event was dispatched:
- // - MOUSE_RELEASED
- // - MOUSE_PRESSED: another button pressed while the first is held down
- // - MOUSE_DRAGGED
- if (SwingUtilities.isDescendingFrom(pressedComponent, nativeContainer))
- mouseEventTarget = pressedComponent;
+ {
+ // If any of the following events occur while a button is held down,
+ // they should be dispatched to the same component to which the
+ // original MOUSE_PRESSED event was dispatched:
+ // - MOUSE_RELEASED
+ // - MOUSE_PRESSED: another button pressed while the first is held
+ // down
+ // - MOUSE_DRAGGED
+ if (AWTUtilities.isDescendingFrom(pressedComponent, nativeContainer))
+ mouseEventTarget = pressedComponent;
+ }
else if (me.getID() == MouseEvent.MOUSE_CLICKED)
{
// Don't dispatch CLICKED events whose target is not the same as the
@@ -1978,6 +2073,7 @@ class LightweightDispatcher implements Serializable
else if (pressCount == 0)
pressedComponent = null;
}
+ return mouseEventTarget;
}
boolean handleEvent(AWTEvent e)
@@ -1986,41 +2082,42 @@ class LightweightDispatcher implements Serializable
{
MouseEvent me = (MouseEvent) e;
- acquireComponentForMouseEvent(me);
-
+ // Make the LightWeightDispatcher reentrant. This is necessary when
+ // a lightweight component does its own modal event queue.
+ Component mouseEventTarget = acquireComponentForMouseEvent(me);
+
// Avoid dispatching ENTERED and EXITED events twice.
if (mouseEventTarget != null
&& mouseEventTarget.isShowing()
&& e.getID() != MouseEvent.MOUSE_ENTERED
&& e.getID() != MouseEvent.MOUSE_EXITED)
{
- MouseEvent newEvt =
- SwingUtilities.convertMouseEvent(nativeContainer, me,
- mouseEventTarget);
- mouseEventTarget.dispatchEvent(newEvt);
-
switch (e.getID())
{
- case MouseEvent.MOUSE_PRESSED:
- if (pressCount++ == 0)
- pressedComponent = mouseEventTarget;
- break;
-
- case MouseEvent.MOUSE_RELEASED:
- // Clear our memory of the original PRESSED event, only if
- // we're not expecting a CLICKED event after this. If
- // there is a CLICKED event after this, it will do clean up.
- if (--pressCount == 0
- && mouseEventTarget != pressedComponent)
- pressedComponent = null;
- break;
+ case MouseEvent.MOUSE_PRESSED:
+ if (pressCount++ == 0)
+ pressedComponent = mouseEventTarget;
+ break;
+ case MouseEvent.MOUSE_RELEASED:
+ // Clear our memory of the original PRESSED event, only if
+ // we're not expecting a CLICKED event after this. If
+ // there is a CLICKED event after this, it will do clean up.
+ if (--pressCount == 0
+ && mouseEventTarget != pressedComponent)
+ pressedComponent = null;
+ break;
}
- if (newEvt.isConsumed())
- e.consume();
+
+ MouseEvent newEvt =
+ AWTUtilities.convertMouseEvent(nativeContainer, me,
+ mouseEventTarget);
+ mouseEventTarget.dispatchEvent(newEvt);
+
+ if (newEvt.isConsumed())
+ e.consume();
}
}
-
+
return e.isConsumed();
}
-
-} // class LightweightDispatcher
+}
diff --git a/libjava/classpath/java/awt/EventQueue.java b/libjava/classpath/java/awt/EventQueue.java
index a8b0078..15b6e1e 100644
--- a/libjava/classpath/java/awt/EventQueue.java
+++ b/libjava/classpath/java/awt/EventQueue.java
@@ -38,8 +38,6 @@ exception statement from your version. */
package java.awt;
-import gnu.java.awt.ClasspathToolkit;
-
import java.awt.event.ActionEvent;
import java.awt.event.InputEvent;
import java.awt.event.InputMethodEvent;
@@ -78,10 +76,7 @@ public class EventQueue
private EventDispatchThread dispatchThread = new EventDispatchThread(this);
private boolean shutdown = false;
- private long lastNativeQueueAccess = 0;
- private long humanLatencyThreshold = 100;
-
- synchronized void setShutdown (boolean b)
+ synchronized private void setShutdown (boolean b)
{
shutdown = b;
}
@@ -94,8 +89,8 @@ public class EventQueue
// This is the exact self-shutdown condition specified in J2SE:
// http://java.sun.com/j2se/1.4.2/docs/api/java/awt/doc-files/AWTThreadIssues.html
- if (peekEvent() == null
- && ((ClasspathToolkit) Toolkit.getDefaultToolkit()).nativeQueueEmpty())
+ // FIXME: check somewhere that the native queue is empty
+ if (peekEvent() == null)
{
Frame[] frames = Frame.getFrames();
for (int i = 0; i < frames.length; ++i)
@@ -127,50 +122,22 @@ public class EventQueue
{
if (next != null)
return next.getNextEvent();
-
- ClasspathToolkit tk = ((ClasspathToolkit) Toolkit.getDefaultToolkit());
- long curr = System.currentTimeMillis();
-
- if (! tk.nativeQueueEmpty() &&
- (curr - lastNativeQueueAccess > humanLatencyThreshold))
- {
- tk.iterateNativeQueue(this, false);
- lastNativeQueueAccess = curr;
- }
while (next_in == next_out)
{
- // Only the EventDispatchThread associated with the top of the stack is
- // allowed to get events from the native source; everyone else just
- // waits on the head of the queue.
-
- if (isDispatchThread())
- {
- // We are not allowed to return null from this method, yet it
- // is possible that we actually have run out of native events
- // in the enclosing while() loop, and none of the native events
- // happened to cause AWT events. We therefore ought to check
- // the isShutdown() condition here, before risking a "native
- // wait". If we check it before entering this function we may
- // wait forever for events after the shutdown condition has
- // arisen.
-
- if (isShutdown())
- throw new InterruptedException();
-
- tk.iterateNativeQueue(this, true);
- lastNativeQueueAccess = System.currentTimeMillis();
- }
- else
- {
- try
- {
- wait();
- }
- catch (InterruptedException ie)
- {
- }
- }
+ // We are not allowed to return null from this method, yet it
+ // is possible that we actually have run out of native events
+ // in the enclosing while() loop, and none of the native events
+ // happened to cause AWT events. We therefore ought to check
+ // the isShutdown() condition here, before risking a "native
+ // wait". If we check it before entering this function we may
+ // wait forever for events after the shutdown condition has
+ // arisen.
+
+ if (isShutdown())
+ throw new InterruptedException();
+
+ wait();
}
AWTEvent res = queue[next_out];
@@ -298,15 +265,6 @@ public class EventQueue
dispatchThread.start();
}
- // Window events might represent the closing of a window, which
- // might cause the end of the dispatch thread's life, so we'll wake
- // it up here to give it a chance to check for shutdown.
-
- if (!isDispatchThread()
- || (evt.getID() == WindowEvent.WINDOW_CLOSED)
- || (evt.getID() == WindowEvent.WINDOW_CLOSING))
- ((ClasspathToolkit) Toolkit.getDefaultToolkit()).wakeNativeQueue();
-
notify();
}
@@ -478,7 +436,6 @@ public class EventQueue
next_in = 0;
next_out = 0;
- ((ClasspathToolkit) Toolkit.getDefaultToolkit()).wakeNativeQueue();
setShutdown(true);
dispatchThread = null;
this.notifyAll();
diff --git a/libjava/classpath/java/awt/FlowLayout.java b/libjava/classpath/java/awt/FlowLayout.java
index 4674990..7d0771d 100644
--- a/libjava/classpath/java/awt/FlowLayout.java
+++ b/libjava/classpath/java/awt/FlowLayout.java
@@ -205,12 +205,12 @@ public class FlowLayout implements LayoutManager, Serializable
else if (align == TRAILING)
myalign = left_to_right ? RIGHT : LEFT;
- if (myalign == LEFT)
- x = ins.left + hgap;
+ if (myalign == RIGHT)
+ x = ins.left + (d.width - new_w) + hgap;
else if (myalign == CENTER)
x = ins.left + (d.width - new_w) / 2 + hgap;
- else
- x = ins.left + (d.width - new_w) + hgap;
+ else // LEFT and all other values of align.
+ x = ins.left + hgap;
for (int k = i; k < j; ++k)
{
@@ -269,9 +269,9 @@ public class FlowLayout implements LayoutManager, Serializable
*/
public void setAlignment (int align)
{
- if (align != LEFT && align != RIGHT && align != CENTER
- && align != LEADING && align != TRAILING)
- throw new IllegalArgumentException ("invalid alignment: " + align);
+ // The JDK accepts invalid values and treats them as
+ // LEFT during layout, so do we. The invalid value is even stored,
+ // getAlignment() returns the same invalid value.
this.align = align;
}
diff --git a/libjava/classpath/java/awt/Font.java b/libjava/classpath/java/awt/Font.java
index 30961ab..5de9458 100644
--- a/libjava/classpath/java/awt/Font.java
+++ b/libjava/classpath/java/awt/Font.java
@@ -353,9 +353,11 @@ private static final long serialVersionUID = -4206021311591459213L;
this(null, attrs);
}
- /* This extra constructor is here to permit ClasspathToolkit and to build
- a font with a "logical name" as well as attrs. */
- public Font (String name, Map attrs)
+ /* This extra constructor is here to permit ClasspathToolkit and to
+ build a font with a "logical name" as well as attrs.
+ ClasspathToolkit.getFont(String,Map) uses reflection to call this
+ package-private constructor. */
+ Font (String name, Map attrs)
{
// If attrs is null, setting it to an empty HashMap will give this
// Font default attributes.
diff --git a/libjava/classpath/java/awt/FontMetrics.java b/libjava/classpath/java/awt/FontMetrics.java
index e702a62..6dd73ec 100644
--- a/libjava/classpath/java/awt/FontMetrics.java
+++ b/libjava/classpath/java/awt/FontMetrics.java
@@ -193,7 +193,8 @@ public abstract class FontMetrics implements java.io.Serializable
*/
public int charWidth(int ch)
{
- return charWidth((char) ch);
+ char[] chars = Character.toChars(ch);
+ return charsWidth(chars, 0, chars.length);
}
/**
@@ -235,7 +236,8 @@ public abstract class FontMetrics implements java.io.Serializable
public int charsWidth(char[] buf, int offset, int len)
{
int total_width = 0;
- for (int i = offset; i < len; i++)
+ int endOffset = offset + len;
+ for (int i = offset; i < endOffset; i++)
total_width += charWidth(buf[i]);
return total_width;
}
diff --git a/libjava/classpath/java/awt/Frame.java b/libjava/classpath/java/awt/Frame.java
index 0cb97f8..05c9384 100644
--- a/libjava/classpath/java/awt/Frame.java
+++ b/libjava/classpath/java/awt/Frame.java
@@ -401,20 +401,6 @@ remove(MenuComponent menu)
menuBar.remove(menu);
}
-/**
- * Notifies this frame that it should create its native peer.
- */
-private static void fireDummyEvent()
-{
- EventQueue.invokeLater(new Runnable()
- {
- public void run()
- {
- // Do nothing here.
- }
- });
-}
-
public void
addNotify()
{
@@ -423,11 +409,6 @@ addNotify()
if (peer == null)
peer = getToolkit ().createFrame (this);
- // We now know there's a Frame (us) with a live peer, so we can start the
- // fundamental queue and dispatch thread, by inserting a dummy event.
- if (parent != null && parent.isDisplayable())
- fireDummyEvent();
-
super.addNotify();
}
@@ -436,12 +417,6 @@ public void removeNotify()
if (menuBar != null)
menuBar.removeNotify();
super.removeNotify();
-
- // By now we've been disconnected from the peer, and the peer set to
- // null. This is formally the same as saying "we just became
- // un-displayable", so we wake up the event queue with a dummy event to
- // see if it's time to shut down.
- fireDummyEvent();
}
/**
diff --git a/libjava/classpath/java/awt/GraphicsConfiguration.java b/libjava/classpath/java/awt/GraphicsConfiguration.java
index 6dc27793..069d741 100644
--- a/libjava/classpath/java/awt/GraphicsConfiguration.java
+++ b/libjava/classpath/java/awt/GraphicsConfiguration.java
@@ -126,6 +126,22 @@ public abstract class GraphicsConfiguration
}
/**
+ * Returns a buffered volatile image optimized to this device, and
+ * with the given transparency. Because the buffer is volatile, it
+ * can be optimized by native graphics accelerators.
+ *
+ * @param w the width of the buffer
+ * @param h the height of the buffer
+ * @param transparency the transparency value for the buffer
+ * @return the buffered image, or null if none is supported
+ * @throws AWTException if the capabilities cannot be met
+ * @since 1.5
+ */
+ public abstract VolatileImage createCompatibleVolatileImage(int width,
+ int height,
+ int transparency);
+
+ /**
* Returns a buffered image optimized to this device, and with the specified
* transparency, so that blitting can be supported in the buffered image.
*
diff --git a/libjava/classpath/java/awt/GridBagLayout.java b/libjava/classpath/java/awt/GridBagLayout.java
index 767610c..7f9ab24 100644
--- a/libjava/classpath/java/awt/GridBagLayout.java
+++ b/libjava/classpath/java/awt/GridBagLayout.java
@@ -192,16 +192,12 @@ public class GridBagLayout
if (clone.gridwidth == 0)
clone.gridwidth = GridBagConstraints.REMAINDER;
- else if (clone.gridwidth < 0
- && clone.gridwidth != GridBagConstraints.REMAINDER
- && clone.gridwidth != GridBagConstraints.RELATIVE)
+ else if (clone.gridwidth < 0)
clone.gridwidth = 1;
if (clone.gridheight == 0)
clone.gridheight = GridBagConstraints.REMAINDER;
- else if (clone.gridheight < 0
- && clone.gridheight != GridBagConstraints.REMAINDER
- && clone.gridheight != GridBagConstraints.RELATIVE)
+ else if (clone.gridheight < 0)
clone.gridheight = 1;
comptable.put (component, clone);
@@ -913,7 +909,7 @@ public class GridBagLayout
sizes[start] = Math.max(sizes[start], size);
weights[start] = Math.max(weights[start], weight);
}
- else
+ else if (span > 1)
{
int numOccupied = span;
int lastOccupied = -1;
diff --git a/libjava/classpath/java/awt/Label.java b/libjava/classpath/java/awt/Label.java
index 8867fa1..d6db329 100644
--- a/libjava/classpath/java/awt/Label.java
+++ b/libjava/classpath/java/awt/Label.java
@@ -215,12 +215,17 @@ getText()
public synchronized void
setText(String text)
{
- this.text = text;
-
- if (peer != null)
+ if ((this.text == null && text != null)
+ || (this.text != null && ! this.text.equals(text)))
{
- LabelPeer lp = (LabelPeer) peer;
- lp.setText (text);
+ this.text = text;
+
+ if (peer != null)
+ {
+ LabelPeer lp = (LabelPeer) peer;
+ lp.setText (text);
+ }
+ invalidate();
}
}
diff --git a/libjava/classpath/java/awt/List.java b/libjava/classpath/java/awt/List.java
index 5fcc79b..ab7d359 100644
--- a/libjava/classpath/java/awt/List.java
+++ b/libjava/classpath/java/awt/List.java
@@ -163,6 +163,7 @@ List(int rows, boolean multipleMode)
{
this.rows = rows;
this.multipleMode = multipleMode;
+ selected = new int[0];
if (GraphicsEnvironment.isHeadless())
throw new HeadlessException ();
diff --git a/libjava/classpath/java/awt/MenuItem.java b/libjava/classpath/java/awt/MenuItem.java
index 66798c8..58dcb67 100644
--- a/libjava/classpath/java/awt/MenuItem.java
+++ b/libjava/classpath/java/awt/MenuItem.java
@@ -179,14 +179,11 @@ private transient ActionListener action_listeners;
*/
public boolean setCurrentAccessibleValue(Number number)
{
- if (number.intValue() == 0)
- {
- setEnabled(false);
- return false;
- }
-
- setEnabled(true);
- return true;
+ boolean result = (number.intValue() != 0);
+ // this. is required by javac 1.3, otherwise it is confused with
+ // MenuItem.this.setEnabled.
+ this.setEnabled(result);
+ return result;
}
/* (non-Javadoc)
diff --git a/libjava/classpath/java/awt/TextComponent.java b/libjava/classpath/java/awt/TextComponent.java
index 9edbd88..60e72fc 100644
--- a/libjava/classpath/java/awt/TextComponent.java
+++ b/libjava/classpath/java/awt/TextComponent.java
@@ -475,7 +475,7 @@ select(int selectionStart, int selectionEnd)
if (selectionEnd > text.length())
selectionEnd = text.length();
- if (selectionStart > getSelectionEnd())
+ if (selectionStart > selectionEnd)
selectionStart = selectionEnd;
this.selectionStart = selectionStart;
diff --git a/libjava/classpath/java/awt/Toolkit.java b/libjava/classpath/java/awt/Toolkit.java
index c7c6f9f..2ca88b6 100644
--- a/libjava/classpath/java/awt/Toolkit.java
+++ b/libjava/classpath/java/awt/Toolkit.java
@@ -790,6 +790,9 @@ public abstract class Toolkit
{
// Presumably the only reason this isn't abstract is for backwards
// compatibility? FIXME?
+ if (GraphicsEnvironment.isHeadless())
+ throw new HeadlessException("No custom cursor in an headless graphics "
+ + "environment.");
return null;
}
@@ -801,6 +804,9 @@ public abstract class Toolkit
*/
public Dimension getBestCursorSize(int preferredWidth, int preferredHeight)
{
+ if (GraphicsEnvironment.isHeadless())
+ throw new HeadlessException("No best cursor size in an headless "
+ + "graphics environment.");
return new Dimension (0,0);
}
diff --git a/libjava/classpath/java/awt/Window.java b/libjava/classpath/java/awt/Window.java
index e26c4e3..1689d03 100644
--- a/libjava/classpath/java/awt/Window.java
+++ b/libjava/classpath/java/awt/Window.java
@@ -155,6 +155,9 @@ public class Window extends Container implements Accessible
}
}
});
+
+ GraphicsEnvironment g = GraphicsEnvironment.getLocalGraphicsEnvironment();
+ graphicsConfiguration = g.getDefaultScreenDevice().getDefaultConfiguration();
}
Window(GraphicsConfiguration gc)
@@ -619,6 +622,8 @@ public class Window extends Container implements Accessible
|| windowStateListener != null
|| (eventMask & AWTEvent.WINDOW_EVENT_MASK) != 0))
processEvent(e);
+ else if (e.id == ComponentEvent.COMPONENT_RESIZED)
+ validate ();
else
super.dispatchEventImpl(e);
}
@@ -741,7 +746,25 @@ public class Window extends Container implements Accessible
if (activeWindow == this)
return manager.getFocusOwner ();
else
- return windowFocusOwner;
+ return null;
+ }
+
+ /**
+ * Returns the child component of this window that would receive
+ * focus if this window were to become focused. If the window
+ * already has the top-level focus, then this method returns the
+ * same component as getFocusOwner. If no child component has
+ * requested focus within the window, then the initial focus owner
+ * is returned. If this is a non-focusable window, this method
+ * returns null.
+ *
+ * @return the child component of this window that most recently had
+ * the focus, or <code>null</code>
+ * @since 1.4
+ */
+ public Component getMostRecentFocusOwner ()
+ {
+ return windowFocusOwner;
}
/**
@@ -1070,44 +1093,6 @@ public class Window extends Container implements Accessible
this.focusableWindowState = focusableWindowState;
}
- // setBoundsCallback is needed so that when a user moves a window,
- // the Window's location can be updated without calling the peer's
- // setBounds method. When a user moves a window the peer window's
- // location is updated automatically and the windowing system sends
- // a message back to the application informing it of its updated
- // dimensions. We must update the AWT Window class with these new
- // dimensions. But we don't want to call the peer's setBounds
- // method, because the peer's dimensions have already been updated.
- // (Under X, having this method prevents Configure event loops when
- // moving windows: Component.setBounds -> peer.setBounds ->
- // postConfigureEvent -> Component.setBounds -> ... In some cases
- // Configure event loops cause windows to jitter back and forth
- // continuously).
- void setBoundsCallback (int x, int y, int w, int h)
- {
- if (this.x == x && this.y == y && width == w && height == h)
- return;
- invalidate();
- boolean resized = width != w || height != h;
- boolean moved = this.x != x || this.y != y;
- this.x = x;
- this.y = y;
- width = w;
- height = h;
- if (resized && isShowing ())
- {
- ComponentEvent ce =
- new ComponentEvent(this, ComponentEvent.COMPONENT_RESIZED);
- getToolkit().getSystemEventQueue().postEvent(ce);
- }
- if (moved && isShowing ())
- {
- ComponentEvent ce =
- new ComponentEvent(this, ComponentEvent.COMPONENT_MOVED);
- getToolkit().getSystemEventQueue().postEvent(ce);
- }
- }
-
/**
* Generate a unique name for this window.
*
diff --git a/libjava/classpath/java/awt/datatransfer/Clipboard.java b/libjava/classpath/java/awt/datatransfer/Clipboard.java
index 9953a72..5fa1d1a 100644
--- a/libjava/classpath/java/awt/datatransfer/Clipboard.java
+++ b/libjava/classpath/java/awt/datatransfer/Clipboard.java
@@ -1,5 +1,5 @@
/* Clipboard.java -- Class for transferring data via cut and paste.
- Copyright (C) 1999, 2001 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2001, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,16 +38,21 @@ exception statement from your version. */
package java.awt.datatransfer;
+import java.io.IOException;
+import java.util.ArrayList;
+
/**
* This class allows data to be transferred using a cut and paste type
* mechanism.
*
* @author Aaron M. Renn (arenn@urbanophile.com)
+ * @author Mark J. Wielaard (mark@klomp.org)
*/
public class Clipboard
{
/**
- * The data being transferred.
+ * The data currently on this clipboard. For use by
+ * subclasses. Also returned by the public method getContents().
*/
protected Transferable contents;
@@ -57,7 +62,10 @@ public class Clipboard
protected ClipboardOwner owner;
// The clipboard name
- private String name;
+ private final String name;
+
+ // The flavor listeners (most likely small).
+ private final ArrayList listeners = new ArrayList(3);
/**
* Initializes a new instance of <code>Clipboard</code> with the
@@ -81,7 +89,8 @@ public class Clipboard
/**
* Returns the contents of the clipboard.
*
- * @param requestor The object requesting the contents.
+ * @param requestor The object requesting the contents. This
+ * implementation ignores this parameter.
*
* @exception IllegalStateException If the clipboard is currently unavailable
*/
@@ -91,24 +100,108 @@ public class Clipboard
}
/**
- * Sets the content and owner of this clipboard.
- * If the given owner is different from the current owner
- * then lostOwnership is called on the current owner.
- * XXX - is this called with the old or new contents.
+ * Sets the content and owner of this clipboard. If the given owner
+ * is different from the current owner then <code>lostOwnership()</code>
+ * is called on the current owner with the old contents of the given
+ * clipboard.
*
* @param contents The new clipboard contents.
* @param owner The new clipboard owner
*
* @exception IllegalStateException If the clipboard is currently unavailable
*/
- public synchronized void setContents(Transferable contents, ClipboardOwner owner)
+ public synchronized void setContents(Transferable contents,
+ ClipboardOwner owner)
{
- if (this.owner != owner)
- if (this.owner != null)
- this.owner.lostOwnership(this, contents);
-
- this.owner = owner;
+ Transferable oldContents = getContents(null);
this.contents = contents;
+ if (this.owner != owner)
+ {
+ ClipboardOwner oldOwner = this.owner;
+ this.owner = owner;
+ if (oldOwner != null)
+ oldOwner.lostOwnership(this, oldContents);
+ }
+
+ FlavorListener[] fs = getFlavorListeners();
+ if (fs.length > 0)
+ {
+ // We are a bit optimistic here. We assume DataFlavors will be
+ // given in the same order. If the number of flavors is
+ // different or the order of the DataFlavors in the list then
+ // fire a change event.
+ boolean newFlavors = ((contents != null && oldContents == null)
+ || (contents == null && oldContents != null));
+ if (!newFlavors && contents != null && oldContents != null)
+ {
+ DataFlavor[] df1 = contents.getTransferDataFlavors();
+ DataFlavor[] df2 = oldContents.getTransferDataFlavors();
+ newFlavors = df1.length != df2.length;
+
+ for (int i = 0; !newFlavors && i < df1.length; i++)
+ newFlavors = !df1[i].equals(df2[i]);
+ }
+
+ if (newFlavors)
+ {
+ FlavorEvent e = new FlavorEvent(this);
+ for (int i = 0; i < fs.length; i++)
+ fs[i].flavorsChanged(e);
+ }
+ }
+ }
+
+ public DataFlavor[] getAvailableDataFlavors()
+ {
+ Transferable c = getContents(null);
+ if (c == null)
+ return new DataFlavor[0];
+ else
+ return c.getTransferDataFlavors();
+ }
+
+ public boolean isDataFlavorAvailable(DataFlavor flavor)
+ {
+ DataFlavor[] fs = getAvailableDataFlavors();
+ for (int i = 0; i < fs.length; i++)
+ if (flavor.equals(fs[i]))
+ return true;
+
+ return false;
}
-}
+ public Object getData(DataFlavor flavor)
+ throws UnsupportedFlavorException, IOException
+ {
+ Transferable c = getContents(null);
+ if (c == null)
+ throw new UnsupportedFlavorException(flavor);
+ else
+ return c.getTransferData(flavor);
+ }
+
+ public void addFlavorListener(FlavorListener listener)
+ {
+ synchronized(listeners)
+ {
+ listeners.add(listener);
+ }
+ }
+
+ public void removeFlavorListener(FlavorListener listener)
+ {
+ synchronized(listeners)
+ {
+ listeners.remove(listener);
+ }
+ }
+
+ public FlavorListener[] getFlavorListeners()
+ {
+ synchronized(listeners)
+ {
+ return (FlavorListener[])
+ listeners.toArray(new FlavorListener[listeners.size()]);
+ }
+ }
+}
diff --git a/libjava/classpath/java/awt/datatransfer/DataFlavor.java b/libjava/classpath/java/awt/datatransfer/DataFlavor.java
index e5fbd24..38f415b 100644
--- a/libjava/classpath/java/awt/datatransfer/DataFlavor.java
+++ b/libjava/classpath/java/awt/datatransfer/DataFlavor.java
@@ -49,6 +49,7 @@ import java.io.StringReader;
import java.io.UnsupportedEncodingException;
import java.nio.ByteBuffer;
import java.nio.CharBuffer;
+import java.rmi.Remote;
/**
* This class represents a particular data format used for transferring
@@ -127,10 +128,9 @@ static
javaFileListFlavor
= new DataFlavor(java.util.List.class,
+ "application/x-java-file-list; class=java.util.List",
"Java File List");
- // javaFileListFlavor.mimeType = "application/x-java-file-list";
-
imageFlavor
= new DataFlavor(java.awt.Image.class,
"Java Image");
@@ -335,7 +335,8 @@ getRepresentationClassFromMime(String mimeString, ClassLoader classLoader)
public
DataFlavor(String mimeType, String humanPresentableName)
{
- this (getRepresentationClassFromMime (mimeType, null), humanPresentableName);
+ this (getRepresentationClassFromMime (mimeType, null),
+ mimeType, humanPresentableName);
}
/*************************************************************************/
@@ -426,17 +427,15 @@ getPrimaryType()
public String
getSubType()
{
- int idx = mimeType.indexOf("/");
- if (idx == -1)
- return("");
-
- String subtype = mimeType.substring(idx + 1);
+ int start = mimeType.indexOf("/");
+ if (start == -1)
+ return "";
- idx = subtype.indexOf(" ");
- if (idx == -1)
- return(subtype);
+ int end = mimeType.indexOf(";", start + 1);
+ if (end == -1)
+ return mimeType.substring(start + 1);
else
- return(subtype.substring(0, idx));
+ return mimeType.substring(start + 1, end);
}
/*************************************************************************/
@@ -480,6 +479,9 @@ getParameter(String paramName, String mimeString)
public String
getParameter(String paramName)
{
+ if ("humanPresentableName".equals(paramName))
+ return getHumanPresentableName();
+
return getParameter(paramName, mimeType);
}
@@ -500,21 +502,28 @@ setHumanPresentableName(String humanPresentableName)
/**
* Tests the MIME type of this object for equality against the specified
- * MIME type.
+ * MIME type. Ignores parameters.
*
* @param mimeType The MIME type to test against.
*
* @return <code>true</code> if the MIME type is equal to this object's
- * MIME type, <code>false</code> otherwise.
+ * MIME type (ignoring parameters), <code>false</code> otherwise.
*
* @exception NullPointerException If mimeType is null.
*/
public boolean
isMimeTypeEqual(String mimeType)
{
- // FIXME: Need to handle default attributes and parameters
+ String mime = getMimeType();
+ int i = mime.indexOf(";");
+ if (i != -1)
+ mime = mime.substring(0, i);
+
+ i = mimeType.indexOf(";");
+ if (i != -1)
+ mimeType = mimeType.substring(0, i);
- return(this.mimeType.equals(mimeType));
+ return mime.equals(mimeType);
}
/*************************************************************************/
@@ -599,8 +608,7 @@ isRepresentationClassSerializable()
public boolean
isRepresentationClassRemote()
{
- // FIXME: Implement
- throw new RuntimeException("Not implemented");
+ return Remote.class.isAssignableFrom (representationClass);
}
/*************************************************************************/
@@ -852,12 +860,11 @@ readExternal(ObjectInput stream) throws IOException, ClassNotFoundException
public String
toString()
{
- return("DataFlavor[representationClass="
- + representationClass.getName()
- + ",mimeType="
- + mimeType
- + "humanPresentableName="
- + humanPresentableName);
+ return(getClass().getName()
+ + "[representationClass=" + getRepresentationClass().getName()
+ + ",mimeType=" + getMimeType()
+ + ",humanPresentableName=" + getHumanPresentableName()
+ + "]");
}
/*************************************************************************/
diff --git a/libjava/classpath/java/awt/event/MouseWheelEvent.java b/libjava/classpath/java/awt/event/MouseWheelEvent.java
index bc603aa..d1d22d2 100644
--- a/libjava/classpath/java/awt/event/MouseWheelEvent.java
+++ b/libjava/classpath/java/awt/event/MouseWheelEvent.java
@@ -49,7 +49,7 @@ import javax.swing.Scrollable;
/**
* This event is generated for a mouse wheel rotation. The wheel (the middle
* mouse button on most modern mice) can be rotated towards or away from the
- * user, and is ofteh used for scrolling.
+ * user, and is often used for scrolling.
*
* <p>Because of the special use for scrolling components, MouseWheelEvents
* often affect a different component than the one located at the point of
diff --git a/libjava/classpath/java/awt/image/AreaAveragingScaleFilter.java b/libjava/classpath/java/awt/image/AreaAveragingScaleFilter.java
index b9ca1b7..194d483 100644
--- a/libjava/classpath/java/awt/image/AreaAveragingScaleFilter.java
+++ b/libjava/classpath/java/awt/image/AreaAveragingScaleFilter.java
@@ -80,6 +80,7 @@ public class AreaAveragingScaleFilter extends ReplicateScaleFilter
*/
public void setHints(int flags)
{
+ if (consumer != null)
consumer.setHints(flags);
}
@@ -100,6 +101,7 @@ public class AreaAveragingScaleFilter extends ReplicateScaleFilter
public void setPixels(int x, int y, int w, int h,
ColorModel model, byte[] pixels, int offset, int scansize)
{
+ if (consumer != null)
consumer.setPixels(x, y, w, h, model, pixels, offset, scansize);
}
@@ -120,6 +122,7 @@ public class AreaAveragingScaleFilter extends ReplicateScaleFilter
public void setPixels(int x, int y, int w, int h,
ColorModel model, int[] pixels, int offset, int scansize)
{
+ if (consumer != null)
consumer.setPixels(x, y, w, h, model, pixels, offset, scansize);
}
diff --git a/libjava/classpath/java/awt/image/ConvolveOp.java b/libjava/classpath/java/awt/image/ConvolveOp.java
index f841c13..49ca2a6 100644
--- a/libjava/classpath/java/awt/image/ConvolveOp.java
+++ b/libjava/classpath/java/awt/image/ConvolveOp.java
@@ -1,5 +1,5 @@
/* ConvolveOp.java --
- Copyright (C) 2004 Free Software Foundation -- ConvolveOp
+ Copyright (C) 2004, 2005 Free Software Foundation -- ConvolveOp
This file is part of GNU Classpath.
@@ -177,11 +177,13 @@ public class ConvolveOp implements BufferedImageOp, RasterOp
}
/**
+ * Returns (a clone of) the convolution kernel.
+ *
* @return The convolution kernel.
*/
public Kernel getKernel()
{
- return kernel;
+ return (Kernel) kernel.clone();
}
/* (non-Javadoc)
@@ -189,8 +191,6 @@ public class ConvolveOp implements BufferedImageOp, RasterOp
* java.awt.image.WritableRaster)
*/
public WritableRaster filter(Raster src, WritableRaster dest) {
- if (src.numBands != dest.numBands)
- throw new ImagingOpException(null);
if (src == dest)
throw new IllegalArgumentException();
if (src.getWidth() < kernel.getWidth() ||
@@ -199,6 +199,8 @@ public class ConvolveOp implements BufferedImageOp, RasterOp
if (dest == null)
dest = createCompatibleDestRaster(src);
+ else if (src.numBands != dest.numBands)
+ throw new ImagingOpException(null);
// Deal with bottom edge
if (edge == EDGE_ZERO_FILL)
diff --git a/libjava/classpath/java/awt/image/CropImageFilter.java b/libjava/classpath/java/awt/image/CropImageFilter.java
index 490f43c..4fcfdec 100644
--- a/libjava/classpath/java/awt/image/CropImageFilter.java
+++ b/libjava/classpath/java/awt/image/CropImageFilter.java
@@ -79,6 +79,7 @@ public class CropImageFilter extends ImageFilter
*/
public void setDimensions(int width, int height)
{
+ if (consumer != null)
consumer.setDimensions(this.width, this.height);
}
@@ -93,7 +94,8 @@ public class CropImageFilter extends ImageFilter
public void setProperties(Hashtable props)
{
props.put("filters", "CropImageFilter");
- consumer.setProperties(props);
+ if (consumer != null)
+ consumer.setProperties(props);
}
/**
@@ -130,9 +132,10 @@ public class CropImageFilter extends ImageFilter
cropped[i * bounds.width + j] = pixels[start + bounds.x + j];
}
- consumer.setPixels(bounds.x, bounds.y,
- bounds.width, bounds.height,
- model, cropped, 0, bounds.width);
+ if (consumer != null)
+ consumer.setPixels(0, 0,
+ bounds.width, bounds.height,
+ model, cropped, 0, bounds.width);
}
}
@@ -170,9 +173,10 @@ public class CropImageFilter extends ImageFilter
cropped[i * bounds.width + j] = pixels[start + bounds.x + j];
}
- consumer.setPixels(bounds.x, bounds.y,
- bounds.width, bounds.height,
- model, cropped, 0, bounds.width);
+ if (consumer != null)
+ consumer.setPixels(0, 0,
+ bounds.width, bounds.height,
+ model, cropped, 0, bounds.width);
}
}
diff --git a/libjava/classpath/java/awt/image/DirectColorModel.java b/libjava/classpath/java/awt/image/DirectColorModel.java
index c98c3f8..4f37151 100644
--- a/libjava/classpath/java/awt/image/DirectColorModel.java
+++ b/libjava/classpath/java/awt/image/DirectColorModel.java
@@ -348,9 +348,24 @@ public class DirectColorModel extends PackedColorModel
{
return getComponents(getPixelFromArray(pixel), components, offset);
}
-
+
+ /**
+ * Creates a <code>WriteableRaster</code> that has a <code>SampleModel</code>
+ * that is compatible with this <code>ColorModel</code>.
+ *
+ * @param w the width of the writeable raster to create
+ * @param h the height of the writeable raster to create
+ *
+ * @throws IllegalArgumentException if <code>w</code> or <code>h</code>
+ * is less than or equal to zero
+ */
public final WritableRaster createCompatibleWritableRaster(int w, int h)
{
+ // Sun also makes this check here.
+ if(w <= 0 || h <= 0)
+ throw new IllegalArgumentException("width (=" + w + ") and height (="
+ + h + ") must be > 0");
+
SampleModel sm = createCompatibleSampleModel(w, h);
Point origin = new Point(0, 0);
return Raster.createWritableRaster(sm, origin);
@@ -418,3 +433,4 @@ public class DirectColorModel extends PackedColorModel
return super.toString();
}
}
+
diff --git a/libjava/classpath/java/awt/image/ImageFilter.java b/libjava/classpath/java/awt/image/ImageFilter.java
index 9940a2b..c39c4a4 100644
--- a/libjava/classpath/java/awt/image/ImageFilter.java
+++ b/libjava/classpath/java/awt/image/ImageFilter.java
@@ -125,6 +125,7 @@ public class ImageFilter implements ImageConsumer, Cloneable
*/
public void setDimensions(int width, int height)
{
+ if (consumer != null)
consumer.setDimensions(width, height);
}
@@ -137,7 +138,8 @@ public class ImageFilter implements ImageConsumer, Cloneable
public void setProperties(Hashtable props)
{
props.put("filters", "ImageFilter");
- consumer.setProperties(props);
+ if (consumer != null)
+ consumer.setProperties(props);
}
/**
@@ -149,6 +151,7 @@ public class ImageFilter implements ImageConsumer, Cloneable
* @see ColorModel */
public void setColorModel(ColorModel model)
{
+ if (consumer != null)
consumer.setColorModel(model);
}
@@ -164,6 +167,7 @@ public class ImageFilter implements ImageConsumer, Cloneable
*/
public void setHints(int flags)
{
+ if (consumer != null)
consumer.setHints(flags);
}
@@ -184,6 +188,7 @@ public class ImageFilter implements ImageConsumer, Cloneable
public void setPixels(int x, int y, int w, int h,
ColorModel model, byte[] pixels, int offset, int scansize)
{
+ if (consumer != null)
consumer.setPixels(x, y, w, h, model, pixels, offset, scansize);
}
@@ -204,6 +209,7 @@ public class ImageFilter implements ImageConsumer, Cloneable
public void setPixels(int x, int y, int w, int h,
ColorModel model, int[] pixels, int offset, int scansize)
{
+ if (consumer != null)
consumer.setPixels(x, y, w, h, model, pixels, offset, scansize);
}
@@ -215,6 +221,7 @@ public class ImageFilter implements ImageConsumer, Cloneable
*/
public void imageComplete(int status)
{
+ if (consumer != null)
consumer.imageComplete(status);
}
}
diff --git a/libjava/classpath/java/awt/image/PixelGrabber.java b/libjava/classpath/java/awt/image/PixelGrabber.java
index b576dbf..b8ca70c 100644
--- a/libjava/classpath/java/awt/image/PixelGrabber.java
+++ b/libjava/classpath/java/awt/image/PixelGrabber.java
@@ -131,6 +131,9 @@ public class PixelGrabber implements ImageConsumer
public PixelGrabber(ImageProducer ip, int x, int y, int w, int h,
int pix[], int off, int scansize)
{
+ if (ip == null)
+ throw new NullPointerException("The ImageProducer must not be null.");
+
this.ip = ip;
this.x = x;
this.y = y;
@@ -179,6 +182,10 @@ public class PixelGrabber implements ImageConsumer
boolean forceRGB)
{
this.ip = img.getSource();
+
+ if (this.ip == null)
+ throw new NullPointerException("The ImageProducer must not be null.");
+
this.x = x;
this.y = y;
width = w;
@@ -209,7 +216,15 @@ public class PixelGrabber implements ImageConsumer
{
public void run ()
{
- ip.startProduction (PixelGrabber.this);
+ try
+ {
+ ip.startProduction (PixelGrabber.this);
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ imageComplete(ImageConsumer.IMAGEABORTED);
+ }
}
};
grabberThread.start ();
@@ -601,7 +616,8 @@ public class PixelGrabber implements ImageConsumer
consumerStatus = status;
setObserverStatus ();
grabbing = false;
- ip.removeConsumer (this);
+ if (ip != null)
+ ip.removeConsumer (this);
notifyAll ();
}
diff --git a/libjava/classpath/java/awt/image/RGBImageFilter.java b/libjava/classpath/java/awt/image/RGBImageFilter.java
index f7b39b9..ecfed06 100644
--- a/libjava/classpath/java/awt/image/RGBImageFilter.java
+++ b/libjava/classpath/java/awt/image/RGBImageFilter.java
@@ -79,10 +79,12 @@ public abstract class RGBImageFilter extends ImageFilter
if( ( model instanceof IndexColorModel) && canFilterIndexColorModel ) {
newmodel = filterIndexColorModel( (IndexColorModel) model );
- consumer.setColorModel(newmodel);
+ if (consumer != null)
+ consumer.setColorModel(newmodel);
}
else {
- consumer.setColorModel(ColorModel.getRGBdefault());
+ if (consumer != null)
+ consumer.setColorModel(ColorModel.getRGBdefault());
}
}
@@ -178,6 +180,7 @@ public abstract class RGBImageFilter extends ImageFilter
{
if(model == origmodel && (model instanceof IndexColorModel) && canFilterIndexColorModel)
{
+ if (consumer != null)
consumer.setPixels(x, y, w, h, newmodel, pixels, offset, scansize);
}
else
@@ -185,7 +188,8 @@ public abstract class RGBImageFilter extends ImageFilter
int intPixels[] =
convertColorModelToDefault( x, y, w, h, model, pixels, offset, scansize );
filterRGBPixels( x, y, w, h, intPixels, offset, scansize );
- consumer.setPixels(x, y, w, h, ColorModel.getRGBdefault(), intPixels, offset, scansize);
+ if (consumer != null)
+ consumer.setPixels(x, y, w, h, ColorModel.getRGBdefault(), intPixels, offset, scansize);
}
}
@@ -209,6 +213,7 @@ public abstract class RGBImageFilter extends ImageFilter
{
if(model == origmodel && (model instanceof IndexColorModel) && canFilterIndexColorModel)
{
+ if (consumer != null)
consumer.setPixels(x, y, w, h, newmodel, pixels, offset, scansize);
}
else
@@ -216,7 +221,8 @@ public abstract class RGBImageFilter extends ImageFilter
//FIXME: Store the filtered pixels in a separate temporary buffer?
convertColorModelToDefault( x, y, w, h, model, pixels, offset, scansize );
filterRGBPixels( x, y, w, h, pixels, offset, scansize );
- consumer.setPixels(x, y, w, h, ColorModel.getRGBdefault(), pixels, offset, scansize);
+ if (consumer != null)
+ consumer.setPixels(x, y, w, h, ColorModel.getRGBdefault(), pixels, offset, scansize);
}
}
diff --git a/libjava/classpath/java/awt/image/ReplicateScaleFilter.java b/libjava/classpath/java/awt/image/ReplicateScaleFilter.java
index 3841e49..d76f9db 100644
--- a/libjava/classpath/java/awt/image/ReplicateScaleFilter.java
+++ b/libjava/classpath/java/awt/image/ReplicateScaleFilter.java
@@ -124,7 +124,8 @@ public class ReplicateScaleFilter extends ImageFilter
destHeight = (int) (height * ((double) destWidth / srcWidth));
}
- consumer.setDimensions(destWidth, destHeight);
+ if (consumer != null)
+ consumer.setDimensions(destWidth, destHeight);
}
/**
@@ -136,7 +137,8 @@ public class ReplicateScaleFilter extends ImageFilter
public void setProperties(Hashtable props)
{
props.put("filters", "ReplicateScaleFilter");
- consumer.setProperties(props);
+ if (consumer != null)
+ consumer.setProperties(props);
}
/**
@@ -165,9 +167,10 @@ public class ReplicateScaleFilter extends ImageFilter
model, pixels, offset, scansize,
rx, ry, destScansize);
- consumer.setPixels((int) Math.floor(x/rx), (int) Math.floor(y/ry),
- (int) Math.ceil(w/rx), (int) Math.ceil(h/ry),
- model, destPixels, 0, destScansize);
+ if (consumer != null)
+ consumer.setPixels((int) Math.floor(x/rx), (int) Math.floor(y/ry),
+ (int) Math.ceil(w/rx), (int) Math.ceil(h/ry),
+ model, destPixels, 0, destScansize);
}
/**
@@ -196,9 +199,10 @@ public class ReplicateScaleFilter extends ImageFilter
model, pixels, offset, scansize,
rx, ry, destScansize);
- consumer.setPixels((int) Math.floor(x/rx), (int) Math.floor(y/ry),
- (int) Math.ceil(w/rx), (int) Math.ceil(h/ry),
- model, destPixels, 0, destScansize);
+ if (consumer != null)
+ consumer.setPixels((int) Math.floor(x/rx), (int) Math.floor(y/ry),
+ (int) Math.ceil(w/rx), (int) Math.ceil(h/ry),
+ model, destPixels, 0, destScansize);
}
private byte[] replicatePixels(int srcx, int srcy, int srcw, int srch,
diff --git a/libjava/classpath/java/awt/peer/ComponentPeer.java b/libjava/classpath/java/awt/peer/ComponentPeer.java
index 7ed8f60..1ba1692 100644
--- a/libjava/classpath/java/awt/peer/ComponentPeer.java
+++ b/libjava/classpath/java/awt/peer/ComponentPeer.java
@@ -51,6 +51,7 @@ import java.awt.Graphics;
import java.awt.GraphicsConfiguration;
import java.awt.Image;
import java.awt.Point;
+import java.awt.Rectangle;
import java.awt.Toolkit;
import java.awt.event.PaintEvent;
import java.awt.image.ColorModel;
@@ -184,4 +185,48 @@ public interface ComponentPeer
* @since 1.2
*/
void destroyBuffers();
+
+ /**
+ * Get the bounds of this component peer.
+ *
+ * @return component peer bounds
+ * @since 1.5
+ */
+ Rectangle getBounds();
+
+ /**
+ * Reparent this component under another container.
+ *
+ * @param parent
+ * @since 1.5
+ */
+ void reparent(ContainerPeer parent);
+
+ /**
+ * Set the bounds of this component peer.
+ *
+ * @param x the new x co-ordinate
+ * @param y the new y co-ordinate
+ * @param width the new width
+ * @param height the new height
+ * @param z the new stacking level
+ * @since 1.5
+ */
+ void setBounds (int x, int y, int width, int height, int z);
+
+ /**
+ * Check if this component supports being reparented.
+ *
+ * @return true if this component can be reparented,
+ * false otherwise.
+ * @since 1.5
+ */
+ boolean isReparentSupported();
+
+ /**
+ * Layout this component peer.
+ *
+ * @since 1.5
+ */
+ void layout();
}
diff --git a/libjava/classpath/java/awt/peer/ContainerPeer.java b/libjava/classpath/java/awt/peer/ContainerPeer.java
index f1373a1..76673a1 100644
--- a/libjava/classpath/java/awt/peer/ContainerPeer.java
+++ b/libjava/classpath/java/awt/peer/ContainerPeer.java
@@ -54,6 +54,31 @@ public interface ContainerPeer extends ComponentPeer
void endLayout();
boolean isPaintPending();
-
+
+ /**
+ * Check if this container peer can be restacked.
+ *
+ * @return true if this container peer supports being restacked, false otherwise
+ * @since 1.5
+ */
+ boolean isRestackSupported();
+
+ /**
+ * Cancel a pending paint event on a region of this container.
+ *
+ * @param x the x co-ordinate of the region
+ * @param y the y co-ordinate of the region
+ * @param width the width of the region
+ * @param height the height of the region
+ * @since 1.5
+ */
+ void cancelPendingPaint(int x, int y, int width, int height);
+
+ /**
+ * Restack the component peers in this container peer.
+ *
+ * @since 1.5
+ */
+ void restack();
} // interface ContainerPeer
diff --git a/libjava/classpath/java/awt/peer/FramePeer.java b/libjava/classpath/java/awt/peer/FramePeer.java
index 13498ff..13435f8 100644
--- a/libjava/classpath/java/awt/peer/FramePeer.java
+++ b/libjava/classpath/java/awt/peer/FramePeer.java
@@ -51,5 +51,25 @@ public interface FramePeer extends WindowPeer
int getState();
void setState(int state);
void setMaximizedBounds(Rectangle r);
+
+ /**
+ * Check if this frame peer supports being restacked.
+ *
+ * @return true if this frame peer can be restacked,
+ * false otherwise
+ * @since 1.5
+ */
+ boolean isRestackSupported();
+
+ /**
+ * Sets the bounds of this frame peer.
+ *
+ * @param x the new x co-ordinate
+ * @param y the new y co-ordinate
+ * @param width the new width
+ * @param height the new height
+ * @since 1.5
+ */
+ void setBoundsPrivate(int x, int y, int width, int height);
} // interface FramePeer
diff --git a/libjava/classpath/java/awt/peer/MenuBarPeer.java b/libjava/classpath/java/awt/peer/MenuBarPeer.java
index c5f7c58..44e37e2 100644
--- a/libjava/classpath/java/awt/peer/MenuBarPeer.java
+++ b/libjava/classpath/java/awt/peer/MenuBarPeer.java
@@ -42,6 +42,7 @@ import java.awt.Menu;
public interface MenuBarPeer extends MenuComponentPeer
{
+ void addMenu(Menu m);
void addHelpMenu(Menu menu);
void delMenu(int index);
} // interface MenuBarPeer
diff --git a/libjava/classpath/java/awt/peer/MenuComponentPeer.java b/libjava/classpath/java/awt/peer/MenuComponentPeer.java
index 1b10ca1..bfd3414 100644
--- a/libjava/classpath/java/awt/peer/MenuComponentPeer.java
+++ b/libjava/classpath/java/awt/peer/MenuComponentPeer.java
@@ -38,8 +38,18 @@ exception statement from your version. */
package java.awt.peer;
+import java.awt.Font;
+
public interface MenuComponentPeer
{
void dispose();
+
+ /**
+ * Set the font on this menu component peer.
+ *
+ * @param font the new font
+ * @since 1.5
+ */
+ void setFont (Font font);
} // interface MenuComponentPeer
diff --git a/libjava/classpath/java/awt/peer/MenuPeer.java b/libjava/classpath/java/awt/peer/MenuPeer.java
index c51ea73..91d0f0d 100644
--- a/libjava/classpath/java/awt/peer/MenuPeer.java
+++ b/libjava/classpath/java/awt/peer/MenuPeer.java
@@ -43,6 +43,7 @@ import java.awt.MenuItem;
public interface MenuPeer extends MenuItemPeer
{
void addItem (MenuItem item);
+ void addSeparator ();
void delItem (int index);
}
diff --git a/libjava/classpath/java/awt/peer/TextComponentPeer.java b/libjava/classpath/java/awt/peer/TextComponentPeer.java
index cacc7d8..f807299 100644
--- a/libjava/classpath/java/awt/peer/TextComponentPeer.java
+++ b/libjava/classpath/java/awt/peer/TextComponentPeer.java
@@ -39,6 +39,7 @@ exception statement from your version. */
package java.awt.peer;
import java.awt.Rectangle;
+import java.awt.im.InputMethodRequests;
public interface TextComponentPeer extends ComponentPeer
{
@@ -53,5 +54,13 @@ public interface TextComponentPeer extends ComponentPeer
int getIndexAtPoint(int x, int y);
Rectangle getCharacterBounds(int pos);
long filterEvents(long filter);
+
+ /**
+ * Retrieve this text component peer's input method requests.
+ *
+ * @return the input method requests made by this text component peer
+ * @since 1.5
+ */
+ InputMethodRequests getInputMethodRequests();
} // interface TextComponentPeer
diff --git a/libjava/classpath/java/awt/peer/WindowPeer.java b/libjava/classpath/java/awt/peer/WindowPeer.java
index 8f136dd..6c014de 100644
--- a/libjava/classpath/java/awt/peer/WindowPeer.java
+++ b/libjava/classpath/java/awt/peer/WindowPeer.java
@@ -42,5 +42,19 @@ public interface WindowPeer extends ContainerPeer
{
void toBack();
void toFront();
+
+ /**
+ * FIXME: unknown.
+ * @since 1.5
+ */
+ void updateAlwaysOnTop();
+
+ /**
+ * Request that this window peer be given the window focus.
+ *
+ * @return true if the window received focus, false otherwise
+ * @since 1.5
+ */
+ boolean requestWindowFocus();
} // interface WindowPeer
diff --git a/libjava/classpath/java/beans/Expression.java b/libjava/classpath/java/beans/Expression.java
index 20b04f1..d92cb72 100644
--- a/libjava/classpath/java/beans/Expression.java
+++ b/libjava/classpath/java/beans/Expression.java
@@ -1,5 +1,5 @@
/* java.beans.Expression
- Copyright (C) 2004 Free Software Foundation, Inc.
+ Copyright (C) 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -51,7 +51,7 @@ public class Expression extends Statement
{
// This is a placeholder to indicate that value hasn't been set
// yet;
- private static final Object unset = new Object();
+ private static final Object UNSET = new Object();
// The value to return. This is equal to unset until getValue is called.
private Object value;
@@ -89,7 +89,7 @@ public class Expression extends Statement
public Expression(Object target, String methodName, Object[] arguments)
{
super(target, methodName, arguments);
- this.value = unset;
+ this.value = UNSET;
}
/**
@@ -105,7 +105,7 @@ public class Expression extends Statement
*/
public Object getValue() throws Exception
{
- if (value == unset)
+ if (value == UNSET)
value = doExecute();
return value;
}
@@ -126,7 +126,7 @@ public class Expression extends Statement
public String toString()
{
String result = super.toString();
- if (value != unset)
+ if (value != UNSET)
return value.getClass().getName() + " " + result;
return result;
}
diff --git a/libjava/classpath/java/beans/Statement.java b/libjava/classpath/java/beans/Statement.java
index 01f86dd..8e916a2 100644
--- a/libjava/classpath/java/beans/Statement.java
+++ b/libjava/classpath/java/beans/Statement.java
@@ -1,5 +1,5 @@
/* java.beans.Statement
- Copyright (C) 2004 Free Software Foundation, Inc.
+ Copyright (C) 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -42,6 +42,9 @@ import java.lang.reflect.Array;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.WeakHashMap;
+
/**
* class Statement
*
@@ -54,6 +57,11 @@ import java.lang.reflect.Method;
*/
public class Statement
{
+ /** Nested map for the relation between a class, its instances and their
+ * names.
+ */
+ private static HashMap classMaps = new HashMap();
+
private Object target;
private String methodName;
private Object[] arguments;
@@ -64,8 +72,11 @@ public class Statement
private transient Constructor ctor;
/**
- * Constructs a statement representing the invocation of
- * object.methodName(arg[0], arg[1], ...);
+ * <p>Constructs a statement representing the invocation of
+ * object.methodName(arg[0], arg[1], ...);</p>
+ *
+ * <p>If the argument array is null it is replaced with an
+ * array of zero length.</p>
*
* @param target The object to invoke the method on.
* @param methodName The object method to invoke.
@@ -75,7 +86,41 @@ public class Statement
{
this.target = target;
this.methodName = methodName;
- this.arguments = arguments;
+ this.arguments = (arguments != null) ? arguments : new Object[0];
+ storeTargetName(target);
+ }
+
+ /** Creates a name for the target instance or does nothing if the object's
+ * name is already known. This makes sure that there *is* a name for every
+ * target instance.
+ */
+ private static synchronized void storeTargetName(Object obj)
+ {
+ Class klass = obj.getClass();
+ WeakHashMap names = (WeakHashMap) classMaps.get(klass);
+
+ if ( names == null )
+ {
+ names = new WeakHashMap();
+
+ names.put(obj,
+ ( klass == String.class ? ("\"" + obj + "\"") :
+ (klass.getName() + names.size()) ));
+
+ classMaps.put(klass, names);
+
+ return;
+ }
+
+ String targetName = (String) names.get(obj);
+ if ( targetName == null )
+ {
+ names.put(obj,
+ ( klass == String.class ? ("\"" + obj + "\"") :
+ (klass.getName() + names.size()) ));
+ }
+
+ // Nothing to do. The given object was already stored.
}
/**
@@ -234,15 +279,7 @@ public class Statement
{
// Skip methods with wrong number of args.
Class ptypes[] = ctors[i].getParameterTypes();
- System.out.println("ptypeslen = " + ptypes.length);
- System.out.println("ptypes = " + ptypes);
- System.out.println("ctor = " + ctors[i].getName());
- for (int j=0; j < ptypes.length; j++) {
- System.out.println("param = " + ptypes[i].getName());
-
- }
-
-
+
if (ptypes.length != args.length)
continue;
@@ -313,14 +350,24 @@ public class Statement
/** Return a string representation. */
public String toString()
{
- String result = target.getClass().getName() + "." + methodName + "(";
+ StringBuffer result = new StringBuffer();
+
+ Class klass = target.getClass();
+
+ result.append( ((WeakHashMap) classMaps.get(klass)).get(target));
+ result.append(".");
+ result.append(methodName);
+ result.append("(");
+
String sep = "";
for (int i = 0; i < arguments.length; i++)
{
- result = result + sep + arguments[i].getClass().getName();
- sep = ", ";
+ result.append(sep);
+ result.append(arguments[i].getClass().getName());
+ sep = ", ";
}
- result = result + ")";
- return result;
+ result.append(")");
+
+ return result.toString();
}
}
diff --git a/libjava/classpath/java/io/ObjectInputStream.java b/libjava/classpath/java/io/ObjectInputStream.java
index 05776a7..54d5eea 100644
--- a/libjava/classpath/java/io/ObjectInputStream.java
+++ b/libjava/classpath/java/io/ObjectInputStream.java
@@ -501,8 +501,7 @@ public class ObjectInputStream extends InputStream
flags, fields);
assignNewHandle(osc);
- if (callersClassLoader == null)
- callersClassLoader = currentLoader();
+ ClassLoader callersClassLoader = currentLoader();
for (int i = 0; i < field_count; i++)
{
@@ -528,36 +527,7 @@ public class ObjectInputStream extends InputStream
/* Now that fields have been read we may resolve the class
* (and read annotation if needed). */
- Class clazz;
- try
- {
- clazz = resolveClass(osc);
- }
- catch (ClassNotFoundException cnfe)
- {
- // Maybe it was an primitive class?
- if (name.equals("void"))
- clazz = Void.TYPE;
- else if (name.equals("boolean"))
- clazz = Boolean.TYPE;
- else if (name.equals("byte"))
- clazz = Byte.TYPE;
- else if (name.equals("short"))
- clazz = Short.TYPE;
- else if (name.equals("char"))
- clazz = Character.TYPE;
- else if (name.equals("int"))
- clazz = Integer.TYPE;
- else if (name.equals("long"))
- clazz = Long.TYPE;
- else if (name.equals("float"))
- clazz = Float.TYPE;
- else if (name.equals("double"))
- clazz = Double.TYPE;
- else
- throw cnfe;
- }
-
+ Class clazz = resolveClass(osc);
boolean oldmode = setBlockDataMode(true);
osc.setClass(clazz, lookupClass(clazz.getSuperclass()));
classLookupTable.put(clazz, osc);
@@ -770,16 +740,34 @@ public class ObjectInputStream extends InputStream
protected Class resolveClass(ObjectStreamClass osc)
throws ClassNotFoundException, IOException
{
- if (callersClassLoader == null)
+ String name = osc.getName();
+ try
{
- callersClassLoader = currentLoader ();
- if (DEBUG && dump)
- {
- dumpElementln ("CallersClassLoader = " + callersClassLoader);
- }
+ return Class.forName(name, true, currentLoader());
+ }
+ catch(ClassNotFoundException x)
+ {
+ if (name.equals("void"))
+ return Void.TYPE;
+ else if (name.equals("boolean"))
+ return Boolean.TYPE;
+ else if (name.equals("byte"))
+ return Byte.TYPE;
+ else if (name.equals("char"))
+ return Character.TYPE;
+ else if (name.equals("short"))
+ return Short.TYPE;
+ else if (name.equals("int"))
+ return Integer.TYPE;
+ else if (name.equals("long"))
+ return Long.TYPE;
+ else if (name.equals("float"))
+ return Float.TYPE;
+ else if (name.equals("double"))
+ return Double.TYPE;
+ else
+ throw x;
}
-
- return Class.forName(osc.getName(), true, callersClassLoader);
}
/**
@@ -957,19 +945,13 @@ public class ObjectInputStream extends InputStream
{
if (this.readDataFromBlock)
{
- if (this.blockDataPosition + length > this.blockDataBytes)
- {
- int remain = this.blockDataBytes - this.blockDataPosition;
- if (remain != 0)
- {
- System.arraycopy(this.blockData, this.blockDataPosition,
- data, offset, remain);
- offset += remain;
- length -= remain;
- }
- readNextBlock ();
- }
-
+ int remain = this.blockDataBytes - this.blockDataPosition;
+ if (remain == 0)
+ {
+ readNextBlock();
+ remain = this.blockDataBytes - this.blockDataPosition;
+ }
+ length = Math.min(length, remain);
System.arraycopy(this.blockData, this.blockDataPosition,
data, offset, length);
this.blockDataPosition += length;
@@ -1281,7 +1263,7 @@ public class ObjectInputStream extends InputStream
}
catch (NoSuchFieldException e)
{
- throw new IllegalArgumentException(e.getMessage());
+ throw new IllegalArgumentException(e);
}
}
@@ -1426,6 +1408,7 @@ public class ObjectInputStream extends InputStream
ObjectStreamField field = clazz.getField(name);
boolean illegal = false;
+ // XXX This code is horrible and needs to be rewritten!
try
{
try
@@ -1485,7 +1468,7 @@ public class ObjectInputStream extends InputStream
catch (NoSuchFieldException e)
{
if (field == null)
- throw new IllegalArgumentException(e.getMessage());
+ throw new IllegalArgumentException(e);
}
}
@@ -1829,8 +1812,8 @@ public class ObjectInputStream extends InputStream
}
catch (InstantiationException e)
{
- throw new ClassNotFoundException
- ("Instance of " + real_class + " could not be created");
+ throw (ClassNotFoundException) new ClassNotFoundException
+ ("Instance of " + real_class + " could not be created").initCause(e);
}
}
@@ -1871,13 +1854,13 @@ public class ObjectInputStream extends InputStream
if (exception instanceof ClassNotFoundException)
throw (ClassNotFoundException) exception;
- throw new IOException("Exception thrown from readObject() on " +
- klass + ": " + exception.getClass().getName());
+ throw (IOException) new IOException(
+ "Exception thrown from readObject() on " + klass).initCause(x);
}
catch (Exception x)
{
- throw new IOException("Failure invoking readObject() on " +
- klass + ": " + x.getClass().getName());
+ throw (IOException) new IOException(
+ "Failure invoking readObject() on " + klass).initCause(x);
}
// Invalidate fields which has been read through readFields.
@@ -1905,7 +1888,6 @@ public class ObjectInputStream extends InputStream
private Hashtable classLookupTable;
private GetField prereadFields;
- private ClassLoader callersClassLoader;
private static boolean dump;
// The nesting depth for debugging output
diff --git a/libjava/classpath/java/lang/Character.java b/libjava/classpath/java/lang/Character.java
index 4eac147..1e4f219 100644
--- a/libjava/classpath/java/lang/Character.java
+++ b/libjava/classpath/java/lang/Character.java
@@ -1457,6 +1457,57 @@ public final class Character implements Serializable, Comparable
private static final int MIRROR_MASK = 0x40;
/**
+ * Min value for supplementary code point.
+ *
+ * @since 1.5
+ */
+ public static final int MIN_SUPPLEMENTARY_CODE_POINT = 0x10000;
+
+ /**
+ * Min value for code point.
+ *
+ * @since 1.5
+ */
+ public static final int MIN_CODE_POINT = 0;
+
+
+ /**
+ * Max value for code point.
+ *
+ * @since 1.5
+ */
+ public static final int MAX_CODE_POINT = 0x010ffff;
+
+
+ /**
+ * Minimum high surrrogate code in UTF-16 encoding.
+ *
+ * @since 1.5
+ */
+ public static final char MIN_HIGH_SURROGATE = '\ud800';
+
+ /**
+ * Maximum high surrrogate code in UTF-16 encoding.
+ *
+ * @since 1.5
+ */
+ public static final char MAX_HIGH_SURROGATE = '\udbff';
+
+ /**
+ * Minimum low surrrogate code in UTF-16 encoding.
+ *
+ * @since 1.5
+ */
+ public static final char MIN_LOW_SURROGATE = '\udc00';
+
+ /**
+ * Maximum low surrrogate code in UTF-16 encoding.
+ *
+ * @since 1.5
+ */
+ public static final char MAX_LOW_SURROGATE = '\udfff';
+
+ /**
* Grabs an attribute offset from the Unicode attribute database. The lower
* 5 bits are the character type, the next 2 bits are flags, and the top
* 9 bits are the offset into the attribute tables.
@@ -2250,4 +2301,118 @@ public final class Character implements Serializable, Comparable
{
return compareTo((Character) o);
}
+
+ /**
+ * Converts a unicode code point to a UTF-16 representation of that
+ * code point.
+ *
+ * @param codePoint the unicode code point
+ *
+ * @return the UTF-16 representation of that code point
+ *
+ * @throws IllegalArgumentException if the code point is not a valid
+ * unicode code point
+ *
+ * @since 1.5
+ */
+ public static char[] toChars(int codePoint)
+ {
+ char[] result = new char[charCount(codePoint)];
+ int ignore = toChars(codePoint, result, 0);
+ return result;
+ }
+
+ /**
+ * Converts a unicode code point to its UTF-16 representation.
+ *
+ * @param codePoint the unicode code point
+ * @param dst the target char array
+ * @param dstIndex the start index for the target
+ *
+ * @return number of characters written to <code>dst</code>
+ *
+ * @throws IllegalArgumentException if <code>codePoint</code> is not a
+ * valid unicode code point
+ * @throws NullPointerException if <code>dst</code> is <code>null</code>
+ * @throws IndexOutOfBoundsException if <code>dstIndex</code> is not valid
+ * in <code>dst</code> or if the UTF-16 representation does not
+ * fit into <code>dst</code>
+ *
+ * @since 1.5
+ */
+ public static int toChars(int codePoint, char[] dst, int dstIndex)
+ {
+ if (!isValidCodePoint(codePoint))
+ {
+ throw new IllegalArgumentException("not a valid code point: "
+ + codePoint);
+ }
+
+ int result;
+ if (isSupplementaryCodePoint(codePoint))
+ {
+ // Write second char first to cause IndexOutOfBoundsException
+ // immediately.
+ dst[dstIndex + 1] = (char) ((codePoint & 0x3ff)
+ + (int) MIN_LOW_SURROGATE );
+ dst[dstIndex] = (char) ((codePoint >> 10) + (int) MIN_HIGH_SURROGATE);
+ result = 2;
+ }
+ else
+ {
+ dst[dstIndex] = (char) codePoint;
+ result = 1;
+ }
+ return result;
+ }
+
+ /**
+ * Return number of 16-bit characters required to represent the given
+ * code point.
+ *
+ * @param codePoint a uncode code point
+ *
+ * @return 2 if codePoint >= 0x10000, 1 otherwise.
+ *
+ * @since 1.5
+ */
+ public static int charCount(int codePoint)
+ {
+ return
+ (codePoint >= MIN_SUPPLEMENTARY_CODE_POINT)
+ ? 2
+ : 1;
+ }
+
+ /**
+ * Determines whether the specified code point is
+ * in the range 0x10000 .. 0x10FFFF, i.e. the character is within the Unicode
+ * supplementary character range.
+ *
+ * @param codePoint a Unicode code point
+ *
+ * @return <code>true</code> if code point is in supplementary range
+ *
+ * @since 1.5
+ */
+ public static boolean isSupplementaryCodePoint(int codePoint)
+ {
+ return codePoint >= MIN_SUPPLEMENTARY_CODE_POINT
+ && codePoint <= MAX_CODE_POINT;
+ }
+
+ /**
+ * Determines whether the specified code point is
+ * in the range 0x0000 .. 0x10FFFF, i.e. it is a valid Unicode code point.
+ *
+ * @param codePoint a Unicode code point
+ *
+ * @return <code>true</code> if code point is valid
+ *
+ * @since 1.5
+ */
+ public static boolean isValidCodePoint(int codePoint)
+ {
+ return codePoint >= MIN_CODE_POINT && codePoint <= MAX_CODE_POINT;
+ }
} // class Character
diff --git a/libjava/classpath/java/lang/Class.java b/libjava/classpath/java/lang/Class.java
index 6b8bc93..22f148e 100644
--- a/libjava/classpath/java/lang/Class.java
+++ b/libjava/classpath/java/lang/Class.java
@@ -156,11 +156,7 @@ public final class Class implements Serializable
*/
public static Class forName(String name) throws ClassNotFoundException
{
- Class result = VMClass.forName (name);
- if (result == null)
- result = Class.forName(name, true,
- VMStackWalker.getCallingClassLoader());
- return result;
+ return VMClass.forName(name, true, VMStackWalker.getCallingClassLoader());
}
/**
@@ -205,24 +201,8 @@ public final class Class implements Serializable
if (cl != null)
sm.checkPermission(new RuntimePermission("getClassLoader"));
}
- if (name.startsWith("["))
- return VMClass.loadArrayClass(name, null);
- Class c = VMClassLoader.loadClass(name, true);
- if (c != null)
- {
- if (initialize)
- VMClass.initialize(c);
- return c;
- }
- throw new ClassNotFoundException(name);
}
- if (name.startsWith("["))
- return VMClass.loadArrayClass(name, classloader);
- Class c = classloader.loadClass(name);
- classloader.resolveClass(c);
- if (initialize)
- VMClass.initialize(c);
- return c;
+ return VMClass.forName(name, initialize, classloader);
}
/**
diff --git a/libjava/classpath/java/lang/ClassLoader.java b/libjava/classpath/java/lang/ClassLoader.java
index b644511..0d50a6e 100644
--- a/libjava/classpath/java/lang/ClassLoader.java
+++ b/libjava/classpath/java/lang/ClassLoader.java
@@ -124,14 +124,6 @@ import java.util.StringTokenizer;
public abstract class ClassLoader
{
/**
- * All classes loaded by this classloader. VM's may choose to implement
- * this cache natively; but it is here available for use if necessary. It
- * is not private in order to allow native code (and trusted subclasses)
- * access to this field.
- */
- final HashMap loadedClasses = new HashMap();
-
- /**
* All packages defined by this classloader. It is not private in order to
* allow native code (and trusted subclasses) access to this field.
*/
@@ -472,15 +464,11 @@ public abstract class ClassLoader
ProtectionDomain domain)
throws ClassFormatError
{
+ checkInitialized();
if (domain == null)
domain = StaticData.defaultProtectionDomain;
- if (! initialized)
- throw new SecurityException("attempt to define class from uninitialized class loader");
- Class retval = VMClassLoader.defineClass(this, name, data,
- offset, len, domain);
- loadedClasses.put(retval.getName(), retval);
- return retval;
+ return VMClassLoader.defineClass(this, name, data, offset, len, domain);
}
/**
@@ -493,6 +481,7 @@ public abstract class ClassLoader
*/
protected final void resolveClass(Class c)
{
+ checkInitialized();
VMClassLoader.resolveClass(c);
}
@@ -508,6 +497,7 @@ public abstract class ClassLoader
protected final Class findSystemClass(String name)
throws ClassNotFoundException
{
+ checkInitialized();
return Class.forName(name, false, StaticData.systemClassLoader);
}
@@ -544,6 +534,7 @@ public abstract class ClassLoader
*/
protected final void setSigners(Class c, Object[] signers)
{
+ checkInitialized();
c.setSigners(signers);
}
@@ -556,9 +547,8 @@ public abstract class ClassLoader
*/
protected final synchronized Class findLoadedClass(String name)
{
- // NOTE: If the VM is keeping its own cache, it may make sense to have
- // this method be native.
- return (Class) loadedClasses.get(name);
+ checkInitialized();
+ return VMClassLoader.findLoadedClass(this, name);
}
/**
@@ -1113,4 +1103,16 @@ public abstract class ClassLoader
.initCause(e);
}
}
+
+ /**
+ * Before doing anything "dangerous" please call this method to make sure
+ * this class loader instance was properly constructed (and not obtained
+ * by exploiting the finalizer attack)
+ * @see #initialized
+ */
+ private void checkInitialized()
+ {
+ if (! initialized)
+ throw new SecurityException("attempt to use uninitialized class loader");
+ }
}
diff --git a/libjava/classpath/java/lang/IllegalArgumentException.java b/libjava/classpath/java/lang/IllegalArgumentException.java
index 7b822b9..75a0b8b 100644
--- a/libjava/classpath/java/lang/IllegalArgumentException.java
+++ b/libjava/classpath/java/lang/IllegalArgumentException.java
@@ -47,7 +47,8 @@ package java.lang;
*
* @author Brian Jones
* @author Warren Levy (warrenl@cygnus.com)
- * @status updated to 1.4
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
+ * @status updated to 1.5
*/
public class IllegalArgumentException extends RuntimeException
{
@@ -72,4 +73,57 @@ public class IllegalArgumentException extends RuntimeException
{
super(s);
}
+
+ /**
+ * <p>
+ * Constructs a <code>IllegalArgumentException</code> using
+ * the specified error message, which should give further details
+ * as to the reason for this exception. The specified cause
+ * <code>Throwable</code> may be used to provide additional history,
+ * with regards to the root of the problem. It is perfectly valid
+ * for this to be null, if the cause of the problem is unknown.
+ * </p>
+ * <p>
+ * <strong>Note</strong>: the detail message from the cause is not
+ * automatically incorporated into the resulting detail message of
+ * this exception.
+ * </p>
+ *
+ * @param message the detail message, which should give the reason for
+ * this exception being thrown.
+ * @param cause the cause of this exception, or null if the cause
+ * is unknown.
+ * @since 1.5
+ */
+ public IllegalArgumentException(String message, Throwable cause)
+ {
+ super(message, cause);
+ }
+
+ /**
+ * <p>
+ * Constructs a <code>IllegalArgumentException</code> using
+ * the specified cause <code>Throwable</code>, which may be used
+ * to provide additional history, with regards to the root of the
+ * problem. It is perfectly valid for this to be null, if the
+ * cause of the problem is unknown.
+ * </p>
+ * <p>
+ * The detail message is automatically constructed from the detail
+ * message of the supplied causal exception. If the cause is null,
+ * then the detail message will also be null. Otherwise, the detail
+ * message of this exception will be that of the causal exception.
+ * This makes this constructor very useful for simply wrapping another
+ * exception.
+ * </p>
+ *
+ * @param cause the cause of this exception, or null if the cause
+ * is unknown.
+ * @since 1.5
+ */
+ public IllegalArgumentException(Throwable cause)
+ {
+ super(cause);
+ }
+
}
diff --git a/libjava/classpath/java/lang/IllegalStateException.java b/libjava/classpath/java/lang/IllegalStateException.java
index 5c2bbad..6b4e5f8 100644
--- a/libjava/classpath/java/lang/IllegalStateException.java
+++ b/libjava/classpath/java/lang/IllegalStateException.java
@@ -51,8 +51,9 @@ package java.lang;
*
* @author Brian Jones
* @author Warren Levy (warrenl@cygnus.com)
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
* @since 1.1
- * @status updated to 1.4
+ * @status updated to 1.5
*/
public class IllegalStateException extends RuntimeException
{
@@ -77,4 +78,58 @@ public class IllegalStateException extends RuntimeException
{
super(s);
}
+
+ /**
+ * <p>
+ * Constructs a <code>IllegalStateException</code> using
+ * the specified error message, which should give further details
+ * as to the reason for this exception. The specified cause
+ * <code>Throwable</code> may be used to provide additional history,
+ * with regards to the root of the problem. It is perfectly valid
+ * for this to be null, if the cause of the problem is unknown.
+ * </p>
+ * <p>
+ * <strong>Note</strong>: the detail message from the cause is not
+ * automatically incorporated into the resulting detail message of
+ * this exception.
+ * </p>
+ *
+ * @param message the detail message, which should give the reason for
+ * this exception being thrown.
+ * @param cause the cause of this exception, or null if the cause
+ * is unknown.
+ * @since 1.5
+ */
+ public IllegalStateException(String message, Throwable cause)
+ {
+ super(message, cause);
+ }
+
+ /**
+ * <p>
+ * Constructs a <code>IllegalStateException</code> using
+ * the specified cause <code>Throwable</code>, which may be used
+ * to provide additional history, with regards to the root of the
+ * problem. It is perfectly valid for this to be null, if the
+ * cause of the problem is unknown.
+ * </p>
+ * <p>
+ * The detail message is automatically constructed from the detail
+ * message of the supplied causal exception. If the cause is null,
+ * then the detail message will also be null. Otherwise, the detail
+ * message of this exception will be that of the causal exception.
+ * This makes this constructor very useful for simply wrapping another
+ * exception.
+ * </p>
+ *
+ * @param cause the cause of this exception, or null if the cause
+ * is unknown.
+ * @since 1.5
+ */
+ public IllegalStateException(Throwable cause)
+ {
+ super(cause);
+ }
+
}
+
diff --git a/libjava/classpath/java/lang/Integer.java b/libjava/classpath/java/lang/Integer.java
index 07be4e3..53de9ab 100644
--- a/libjava/classpath/java/lang/Integer.java
+++ b/libjava/classpath/java/lang/Integer.java
@@ -718,12 +718,12 @@ public final class Integer extends Number implements Comparable
int len = str.length();
boolean isNeg = false;
if (len == 0)
- throw new NumberFormatException();
+ throw new NumberFormatException("string length is null");
int ch = str.charAt(index);
if (ch == '-')
{
if (len == 1)
- throw new NumberFormatException();
+ throw new NumberFormatException("pure '-'");
isNeg = true;
ch = str.charAt(++index);
}
@@ -748,7 +748,7 @@ public final class Integer extends Number implements Comparable
}
}
if (index == len)
- throw new NumberFormatException();
+ throw new NumberFormatException("non terminated number: " + str);
int max = MAX_VALUE / radix;
// We can't directly write `max = (MAX_VALUE + 1) / radix'.
@@ -760,12 +760,12 @@ public final class Integer extends Number implements Comparable
while (index < len)
{
if (val < 0 || val > max)
- throw new NumberFormatException();
+ throw new NumberFormatException("number overflow (pos=" + index + ") : " + str);
ch = Character.digit(str.charAt(index++), radix);
val = val * radix + ch;
if (ch < 0 || (val < 0 && (! isNeg || val != MIN_VALUE)))
- throw new NumberFormatException();
+ throw new NumberFormatException("invalid character at position " + index + " in " + str);
}
return isNeg ? -val : val;
}
diff --git a/libjava/classpath/java/lang/SecurityException.java b/libjava/classpath/java/lang/SecurityException.java
index a95d797..84be33c 100644
--- a/libjava/classpath/java/lang/SecurityException.java
+++ b/libjava/classpath/java/lang/SecurityException.java
@@ -45,8 +45,9 @@ package java.lang;
*
* @author Brian Jones
* @author Warren Levy (warrenl@cygnus.com)
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
* @see SecurityManager
- * @status updated to 1.4
+ * @status updated to 1.5
*/
public class SecurityException extends RuntimeException
{
@@ -71,4 +72,57 @@ public class SecurityException extends RuntimeException
{
super(s);
}
+
+ /**
+ * <p>
+ * Constructs a <code>SecurityException</code> using
+ * the specified error message, which should give further details
+ * as to the reason for this exception. The specified cause
+ * <code>Throwable</code> may be used to provide additional history,
+ * with regards to the root of the problem. It is perfectly valid
+ * for this to be null, if the cause of the problem is unknown.
+ * </p>
+ * <p>
+ * <strong>Note</strong>: the detail message from the cause is not
+ * automatically incorporated into the resulting detail message of
+ * this exception.
+ * </p>
+ *
+ * @param message the detail message, which should give the reason for
+ * this exception being thrown.
+ * @param cause the cause of this exception, or null if the cause
+ * is unknown.
+ * @since 1.5
+ */
+ public SecurityException(String message, Throwable cause)
+ {
+ super(message, cause);
+ }
+
+ /**
+ * <p>
+ * Constructs a <code>SecurityException</code> using
+ * the specified cause <code>Throwable</code>, which may be used
+ * to provide additional history, with regards to the root of the
+ * problem. It is perfectly valid for this to be null, if the
+ * cause of the problem is unknown.
+ * </p>
+ * <p>
+ * The detail message is automatically constructed from the detail
+ * message of the supplied causal exception. If the cause is null,
+ * then the detail message will also be null. Otherwise, the detail
+ * message of this exception will be that of the causal exception.
+ * This makes this constructor very useful for simply wrapping another
+ * exception.
+ * </p>
+ *
+ * @param cause the cause of this exception, or null if the cause
+ * is unknown.
+ * @since 1.5
+ */
+ public SecurityException(Throwable cause)
+ {
+ super(cause);
+ }
+
}
diff --git a/libjava/classpath/java/lang/UnsupportedOperationException.java b/libjava/classpath/java/lang/UnsupportedOperationException.java
index 0387d0e..e691cc7 100644
--- a/libjava/classpath/java/lang/UnsupportedOperationException.java
+++ b/libjava/classpath/java/lang/UnsupportedOperationException.java
@@ -44,8 +44,9 @@ package java.lang;
* requested of it that it does not support.
*
* @author Warren Levy (warrenl@cygnus.com)
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
* @since 1.2
- * @status updated to 1.4
+ * @status updated to 1.5
*/
public class UnsupportedOperationException extends RuntimeException
{
@@ -70,4 +71,57 @@ public class UnsupportedOperationException extends RuntimeException
{
super(s);
}
+
+ /**
+ * <p>
+ * Constructs a <code>UnsupportedOperationException</code> using
+ * the specified error message, which should give further details
+ * as to the reason for this exception. The specified cause
+ * <code>Throwable</code> may be used to provide additional history,
+ * with regards to the root of the problem. It is perfectly valid
+ * for this to be null, if the cause of the problem is unknown.
+ * </p>
+ * <p>
+ * <strong>Note</strong>: the detail message from the cause is not
+ * automatically incorporated into the resulting detail message of
+ * this exception.
+ * </p>
+ *
+ * @param message the detail message, which should give the reason for
+ * this exception being thrown.
+ * @param cause the cause of this exception, or null if the cause
+ * is unknown.
+ * @since 1.5
+ */
+ public UnsupportedOperationException(String message, Throwable cause)
+ {
+ super(message, cause);
+ }
+
+ /**
+ * <p>
+ * Constructs a <code>UnsupportedOperationException</code> using
+ * the specified cause <code>Throwable</code>, which may be used
+ * to provide additional history, with regards to the root of the
+ * problem. It is perfectly valid for this to be null, if the
+ * cause of the problem is unknown.
+ * </p>
+ * <p>
+ * The detail message is automatically constructed from the detail
+ * message of the supplied causal exception. If the cause is null,
+ * then the detail message will also be null. Otherwise, the detail
+ * message of this exception will be that of the causal exception.
+ * This makes this constructor very useful for simply wrapping another
+ * exception.
+ * </p>
+ *
+ * @param cause the cause of this exception, or null if the cause
+ * is unknown.
+ * @since 1.5
+ */
+ public UnsupportedOperationException(Throwable cause)
+ {
+ super(cause);
+ }
+
}
diff --git a/libjava/classpath/java/lang/reflect/Proxy.java b/libjava/classpath/java/lang/reflect/Proxy.java
index dc1ac87..7a5fd30 100644
--- a/libjava/classpath/java/lang/reflect/Proxy.java
+++ b/libjava/classpath/java/lang/reflect/Proxy.java
@@ -38,7 +38,6 @@ exception statement from your version. */
package java.lang.reflect;
-import gnu.classpath.Configuration;
import gnu.java.lang.reflect.TypeSignature;
import java.io.Serializable;
@@ -263,16 +262,16 @@ public class Proxy implements Serializable
Class clazz = (Class) proxyClasses.get(pt);
if (clazz == null)
{
- if (Configuration.HAVE_NATIVE_GET_PROXY_CLASS)
- clazz = getProxyClass0(loader, interfaces);
+ if (VMProxy.HAVE_NATIVE_GET_PROXY_CLASS)
+ clazz = VMProxy.getProxyClass(loader, interfaces);
else
{
- ProxyData data = (Configuration.HAVE_NATIVE_GET_PROXY_DATA
- ? getProxyData0(loader, interfaces)
+ ProxyData data = (VMProxy.HAVE_NATIVE_GET_PROXY_DATA
+ ? VMProxy.getProxyData(loader, interfaces)
: ProxyData.getProxyData(pt));
- clazz = (Configuration.HAVE_NATIVE_GENERATE_PROXY_CLASS
- ? generateProxyClass0(loader, data)
+ clazz = (VMProxy.HAVE_NATIVE_GENERATE_PROXY_CLASS
+ ? VMProxy.generateProxyClass(loader, data)
: new ClassFactory(data).generate(loader));
}
@@ -388,74 +387,6 @@ public class Proxy implements Serializable
}
/**
- * Optional native method to replace (and speed up) the pure Java
- * implementation of getProxyClass. Only needed if
- * Configuration.HAVE_NATIVE_GET_PROXY_CLASS is true, this does the
- * work of both getProxyData0 and generateProxyClass0 with no
- * intermediate form in Java. The native code may safely assume that
- * this class must be created, and does not already exist.
- *
- * @param loader the class loader to define the proxy class in; null
- * implies the bootstrap class loader
- * @param interfaces the interfaces the class will extend
- * @return the generated proxy class
- * @throws IllegalArgumentException if the constraints for getProxyClass
- * were violated, except for problems with null
- * @throws NullPointerException if `interfaces' is null or contains
- * a null entry, or if handler is null
- * @see Configuration#HAVE_NATIVE_GET_PROXY_CLASS
- * @see #getProxyClass(ClassLoader, Class[])
- * @see #getProxyData0(ClassLoader, Class[])
- * @see #generateProxyClass0(ProxyData)
- */
- private static native Class getProxyClass0(ClassLoader loader,
- Class[] interfaces);
-
- /**
- * Optional native method to replace (and speed up) the pure Java
- * implementation of getProxyData. Only needed if
- * Configuration.HAVE_NATIVE_GET_PROXY_DATA is true. The native code
- * may safely assume that a new ProxyData object must be created which
- * does not duplicate any existing ones.
- *
- * @param loader the class loader to define the proxy class in; null
- * implies the bootstrap class loader
- * @param interfaces the interfaces the class will extend
- * @return all data that is required to make this proxy class
- * @throws IllegalArgumentException if the constraints for getProxyClass
- * were violated, except for problems with null
- * @throws NullPointerException if `interfaces' is null or contains
- * a null entry, or if handler is null
- * @see Configuration.HAVE_NATIVE_GET_PROXY_DATA
- * @see #getProxyClass(ClassLoader, Class[])
- * @see #getProxyClass0(ClassLoader, Class[])
- * @see ProxyType#getProxyData()
- */
- private static native ProxyData getProxyData0(ClassLoader loader,
- Class[] interfaces);
-
- /**
- * Optional native method to replace (and speed up) the pure Java
- * implementation of generateProxyClass. Only needed if
- * Configuration.HAVE_NATIVE_GENERATE_PROXY_CLASS is true. The native
- * code may safely assume that a new Class must be created, and that
- * the ProxyData object does not describe any existing class.
- *
- * @param loader the class loader to define the proxy class in; null
- * implies the bootstrap class loader
- * @param data the struct of information to convert to a Class. This
- * has already been verified for all problems except exceeding
- * VM limitations
- * @return the newly generated class
- * @throws IllegalArgumentException if VM limitations are exceeded
- * @see #getProxyClass(ClassLoader, Class[])
- * @see #getProxyClass0(ClassLoader, Class[])
- * @see ProxyData#generateProxyClass(ClassLoader)
- */
- private static native Class generateProxyClass0(ClassLoader loader,
- ProxyData data);
-
- /**
* Helper class for mapping unique ClassLoader and interface combinations
* to proxy classes.
*
@@ -502,49 +433,6 @@ public class Proxy implements Serializable
return hash;
}
- // A more comprehensive comparison of two arrays,
- // ignore array element order, and
- // ignore redundant elements
- private static boolean sameTypes(Class arr1[], Class arr2[]) {
- if (arr1.length == 1 && arr2.length == 1) {
- return arr1[0] == arr2[0];
- }
-
- // total occurrance of elements of arr1 in arr2
- int total_occ_of_arr1_in_arr2 = 0;
- each_type:
- for (int i = arr1.length; --i >= 0; )
- {
- Class t = arr1[i];
- for (int j = i; --j >= 0; )
- {
- if (t == arr1[j])
- { //found duplicate type
- continue each_type;
- }
- }
-
- // count c(a unique element of arr1)'s
- // occurrences in arr2
- int occ_in_arr2 = 0;
- for (int j = arr2.length; --j >= 0; )
- {
- if (t == arr2[j])
- {
- ++occ_in_arr2;
- }
- }
- if (occ_in_arr2 == 0)
- { // t does not occur in arr2
- return false;
- }
-
- total_occ_of_arr1_in_arr2 += occ_in_arr2;
- }
- // now, each element of arr2 must have been visited
- return total_occ_of_arr1_in_arr2 == arr2.length;
- }
-
/**
* Calculates equality.
*
@@ -556,7 +444,10 @@ public class Proxy implements Serializable
ProxyType pt = (ProxyType) other;
if (loader != pt.loader || interfaces.length != pt.interfaces.length)
return false;
- return sameTypes(interfaces, pt.interfaces);
+ for (int i = 0; i < interfaces.length; i++)
+ if (interfaces[i] != pt.interfaces[i])
+ return false;
+ return true;
}
} // class ProxyType
@@ -720,7 +611,7 @@ public class Proxy implements Serializable
*
* @author Eric Blake (ebb9@email.byu.edu)
*/
- private static final class ProxyData
+ static final class ProxyData
{
/**
* The package this class is in <b>including the trailing dot</b>
@@ -876,7 +767,6 @@ public class Proxy implements Serializable
private static final class ClassFactory
{
/** Constants for assisting the compilation */
- private static final byte POOL = 0;
private static final byte FIELD = 1;
private static final byte METHOD = 2;
private static final byte INTERFACE = 3;
@@ -909,7 +799,6 @@ public class Proxy implements Serializable
private static final char GETFIELD = 180;
private static final char INVOKEVIRTUAL = 182;
private static final char INVOKESPECIAL = 183;
- private static final char INVOKESTATIC = 184;
private static final char INVOKEINTERFACE = 185;
private static final char NEW = 187;
private static final char ANEWARRAY = 189;
diff --git a/libjava/classpath/java/net/DatagramSocket.java b/libjava/classpath/java/net/DatagramSocket.java
index 8596b7f..875ddc7 100644
--- a/libjava/classpath/java/net/DatagramSocket.java
+++ b/libjava/classpath/java/net/DatagramSocket.java
@@ -1,5 +1,5 @@
/* DatagramSocket.java -- A class to model UDP sockets
- Copyright (C) 1998, 1999, 2000, 2002, 2003, 2004
+ Copyright (C) 1998, 1999, 2000, 2002, 2003, 2004, 2005
Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,6 +38,8 @@ exception statement from your version. */
package java.net;
+import gnu.classpath.SystemProperties;
+
import gnu.java.net.PlainDatagramSocketImpl;
import gnu.java.nio.DatagramChannelImpl;
@@ -172,7 +174,7 @@ public class DatagramSocket
*/
public DatagramSocket(SocketAddress address) throws SocketException
{
- String propVal = System.getProperty("impl.prefix");
+ String propVal = SystemProperties.getProperty("impl.prefix");
if (propVal == null || propVal.equals(""))
impl = new PlainDatagramSocketImpl();
else
diff --git a/libjava/classpath/java/net/Inet4Address.java b/libjava/classpath/java/net/Inet4Address.java
index 00c6501..74ce6ef 100644
--- a/libjava/classpath/java/net/Inet4Address.java
+++ b/libjava/classpath/java/net/Inet4Address.java
@@ -142,7 +142,7 @@ public final class Inet4Address extends InetAddress
*/
public boolean isMCNodeLocal()
{
- return isMCNodeLocal();
+ return super.isMCNodeLocal();
}
/**
@@ -172,7 +172,7 @@ public final class Inet4Address extends InetAddress
*/
public boolean isMCOrgLocal()
{
- return isMCOrgLocal();
+ return super.isMCOrgLocal();
}
/**
diff --git a/libjava/classpath/java/net/JarURLConnection.java b/libjava/classpath/java/net/JarURLConnection.java
index 3067ecb..0ffd1af 100644
--- a/libjava/classpath/java/net/JarURLConnection.java
+++ b/libjava/classpath/java/net/JarURLConnection.java
@@ -1,5 +1,5 @@
/* JarURLConnection.java -- Class for manipulating remote jar files
- Copyright (C) 1998, 2002, 2003 Free Software Foundation, Inc.
+ Copyright (C) 1998, 2002, 2003, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -151,8 +151,9 @@ public abstract class JarURLConnection extends URLConnection
*/
public JarEntry getJarEntry() throws IOException
{
+ if (entryName == null)
+ return null;
JarFile jarFile = getJarFile();
-
return jarFile != null ? jarFile.getJarEntry(entryName) : null;
}
diff --git a/libjava/classpath/java/net/NetworkInterface.java b/libjava/classpath/java/net/NetworkInterface.java
index eccd2da..47b1c67 100644
--- a/libjava/classpath/java/net/NetworkInterface.java
+++ b/libjava/classpath/java/net/NetworkInterface.java
@@ -38,7 +38,12 @@ exception statement from your version. */
package java.net;
+import java.util.Collection;
+import java.util.Collections;
import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
import java.util.Vector;
/**
@@ -143,9 +148,7 @@ public final class NetworkInterface
public static NetworkInterface getByName(String name)
throws SocketException
{
- Vector networkInterfaces = VMNetworkInterface.getInterfaces();
-
- for (Enumeration e = networkInterfaces.elements(); e.hasMoreElements();)
+ for (Enumeration e = getNetworkInterfaces(); e.hasMoreElements();)
{
NetworkInterface tmp = (NetworkInterface) e.nextElement();
@@ -170,9 +173,7 @@ public final class NetworkInterface
public static NetworkInterface getByInetAddress(InetAddress addr)
throws SocketException
{
- Vector networkInterfaces = VMNetworkInterface.getInterfaces();
-
- for (Enumeration interfaces = networkInterfaces.elements();
+ for (Enumeration interfaces = getNetworkInterfaces();
interfaces.hasMoreElements();)
{
NetworkInterface tmp = (NetworkInterface) interfaces.nextElement();
@@ -188,6 +189,41 @@ public final class NetworkInterface
throw new SocketException("no network interface is bound to such an IP address");
}
+ static private Collection condense(Collection interfaces)
+ {
+ final Map condensed = new HashMap();
+
+ final Iterator interfs = interfaces.iterator();
+ while (interfs.hasNext()) {
+
+ final NetworkInterface face = (NetworkInterface) interfs.next();
+ final String name = face.getName();
+
+ if (condensed.containsKey(name))
+ {
+ final NetworkInterface conface = (NetworkInterface) condensed.get(name);
+ if (!conface.inetAddresses.containsAll(face.inetAddresses))
+ {
+ final Iterator faceAddresses = face.inetAddresses.iterator();
+ while (faceAddresses.hasNext())
+ {
+ final InetAddress faceAddress = (InetAddress) faceAddresses.next();
+ if (!conface.inetAddresses.contains(faceAddress))
+ {
+ conface.inetAddresses.add(faceAddress);
+ }
+ }
+ }
+ }
+ else
+ {
+ condensed.put(name, face);
+ }
+ }
+
+ return condensed.values();
+ }
+
/**
* Return an <code>Enumeration</code> of all available network interfaces
*
@@ -202,7 +238,9 @@ public final class NetworkInterface
if (networkInterfaces.isEmpty())
return null;
- return networkInterfaces.elements();
+ Collection condensed = condense(networkInterfaces);
+
+ return Collections.enumeration(condensed);
}
/**
diff --git a/libjava/classpath/java/net/URLClassLoader.java b/libjava/classpath/java/net/URLClassLoader.java
index 8ebc3e0..85b3857 100644
--- a/libjava/classpath/java/net/URLClassLoader.java
+++ b/libjava/classpath/java/net/URLClassLoader.java
@@ -588,10 +588,10 @@ public class URLClassLoader extends SecureClassLoader
* in the order given to the URLClassLoader which uses these URLs to
* load classes and resources (after using the default parent ClassLoader).
*
- * @exception SecurityException if the SecurityManager disallows the
- * creation of a ClassLoader.
* @param urls Locations that should be searched by this ClassLoader when
* resolving Classes or Resources.
+ * @exception SecurityException if the SecurityManager disallows the
+ * creation of a ClassLoader.
* @see SecureClassLoader
*/
public URLClassLoader(URL[] urls) throws SecurityException
@@ -610,13 +610,13 @@ public class URLClassLoader extends SecureClassLoader
* can throw a SecurityException. Then the supplied URLs are added
* in the order given to the URLClassLoader which uses these URLs to
* load classes and resources (after using the supplied parent ClassLoader).
- * @exception SecurityException if the SecurityManager disallows the
- * creation of a ClassLoader.
- * @exception SecurityException
* @param urls Locations that should be searched by this ClassLoader when
* resolving Classes or Resources.
* @param parent The parent class loader used before trying this class
* loader.
+ * @exception SecurityException if the SecurityManager disallows the
+ * creation of a ClassLoader.
+ * @exception SecurityException
* @see SecureClassLoader
*/
public URLClassLoader(URL[] urls, ClassLoader parent)
@@ -658,14 +658,14 @@ public class URLClassLoader extends SecureClassLoader
* load classes and resources (after using the supplied parent ClassLoader).
* It will use the supplied <CODE>URLStreamHandlerFactory</CODE> to get the
* protocol handlers of the supplied URLs.
- * @exception SecurityException if the SecurityManager disallows the
- * creation of a ClassLoader.
- * @exception SecurityException
* @param urls Locations that should be searched by this ClassLoader when
* resolving Classes or Resources.
* @param parent The parent class loader used before trying this class
* loader.
* @param factory Used to get the protocol handler for the URLs.
+ * @exception SecurityException if the SecurityManager disallows the
+ * creation of a ClassLoader.
+ * @exception SecurityException
* @see SecureClassLoader
*/
public URLClassLoader(URL[] urls, ClassLoader parent,
@@ -764,12 +764,12 @@ public class URLClassLoader extends SecureClassLoader
* package is sealed. If the Manifest indicates that the package is sealed
* then the Package will be sealed with respect to the supplied URL.
*
- * @exception IllegalArgumentException If this package name already exists
- * in this class loader
* @param name The name of the package
* @param manifest The manifest describing the specification,
* implementation and sealing details of the package
* @param url the code source url to seal the package
+ * @exception IllegalArgumentException If this package name already exists
+ * in this class loader
* @return the defined Package
*/
protected Package definePackage(String name, Manifest manifest, URL url)
@@ -900,7 +900,11 @@ public class URLClassLoader extends SecureClassLoader
else
result = defineClass(className, classData, 0, classData.length, source);
- super.setSigners(result, resource.getCertificates());
+ // Avoid NullPointerExceptions.
+ Certificate[] resourceCertificates = resource.getCertificates();
+ if(resourceCertificates != null)
+ super.setSigners(result, resourceCertificates);
+
return result;
}
catch (IOException ioe)
@@ -1016,11 +1020,11 @@ public class URLClassLoader extends SecureClassLoader
/**
* Finds all the resources with a particular name from all the locations.
*
- * @exception IOException when an error occurs accessing one of the
- * locations
* @param resourceName the name of the resource to lookup
* @return a (possible empty) enumeration of URLs where the resource can be
* found
+ * @exception IOException when an error occurs accessing one of the
+ * locations
*/
public Enumeration findResources(String resourceName)
throws IOException
@@ -1055,7 +1059,7 @@ public class URLClassLoader extends SecureClassLoader
*
* @param source The codesource that needs the permissions to be accessed
* @return the collection of permissions needed to access the code resource
- * @see java.security.SecureClassLoader#getPermissions()
+ * @see java.security.SecureClassLoader#getPermissions(CodeSource)
*/
protected PermissionCollection getPermissions(CodeSource source)
{
diff --git a/libjava/classpath/java/nio/Buffer.java b/libjava/classpath/java/nio/Buffer.java
index 47dabf2..2c7e00d 100644
--- a/libjava/classpath/java/nio/Buffer.java
+++ b/libjava/classpath/java/nio/Buffer.java
@@ -38,7 +38,7 @@ exception statement from your version. */
package java.nio;
-import gnu.classpath.RawData;
+import gnu.classpath.Pointer;
/**
* @since 1.4
@@ -49,7 +49,7 @@ public abstract class Buffer
int limit = 0;
int pos = 0;
int mark = -1;
- RawData address;
+ Pointer address;
/**
* Creates a new Buffer.
diff --git a/libjava/classpath/java/nio/DirectByteBufferImpl.java b/libjava/classpath/java/nio/DirectByteBufferImpl.java
index 1667299..53bb668 100644
--- a/libjava/classpath/java/nio/DirectByteBufferImpl.java
+++ b/libjava/classpath/java/nio/DirectByteBufferImpl.java
@@ -1,4 +1,4 @@
-/* DirectByteBufferImpl.java --
+/* DirectByteBufferImpl.java --
Copyright (C) 2003, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,7 +38,7 @@ exception statement from your version. */
package java.nio;
-import gnu.classpath.RawData;
+import gnu.classpath.Pointer;
abstract class DirectByteBufferImpl extends ByteBuffer
{
@@ -59,9 +59,9 @@ abstract class DirectByteBufferImpl extends ByteBuffer
static final class ReadOnly extends DirectByteBufferImpl
{
- ReadOnly(Object owner, RawData address,
- int capacity, int limit,
- int position)
+ ReadOnly(Object owner, Pointer address,
+ int capacity, int limit,
+ int position)
{
super(owner, address, capacity, limit, position);
}
@@ -89,9 +89,9 @@ abstract class DirectByteBufferImpl extends ByteBuffer
super(capacity);
}
- ReadWrite(Object owner, RawData address,
- int capacity, int limit,
- int position)
+ ReadWrite(Object owner, Pointer address,
+ int capacity, int limit,
+ int position)
{
super(owner, address, capacity, limit, position);
}
@@ -109,9 +109,9 @@ abstract class DirectByteBufferImpl extends ByteBuffer
this.address = VMDirectByteBuffer.allocate(capacity);
}
- DirectByteBufferImpl(Object owner, RawData address,
- int capacity, int limit,
- int position)
+ DirectByteBufferImpl(Object owner, Pointer address,
+ int capacity, int limit,
+ int position)
{
super(capacity, limit, position, -1);
this.owner = owner;
@@ -120,7 +120,7 @@ abstract class DirectByteBufferImpl extends ByteBuffer
/**
* Allocates a new direct byte buffer.
- */
+ */
public static ByteBuffer allocate(int capacity)
{
return new DirectByteBufferImpl.ReadWrite(capacity);
@@ -131,7 +131,7 @@ abstract class DirectByteBufferImpl extends ByteBuffer
if (owner == this)
VMDirectByteBuffer.free(address);
}
-
+
public byte get()
{
checkForUnderflow();
@@ -170,7 +170,7 @@ abstract class DirectByteBufferImpl extends ByteBuffer
position(pos + 1);
return this;
}
-
+
public ByteBuffer put(int index, byte value)
{
checkIndex(index);
@@ -178,12 +178,24 @@ abstract class DirectByteBufferImpl extends ByteBuffer
VMDirectByteBuffer.put(address, index, value);
return this;
}
-
+
+ public ByteBuffer put (byte[] src, int offset, int length)
+ {
+ checkArraySize (src.length, offset, length);
+ checkForUnderflow (length);
+
+ int index = position ();
+ VMDirectByteBuffer.put (address, index, src, offset, length);
+ position (index + length);
+
+ return this;
+ }
+
void shiftDown(int dst_offset, int src_offset, int count)
{
VMDirectByteBuffer.shiftDown(address, dst_offset, src_offset, count);
}
-
+
public ByteBuffer compact()
{
checkIfReadOnly();
@@ -191,15 +203,15 @@ abstract class DirectByteBufferImpl extends ByteBuffer
int pos = position();
if (pos > 0)
{
- int count = remaining();
- VMDirectByteBuffer.shiftDown(address, 0, pos, count);
- position(count);
- limit(capacity());
+ int count = remaining();
+ VMDirectByteBuffer.shiftDown(address, 0, pos, count);
+ position(count);
+ limit(capacity());
}
else
{
- position(limit());
- limit(capacity());
+ position(limit());
+ limit(capacity());
}
return this;
}
@@ -233,9 +245,9 @@ abstract class DirectByteBufferImpl extends ByteBuffer
if (mark != pos)
{
- result.position(mark);
- result.mark();
- result.position(pos);
+ result.position(mark);
+ result.mark();
+ result.position(pos);
}
return result;
}
@@ -289,18 +301,18 @@ abstract class DirectByteBufferImpl extends ByteBuffer
{
return ByteBufferHelper.getChar(this, order());
}
-
+
public ByteBuffer putChar(char value)
{
ByteBufferHelper.putChar(this, value, order());
return this;
}
-
+
public char getChar(int index)
{
return ByteBufferHelper.getChar(this, index, order());
}
-
+
public ByteBuffer putChar(int index, char value)
{
ByteBufferHelper.putChar(this, index, value, order());
@@ -311,18 +323,18 @@ abstract class DirectByteBufferImpl extends ByteBuffer
{
return ByteBufferHelper.getShort(this, order());
}
-
+
public ByteBuffer putShort(short value)
{
ByteBufferHelper.putShort(this, value, order());
return this;
}
-
+
public short getShort(int index)
{
return ByteBufferHelper.getShort(this, index, order());
}
-
+
public ByteBuffer putShort(int index, short value)
{
ByteBufferHelper.putShort(this, index, value, order());
@@ -333,18 +345,18 @@ abstract class DirectByteBufferImpl extends ByteBuffer
{
return ByteBufferHelper.getInt(this, order());
}
-
+
public ByteBuffer putInt(int value)
{
ByteBufferHelper.putInt(this, value, order());
return this;
}
-
+
public int getInt(int index)
{
return ByteBufferHelper.getInt(this, index, order());
}
-
+
public ByteBuffer putInt(int index, int value)
{
ByteBufferHelper.putInt(this, index, value, order());
@@ -355,18 +367,18 @@ abstract class DirectByteBufferImpl extends ByteBuffer
{
return ByteBufferHelper.getLong(this, order());
}
-
+
public ByteBuffer putLong(long value)
{
ByteBufferHelper.putLong(this, value, order());
return this;
}
-
+
public long getLong(int index)
{
return ByteBufferHelper.getLong(this, index, order());
}
-
+
public ByteBuffer putLong(int index, long value)
{
ByteBufferHelper.putLong(this, index, value, order());
@@ -377,13 +389,13 @@ abstract class DirectByteBufferImpl extends ByteBuffer
{
return ByteBufferHelper.getFloat(this, order());
}
-
+
public ByteBuffer putFloat(float value)
{
ByteBufferHelper.putFloat(this, value, order());
return this;
}
-
+
public float getFloat(int index)
{
return ByteBufferHelper.getFloat(this, index, order());
@@ -405,12 +417,12 @@ abstract class DirectByteBufferImpl extends ByteBuffer
ByteBufferHelper.putDouble(this, value, order());
return this;
}
-
+
public double getDouble(int index)
{
return ByteBufferHelper.getDouble(this, index, order());
}
-
+
public ByteBuffer putDouble(int index, double value)
{
ByteBufferHelper.putDouble(this, index, value, order());
diff --git a/libjava/classpath/java/nio/MappedByteBufferImpl.java b/libjava/classpath/java/nio/MappedByteBufferImpl.java
index 1b075d8..a53040f 100644
--- a/libjava/classpath/java/nio/MappedByteBufferImpl.java
+++ b/libjava/classpath/java/nio/MappedByteBufferImpl.java
@@ -38,7 +38,7 @@ exception statement from your version. */
package java.nio;
-import gnu.classpath.RawData;
+import gnu.classpath.Pointer;
import java.io.IOException;
@@ -48,12 +48,12 @@ final class MappedByteBufferImpl extends MappedByteBuffer
/** Posix uses this for the pointer returned by mmap;
* Win32 uses it for the pointer returned by MapViewOfFile. */
- public RawData implPtr;
+ public Pointer implPtr;
/** Posix uses this for the actual length passed to mmap;
* Win32 uses it for the pointer returned by CreateFileMapping. */
public long implLen;
- public MappedByteBufferImpl(RawData address, int size, boolean readOnly)
+ public MappedByteBufferImpl(Pointer address, int size, boolean readOnly)
throws IOException
{
super(size, size, 0, -1);
diff --git a/libjava/classpath/java/nio/channels/FileLock.java b/libjava/classpath/java/nio/channels/FileLock.java
index 151c23f..c466958 100644
--- a/libjava/classpath/java/nio/channels/FileLock.java
+++ b/libjava/classpath/java/nio/channels/FileLock.java
@@ -45,10 +45,10 @@ import java.io.IOException;
*/
public abstract class FileLock
{
- FileChannel channel;
- long position;
- long size;
- boolean shared;
+ private final FileChannel channel;
+ private final long position;
+ private final long size;
+ private final boolean shared;
/**
* Initializes the file lock.
diff --git a/libjava/classpath/java/nio/charset/Charset.java b/libjava/classpath/java/nio/charset/Charset.java
index 6de2917..0476b0d 100644
--- a/libjava/classpath/java/nio/charset/Charset.java
+++ b/libjava/classpath/java/nio/charset/Charset.java
@@ -68,9 +68,9 @@ public abstract class Charset implements Comparable
{
private CharsetEncoder cachedEncoder;
private CharsetDecoder cachedDecoder;
-
+
/**
- * Charset providers.
+ * Extra Charset providers.
*/
private static CharsetProvider[] providers;
@@ -204,13 +204,19 @@ public abstract class Charset implements Comparable
private static Charset charsetForName(String charsetName)
{
checkName (charsetName);
- Charset cs = null;
- CharsetProvider[] providers = providers2();
- for (int i = 0; i < providers.length; i++)
+ // Try the default provider first
+ // (so we don't need to load external providers unless really necessary)
+ // if it is an exotic charset try loading the external providers.
+ Charset cs = provider().charsetForName(charsetName);
+ if (cs == null)
{
- cs = providers[i].charsetForName(charsetName);
- if (cs != null)
- break;
+ CharsetProvider[] providers = providers2();
+ for (int i = 0; i < providers.length; i++)
+ {
+ cs = providers[i].charsetForName(charsetName);
+ if (cs != null)
+ break;
+ }
}
return cs;
}
@@ -218,6 +224,11 @@ public abstract class Charset implements Comparable
public static SortedMap availableCharsets()
{
TreeMap charsets = new TreeMap(String.CASE_INSENSITIVE_ORDER);
+ for (Iterator i = provider().charsets(); i.hasNext(); )
+ {
+ Charset cs = (Charset) i.next();
+ charsets.put(cs.name(), cs);
+ }
CharsetProvider[] providers = providers2();
for (int j = 0; j < providers.length; j++)
@@ -246,7 +257,7 @@ public abstract class Charset implements Comparable
/**
* We need to support multiple providers, reading them from
* java.nio.charset.spi.CharsetProvider in the resource directory
- * META-INF/services.
+ * META-INF/services. This returns the "extra" charset providers.
*/
private static CharsetProvider[] providers2()
{
@@ -257,7 +268,6 @@ public abstract class Charset implements Comparable
Enumeration en = ClassLoader.getSystemResources
("META-INF/services/java.nio.charset.spi.CharsetProvider");
LinkedHashSet set = new LinkedHashSet();
- set.add(provider());
while (en.hasMoreElements())
{
BufferedReader rdr = new BufferedReader(new InputStreamReader
diff --git a/libjava/classpath/java/rmi/server/RMIClassLoader.java b/libjava/classpath/java/rmi/server/RMIClassLoader.java
index 1a2e283..a7a7cb8 100644
--- a/libjava/classpath/java/rmi/server/RMIClassLoader.java
+++ b/libjava/classpath/java/rmi/server/RMIClassLoader.java
@@ -214,7 +214,7 @@ public class RMIClassLoader
//try context class loader first
try
{
- return loader.loadClass (name);
+ return Class.forName(name, false, loader);
}
catch (ClassNotFoundException e)
{
@@ -237,7 +237,7 @@ public class RMIClassLoader
") at codebase (" + codebases + ")");
}
- return loader.loadClass (name);
+ return Class.forName(name, false, loader);
}
/**
diff --git a/libjava/classpath/java/security/KeyPairGenerator.java b/libjava/classpath/java/security/KeyPairGenerator.java
index e6f926e..a6e010be 100644
--- a/libjava/classpath/java/security/KeyPairGenerator.java
+++ b/libjava/classpath/java/security/KeyPairGenerator.java
@@ -1,5 +1,5 @@
/* KeyPairGenerator.java --- Key Pair Generator Class
- Copyright (C) 1999, 2002, 2003, 2004 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -300,7 +300,6 @@ public abstract class KeyPairGenerator extends KeyPairGeneratorSpi
*/
public void initialize(int keysize, SecureRandom random)
{
- initialize(keysize, random);
}
/**
diff --git a/libjava/classpath/java/security/cert/X509CertSelector.java b/libjava/classpath/java/security/cert/X509CertSelector.java
index 4149a37..e3b8c0e 100644
--- a/libjava/classpath/java/security/cert/X509CertSelector.java
+++ b/libjava/classpath/java/security/cert/X509CertSelector.java
@@ -1,5 +1,5 @@
/* X509CertSelector.java -- selects X.509 certificates by criteria.
- Copyright (C) 2004 Free Software Foundation, Inc.
+ Copyright (C) 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -915,7 +915,7 @@ public class X509CertSelector implements CertSelector, Cloneable
}
if (sigId != null)
{
- if (!sigId.equals(cert.getSigAlgOID()))
+ if (!sigId.toString().equals(cert.getSigAlgOID()))
return false;
}
if (subjectKeyId != null)
diff --git a/libjava/classpath/java/sql/Date.java b/libjava/classpath/java/sql/Date.java
index 48a274f..d429cc8 100644
--- a/libjava/classpath/java/sql/Date.java
+++ b/libjava/classpath/java/sql/Date.java
@@ -1,5 +1,5 @@
/* Date.java -- Wrapper around java.util.Date
- Copyright (C) 1999, 2000, 2003 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2000, 2003, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -154,8 +154,6 @@ public class Date extends java.util.Date
*
* @param str The string to parse.
* @return The resulting <code>java.sql.Date</code> value.
- *
- * @deprecated
*/
public static Date valueOf (String str)
{
@@ -178,8 +176,6 @@ public class Date extends java.util.Date
* This method returns this date in JDBC format.
*
* @return This date as a string.
- *
- * @deprecated
*/
public String toString()
{
diff --git a/libjava/classpath/java/sql/Time.java b/libjava/classpath/java/sql/Time.java
index eb6ef2d..5755152 100644
--- a/libjava/classpath/java/sql/Time.java
+++ b/libjava/classpath/java/sql/Time.java
@@ -1,5 +1,5 @@
/* Time.java -- Wrapper around java.util.Date
- Copyright (C) 1999, 2000, 2002, 2003 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2000, 2002, 2003, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -139,8 +139,6 @@ public class Time extends java.util.Date
*
* @param str The string to parse.
* @return The resulting <code>java.sql.Time</code> value.
- *
- * @deprecated
*/
public static Time valueOf (String str)
{
@@ -193,8 +191,6 @@ public class Time extends java.util.Date
* This method returns this date in JDBC format.
*
* @return This date as a string.
- *
- * @deprecated
*/
public String toString ()
{
diff --git a/libjava/classpath/java/text/AttributedCharacterIterator.java b/libjava/classpath/java/text/AttributedCharacterIterator.java
index e5686ba..8413c20 100644
--- a/libjava/classpath/java/text/AttributedCharacterIterator.java
+++ b/libjava/classpath/java/text/AttributedCharacterIterator.java
@@ -58,7 +58,7 @@ import java.util.Set;
public interface AttributedCharacterIterator extends CharacterIterator
{
/**
- * This class defines attribute keys that are used as text attributes.
+ * Defines attribute keys that are used as text attributes.
*/
public static class Attribute implements Serializable
{
@@ -74,7 +74,8 @@ public interface AttributedCharacterIterator extends CharacterIterator
* This is the attribute for the reading form of text. This is used
* for storing pronunciation along with the written text for languages
* which need it. The value of attributes of this key type are
- * instances of <code>Annotation</code> which wrappers a <code>String</code>.
+ * instances of <code>Annotation</code> which wrappers a
+ * <code>String</code>.
*/
public static final Attribute READING = new Attribute ("READING");
@@ -87,14 +88,13 @@ public interface AttributedCharacterIterator extends CharacterIterator
new Attribute ("INPUT_METHOD_SEGMENT");
/**
- * This is the name of the attribute key
+ * The name of the attribute key
* @serial
*/
private String name;
/**
- * This method initializes a new instance of this class with the specified
- * name.
+ * Initializes a new instance of this class with the specified name.
*
* @param name The name of this attribute key.
*/
@@ -104,7 +104,7 @@ public interface AttributedCharacterIterator extends CharacterIterator
}
/**
- * This method returns the name of this attribute.
+ * Returns the name of this attribute.
*
* @return The attribute name
*/
@@ -114,14 +114,16 @@ public interface AttributedCharacterIterator extends CharacterIterator
}
/**
- * This method resolves an instance of <code>AttributedCharacterIterator.Attribute</code>
+ * Resolves an instance of
+ * <code>AttributedCharacterIterator.Attribute</code>
* that is being deserialized to one of the three pre-defined attribute
* constants. It does this by comparing the names of the attributes. The
* constant that the deserialized object resolves to is returned.
*
* @return The resolved contant value
*
- * @exception InvalidObjectException If the object being deserialized cannot be resolved.
+ * @exception InvalidObjectException If the object being deserialized
+ * cannot be resolved.
*/
protected Object readResolve() throws InvalidObjectException
{
@@ -134,21 +136,25 @@ public interface AttributedCharacterIterator extends CharacterIterator
if (this.equals (INPUT_METHOD_SEGMENT))
return INPUT_METHOD_SEGMENT;
- throw new InvalidObjectException ("Can't resolve Attribute: " + getName());
+ throw new InvalidObjectException ("Can't resolve Attribute: "
+ + getName());
}
/**
- * This method tests this object for equality against the specified object.
+ * Tests this object for equality against the specified object.
* The two objects will be considered equal if and only if:
* <ul>
* <li>The specified object is not <code>null</code>.
- * <li>The specified object is an instance of <code>AttributedCharacterIterator.Attribute</code>.
+ * <li>The specified object is an instance of
+ * <code>AttributedCharacterIterator.Attribute</code>.
* <li>The specified object has the same attribute name as this object.
* </ul>
*
- * @param The <code>Object</code> to test for equality against this object.
+ * @param obj the <code>Object</code> to test for equality against this
+ * object.
*
- * @return <code>true</code> if the specified object is equal to this one, <code>false</code> otherwise.
+ * @return <code>true</code> if the specified object is equal to this one,
+ * <code>false</code> otherwise.
*/
public final boolean equals (Object obj)
{
@@ -159,7 +165,7 @@ public interface AttributedCharacterIterator extends CharacterIterator
}
/**
- * This method returns a hash value for this object.
+ * Returns a hash value for this object.
*
* @return A hash value for this object.
*/
@@ -169,7 +175,7 @@ public interface AttributedCharacterIterator extends CharacterIterator
}
/**
- * This method returns a <code>String</code> representation of this object.
+ * Returns a <code>String</code> representation of this object.
*
* @return A <code>String</code> representation of this object.
*/
@@ -181,7 +187,7 @@ public interface AttributedCharacterIterator extends CharacterIterator
} // Inner class Attribute
/**
- * This method returns a list of all keys that are defined for the
+ * Returns a list of all keys that are defined for the
* text range. This can be an empty list if no attributes are defined.
*
* @return A list of keys
@@ -189,15 +195,15 @@ public interface AttributedCharacterIterator extends CharacterIterator
Set getAllAttributeKeys();
/**
- * This method returns a <code>Map</code> of the attributed defined for
- * the current character.
+ * Returns a <code>Map</code> of the attributes defined for the current
+ * character.
*
* @return A <code>Map</code> of the attributes for the current character.
*/
Map getAttributes();
/**
- * This method returns the value of the specified attribute for the
+ * Returns the value of the specified attribute for the
* current character. If the attribute is not defined for the current
* character, <code>null</code> is returned.
*
@@ -208,7 +214,7 @@ public interface AttributedCharacterIterator extends CharacterIterator
Object getAttribute (AttributedCharacterIterator.Attribute attrib);
/**
- * This method returns the index of the first character in the run that
+ * Returns the index of the first character in the run that
* contains all attributes defined for the current character.
*
* @return The start index of the run
@@ -216,7 +222,7 @@ public interface AttributedCharacterIterator extends CharacterIterator
int getRunStart();
/**
- * This method returns the index of the first character in the run that
+ * Returns the index of the first character in the run that
* contains all attributes in the specified <code>Set</code> defined for
* the current character.
*
@@ -227,7 +233,7 @@ public interface AttributedCharacterIterator extends CharacterIterator
int getRunStart (Set attribs);
/**
- * This method returns the index of the first character in the run that
+ * Returns the index of the first character in the run that
* contains the specified attribute defined for the current character.
*
* @param attrib The attribute.
@@ -237,15 +243,15 @@ public interface AttributedCharacterIterator extends CharacterIterator
int getRunStart (AttributedCharacterIterator.Attribute attrib);
/**
- * This method returns the index of the character after the end of the run
- * that contains all attributed defined for the current character.
+ * Returns the index of the character after the end of the run
+ * that contains all attributes defined for the current character.
*
* @return The end index of the run.
*/
int getRunLimit();
/**
- * This method returns the index of the character after the end of the run
+ * Returns the index of the character after the end of the run
* that contains all attributes in the specified <code>Set</code> defined
* for the current character.
*
@@ -256,7 +262,7 @@ public interface AttributedCharacterIterator extends CharacterIterator
int getRunLimit (Set attribs);
/**
- * This methods returns the index of the character after the end of the run
+ * Returns the index of the character after the end of the run
* that contains the specified attribute defined for the current character.
*
* @param attrib The attribute.
diff --git a/libjava/classpath/java/text/AttributedString.java b/libjava/classpath/java/text/AttributedString.java
index b9ced8f..9f0d5af 100644
--- a/libjava/classpath/java/text/AttributedString.java
+++ b/libjava/classpath/java/text/AttributedString.java
@@ -1,5 +1,5 @@
/* AttributedString.java -- Models text with attributes
- Copyright (C) 1998, 1999, 2004 Free Software Foundation, Inc.
+ Copyright (C) 1998, 1999, 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -47,379 +47,326 @@ import java.util.Map;
import java.util.Set;
/**
- * This class models a <code>String</code> with attributes over various
- * subranges of the string. It allows applications to access this
- * information via the <code>AttributedCharcterIterator</code> interface.
- *
- * @version 0.0
- *
- * @author Aaron M. Renn (arenn@urbanophile.com)
- */
-public class AttributedString
-{
-
-/*************************************************************************/
-
-/*
- * Inner Classes
- */
-
-/**
- * This class contains the attributes and ranges of text over which
- * that attributes apply.
- */
-final class AttributeRange
-{
-
-/*
- * Instance Variables
- */
-
-/**
- * A Map of the attributes
- */
-Map attribs;
-
-/**
- * The beginning index of the attributes
- */
-int begin_index;
-
-/**
- * The ending index of the attributes
- */
-int end_index;
-
-/*************************************************************************/
-
-/*
- * Constructors
- */
-
-AttributeRange(Map attribs, int begin_index, int end_index)
-{
- this.attribs = attribs;
- this.begin_index = begin_index;
- this.end_index = end_index;
-}
-
-} // Inner class AttributeRange
-
-/*************************************************************************/
-
-/*
- * Instance Variables
+ * This class models a <code>String</code> with attributes over various
+ * subranges of the string. It allows applications to access this
+ * information via the <code>AttributedCharcterIterator</code> interface.
+ *
+ * @author Aaron M. Renn (arenn@urbanophile.com)
*/
-
-/**
- * This object holds the string we are representing.
- */
-private StringCharacterIterator sci;
-
-/**
- * This is the attribute information
- */
-private AttributeRange[] attribs;
-
-/*************************************************************************/
-
-/*
- * Constructors
- */
-
-/**
- * This method initializes a new instance of <code>AttributedString</code>
- * that represents the specified <code>String</code> with no attributes.
- *
- * @param str The <code>String</code> to be attributed.
- */
-public
-AttributedString(String str)
-{
- sci = new StringCharacterIterator(str);
- attribs = new AttributeRange[0];
-}
-
-/*************************************************************************/
-
-/**
- * This method initializes a new instance of <code>AttributedString</code>
- * that represents that specified <code>String</code> with the specified
- * attributes over the entire length of the <code>String</code>.
- *
- * @param str The <code>String</code> to be attributed.
- * @param attributes The attribute list.
- */
-public
-AttributedString(String str, Map attributes)
-{
- this(str);
-
- attribs = new AttributeRange[1];
- attribs[0] = new AttributeRange(attributes, 0, str.length());
-}
-
-/*************************************************************************/
-
-/**
- * This method initializes a new instance of <code>AttributedString</code>
- * that will use the text and attribute information from the specified
- * <code>AttributedCharacterIterator</code>.
- *
- * @param aci The <code>AttributedCharacterIterator</code> containing the text and attribute information.
- */
-public
-AttributedString(AttributedCharacterIterator aci)
-{
- this(aci, aci.getBeginIndex(), aci.getEndIndex(), null);
-}
-
-/*************************************************************************/
-
-/**
- * This method initializes a new instance of <code>AttributedString</code>
- * that will use the text and attribute information from the specified
- * subrange of the specified <code>AttributedCharacterIterator</code>.
- *
- * @param aci The <code>AttributedCharacterIterator</code> containing the text and attribute information.
- * @param begin_index The beginning index of the text subrange.
- * @param end_index The ending index of the text subrange.
- */
-public
-AttributedString(AttributedCharacterIterator aci, int begin_index,
- int end_index)
+public class AttributedString
{
- this(aci, begin_index, end_index, null);
-}
-
-/*************************************************************************/
-/**
- * This method initializes a new instance of <code>AttributedString</code>
- * that will use the text and attribute information from the specified
- * subrange of the specified <code>AttributedCharacterIterator</code>.
- * Only attributes from the source iterator that are present in the
- * specified array of attributes will be included in the attribute list
- * for this object.
- *
- * @param aci The <code>AttributedCharacterIterator</code> containing the text and attribute information.
- * @param begin_index The beginning index of the text subrange.
- * @param end_index The ending index of the text subrange.
- * @param attributes A list of attributes to include from the iterator, or <code>null</code> to include all attributes.
- */
-public
-AttributedString(AttributedCharacterIterator aci, int begin_index,
- int end_index, AttributedCharacterIterator.Attribute[] attributes)
-{
- // Validate some arguments
- if ((begin_index < 0) || (end_index < begin_index))
- throw new IllegalArgumentException("Bad index values");
-
- StringBuffer sb = new StringBuffer("");
-
- // Get the valid attribute list
- Set all_attribs = aci.getAllAttributeKeys();
- if (attributes != null)
- all_attribs.retainAll(Arrays.asList(attributes));
-
- // Loop through and extract the attributes
- char c = aci.setIndex(begin_index);
-
- ArrayList accum = new ArrayList();
- do
- {
- sb.append(c);
-
- Iterator iter = all_attribs.iterator();
- while(iter.hasNext())
- {
- Object obj = iter.next();
-
- // What should we do if this is not true?
- if (!(obj instanceof AttributedCharacterIterator.Attribute))
- continue;
-
- AttributedCharacterIterator.Attribute attrib =
- (AttributedCharacterIterator.Attribute)obj;
-
- // Make sure the attribute is defined.
- int rl = aci.getRunLimit(attrib);
- if (rl == -1)
- continue;
- if (rl > end_index)
- rl = end_index;
- rl -= begin_index;
-
- // Check to see if we already processed this one
- int rs = aci.getRunStart(attrib);
- if ((rs < aci.getIndex()) && (aci.getIndex() != begin_index))
- continue;
-
- // If the attribute run starts before the beginning index, we
- // need to junk it if it is an Annotation.
- Object attrib_obj = aci.getAttribute(attrib);
- if (rs < begin_index)
- {
- if (attrib_obj instanceof Annotation)
- continue;
-
- rs = begin_index;
- }
- else
- {
- rs -= begin_index;
- }
-
- // Create a map object. Yes this will only contain one attribute
- Map new_map = new Hashtable();
- new_map.put(attrib, attrib_obj);
-
- // Add it to the attribute list.
- accum.add(new AttributeRange(new_map, rs, rl));
- }
-
- c = aci.next();
+ /**
+ * The attributes and ranges of text over which those attributes apply.
+ */
+ final class AttributeRange
+ {
+
+ /** A Map of the attributes */
+ Map attribs;
+
+ /** The beginning index of the attributes */
+ int begin_index;
+
+ /** The ending index of the attributes */
+ int end_index;
+
+ /**
+ * Creates a new attribute range.
+ *
+ * @param attribs the attributes.
+ * @param begin_index the start index.
+ * @param end_index the end index.
+ */
+ AttributeRange(Map attribs, int begin_index, int end_index)
+ {
+ this.attribs = attribs;
+ this.begin_index = begin_index;
+ this.end_index = end_index;
}
- while(c != CharacterIterator.DONE);
-
- attribs = new AttributeRange[accum.size()];
- attribs = (AttributeRange[]) accum.toArray(attribs);
-
- sci = new StringCharacterIterator(sb.toString());
-}
-
-/*************************************************************************/
-
-/*
- * Instance Methods
- */
-
-/**
- * This method adds a new attribute that will cover the entire string.
- *
- * @param attrib The attribute to add.
- * @param value The value of the attribute.
- */
-public void
-addAttribute(AttributedCharacterIterator.Attribute attrib, Object value)
-{
- addAttribute(attrib, value, 0, sci.getEndIndex());
-}
-
-/*************************************************************************/
-
-/**
- * This method adds a new attribute that will cover the specified subrange
- * of the string.
- *
- * @param attrib The attribute to add.
- * @param value The value of the attribute, which may be null.
- * @param begin_index The beginning index of the subrange.
- * @param end_index The ending index of the subrange.
- *
- * @exception IllegalArgumentException If attribute is <code>null</code> or the subrange is not valid.
- */
-public void
-addAttribute(AttributedCharacterIterator.Attribute attrib, Object value,
- int begin_index, int end_index)
-{
- if (attrib == null)
- throw new IllegalArgumentException("null attribute");
-
- HashMap hm = new HashMap();
- hm.put(attrib, value);
- addAttributes(hm, begin_index, end_index);
-}
-
-/*************************************************************************/
-
-/**
- * This method adds all of the attributes in the specified list to the
- * specified subrange of the string.
- *
- * @param attributes The list of attributes.
- * @param begin_index The beginning index.
- * @param end_index The ending index
- *
- * @param IllegalArgumentException If the list is <code>null</code> or the subrange is not valid.
- */
-public void
-addAttributes(Map attributes, int begin_index, int end_index)
-{
- if (attributes == null)
- throw new IllegalArgumentException("null attribute");
-
- if ((begin_index < 0) || (end_index > sci.getEndIndex()) ||
- (end_index < begin_index))
- throw new IllegalArgumentException("bad range");
-
- AttributeRange[] new_list = new AttributeRange[attribs.length + 1];
- System.arraycopy(attribs, 0, new_list, 0, attribs.length);
- attribs = new_list;
- attribs[attribs.length - 1] = new AttributeRange(attributes, begin_index,
- end_index);
-}
-
-/*************************************************************************/
-
-/**
- * This method returns an <code>AttributedCharacterIterator</code> that
- * will iterate over the entire string.
- *
- * @return An <code>AttributedCharacterIterator</code> for the entire string.
- */
-public AttributedCharacterIterator
-getIterator()
-{
- return(new AttributedStringIterator(sci, attribs, 0, sci.getEndIndex(), null));
-}
-
-/*************************************************************************/
-
-/**
- * This method returns an <code>AttributedCharacterIterator</code> that
- * will iterate over the entire string. This iterator will return information
- * about the list of attributes in the specified array. Attributes not in
- * the array may or may not be returned by the iterator. If the specified
- * array is <code>null</code>, all attributes will be returned.
- *
- * @param attributes A list of attributes to include in the returned iterator.
- *
- * @return An <code>AttributedCharacterIterator</code> for this string.
- */
-public AttributedCharacterIterator
-getIterator(AttributedCharacterIterator.Attribute[] attributes)
-{
- return(getIterator(attributes, 0, sci.getEndIndex()));
-}
-
-/*************************************************************************/
-
-/**
- * This method returns an <code>AttributedCharacterIterator</code> that
- * will iterate over the specified subrange. This iterator will return information
- * about the list of attributes in the specified array. Attributes not in
- * the array may or may not be returned by the iterator. If the specified
- * array is <code>null</code>, all attributes will be returned.
- *
- * @param attributes A list of attributes to include in the returned iterator.
- * @param begin_index The beginning index of the subrange.
- * @param end_index The ending index of the subrange.
- *
- * @return An <code>AttributedCharacterIterator</code> for this string.
- */
-public AttributedCharacterIterator
-getIterator(AttributedCharacterIterator.Attribute[] attributes,
- int begin_index, int end_index)
-{
- if ((begin_index < 0) || (end_index > sci.getEndIndex()) ||
- (end_index < begin_index))
- throw new IllegalArgumentException("bad range");
-
- return(new AttributedStringIterator(sci, attribs, begin_index, end_index,
- attributes));
-}
+ } // Inner class AttributeRange
+
+ /** The string we are representing. */
+ private StringCharacterIterator sci;
+
+ /** The attribute information */
+ private AttributeRange[] attribs;
+
+ /**
+ * Creates a new instance of <code>AttributedString</code>
+ * that represents the specified <code>String</code> with no attributes.
+ *
+ * @param str The <code>String</code> to be attributed (<code>null</code> not
+ * permitted).
+ *
+ * @throws NullPointerException if <code>str</code> is <code>null</code>.
+ */
+ public AttributedString(String str)
+ {
+ sci = new StringCharacterIterator(str);
+ attribs = new AttributeRange[0];
+ }
+
+ /**
+ * Creates a new instance of <code>AttributedString</code>
+ * that represents that specified <code>String</code> with the specified
+ * attributes over the entire length of the <code>String</code>.
+ *
+ * @param str The <code>String</code> to be attributed.
+ * @param attributes The attribute list.
+ */
+ public AttributedString(String str, Map attributes)
+ {
+ this(str);
+
+ attribs = new AttributeRange[1];
+ attribs[0] = new AttributeRange(attributes, 0, str.length());
+ }
+
+ /**
+ * Initializes a new instance of <code>AttributedString</code>
+ * that will use the text and attribute information from the specified
+ * <code>AttributedCharacterIterator</code>.
+ *
+ * @param aci The <code>AttributedCharacterIterator</code> containing the
+ * text and attribute information (<code>null</code> not
+ * permitted).
+ *
+ * @throws NullPointerException if <code>aci</code> is <code>null</code>.
+ */
+ public AttributedString(AttributedCharacterIterator aci)
+ {
+ this(aci, aci.getBeginIndex(), aci.getEndIndex(), null);
+ }
+
+ /**
+ * Initializes a new instance of <code>AttributedString</code>
+ * that will use the text and attribute information from the specified
+ * subrange of the specified <code>AttributedCharacterIterator</code>.
+ *
+ * @param aci The <code>AttributedCharacterIterator</code> containing the
+ * text and attribute information.
+ * @param begin_index The beginning index of the text subrange.
+ * @param end_index The ending index of the text subrange.
+ */
+ public AttributedString(AttributedCharacterIterator aci, int begin_index,
+ int end_index)
+ {
+ this(aci, begin_index, end_index, null);
+ }
+
+ /**
+ * Initializes a new instance of <code>AttributedString</code>
+ * that will use the text and attribute information from the specified
+ * subrange of the specified <code>AttributedCharacterIterator</code>.
+ * Only attributes from the source iterator that are present in the
+ * specified array of attributes will be included in the attribute list
+ * for this object.
+ *
+ * @param aci The <code>AttributedCharacterIterator</code> containing the
+ * text and attribute information.
+ * @param begin_index The beginning index of the text subrange.
+ * @param end_index The ending index of the text subrange.
+ * @param attributes A list of attributes to include from the iterator, or
+ * <code>null</code> to include all attributes.
+ */
+ public AttributedString(AttributedCharacterIterator aci, int begin_index,
+ int end_index, AttributedCharacterIterator.Attribute[] attributes)
+ {
+ // Validate some arguments
+ if ((begin_index < 0) || (end_index < begin_index))
+ throw new IllegalArgumentException("Bad index values");
+
+ StringBuffer sb = new StringBuffer("");
+
+ // Get the valid attribute list
+ Set all_attribs = aci.getAllAttributeKeys();
+ if (attributes != null)
+ all_attribs.retainAll(Arrays.asList(attributes));
+
+ // Loop through and extract the attributes
+ char c = aci.setIndex(begin_index);
+
+ ArrayList accum = new ArrayList();
+ do
+ {
+ sb.append(c);
+
+ Iterator iter = all_attribs.iterator();
+ while(iter.hasNext())
+ {
+ Object obj = iter.next();
+
+ // What should we do if this is not true?
+ if (!(obj instanceof AttributedCharacterIterator.Attribute))
+ continue;
+
+ AttributedCharacterIterator.Attribute attrib =
+ (AttributedCharacterIterator.Attribute)obj;
+
+ // Make sure the attribute is defined.
+ int rl = aci.getRunLimit(attrib);
+ if (rl == -1)
+ continue;
+ if (rl > end_index)
+ rl = end_index;
+ rl -= begin_index;
+
+ // Check to see if we already processed this one
+ int rs = aci.getRunStart(attrib);
+ if ((rs < aci.getIndex()) && (aci.getIndex() != begin_index))
+ continue;
+
+ // If the attribute run starts before the beginning index, we
+ // need to junk it if it is an Annotation.
+ Object attrib_obj = aci.getAttribute(attrib);
+ if (rs < begin_index)
+ {
+ if (attrib_obj instanceof Annotation)
+ continue;
+
+ rs = begin_index;
+ }
+ else
+ {
+ rs -= begin_index;
+ }
+
+ // Create a map object. Yes this will only contain one attribute
+ Map new_map = new Hashtable();
+ new_map.put(attrib, attrib_obj);
+
+ // Add it to the attribute list.
+ accum.add(new AttributeRange(new_map, rs, rl));
+ }
+
+ c = aci.next();
+ }
+ while(c != CharacterIterator.DONE);
+
+ attribs = new AttributeRange[accum.size()];
+ attribs = (AttributeRange[]) accum.toArray(attribs);
+
+ sci = new StringCharacterIterator(sb.toString());
+ }
+
+ /**
+ * Adds a new attribute that will cover the entire string.
+ *
+ * @param attrib The attribute to add.
+ * @param value The value of the attribute.
+ */
+ public void addAttribute(AttributedCharacterIterator.Attribute attrib,
+ Object value)
+ {
+ addAttribute(attrib, value, 0, sci.getEndIndex());
+ }
+
+ /**
+ * Adds a new attribute that will cover the specified subrange
+ * of the string.
+ *
+ * @param attrib The attribute to add.
+ * @param value The value of the attribute, which may be <code>null</code>.
+ * @param begin_index The beginning index of the subrange.
+ * @param end_index The ending index of the subrange.
+ *
+ * @exception IllegalArgumentException If attribute is <code>null</code> or
+ * the subrange is not valid.
+ */
+ public void addAttribute(AttributedCharacterIterator.Attribute attrib,
+ Object value, int begin_index, int end_index)
+ {
+ if (attrib == null)
+ throw new IllegalArgumentException("null attribute");
+
+ HashMap hm = new HashMap();
+ hm.put(attrib, value);
+
+ addAttributes(hm, begin_index, end_index);
+ }
+
+ /**
+ * Adds all of the attributes in the specified list to the
+ * specified subrange of the string.
+ *
+ * @param attributes The list of attributes.
+ * @param begin_index The beginning index.
+ * @param end_index The ending index
+ *
+ * @throws IllegalArgumentException If the list is <code>null</code> or the
+ * subrange is not valid.
+ */
+ public void addAttributes(Map attributes, int begin_index, int end_index)
+ {
+ if (attributes == null)
+ throw new IllegalArgumentException("null attribute");
+
+ if ((begin_index < 0) || (end_index > sci.getEndIndex()) ||
+ (end_index < begin_index))
+ throw new IllegalArgumentException("bad range");
+
+ AttributeRange[] new_list = new AttributeRange[attribs.length + 1];
+ System.arraycopy(attribs, 0, new_list, 0, attribs.length);
+ attribs = new_list;
+ attribs[attribs.length - 1] = new AttributeRange(attributes, begin_index,
+ end_index);
+ }
+
+ /**
+ * Returns an <code>AttributedCharacterIterator</code> that
+ * will iterate over the entire string.
+ *
+ * @return An <code>AttributedCharacterIterator</code> for the entire string.
+ */
+ public AttributedCharacterIterator getIterator()
+ {
+ return(new AttributedStringIterator(sci, attribs, 0, sci.getEndIndex(),
+ null));
+ }
+
+ /**
+ * Returns an <code>AttributedCharacterIterator</code> that
+ * will iterate over the entire string. This iterator will return information
+ * about the list of attributes in the specified array. Attributes not in
+ * the array may or may not be returned by the iterator. If the specified
+ * array is <code>null</code>, all attributes will be returned.
+ *
+ * @param attributes A list of attributes to include in the returned iterator.
+ *
+ * @return An <code>AttributedCharacterIterator</code> for this string.
+ */
+ public AttributedCharacterIterator getIterator(
+ AttributedCharacterIterator.Attribute[] attributes)
+ {
+ return(getIterator(attributes, 0, sci.getEndIndex()));
+ }
+
+ /**
+ * Returns an <code>AttributedCharacterIterator</code> that
+ * will iterate over the specified subrange. This iterator will return
+ * information about the list of attributes in the specified array.
+ * Attributes not in the array may or may not be returned by the iterator.
+ * If the specified array is <code>null</code>, all attributes will be
+ * returned.
+ *
+ * @param attributes A list of attributes to include in the returned iterator.
+ * @param begin_index The beginning index of the subrange.
+ * @param end_index The ending index of the subrange.
+ *
+ * @return An <code>AttributedCharacterIterator</code> for this string.
+ */
+ public AttributedCharacterIterator getIterator(
+ AttributedCharacterIterator.Attribute[] attributes,
+ int begin_index, int end_index)
+ {
+ if ((begin_index < 0) || (end_index > sci.getEndIndex()) ||
+ (end_index < begin_index))
+ throw new IllegalArgumentException("bad range");
+
+ return(new AttributedStringIterator(sci, attribs, begin_index, end_index,
+ attributes));
+ }
} // class AttributedString
-
diff --git a/libjava/classpath/java/text/AttributedStringIterator.java b/libjava/classpath/java/text/AttributedStringIterator.java
index 7d7bf27..7fba5d6 100644
--- a/libjava/classpath/java/text/AttributedStringIterator.java
+++ b/libjava/classpath/java/text/AttributedStringIterator.java
@@ -55,129 +55,102 @@ import java.util.Set;
class AttributedStringIterator implements AttributedCharacterIterator
{
-/*************************************************************************/
-
-/**
- * Instance Variables
- */
-
-/**
- * The character iterator containing the text
- */
-private CharacterIterator ci;
-
-/**
- * The list of attributes and ranges
- */
-private AttributedString.AttributeRange[] attribs;
-
-/**
- * The list of attributes that the user is interested in. We may,
- * at our option, not return any other attributes.
- */
-private AttributedCharacterIterator.Attribute[] restricts;
-
-/*************************************************************************/
-
-/*
- * Constructors
- */
-
-AttributedStringIterator(StringCharacterIterator sci,
- AttributedString.AttributeRange[] attribs,
- int begin_index, int end_index,
- AttributedCharacterIterator.Attribute[] restricts)
-{
- this.ci = new StringCharacterIterator(sci, begin_index, end_index);
- this.attribs = attribs;
- this.restricts = restricts;
-}
-
-/*************************************************************************/
-
-/*
- * Instance Methods
- */
-
-// First we have a bunch of stupid redirects. If StringCharacterIterator
-// weren't final, I just would have extended that for this class. Alas, no.
-
-public Object
-clone()
-{
- return(ci.clone());
-}
-
-public char
-current()
-{
- return(ci.current());
-}
-
-public char
-next()
-{
- return(ci.next());
-}
-
-public char
-previous()
-{
- return(ci.previous());
-}
-
-public char
-first()
-{
- return(ci.first());
-}
-
-public char
-last()
-{
- return(ci.last());
-}
-
-public int
-getIndex()
-{
- return(ci.getIndex());
-}
-
-public char
-setIndex(int index)
-{
- return(ci.setIndex(index));
-}
-
-public int
-getBeginIndex()
-{
- return(ci.getBeginIndex());
-}
-
-public int
-getEndIndex()
-{
- return(ci.getEndIndex());
-}
-
-/*
- * Here is where the AttributedCharacterIterator methods start.
- */
-
-/*************************************************************************/
-
-/**
- * Returns a list of all the attribute keys that are defined anywhere
- * on this string.
- */
-public Set
-getAllAttributeKeys()
-{
- HashSet s = new HashSet();
- if (attribs == null)
- return(s);
+ /*************************************************************************/
+
+ /** The character iterator containing the text */
+ private CharacterIterator ci;
+
+ /** The list of attributes and ranges */
+ private AttributedString.AttributeRange[] attribs;
+
+ /**
+ * The list of attributes that the user is interested in. We may,
+ * at our option, not return any other attributes.
+ */
+ private AttributedCharacterIterator.Attribute[] restricts;
+
+ /*************************************************************************/
+
+ AttributedStringIterator(StringCharacterIterator sci,
+ AttributedString.AttributeRange[] attribs,
+ int begin_index, int end_index,
+ AttributedCharacterIterator.Attribute[] restricts)
+ {
+ this.ci = new StringCharacterIterator(sci, begin_index, end_index);
+ this.attribs = attribs;
+ this.restricts = restricts;
+ }
+
+ /*************************************************************************/
+
+ // First we have a bunch of stupid redirects. If StringCharacterIterator
+ // weren't final, I just would have extended that for this class. Alas, no.
+
+ public Object clone()
+ {
+ return(ci.clone());
+ }
+
+ public char current()
+ {
+ return(ci.current());
+ }
+
+ public char next()
+ {
+ return(ci.next());
+ }
+
+ public char previous()
+ {
+ return(ci.previous());
+ }
+
+ public char first()
+ {
+ return(ci.first());
+ }
+
+ public char last()
+ {
+ return(ci.last());
+ }
+
+ public int getIndex()
+ {
+ return(ci.getIndex());
+ }
+
+ public char setIndex(int index)
+ {
+ return(ci.setIndex(index));
+ }
+
+ public int getBeginIndex()
+ {
+ return(ci.getBeginIndex());
+ }
+
+ public int getEndIndex()
+ {
+ return(ci.getEndIndex());
+ }
+
+ /*
+ * Here is where the AttributedCharacterIterator methods start.
+ */
+
+ /*************************************************************************/
+
+ /**
+ * Returns a list of all the attribute keys that are defined anywhere
+ * on this string.
+ */
+ public Set getAllAttributeKeys()
+ {
+ HashSet s = new HashSet();
+ if (attribs == null)
+ return(s);
for (int i = 0; i < attribs.length; i++)
{
@@ -193,156 +166,146 @@ getAllAttributeKeys()
}
}
- return(s);
-}
-
-/*************************************************************************/
-
-/**
- * Various methods that determine how far the run extends for various
- * attribute combinations.
- */
-
-public int
-getRunLimit()
-{
- return(getRunLimit(getAttributes().keySet()));
-}
-
-public int
-getRunLimit(AttributedCharacterIterator.Attribute attrib)
-{
- HashSet s = new HashSet();
- s.add(attrib);
-
- return(getRunLimit(s));
-}
-
-public synchronized int
-getRunLimit(Set attribute_set)
-{
- boolean hit = false;
- int runLimit = ci.getEndIndex ();
- int pos = ci.getIndex ();
-
- for (int i = 0; i < attribs.length; ++i)
- {
- if (pos >= attribs[i].begin_index &&
- pos < attribs[i].end_index)
- {
- Iterator iter = attribute_set.iterator();
- while(iter.hasNext())
- if (attribs[i].attribs.containsKey(iter.next()))
- {
- hit = true;
- runLimit = Math.min(runLimit, attribs[i].end_index);
- }
- }
- }
- if (hit)
- return runLimit;
- else
- return ci.getEndIndex();
-}
-
-/*************************************************************************/
-
-/**
- * Various methods that determine where the run begins for various
- * attribute combinations.
- */
-
-public int
-getRunStart()
-{
- return(getRunStart(getAttributes().keySet()));
-}
-
-public int
-getRunStart(AttributedCharacterIterator.Attribute attrib)
-{
- HashSet s = new HashSet();
- s.add(attrib);
-
- return(getRunStart(s));
-}
-
-public int
-getRunStart(Set attribute_set)
-{
- boolean hit = false;
- int runBegin = 0;
- int pos = ci.getIndex ();
-
- for (int i = 0; i < attribs.length; ++i)
- {
- if (pos >= attribs[i].begin_index &&
- pos <= attribs[i].end_index)
- {
- Iterator iter = attribute_set.iterator();
- while(iter.hasNext())
- if (attribs[i].attribs.containsKey(iter.next()))
- {
- hit = true;
- runBegin = Math.max(runBegin, attribs[i].begin_index);
- }
- }
- }
- if (hit)
- return runBegin;
- else
- return -1;
-}
+ return(s);
+ }
+
+ /*************************************************************************/
+
+ /**
+ * Various methods that determine how far the run extends for various
+ * attribute combinations.
+ */
+
+ public int getRunLimit()
+ {
+ return(getRunLimit(getAttributes().keySet()));
+ }
+
+ public int getRunLimit(AttributedCharacterIterator.Attribute attrib)
+ {
+ HashSet s = new HashSet();
+ s.add(attrib);
+ return(getRunLimit(s));
+ }
+
+ public synchronized int getRunLimit(Set attribute_set)
+ {
+ boolean hit = false;
+ int runLimit = ci.getEndIndex ();
+ int pos = ci.getIndex ();
+
+ for (int i = 0; i < attribs.length; ++i)
+ {
+ if (pos >= attribs[i].begin_index &&
+ pos < attribs[i].end_index)
+ {
+ Iterator iter = attribute_set.iterator();
+ while(iter.hasNext())
+ if (attribs[i].attribs.containsKey(iter.next()))
+ {
+ hit = true;
+ runLimit = Math.min(runLimit, attribs[i].end_index);
+ }
+ }
+ }
+ if (hit)
+ return runLimit;
+ else
+ return ci.getEndIndex();
+ }
+
+ /*************************************************************************/
+
+ /**
+ * Various methods that determine where the run begins for various
+ * attribute combinations.
+ */
+
+ public int getRunStart()
+ {
+ return(getRunStart(getAttributes().keySet()));
+ }
+
+ public int getRunStart(AttributedCharacterIterator.Attribute attrib)
+ {
+ HashSet s = new HashSet();
+ s.add(attrib);
+
+ return(getRunStart(s));
+ }
+
+ public int getRunStart(Set attribute_set)
+ {
+ boolean hit = false;
+ int runBegin = 0;
+ int pos = ci.getIndex();
+
+ for (int i = 0; i < attribs.length; ++i)
+ {
+ if (pos >= attribs[i].begin_index &&
+ pos <= attribs[i].end_index)
+ {
+ Iterator iter = attribute_set.iterator();
+ while(iter.hasNext())
+ if (attribs[i].attribs.containsKey(iter.next()))
+ {
+ hit = true;
+ runBegin = Math.max(runBegin, attribs[i].begin_index);
+ }
+ }
+ }
+ if (hit)
+ return runBegin;
+ else
+ return -1;
+ }
+
+ /*************************************************************************/
+
+ public Object getAttribute(AttributedCharacterIterator.Attribute attrib)
+ {
+ if (attribs == null)
+ return(null);
-/*************************************************************************/
+ for (int i = 0; i < attribs.length; i++)
+ {
+ Set key_set = attribs[i].attribs.keySet();
+ Iterator iter = key_set.iterator();
+ while (iter.hasNext())
+ {
+ Object obj = iter.next();
+
+ // Check for attribute match and range match
+ if (obj.equals(attrib))
+ if ((ci.getIndex() >= attribs[i].begin_index) &&
+ (ci.getIndex() < attribs[i].end_index))
+ return(attribs[i].attribs.get(obj));
+ }
+ }
-public Object
-getAttribute(AttributedCharacterIterator.Attribute attrib)
-{
- if (attribs == null)
return(null);
-
- for (int i = 0; i < attribs.length; i++)
- {
- Set key_set = attribs[i].attribs.keySet();
- Iterator iter = key_set.iterator();
- while (iter.hasNext())
- {
- Object obj = iter.next();
-
- // Check for attribute match and range match
- if (obj.equals(attrib))
- if ((ci.getIndex() >= attribs[i].begin_index) &&
- (ci.getIndex() < attribs[i].end_index))
- return(attribs[i].attribs.get(obj));
- }
- }
-
- return(null);
-}
-
-/*************************************************************************/
-
-/**
- * Return a list of all the attributes and values defined for this
- * character
- */
-public Map
-getAttributes()
-{
- HashMap m = new HashMap();
- if (attribs == null)
- return(m);
+ }
+
+ /*************************************************************************/
+
+ /**
+ * Return a list of all the attributes and values defined for this
+ * character
+ */
+ public Map getAttributes()
+ {
+ HashMap m = new HashMap();
+ if (attribs == null)
+ return(m);
- for (int i = 0; i < attribs.length; i++)
- {
- if ((ci.getIndex() >= attribs[i].begin_index) &&
- (ci.getIndex() < attribs[i].end_index))
- m.putAll(attribs[i].attribs);
- }
+ for (int i = 0; i < attribs.length; i++)
+ {
+ if ((ci.getIndex() >= attribs[i].begin_index) &&
+ (ci.getIndex() < attribs[i].end_index))
+ m.putAll(attribs[i].attribs);
+ }
- return(m);
-}
+ return(m);
+ }
} // class AttributedStringIterator
-
diff --git a/libjava/classpath/java/text/BreakIterator.java b/libjava/classpath/java/text/BreakIterator.java
index d021dce..7ba1168 100644
--- a/libjava/classpath/java/text/BreakIterator.java
+++ b/libjava/classpath/java/text/BreakIterator.java
@@ -114,9 +114,9 @@ public abstract class BreakIterator implements Cloneable
* This methdod returns the offset of the text element boundary following
* the specified offset.
*
- * @param offset The text index from which to find the next text boundary.
+ * @param pos The text index from which to find the next text boundary.
*
- * @param The next text boundary following the specified index.
+ * @return The next text boundary following the specified index.
*/
public abstract int following (int pos);
@@ -186,9 +186,9 @@ public abstract class BreakIterator implements Cloneable
*
* @return A <code>BreakIterator</code> instance for the default locale.
*/
- public static BreakIterator getCharacterInstance (Locale loc)
+ public static BreakIterator getCharacterInstance (Locale locale)
{
- BreakIterator r = getInstance ("CharacterIterator", loc);
+ BreakIterator r = getInstance ("CharacterIterator", locale);
if (r == null)
r = new gnu.java.text.CharacterBreakIterator ();
return r;
@@ -214,9 +214,9 @@ public abstract class BreakIterator implements Cloneable
*
* @return A <code>BreakIterator</code> instance for the default locale.
*/
- public static BreakIterator getLineInstance (Locale loc)
+ public static BreakIterator getLineInstance (Locale locale)
{
- BreakIterator r = getInstance ("LineIterator", loc);
+ BreakIterator r = getInstance ("LineIterator", locale);
if (r == null)
r = new gnu.java.text.LineBreakIterator ();
return r;
@@ -242,9 +242,9 @@ public abstract class BreakIterator implements Cloneable
*
* @return A <code>BreakIterator</code> instance for the default locale.
*/
- public static BreakIterator getSentenceInstance (Locale loc)
+ public static BreakIterator getSentenceInstance (Locale locale)
{
- BreakIterator r = getInstance ("SentenceIterator", loc);
+ BreakIterator r = getInstance ("SentenceIterator", locale);
if (r == null)
r = new gnu.java.text.SentenceBreakIterator ();
return r;
@@ -254,7 +254,7 @@ public abstract class BreakIterator implements Cloneable
* This method returns the text this object is iterating over as a
* <code>CharacterIterator</code>.
*
- * @param The text being iterated over.
+ * @return The text being iterated over.
*/
public abstract CharacterIterator getText ();
@@ -278,9 +278,9 @@ public abstract class BreakIterator implements Cloneable
*
* @return A <code>BreakIterator</code> instance for the default locale.
*/
- public static BreakIterator getWordInstance (Locale loc)
+ public static BreakIterator getWordInstance (Locale locale)
{
- BreakIterator r = getInstance ("WordIterator", loc);
+ BreakIterator r = getInstance ("WordIterator", locale);
if (r == null)
r = new gnu.java.text.WordBreakIterator ();
return r;
@@ -290,7 +290,7 @@ public abstract class BreakIterator implements Cloneable
* This method tests whether or not the specified position is a text
* element boundary.
*
- * @param offset The text position to test.
+ * @param pos The text position to test.
*
* @return <code>true</code> if the position is a boundary,
* <code>false</code> otherwise.
@@ -332,8 +332,7 @@ public abstract class BreakIterator implements Cloneable
* This methdod returns the offset of the text element boundary preceding
* the specified offset.
*
- * @param offset The text index from which to find the preceding
- * text boundary.
+ * @param pos The text index from which to find the preceding text boundary.
*
* @returns The next text boundary preceding the specified index.
*/
@@ -357,7 +356,7 @@ public abstract class BreakIterator implements Cloneable
/**
* This method sets the text string to iterate over.
*
- * @param str The <code>String</code> to iterate over.
+ * @param newText The <code>String</code> to iterate over.
*/
public void setText (String newText)
{
@@ -368,7 +367,7 @@ public abstract class BreakIterator implements Cloneable
* This method sets the text to iterate over from the specified
* <code>CharacterIterator</code>.
*
- * @param ci The desired <code>CharacterIterator</code>.
+ * @param newText The desired <code>CharacterIterator</code>.
*/
public abstract void setText (CharacterIterator newText);
}
diff --git a/libjava/classpath/java/text/CharacterIterator.java b/libjava/classpath/java/text/CharacterIterator.java
index 6b3f951..58d6ddc 100644
--- a/libjava/classpath/java/text/CharacterIterator.java
+++ b/libjava/classpath/java/text/CharacterIterator.java
@@ -1,5 +1,5 @@
/* CharacterIterator.java -- Iterate over a character range
- Copyright (C) 1998, 2001 Free Software Foundation, Inc.
+ Copyright (C) 1998, 2001, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -64,8 +64,8 @@ public interface CharacterIterator extends Cloneable
/**
* This method increments the current index and then returns the character
- * at the new index value. If the index is already at <code>getEndIndex() - 1</code>,
- * it will not be incremented.
+ * at the new index value. If the index is already at
+ * <code>getEndIndex() - 1</code>, it will not be incremented.
*
* @return The character at the position of the incremented index value,
* or <code>DONE</code> if the index has reached getEndIndex() - 1
@@ -78,7 +78,8 @@ public interface CharacterIterator extends Cloneable
* index, it will not be decremented.
*
* @return The character at the position of the decremented index value,
- * or <code>DONE</code> if index was already equal to the beginning index value.
+ * or {@link #DONE} if index was already equal to the beginning index
+ * value.
*/
char previous();
@@ -86,7 +87,8 @@ public interface CharacterIterator extends Cloneable
* This method sets the index value to the beginning of the range and returns
* the character there.
*
- * @return The character at the beginning of the range, or <code>DONE</code> if the range is empty.
+ * @return The character at the beginning of the range, or {@link #DONE} if
+ * the range is empty.
*/
char first();
@@ -95,7 +97,8 @@ public interface CharacterIterator extends Cloneable
* returns the character there. If the range is empty, then the index value
* will be set equal to the beginning index.
*
- * @return The character at the end of the range, or <code>DONE</code> if the range is empty.
+ * @return The character at the end of the range, or {@link #DONE} if the
+ * range is empty.
*/
char last();
@@ -112,7 +115,8 @@ public interface CharacterIterator extends Cloneable
*
* @param index The new index value.
*
- * @return The character at the new index value or <code>DONE</code> if the index value is equal to <code>getEndIndex</code>.
+ * @return The character at the new index value or {@link #DONE} if the index
+ * value is equal to {@link #getEndIndex()}.
*/
char setIndex (int index) throws IllegalArgumentException;
diff --git a/libjava/classpath/java/text/ChoiceFormat.java b/libjava/classpath/java/text/ChoiceFormat.java
index 23c8a8c..94c13a2 100644
--- a/libjava/classpath/java/text/ChoiceFormat.java
+++ b/libjava/classpath/java/text/ChoiceFormat.java
@@ -86,7 +86,7 @@ public class ChoiceFormat extends NumberFormat
* object based on the specified pattern. This pattern is of the form
* "term#string|term#string...". For example "1#Sunday|2#Monday|#Tuesday".
*
- * @param pattern The pattern of terminators and format strings.
+ * @param newPattern The pattern of terminators and format strings.
*
* @exception IllegalArgumentException If the pattern is not valid
*/
@@ -170,7 +170,7 @@ public class ChoiceFormat extends NumberFormat
* This is the same pattern type used by the <code>applyPattern</code>
* method.
*
- * @param pattern The pattern of terminators and format strings.
+ * @param newPattern The pattern of terminators and format strings.
*
* @exception IllegalArgumentException If the pattern is not valid
*/
@@ -229,10 +229,11 @@ public class ChoiceFormat extends NumberFormat
* <code>StringBuffer</code> based on the supplied <code>long</code>
* argument.
*
- * @param number The number used for determine (based on the range
+ * @param num The number used for determine (based on the range
* terminators) which format string to append.
- * @param sb The <code>StringBuffer</code> to append the format string to.
- * @param status Unused.
+ * @param appendBuf The <code>StringBuffer</code> to append the format string
+ * to.
+ * @param pos Unused.
*
* @return The <code>StringBuffer</code> with the format string appended.
*/
@@ -247,10 +248,10 @@ public class ChoiceFormat extends NumberFormat
* <code>StringBuffer</code> based on the supplied <code>double</code>
* argument.
*
- * @param number The number used for determine (based on the range
+ * @param num The number used for determine (based on the range
* terminators) which format string to append.
- * @param sb The <code>StringBuffer</code> to append the format string to.
- * @param status Unused.
+ * @param appendBuf The <code>StringBuffer</code> to append the format string to.
+ * @param pos Unused.
*
* @return The <code>StringBuffer</code> with the format string appended.
*/
@@ -333,7 +334,7 @@ public class ChoiceFormat extends NumberFormat
* double less than the specified double will be returned.
*
* @param d The specified double
- * @param positive <code>true</code> to return the next highest
+ * @param next <code>true</code> to return the next highest
* double, <code>false</code> otherwise.
*
* @return The next highest or lowest double value.
diff --git a/libjava/classpath/java/text/CollationElementIterator.java b/libjava/classpath/java/text/CollationElementIterator.java
index 60b148e..45c7914 100644
--- a/libjava/classpath/java/text/CollationElementIterator.java
+++ b/libjava/classpath/java/text/CollationElementIterator.java
@@ -177,9 +177,11 @@ public final class CollationElementIterator
* This method returns the primary order value for the given collation
* value.
*
- * @param value The collation value returned from <code>next()</code> or <code>previous()</code>.
+ * @param order The collation value returned from <code>next()</code> or
+ * <code>previous()</code>.
*
- * @return The primary order value of the specified collation value. This is the high 16 bits.
+ * @return The primary order value of the specified collation value. This is
+ * the high 16 bits.
*/
public static int primaryOrder(int order)
{
@@ -201,9 +203,11 @@ public final class CollationElementIterator
* This method returns the secondary order value for the given collation
* value.
*
- * @param value The collation value returned from <code>next()</code> or <code>previous()</code>.
+ * @param order The collation value returned from <code>next()</code> or
+ * <code>previous()</code>.
*
- * @return The secondary order value of the specified collation value. This is the bits 8-15.
+ * @return The secondary order value of the specified collation value. This
+ * is the bits 8-15.
*/
public static short secondaryOrder(int order)
{
@@ -215,9 +219,11 @@ public final class CollationElementIterator
* This method returns the tertiary order value for the given collation
* value.
*
- * @param value The collation value returned from <code>next()</code> or <code>previous()</code>.
+ * @param order The collation value returned from <code>next()</code> or
+ * <code>previous()</code>.
*
- * @return The tertiary order value of the specified collation value. This is the low eight bits.
+ * @return The tertiary order value of the specified collation value. This
+ * is the low eight bits.
*/
public static short tertiaryOrder(int order)
{
@@ -458,7 +464,7 @@ public final class CollationElementIterator
*
* @param value The collation order value
*
- * @param The maximum length of an expansion sequence.
+ * @return The maximum length of an expansion sequence.
*/
public int getMaxExpansion(int value)
{
diff --git a/libjava/classpath/java/text/CollationKey.java b/libjava/classpath/java/text/CollationKey.java
index f7e3a24..a467869 100644
--- a/libjava/classpath/java/text/CollationKey.java
+++ b/libjava/classpath/java/text/CollationKey.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package java.text;
+import java.util.Arrays;
+
/* Written using "Java Class Libraries", 2nd edition, plus online
* API docs for JDK 1.2 from http://www.javasoft.com.
* Status: Believed complete and correct.
@@ -154,7 +156,7 @@ public final class CollationKey implements Comparable
if (!ck.getSourceString ().equals (getSourceString ()))
return false;
- if (!ck.toByteArray ().equals (toByteArray ()))
+ if (! Arrays.equals (ck.toByteArray (), toByteArray ()))
return false;
return true;
@@ -190,7 +192,7 @@ public final class CollationKey implements Comparable
/**
* This method returns the collation bit sequence as a byte array.
*
- * @param A byte array containing the collation bit sequence.
+ * @return A byte array containing the collation bit sequence.
*/
public byte[] toByteArray()
{
diff --git a/libjava/classpath/java/text/Collator.java b/libjava/classpath/java/text/Collator.java
index 633bc67..7dea83f 100644
--- a/libjava/classpath/java/text/Collator.java
+++ b/libjava/classpath/java/text/Collator.java
@@ -150,8 +150,8 @@ public abstract class Collator implements Comparator, Cloneable
* <code>Collator</code> and the strength and decomposition rules in
* effect.
*
- * @param str1 The first object to compare
- * @param str2 The second object to compare
+ * @param source The first object to compare
+ * @param target The second object to compare
*
* @return A negative integer if str1 &lt; str2, 0 if str1 == str2, or
* a positive integer if str1 &gt; str2.
@@ -164,8 +164,8 @@ public abstract class Collator implements Comparator, Cloneable
* equal to, or greater than the second argument. These two objects
* must be <code>String</code>'s or an exception will be thrown.
*
- * @param obj1 The first object to compare
- * @param obj2 The second object to compare
+ * @param o1 The first object to compare
+ * @param o2 The second object to compare
*
* @return A negative integer if obj1 &lt; obj2, 0 if obj1 == obj2, or
* a positive integer if obj1 &gt; obj2.
@@ -208,8 +208,8 @@ public abstract class Collator implements Comparator, Cloneable
* according to the collation rules for the locale of this object and
* the current strength and decomposition settings.
*
- * @param str1 The first <code>String</code> to compare
- * @param str2 The second <code>String</code> to compare
+ * @param source The first <code>String</code> to compare
+ * @param target The second <code>String</code> to compare
*
* @return <code>true</code> if the two strings are equal,
* <code>false</code> otherwise.
@@ -256,7 +256,7 @@ public abstract class Collator implements Comparator, Cloneable
* comparisons against a string might be performed multiple times, such
* as during a sort operation.
*
- * @param str The <code>String</code> to convert.
+ * @param source The <code>String</code> to convert.
*
* @return A <code>CollationKey</code> for the specified <code>String</code>.
*/
@@ -292,7 +292,7 @@ public abstract class Collator implements Comparator, Cloneable
* specified locale. If no <code>Collator</code> exists for the desired
* locale, a <code>Collator</code> for the default locale will be returned.
*
- * @param locale The desired localed to load a <code>Collator</code> for.
+ * @param loc The desired localed to load a <code>Collator</code> for.
*
* @return A <code>Collator</code> for the requested locale
*/
@@ -347,7 +347,7 @@ public abstract class Collator implements Comparator, Cloneable
* exception will be thrown. See the documentation for those
* contants for an explanation of this setting.
*
- * @param decmp The new decomposition setting.
+ * @param mode The new decomposition setting.
*
* @exception IllegalArgumentException If the requested
* decomposition setting is not valid.
diff --git a/libjava/classpath/java/text/DateFormat.java b/libjava/classpath/java/text/DateFormat.java
index f6dfceb..5d412aa 100644
--- a/libjava/classpath/java/text/DateFormat.java
+++ b/libjava/classpath/java/text/DateFormat.java
@@ -405,8 +405,18 @@ public abstract class DateFormat extends Format implements Cloneable
* <ul>
* <li>Is not <code>null</code>.</li>
* <li>Is an instance of <code>DateFormat</code>.</li>
- * <li>Has the same numberFormat field value as this object.</li>
+ * <li>Has equal numberFormat field as this object.</li>
+ * <li>Has equal (Calendar) TimeZone rules as this object.</li>
+ * <li>Has equal (Calendar) isLenient results.</li>
+ * <li>Has equal Calendar first day of week and minimal days in week
+ * values.</li>
* </ul>
+ * Note that not all properties of the Calendar are relevant for a
+ * DateFormat. For formatting only the fact whether or not the
+ * TimeZone has the same rules and whether the calendar is lenient
+ * and has the same week rules is compared for this implementation
+ * of equals. Other properties of the Calendar (such as the time)
+ * are not taken into account.
*
* @param obj The object to test for equality against.
*
@@ -419,8 +429,24 @@ public abstract class DateFormat extends Format implements Cloneable
return false;
DateFormat d = (DateFormat) obj;
-
- return numberFormat.equals(d.numberFormat);
+ TimeZone tz = getTimeZone();
+ TimeZone tzd = d.getTimeZone();
+ if (tz.hasSameRules(tzd))
+ if (isLenient() == d.isLenient())
+ {
+ Calendar c = getCalendar();
+ Calendar cd = d.getCalendar();
+ if ((c == null && cd == null)
+ ||
+ (c.getFirstDayOfWeek() == cd.getFirstDayOfWeek()
+ &&
+ c.getMinimalDaysInFirstWeek()
+ == cd.getMinimalDaysInFirstWeek()))
+ return ((numberFormat == null && d.numberFormat == null)
+ || numberFormat.equals(d.numberFormat));
+ }
+
+ return false;
}
/**
@@ -442,9 +468,9 @@ public abstract class DateFormat extends Format implements Cloneable
* thrown.
*
* @param obj The <code>Object</code> to format.
- * @param toAppendTo The <code>StringBuffer</code> to append the resultant
+ * @param buf The <code>StringBuffer</code> to append the resultant
* <code>String</code> to.
- * @param fieldPosition Is updated to the start and end index of the
+ * @param pos Is updated to the start and end index of the
* specified field.
*
* @return The <code>StringBuffer</code> supplied on input, with the
@@ -479,9 +505,9 @@ public abstract class DateFormat extends Format implements Cloneable
* to the specified <code>StringBuffer</code>.
*
* @param date The <code>Date</code> value to format.
- * @param toAppendTo The <code>StringBuffer</code> to append the resultant
+ * @param buf The <code>StringBuffer</code> to append the resultant
* <code>String</code> to.
- * @param fieldPosition Is updated to the start and end index of the
+ * @param pos Is updated to the start and end index of the
* specified field.
*
* @return The <code>StringBuffer</code> supplied on input, with the
@@ -643,7 +669,7 @@ public abstract class DateFormat extends Format implements Cloneable
* localed will be used in place of the default.
*
* @param style The type of formatting to perform.
- * @param aLocale The desired locale.
+ * @param loc The desired locale.
*
* @return A new <code>DateFormat</code> instance.
*/
@@ -744,7 +770,7 @@ public abstract class DateFormat extends Format implements Cloneable
* localed will be used in place of the default.
*
* @param style The type of formatting to perform.
- * @param aLocale The desired locale.
+ * @param loc The desired locale.
*
* @return A new <code>DateFormat</code> instance.
*/
@@ -818,7 +844,7 @@ public abstract class DateFormat extends Format implements Cloneable
* starting parse position on method entry and the ending parse
* position on method exit.
*
- * @param text The string to parse.
+ * @param source The string to parse.
* @param pos The starting parse position in entry, the ending parse
* position on exit.
*
@@ -848,7 +874,7 @@ public abstract class DateFormat extends Format implements Cloneable
* This method specified the <code>Calendar</code> that should be used
* by this object to parse/format datetimes.
*
- * @param The new <code>Calendar</code> for this object.
+ * @param calendar The new <code>Calendar</code> for this object.
*
* @see java.util.Calendar
*/
@@ -873,7 +899,7 @@ public abstract class DateFormat extends Format implements Cloneable
* This method specifies the <code>NumberFormat</code> object that should
* be used by this object to parse/format times.
*
- * @param The <code>NumberFormat</code> in use by this object.
+ * @param numberFormat The <code>NumberFormat</code> in use by this object.
*/
public void setNumberFormat (NumberFormat numberFormat)
{
@@ -883,7 +909,7 @@ public abstract class DateFormat extends Format implements Cloneable
/**
* This method sets the time zone that should be used by this object.
*
- * @param The new time zone.
+ * @param timeZone The new time zone.
*/
public void setTimeZone (TimeZone timeZone)
{
diff --git a/libjava/classpath/java/text/DateFormatSymbols.java b/libjava/classpath/java/text/DateFormatSymbols.java
index 543a5c1..6a20b4c 100644
--- a/libjava/classpath/java/text/DateFormatSymbols.java
+++ b/libjava/classpath/java/text/DateFormatSymbols.java
@@ -41,7 +41,6 @@ package java.text;
import java.util.Locale;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
-import java.util.StringTokenizer;
/**
* This class acts as container for locale specific date/time formatting
@@ -289,7 +288,7 @@ public class DateFormatSymbols implements java.io.Serializable, Cloneable
* This is a two element <code>String</code> array indexed by
* <code>Calendar.AM</code> and <code>Calendar.PM</code>
*
- * @param ampms The new list of AM/PM display strings.
+ * @param value The new list of AM/PM display strings.
*/
public void setAmPmStrings (String[] value)
{
@@ -302,11 +301,11 @@ public class DateFormatSymbols implements java.io.Serializable, Cloneable
* This is a two element <code>String</code>
* array indexed by <code>Calendar.BC</code> and <code>Calendar.AD</code>.
*
- * @param eras The new list of era disply strings.
+ * @param labels The new list of era display strings.
*/
- public void setEras (String[] value)
+ public void setEras (String[] labels)
{
- eras = value;
+ eras = labels;
}
/**
@@ -340,11 +339,11 @@ public class DateFormatSymbols implements java.io.Serializable, Cloneable
* <li>17 - time zone (z)</li>
* </ul>
*
- * @param localPatternChars The new format patter characters
+ * @param chars The new format pattern characters
*/
- public void setLocalPatternChars (String value)
+ public void setLocalPatternChars (String chars)
{
- localPatternChars = value;
+ localPatternChars = chars;
}
/**
@@ -354,11 +353,11 @@ public class DateFormatSymbols implements java.io.Serializable, Cloneable
* <code>Calendar.UNDECEMBER</code>. Note that there are thirteen
* elements because some calendars have thriteen months.
*
- * @param months The list of month display strings.
+ * @param labels The list of month display strings.
*/
- public void setMonths (String[] value)
+ public void setMonths (String[] labels)
{
- months = value;
+ months = labels;
}
/**
@@ -369,11 +368,11 @@ public class DateFormatSymbols implements java.io.Serializable, Cloneable
* through <code>Calendar.UNDECEMBER</code>. Note that there are thirteen
* elements because some calendars have thirteen months.
*
- * @param shortMonths The new list of abbreviated month display strings.
+ * @param labels The new list of abbreviated month display strings.
*/
- public void setShortMonths (String[] value)
+ public void setShortMonths (String[] labels)
{
- shortMonths = value;
+ shortMonths = labels;
}
/**
@@ -384,11 +383,11 @@ public class DateFormatSymbols implements java.io.Serializable, Cloneable
* through <code>Calendar.SATURDAY</code>. Note that the first element
* of this array is ignored.
*
- * @param shortWeekdays This list of abbreviated weekday display strings.
+ * @param labels This list of abbreviated weekday display strings.
*/
- public void setShortWeekdays (String[] value)
+ public void setShortWeekdays (String[] labels)
{
- shortWeekdays = value;
+ shortWeekdays = labels;
}
/**
@@ -398,11 +397,11 @@ public class DateFormatSymbols implements java.io.Serializable, Cloneable
* through <code>Calendar.SATURDAY</code>. Note that the first element
* of this array is ignored.
*
- * @param weekdays This list of weekday display strings.
+ * @param labels This list of weekday display strings.
*/
- public void setWeekdays (String[] value)
+ public void setWeekdays (String[] labels)
{
- weekdays = value;
+ weekdays = labels;
}
/**
@@ -418,11 +417,11 @@ public class DateFormatSymbols implements java.io.Serializable, Cloneable
* <li>4 - the short name of the time zone (daylight savings time).</li>
* </ul>
*
- * @return The list of time zone display strings.
+ * @params zones The list of time zone display strings.
*/
- public void setZoneStrings (String[][] value)
+ public void setZoneStrings (String[][] zones)
{
- zoneStrings = value;
+ zoneStrings = zones;
}
/* Does a "deep" equality test - recurses into arrays. */
@@ -492,7 +491,7 @@ public class DateFormatSymbols implements java.io.Serializable, Cloneable
/**
* Returns a new copy of this object.
*
- * @param A copy of this object
+ * @return A copy of this object
*/
public Object clone ()
{
diff --git a/libjava/classpath/java/text/DecimalFormatSymbols.java b/libjava/classpath/java/text/DecimalFormatSymbols.java
index 81ea001..a8735d3 100644
--- a/libjava/classpath/java/text/DecimalFormatSymbols.java
+++ b/libjava/classpath/java/text/DecimalFormatSymbols.java
@@ -139,7 +139,7 @@ public final class DecimalFormatSymbols implements Cloneable, Serializable
* locales (those with no specified country), such as
* <code>Locale.ENGLISH</code>.
*
- * @param locale The local to load symbols for.
+ * @param loc The local to load symbols for.
* @throws NullPointerException if the locale is null.
*/
public DecimalFormatSymbols (Locale loc)
@@ -422,7 +422,7 @@ public final class DecimalFormatSymbols implements Cloneable, Serializable
/**
* This method sets the currency symbol to the specified value.
*
- * @param currencySymbol The new currency symbol
+ * @param currency The new currency symbol
*/
public void setCurrencySymbol (String currency)
{
@@ -432,7 +432,7 @@ public final class DecimalFormatSymbols implements Cloneable, Serializable
/**
* This method sets the decimal point character to the specified value.
*
- * @param decimalSeparator The new decimal point character
+ * @param decimalSep The new decimal point character
*/
public void setDecimalSeparator (char decimalSep)
{
@@ -464,7 +464,7 @@ public final class DecimalFormatSymbols implements Cloneable, Serializable
/**
* This method sets the character used to separate groups of digits.
*
- * @param groupingSeparator The character used to separate groups of digits.
+ * @param groupSep The character used to separate groups of digits.
*/
public void setGroupingSeparator (char groupSep)
{
@@ -523,8 +523,7 @@ public final class DecimalFormatSymbols implements Cloneable, Serializable
* This method sets the character used for the decimal point in currency
* values.
*
- * @param monetarySeparator The decimal point character used in
- * currency values.
+ * @param decimalSep The decimal point character used in currency values.
*/
public void setMonetaryDecimalSeparator (char decimalSep)
{
@@ -535,7 +534,7 @@ public final class DecimalFormatSymbols implements Cloneable, Serializable
* This method sets the string used to represent the NaN (not a
* number) value.
*
- * @param NaN The string used to represent NaN
+ * @param nan The string used to represent NaN
*/
public void setNaN (String nan)
{
@@ -546,7 +545,7 @@ public final class DecimalFormatSymbols implements Cloneable, Serializable
* This method sets the character used to separate positive and negative
* subpatterns in a format pattern.
*
- * @param patternSeparator The character used to separate positive and
+ * @param patternSep The character used to separate positive and
* negative subpatterns in a format pattern.
*/
public void setPatternSeparator (char patternSep)
diff --git a/libjava/classpath/java/text/MessageFormat.java b/libjava/classpath/java/text/MessageFormat.java
index f7a9f16..f59cfd5 100644
--- a/libjava/classpath/java/text/MessageFormat.java
+++ b/libjava/classpath/java/text/MessageFormat.java
@@ -334,7 +334,7 @@ public class MessageFormat extends Format
/**
* Applies the specified pattern to this MessageFormat.
*
- * @param aPattern The Pattern
+ * @param newPattern The Pattern
*/
public void applyPattern (String newPattern)
{
@@ -378,7 +378,6 @@ public class MessageFormat extends Format
/**
* A convinience method to format patterns.
*
- * @param aPattern The pattern used when formatting.
* @param arguments The array containing the objects to be formatted.
*/
public AttributedCharacterIterator formatToCharacterIterator (Object arguments)
@@ -394,7 +393,7 @@ public class MessageFormat extends Format
/**
* A convinience method to format patterns.
*
- * @param aPattern The pattern used when formatting.
+ * @param pattern The pattern used when formatting.
* @param arguments The array containing the objects to be formatted.
*/
public static String format (String pattern, Object arguments[])
@@ -408,8 +407,8 @@ public class MessageFormat extends Format
/**
* Returns the pattern with the formatted objects.
*
- * @param source The array containing the objects to be formatted.
- * @param result The StringBuffer where the text is appened.
+ * @param arguments The array containing the objects to be formatted.
+ * @param appendBuf The StringBuffer where the text is appened.
* @param fp A FieldPosition object (it is ignored).
*/
public final StringBuffer format (Object arguments[], StringBuffer appendBuf,
@@ -709,8 +708,8 @@ public class MessageFormat extends Format
* Sets the format for the argument at an specified
* index.
*
- * @param index The index.
- * @format The Format object.
+ * @param variableNum The index.
+ * @param newFormat The Format object.
*/
public void setFormat (int variableNum, Format newFormat)
{
@@ -720,7 +719,7 @@ public class MessageFormat extends Format
/**
* Sets the formats for the arguments.
*
- * @param formats An array of Format objects.
+ * @param newFormats An array of Format objects.
*/
public void setFormats (Format[] newFormats)
{
@@ -735,7 +734,7 @@ public class MessageFormat extends Format
/**
* Sets the locale.
*
- * @param locale A Locale
+ * @param loc A Locale
*/
public void setLocale (Locale loc)
{
diff --git a/libjava/classpath/java/text/NumberFormat.java b/libjava/classpath/java/text/NumberFormat.java
index a2c3997..5fede9e 100644
--- a/libjava/classpath/java/text/NumberFormat.java
+++ b/libjava/classpath/java/text/NumberFormat.java
@@ -237,7 +237,8 @@ public abstract class NumberFormat extends Format implements Cloneable
* a <code>StringBuffer</code>.
*
* @param number The <code>double</code> to format.
- * @param sb The <code>StringBuffer</code> to append the formatted number to.
+ * @param sbuf The <code>StringBuffer</code> to append the formatted number
+ * to.
* @param pos The desired <code>FieldPosition</code>.
*
* @return The <code>StringBuffer</code> with the appended number.
@@ -250,7 +251,8 @@ public abstract class NumberFormat extends Format implements Cloneable
* a <code>StringBuffer</code>.
*
* @param number The <code>long</code> to format.
- * @param sb The <code>StringBuffer</code> to append the formatted number to.
+ * @param sbuf The <code>StringBuffer</code> to append the formatted number
+ * to.
* @param pos The desired <code>FieldPosition</code>.
*
* @return The <code>StringBuffer</code> with the appended number.
@@ -371,7 +373,7 @@ public abstract class NumberFormat extends Format implements Cloneable
* will be a concrete subclass of <code>NumberFormat</code>, but the
* actual class returned is dependent on the locale.
*
- * @param locale The desired locale.
+ * @param loc The desired locale.
*
* @return An instance of the default <code>NumberFormat</code> class.
*/
@@ -434,8 +436,6 @@ public abstract class NumberFormat extends Format implements Cloneable
* will be a concrete subclass of <code>NumberFormat</code>, but the
* actual class returned is dependent on the locale.
*
- * @param locale The desired locale.
- *
* @return An instance of the default <code>NumberFormat</code> class.
*/
public static final NumberFormat getNumberInstance ()
@@ -502,7 +502,7 @@ public abstract class NumberFormat extends Format implements Cloneable
* This method returns an instance of <code>NumberFormat</code> suitable
* for formatting and parsing percentage values in the specified locale.
*
- * @param locale The desired locale.
+ * @param loc The desired locale.
*
* @return An instance of <code>NumberFormat</code> for handling percentages.
*/
@@ -571,8 +571,8 @@ public abstract class NumberFormat extends Format implements Cloneable
* <code>Double</code>. If no number can be parsed, no exception is
* thrown. Instead, the parse position remains at its initial index.
*
- * @param str The string to parse.
- * @param pp The desired <code>ParsePosition</code>.
+ * @param sourceStr The string to parse.
+ * @param pos The desired <code>ParsePosition</code>.
*
* @return The parsed <code>Number</code>
*/
@@ -584,7 +584,7 @@ public abstract class NumberFormat extends Format implements Cloneable
* <code>Double</code>. If no number can be parsed, an exception will be
* thrown.
*
- * @param str The string to parse.
+ * @param sourceStr The string to parse.
*
* @return The parsed <code>Number</code>
*
@@ -610,8 +610,8 @@ public abstract class NumberFormat extends Format implements Cloneable
* <code>Double</code>. If no number can be parsed, no exception is
* thrown. Instead, the parse position remains at its initial index.
*
- * @param str The string to parse.
- * @param pp The desired <code>ParsePosition</code>.
+ * @param sourceStr The string to parse.
+ * @param pos The desired <code>ParsePosition</code>.
*
* @return The parsed <code>Object</code>
*/
@@ -629,7 +629,7 @@ public abstract class NumberFormat extends Format implements Cloneable
* might appear as "1,000,000". (Both of these assume the US English
* locale).
*
- * @param groupingUsed <code>true</code> to enable grouping,
+ * @param newValue <code>true</code> to enable grouping,
* <code>false</code> to disable it.
*/
public void setGroupingUsed (boolean newValue)
@@ -643,11 +643,11 @@ public abstract class NumberFormat extends Format implements Cloneable
* current minimum allowed digits, the minimum allowed digits value will
* be lowered to be equal to the new maximum allowed digits value.
*
- * @param maximumFractionDigits The new maximum fraction digits value.
+ * @param digits The new maximum fraction digits value.
*/
- public void setMaximumFractionDigits (int newValue)
+ public void setMaximumFractionDigits (int digits)
{
- maximumFractionDigits = newValue;
+ maximumFractionDigits = digits;
if (getMinimumFractionDigits () > maximumFractionDigits)
setMinimumFractionDigits (maximumFractionDigits);
}
@@ -658,11 +658,11 @@ public abstract class NumberFormat extends Format implements Cloneable
* current minimum allowed digits, the minimum allowed digits value will
* be lowered to be equal to the new maximum allowed digits value.
*
- * @param maximumIntegerDigits The new maximum integer digits value.
+ * @param digits The new maximum integer digits value.
*/
- public void setMaximumIntegerDigits (int newValue)
+ public void setMaximumIntegerDigits (int digits)
{
- maximumIntegerDigits = newValue;
+ maximumIntegerDigits = digits;
if (getMinimumIntegerDigits () > maximumIntegerDigits)
setMinimumIntegerDigits (maximumIntegerDigits);
}
@@ -673,11 +673,11 @@ public abstract class NumberFormat extends Format implements Cloneable
* current maximum allowed digits, the maximum allowed digits value will
* be raised to be equal to the new minimum allowed digits value.
*
- * @param minimumFractionDigits The new minimum fraction digits value.
+ * @param digits The new minimum fraction digits value.
*/
- public void setMinimumFractionDigits (int newValue)
+ public void setMinimumFractionDigits (int digits)
{
- minimumFractionDigits = newValue;
+ minimumFractionDigits = digits;
if (getMaximumFractionDigits () < minimumFractionDigits)
setMaximumFractionDigits (minimumFractionDigits);
}
@@ -688,11 +688,11 @@ public abstract class NumberFormat extends Format implements Cloneable
* current maximum allowed digits, the maximum allowed digits value will
* be raised to be equal to the new minimum allowed digits value.
*
- * @param minimumIntegerDigits The new minimum integer digits value.
+ * @param digits The new minimum integer digits value.
*/
- public void setMinimumIntegerDigits (int newValue)
+ public void setMinimumIntegerDigits (int digits)
{
- minimumIntegerDigits = newValue;
+ minimumIntegerDigits = digits;
if (getMaximumIntegerDigits () < minimumIntegerDigits)
setMaximumIntegerDigits (minimumIntegerDigits);
}
@@ -701,7 +701,7 @@ public abstract class NumberFormat extends Format implements Cloneable
* This method sets the parsing behavior of this object to parse only
* integers or not.
*
- * @param parseIntegerOnly <code>true</code> to parse only integers,
+ * @param value <code>true</code> to parse only integers,
* <code>false</code> otherwise.
*/
public void setParseIntegerOnly (boolean value)
diff --git a/libjava/classpath/java/text/ParseException.java b/libjava/classpath/java/text/ParseException.java
index 6d014ef..4c7ad81 100644
--- a/libjava/classpath/java/text/ParseException.java
+++ b/libjava/classpath/java/text/ParseException.java
@@ -65,7 +65,7 @@ public class ParseException extends Exception
* This method initializes a new instance of <code>ParseException</code>
* with a detailed error message and a error position.
*
- * @param msg the descriptive message describing the error
+ * @param s the descriptive message describing the error
* @param offset the position where the error was encountered
*/
public ParseException(String s, int offset)
diff --git a/libjava/classpath/java/text/SimpleDateFormat.java b/libjava/classpath/java/text/SimpleDateFormat.java
index 789cb83..c0c4cf6 100644
--- a/libjava/classpath/java/text/SimpleDateFormat.java
+++ b/libjava/classpath/java/text/SimpleDateFormat.java
@@ -180,8 +180,8 @@ public class SimpleDateFormat extends DateFormat
* years to be interpreted as representing
* the years between 2004 and 2104.
*
- * @see get2DigitYearStart()
- * @see set2DigitYearStart(java.util.Date)
+ * @see #get2DigitYearStart()
+ * @see #set2DigitYearStart(java.util.Date)
* @see Date
* @serial The start date of the century for parsing two digit years.
* May not be null.
@@ -192,8 +192,8 @@ public class SimpleDateFormat extends DateFormat
* The year at which interpretation of two
* digit years starts.
*
- * @see get2DigitYearStart()
- * @see set2DigitYearStart(java.util.Date)
+ * @see #get2DigitYearStart()
+ * @see #set2DigitYearStart(java.util.Date)
* @serial Ignored.
*/
private transient int defaultCentury;
@@ -204,10 +204,10 @@ public class SimpleDateFormat extends DateFormat
* stored in standardChars. Localized patterns
* are translated to this form.
*
- * @see applyPattern(String)
- * @see applyLocalizedPattern(String)
- * @see toPattern()
- * @see toLocalizedPattern()
+ * @see #applyPattern(String)
+ * @see #applyLocalizedPattern(String)
+ * @see #toPattern()
+ * @see #toLocalizedPattern()
* @serial The non-localized pattern string. May not be null.
*/
private String pattern;
@@ -294,44 +294,73 @@ public class SimpleDateFormat extends DateFormat
int field;
CompiledField current = null;
- for (int i=0; i<pattern.length(); i++) {
- thisChar = pattern.charAt(i);
- field = standardChars.indexOf(thisChar);
- if (field == -1) {
- current = null;
- if ((thisChar >= 'A' && thisChar <= 'Z')
- || (thisChar >= 'a' && thisChar <= 'z')) {
- // Not a valid letter
- throw new IllegalArgumentException("Invalid letter " + thisChar +
- "encountered at character " + i
- + ".");
- } else if (thisChar == '\'') {
- // Quoted text section; skip to next single quote
- pos = pattern.indexOf('\'',i+1);
- if (pos == -1) {
- throw new IllegalArgumentException("Quotes starting at character "
- + i + " not closed.");
+ for (int i = 0; i < pattern.length(); i++)
+ {
+ thisChar = pattern.charAt(i);
+ field = standardChars.indexOf(thisChar);
+ if (field == -1)
+ {
+ current = null;
+ if ((thisChar >= 'A' && thisChar <= 'Z')
+ || (thisChar >= 'a' && thisChar <= 'z'))
+ {
+ // Not a valid letter
+ throw new IllegalArgumentException("Invalid letter "
+ + thisChar +
+ "encountered at character "
+ + i + ".");
+ }
+ else if (thisChar == '\'')
+ {
+ // Quoted text section; skip to next single quote
+ pos = pattern.indexOf('\'', i + 1);
+ // First look for '' -- meaning a single quote.
+ if (pos == i + 1)
+ tokens.add("'");
+ else
+ {
+ // Look for the terminating quote. However, if we
+ // see a '', that represents a literal quote and
+ // we must iterate.
+ StringBuffer buf = new StringBuffer();
+ int oldPos = i + 1;
+ do
+ {
+ if (pos == -1)
+ throw new IllegalArgumentException("Quotes starting at character "
+ + i +
+ " not closed.");
+ buf.append(pattern.substring(oldPos, pos));
+ if (pos + 1 >= pattern.length()
+ || pattern.charAt(pos + 1) != '\'')
+ break;
+ buf.append('\'');
+ oldPos = pos + 2;
+ pos = pattern.indexOf('\'', pos + 2);
+ }
+ while (true);
+ tokens.add(buf.toString());
+ }
+ i = pos;
+ }
+ else
+ {
+ // A special character
+ tokens.add(new Character(thisChar));
+ }
}
- if ((pos+1 < pattern.length()) && (pattern.charAt(pos+1) == '\'')) {
- tokens.add(pattern.substring(i+1,pos+1));
- } else {
- tokens.add(pattern.substring(i+1,pos));
+ else
+ {
+ // A valid field
+ if ((current != null) && (field == current.field))
+ current.size++;
+ else
+ {
+ current = new CompiledField(field, 1, thisChar);
+ tokens.add(current);
+ }
}
- i = pos;
- } else {
- // A special character
- tokens.add(new Character(thisChar));
- }
- } else {
- // A valid field
- if ((current != null) && (field == current.field)) {
- current.size++;
- } else {
- current = new CompiledField(field,1,thisChar);
- tokens.add(current);
- }
}
- }
}
/**
@@ -611,7 +640,7 @@ public class SimpleDateFormat extends DateFormat
* <li>Is using the same century for two digit years.</li>
* </ul>
*
- * @param obj The object to compare for equality against.
+ * @param o The object to compare for equality against.
*
* @return <code>true</code> if the specified object is equal to this object,
* <code>false</code> otherwise.
diff --git a/libjava/classpath/java/text/StringCharacterIterator.java b/libjava/classpath/java/text/StringCharacterIterator.java
index e3adc85..e267488 100644
--- a/libjava/classpath/java/text/StringCharacterIterator.java
+++ b/libjava/classpath/java/text/StringCharacterIterator.java
@@ -76,7 +76,10 @@ public final class StringCharacterIterator implements CharacterIterator
* text of the specified <code>String</code>. The initial index
* value will be set to the first character in the string.
*
- * @param text The <code>String</code> to iterate through.
+ * @param text The <code>String</code> to iterate through (<code>null</code>
+ * not permitted).
+ *
+ * @throws NullPointerException if <code>text</code> is <code>null</code>.
*/
public StringCharacterIterator (String text)
{
@@ -113,7 +116,7 @@ public final class StringCharacterIterator implements CharacterIterator
* @param end The ending position in the character range.
* @param index The initial index position.
*
- * @param IllegalArgumentException If any of the range values are
+ * @throws IllegalArgumentException If any of the range values are
* invalid.
*/
public StringCharacterIterator (String text, int begin, int end, int index)
diff --git a/libjava/classpath/java/util/Observable.java b/libjava/classpath/java/util/Observable.java
index 4c2cddb..916abe4 100644
--- a/libjava/classpath/java/util/Observable.java
+++ b/libjava/classpath/java/util/Observable.java
@@ -77,6 +77,8 @@ public class Observable
*/
public synchronized void addObserver(Observer observer)
{
+ if (observer == null)
+ throw new NullPointerException("can't add null observer");
observers.add(observer);
}
diff --git a/libjava/classpath/java/util/Properties.java b/libjava/classpath/java/util/Properties.java
index c7c19b3..f00615b 100644
--- a/libjava/classpath/java/util/Properties.java
+++ b/libjava/classpath/java/util/Properties.java
@@ -209,8 +209,12 @@ label = Name:\\u0020</pre>
{
if (pos == line.length())
{
- // The line continues on the next line.
+ // The line continues on the next line. If there
+ // is no next line, just treat it as a key with an
+ // empty value.
line = reader.readLine();
+ if (line == null)
+ line = "";
pos = 0;
while (pos < line.length()
&& Character.isWhitespace(c = line.charAt(pos)))
@@ -410,7 +414,17 @@ label = Name:\\u0020</pre>
*/
public String getProperty(String key)
{
- return getProperty(key, null);
+ Properties prop = this;
+ // Eliminate tail recursion.
+ do
+ {
+ String value = (String) prop.get(key);
+ if (value != null)
+ return value;
+ prop = prop.defaults;
+ }
+ while (prop != null);
+ return null;
}
/**
@@ -429,17 +443,10 @@ label = Name:\\u0020</pre>
*/
public String getProperty(String key, String defaultValue)
{
- Properties prop = this;
- // Eliminate tail recursion.
- do
- {
- String value = (String) prop.get(key);
- if (value != null)
- return value;
- prop = prop.defaults;
- }
- while (prop != null);
- return defaultValue;
+ String prop = getProperty(key);
+ if (prop == null)
+ prop = defaultValue;
+ return prop;
}
/**
diff --git a/libjava/classpath/java/util/TimeZone.java b/libjava/classpath/java/util/TimeZone.java
index 99df11d..95117af 100644
--- a/libjava/classpath/java/util/TimeZone.java
+++ b/libjava/classpath/java/util/TimeZone.java
@@ -197,6 +197,7 @@ public abstract class TimeZone implements java.io.Serializable, Cloneable
timezones0.put("MST", tz);
timezones0.put("MST7MDT", tz);
timezones0.put("America/Boise", tz);
+ timezones0.put("America/Cambridge_Bay", tz);
timezones0.put("America/Chihuahua", tz);
timezones0.put("America/Denver", tz);
timezones0.put("America/Edmonton", tz);
@@ -216,15 +217,15 @@ public abstract class TimeZone implements java.io.Serializable, Cloneable
Calendar.OCTOBER, -1, Calendar.SUNDAY, 2000 * 3600);
timezones0.put("CST", tz);
timezones0.put("CST6CDT", tz);
- timezones0.put("America/Cambridge_Bay", tz);
timezones0.put("America/Cancun", tz);
timezones0.put("America/Chicago", tz);
timezones0.put("America/Menominee", tz);
timezones0.put("America/Merida", tz);
timezones0.put("America/Mexico_City", tz);
timezones0.put("America/Monterrey", tz);
+ timezones0.put("America/North_Dakota/Center", tz);
timezones0.put("America/Rainy_River", tz);
- timezones0.put("America/Winnipeg", tz);
+ timezones0.put("America/Rankin_Inlet", tz);
tz = new SimpleTimeZone(-6000 * 3600, "America/Belize");
timezones0.put("America/Belize", tz);
timezones0.put("America/Costa_Rica", tz);
@@ -236,15 +237,24 @@ public abstract class TimeZone implements java.io.Serializable, Cloneable
timezones0.put("America/Tegucigalpa", tz);
timezones0.put("Pacific/Galapagos", tz);
tz = new SimpleTimeZone
+ (-6000 * 3600, "America/Winnipeg",
+ Calendar.APRIL, 1, Calendar.SUNDAY, 2000 * 3600,
+ Calendar.OCTOBER, -1, Calendar.SUNDAY, 3000 * 3600);
+ timezones0.put("America/Winnipeg", tz);
+ tz = new SimpleTimeZone
(-6000 * 3600, "Pacific/Easter",
- Calendar.OCTOBER, 9, -Calendar.SUNDAY, 0 * 3600,
- Calendar.MARCH, 9, -Calendar.SUNDAY, 0 * 3600);
+ Calendar.OCTOBER, 2, Calendar.SATURDAY, 23000 * 3600,
+ Calendar.MARCH, 2, Calendar.SATURDAY, 22000 * 3600);
timezones0.put("Pacific/Easter", tz);
tz = new SimpleTimeZone
(-5000 * 3600, "America/Grand_Turk",
Calendar.APRIL, 1, Calendar.SUNDAY, 0 * 3600,
Calendar.OCTOBER, -1, Calendar.SUNDAY, 0 * 3600);
timezones0.put("America/Grand_Turk", tz);
+ tz = new SimpleTimeZone
+ (-5000 * 3600, "America/Havana",
+ Calendar.APRIL, 1, Calendar.SUNDAY, 1000 * 3600,
+ Calendar.OCTOBER, -1, Calendar.SUNDAY, 1000 * 3600);
timezones0.put("America/Havana", tz);
tz = new SimpleTimeZone(-5000 * 3600, "EST5");
timezones0.put("EST5", tz);
@@ -258,14 +268,11 @@ public abstract class TimeZone implements java.io.Serializable, Cloneable
timezones0.put("America/Indiana/Marengo", tz);
timezones0.put("America/Indiana/Vevay", tz);
timezones0.put("America/Indianapolis", tz);
- timezones0.put("America/Iqaluit", tz);
timezones0.put("America/Jamaica", tz);
timezones0.put("America/Lima", tz);
timezones0.put("America/Panama", tz);
- timezones0.put("America/Pangnirtung", tz);
timezones0.put("America/Port-au-Prince", tz);
- timezones0.put("America/Porto_Acre", tz);
- timezones0.put("America/Rankin_Inlet", tz);
+ timezones0.put("America/Rio_Branco", tz);
tz = new SimpleTimeZone
(-5000 * 3600, "EST",
Calendar.APRIL, 1, Calendar.SUNDAY, 2000 * 3600,
@@ -273,6 +280,7 @@ public abstract class TimeZone implements java.io.Serializable, Cloneable
timezones0.put("EST", tz);
timezones0.put("EST5EDT", tz);
timezones0.put("America/Detroit", tz);
+ timezones0.put("America/Iqaluit", tz);
timezones0.put("America/Kentucky/Louisville", tz);
timezones0.put("America/Kentucky/Monticello", tz);
timezones0.put("America/Louisville", tz);
@@ -280,7 +288,9 @@ public abstract class TimeZone implements java.io.Serializable, Cloneable
timezones0.put("America/Nassau", tz);
timezones0.put("America/New_York", tz);
timezones0.put("America/Nipigon", tz);
+ timezones0.put("America/Pangnirtung", tz);
timezones0.put("America/Thunder_Bay", tz);
+ timezones0.put("America/Toronto", tz);
tz = new SimpleTimeZone(-4000 * 3600, "PRT");
timezones0.put("PRT", tz);
timezones0.put("America/Anguilla", tz);
@@ -309,13 +319,14 @@ public abstract class TimeZone implements java.io.Serializable, Cloneable
timezones0.put("America/Tortola", tz);
tz = new SimpleTimeZone
(-4000 * 3600, "America/Asuncion",
- Calendar.OCTOBER, 1, Calendar.SUNDAY, 0 * 3600,
- Calendar.FEBRUARY, -1, Calendar.SUNDAY, 0 * 3600);
+ Calendar.OCTOBER, 3, Calendar.SUNDAY, 0 * 3600,
+ Calendar.MARCH, 2, Calendar.SUNDAY, 0 * 3600);
timezones0.put("America/Asuncion", tz);
tz = new SimpleTimeZone
- (-4000 * 3600, "America/Cuiaba",
- Calendar.OCTOBER, 2, Calendar.SUNDAY, 0 * 3600,
+ (-4000 * 3600, "America/Campo_Grande",
+ Calendar.OCTOBER, 3, Calendar.SUNDAY, 0 * 3600,
Calendar.FEBRUARY, 3, Calendar.SUNDAY, 0 * 3600);
+ timezones0.put("America/Campo_Grande", tz);
timezones0.put("America/Cuiaba", tz);
tz = new SimpleTimeZone
(-4000 * 3600, "America/Goose_Bay",
@@ -323,6 +334,11 @@ public abstract class TimeZone implements java.io.Serializable, Cloneable
Calendar.OCTOBER, -1, Calendar.SUNDAY, 60000);
timezones0.put("America/Goose_Bay", tz);
tz = new SimpleTimeZone
+ (-4000 * 3600, "America/Santiago",
+ Calendar.OCTOBER, 9, -Calendar.SUNDAY, 1000 * 3600,
+ Calendar.MARCH, 9, -Calendar.SUNDAY, 0 * 3600);
+ timezones0.put("America/Santiago", tz);
+ tz = new SimpleTimeZone
(-4000 * 3600, "America/Glace_Bay",
Calendar.APRIL, 1, Calendar.SUNDAY, 2000 * 3600,
Calendar.OCTOBER, -1, Calendar.SUNDAY, 2000 * 3600);
@@ -331,15 +347,14 @@ public abstract class TimeZone implements java.io.Serializable, Cloneable
timezones0.put("America/Thule", tz);
timezones0.put("Atlantic/Bermuda", tz);
tz = new SimpleTimeZone
- (-4000 * 3600, "America/Santiago",
+ (-4000 * 3600, "Antarctica/Palmer",
Calendar.OCTOBER, 9, -Calendar.SUNDAY, 0 * 3600,
Calendar.MARCH, 9, -Calendar.SUNDAY, 0 * 3600);
- timezones0.put("America/Santiago", tz);
timezones0.put("Antarctica/Palmer", tz);
tz = new SimpleTimeZone
(-4000 * 3600, "Atlantic/Stanley",
- Calendar.SEPTEMBER, 2, Calendar.SUNDAY, 0 * 3600,
- Calendar.APRIL, 16, -Calendar.SUNDAY, 0 * 3600);
+ Calendar.SEPTEMBER, 1, Calendar.SUNDAY, 2000 * 3600,
+ Calendar.APRIL, 3, Calendar.SUNDAY, 2000 * 3600);
timezones0.put("Atlantic/Stanley", tz);
tz = new SimpleTimeZone
(-3500 * 3600, "CNT",
@@ -348,48 +363,54 @@ public abstract class TimeZone implements java.io.Serializable, Cloneable
timezones0.put("CNT", tz);
timezones0.put("America/St_Johns", tz);
tz = new SimpleTimeZone
- (-3000 * 3600, "America/Araguaina",
- Calendar.OCTOBER, 2, Calendar.SUNDAY, 0 * 3600,
+ (-3000 * 3600, "America/Godthab",
+ Calendar.MARCH, 30, -Calendar.SATURDAY, 23000 * 3600,
+ Calendar.OCTOBER, 30, -Calendar.SATURDAY, 23000 * 3600);
+ timezones0.put("America/Godthab", tz);
+ tz = new SimpleTimeZone
+ (-3000 * 3600, "America/Miquelon",
+ Calendar.APRIL, 1, Calendar.SUNDAY, 2000 * 3600,
+ Calendar.OCTOBER, -1, Calendar.SUNDAY, 2000 * 3600);
+ timezones0.put("America/Miquelon", tz);
+ tz = new SimpleTimeZone
+ (-3000 * 3600, "America/Sao_Paulo",
+ Calendar.OCTOBER, 3, Calendar.SUNDAY, 0 * 3600,
Calendar.FEBRUARY, 3, Calendar.SUNDAY, 0 * 3600);
- timezones0.put("America/Araguaina", tz);
timezones0.put("America/Sao_Paulo", tz);
tz = new SimpleTimeZone(-3000 * 3600, "AGT");
timezones0.put("AGT", tz);
+ timezones0.put("America/Araguaina", tz);
+ timezones0.put("America/Argentina/Buenos_Aires", tz);
+ timezones0.put("America/Argentina/Catamarca", tz);
+ timezones0.put("America/Argentina/ComodRivadavia", tz);
+ timezones0.put("America/Argentina/Cordoba", tz);
+ timezones0.put("America/Argentina/Jujuy", tz);
+ timezones0.put("America/Argentina/La_Rioja", tz);
+ timezones0.put("America/Argentina/Mendoza", tz);
+ timezones0.put("America/Argentina/Rio_Gallegos", tz);
+ timezones0.put("America/Argentina/San_Juan", tz);
+ timezones0.put("America/Argentina/Tucuman", tz);
+ timezones0.put("America/Argentina/Ushuaia", tz);
+ timezones0.put("America/Bahia", tz);
timezones0.put("America/Belem", tz);
- timezones0.put("America/Buenos_Aires", tz);
- timezones0.put("America/Catamarca", tz);
timezones0.put("America/Cayenne", tz);
- timezones0.put("America/Cordoba", tz);
timezones0.put("America/Fortaleza", tz);
- timezones0.put("America/Jujuy", tz);
timezones0.put("America/Maceio", tz);
- timezones0.put("America/Mendoza", tz);
timezones0.put("America/Montevideo", tz);
timezones0.put("America/Paramaribo", tz);
timezones0.put("America/Recife", tz);
- timezones0.put("America/Rosario", tz);
- tz = new SimpleTimeZone
- (-3000 * 3600, "America/Godthab",
- Calendar.MARCH, 30, -Calendar.SATURDAY, 22000 * 3600,
- Calendar.OCTOBER, 30, -Calendar.SATURDAY, 22000 * 3600);
- timezones0.put("America/Godthab", tz);
- tz = new SimpleTimeZone
- (-3000 * 3600, "America/Miquelon",
- Calendar.APRIL, 1, Calendar.SUNDAY, 2000 * 3600,
- Calendar.OCTOBER, -1, Calendar.SUNDAY, 2000 * 3600);
- timezones0.put("America/Miquelon", tz);
+ timezones0.put("Antarctica/Rothera", tz);
tz = new SimpleTimeZone(-2000 * 3600, "America/Noronha");
timezones0.put("America/Noronha", tz);
timezones0.put("Atlantic/South_Georgia", tz);
tz = new SimpleTimeZone
(-1000 * 3600, "America/Scoresbysund",
- Calendar.MARCH, -1, Calendar.SUNDAY, 0 * 3600,
- Calendar.OCTOBER, -1, Calendar.SUNDAY, 0 * 3600);
+ Calendar.MARCH, -1, Calendar.SUNDAY, 1000 * 3600,
+ Calendar.OCTOBER, -1, Calendar.SUNDAY, 1000 * 3600);
timezones0.put("America/Scoresbysund", tz);
timezones0.put("Atlantic/Azores", tz);
tz = new SimpleTimeZone(-1000 * 3600, "Atlantic/Cape_Verde");
timezones0.put("Atlantic/Cape_Verde", tz);
- timezones0.put("Atlantic/Jan_Mayen", tz);
tz = new SimpleTimeZone(0 * 3600, "GMT");
timezones0.put("GMT", tz);
timezones0.put("UTC", tz);
@@ -409,6 +430,7 @@ public abstract class TimeZone implements java.io.Serializable, Cloneable
timezones0.put("Africa/Ouagadougou", tz);
timezones0.put("Africa/Sao_Tome", tz);
timezones0.put("Africa/Timbuktu", tz);
+ timezones0.put("America/Danmarkshavn", tz);
timezones0.put("Atlantic/Reykjavik", tz);
timezones0.put("Atlantic/St_Helena", tz);
timezones0.put("Europe/Belfast", tz);
@@ -416,8 +438,8 @@ public abstract class TimeZone implements java.io.Serializable, Cloneable
timezones0.put("Europe/London", tz);
tz = new SimpleTimeZone
(0 * 3600, "WET",
- Calendar.MARCH, -1, Calendar.SUNDAY, 1000 * 3600,
- Calendar.OCTOBER, -1, Calendar.SUNDAY, 1000 * 3600);
+ Calendar.MARCH, -1, Calendar.SUNDAY, 2000 * 3600,
+ Calendar.OCTOBER, -1, Calendar.SUNDAY, 2000 * 3600);
timezones0.put("WET", tz);
timezones0.put("Atlantic/Canary", tz);
timezones0.put("Atlantic/Faeroe", tz);
@@ -444,14 +466,14 @@ public abstract class TimeZone implements java.io.Serializable, Cloneable
timezones0.put("Africa/Windhoek", tz);
tz = new SimpleTimeZone
(1000 * 3600, "CET",
- Calendar.MARCH, -1, Calendar.SUNDAY, 2000 * 3600,
- Calendar.OCTOBER, -1, Calendar.SUNDAY, 2000 * 3600);
+ Calendar.MARCH, -1, Calendar.SUNDAY, 3000 * 3600,
+ Calendar.OCTOBER, -1, Calendar.SUNDAY, 3000 * 3600);
timezones0.put("CET", tz);
- timezones0.put("CEST", tz);
timezones0.put("ECT", tz);
timezones0.put("MET", tz);
timezones0.put("Africa/Ceuta", tz);
timezones0.put("Arctic/Longyearbyen", tz);
+ timezones0.put("Atlantic/Jan_Mayen", tz);
timezones0.put("Europe/Amsterdam", tz);
timezones0.put("Europe/Andorra", tz);
timezones0.put("Europe/Belgrade", tz);
@@ -483,8 +505,8 @@ public abstract class TimeZone implements java.io.Serializable, Cloneable
timezones0.put("Europe/Zurich", tz);
tz = new SimpleTimeZone
(2000 * 3600, "ART",
- Calendar.APRIL, -1, Calendar.FRIDAY, 0 * 3600,
- Calendar.SEPTEMBER, -1, Calendar.THURSDAY, 23000 * 3600);
+ Calendar.APRIL, -1, Calendar.FRIDAY, 1000 * 3600,
+ Calendar.SEPTEMBER, -1, Calendar.THURSDAY, 24000 * 3600);
timezones0.put("ART", tz);
timezones0.put("Africa/Cairo", tz);
tz = new SimpleTimeZone(2000 * 3600, "CAT");
@@ -501,13 +523,11 @@ public abstract class TimeZone implements java.io.Serializable, Cloneable
timezones0.put("Africa/Maseru", tz);
timezones0.put("Africa/Mbabane", tz);
timezones0.put("Africa/Tripoli", tz);
- timezones0.put("Europe/Riga", tz);
- timezones0.put("Europe/Tallinn", tz);
- timezones0.put("Europe/Vilnius", tz);
+ timezones0.put("Asia/Jerusalem", tz);
tz = new SimpleTimeZone
(2000 * 3600, "Asia/Amman",
- Calendar.MARCH, -1, Calendar.THURSDAY, 0 * 3600,
- Calendar.SEPTEMBER, -1, Calendar.THURSDAY, 0 * 3600);
+ Calendar.MARCH, -1, Calendar.THURSDAY, 1000 * 3600,
+ Calendar.SEPTEMBER, -1, Calendar.THURSDAY, 1000 * 3600);
timezones0.put("Asia/Amman", tz);
tz = new SimpleTimeZone
(2000 * 3600, "Asia/Beirut",
@@ -525,14 +545,9 @@ public abstract class TimeZone implements java.io.Serializable, Cloneable
Calendar.OCTOBER, 3, Calendar.FRIDAY, 0 * 3600);
timezones0.put("Asia/Gaza", tz);
tz = new SimpleTimeZone
- (2000 * 3600, "Asia/Jerusalem",
- Calendar.APRIL, 1, 0, 1000 * 3600,
- Calendar.OCTOBER, 1, 0, 1000 * 3600);
- timezones0.put("Asia/Jerusalem", tz);
- tz = new SimpleTimeZone
(2000 * 3600, "EET",
- Calendar.MARCH, -1, Calendar.SUNDAY, 3000 * 3600,
- Calendar.OCTOBER, -1, Calendar.SUNDAY, 3000 * 3600);
+ Calendar.MARCH, -1, Calendar.SUNDAY, 4000 * 3600,
+ Calendar.OCTOBER, -1, Calendar.SUNDAY, 4000 * 3600);
timezones0.put("EET", tz);
timezones0.put("Asia/Istanbul", tz);
timezones0.put("Asia/Nicosia", tz);
@@ -542,28 +557,32 @@ public abstract class TimeZone implements java.io.Serializable, Cloneable
timezones0.put("Europe/Helsinki", tz);
timezones0.put("Europe/Istanbul", tz);
timezones0.put("Europe/Kiev", tz);
+ timezones0.put("Europe/Mariehamn", tz);
timezones0.put("Europe/Nicosia", tz);
+ timezones0.put("Europe/Riga", tz);
timezones0.put("Europe/Simferopol", tz);
timezones0.put("Europe/Sofia", tz);
+ timezones0.put("Europe/Tallinn", tz);
timezones0.put("Europe/Uzhgorod", tz);
+ timezones0.put("Europe/Vilnius", tz);
timezones0.put("Europe/Zaporozhye", tz);
tz = new SimpleTimeZone
(2000 * 3600, "Europe/Kaliningrad",
- Calendar.MARCH, -1, Calendar.SUNDAY, 2000 * 3600,
- Calendar.OCTOBER, -1, Calendar.SUNDAY, 2000 * 3600);
+ Calendar.MARCH, -1, Calendar.SUNDAY, 3000 * 3600,
+ Calendar.OCTOBER, -1, Calendar.SUNDAY, 3000 * 3600);
timezones0.put("Europe/Kaliningrad", tz);
timezones0.put("Europe/Minsk", tz);
tz = new SimpleTimeZone
(3000 * 3600, "Asia/Baghdad",
- Calendar.APRIL, 1, 0, 3000 * 3600,
- Calendar.OCTOBER, 1, 0, 3000 * 3600);
+ Calendar.APRIL, 1, 0, 4000 * 3600,
+ Calendar.OCTOBER, 1, 0, 4000 * 3600);
timezones0.put("Asia/Baghdad", tz);
tz = new SimpleTimeZone
- (3000 * 3600, "Europe/Moscow",
- Calendar.MARCH, -1, Calendar.SUNDAY, 2000 * 3600,
- Calendar.OCTOBER, -1, Calendar.SUNDAY, 2000 * 3600);
+ (3000 * 3600, "Asia/Tbilisi",
+ Calendar.MARCH, -1, Calendar.SUNDAY, 3000 * 3600,
+ Calendar.OCTOBER, -1, Calendar.SUNDAY, 3000 * 3600);
+ timezones0.put("Asia/Tbilisi", tz);
timezones0.put("Europe/Moscow", tz);
- timezones0.put("Europe/Tiraspol", tz);
tz = new SimpleTimeZone(3000 * 3600, "EAT");
timezones0.put("EAT", tz);
timezones0.put("Africa/Addis_Ababa", tz);
@@ -591,49 +610,40 @@ public abstract class TimeZone implements java.io.Serializable, Cloneable
Calendar.OCTOBER, -1, Calendar.SUNDAY, 1000 * 3600);
timezones0.put("Asia/Baku", tz);
tz = new SimpleTimeZone
- (4000 * 3600, "Asia/Aqtau",
- Calendar.MARCH, -1, Calendar.SUNDAY, 0 * 3600,
- Calendar.OCTOBER, -1, Calendar.SUNDAY, 0 * 3600);
- timezones0.put("Asia/Aqtau", tz);
- timezones0.put("Asia/Tbilisi", tz);
- tz = new SimpleTimeZone
(4000 * 3600, "Asia/Yerevan",
- Calendar.MARCH, -1, Calendar.SUNDAY, 2000 * 3600,
- Calendar.OCTOBER, -1, Calendar.SUNDAY, 2000 * 3600);
+ Calendar.MARCH, -1, Calendar.SUNDAY, 3000 * 3600,
+ Calendar.OCTOBER, -1, Calendar.SUNDAY, 3000 * 3600);
timezones0.put("Asia/Yerevan", tz);
timezones0.put("Europe/Samara", tz);
tz = new SimpleTimeZone(4000 * 3600, "NET");
timezones0.put("NET", tz);
+ timezones0.put("Asia/Aqtau", tz);
timezones0.put("Asia/Dubai", tz);
timezones0.put("Asia/Muscat", tz);
+ timezones0.put("Asia/Oral", tz);
timezones0.put("Indian/Mahe", tz);
timezones0.put("Indian/Mauritius", tz);
timezones0.put("Indian/Reunion", tz);
tz = new SimpleTimeZone(4500 * 3600, "Asia/Kabul");
timezones0.put("Asia/Kabul", tz);
tz = new SimpleTimeZone
- (5000 * 3600, "Asia/Aqtobe",
- Calendar.MARCH, -1, Calendar.SUNDAY, 0 * 3600,
- Calendar.OCTOBER, -1, Calendar.SUNDAY, 0 * 3600);
- timezones0.put("Asia/Aqtobe", tz);
- tz = new SimpleTimeZone
(5000 * 3600, "Asia/Bishkek",
Calendar.MARCH, -1, Calendar.SUNDAY, 2500 * 3600,
Calendar.OCTOBER, -1, Calendar.SUNDAY, 2500 * 3600);
timezones0.put("Asia/Bishkek", tz);
tz = new SimpleTimeZone
(5000 * 3600, "Asia/Yekaterinburg",
- Calendar.MARCH, -1, Calendar.SUNDAY, 2000 * 3600,
- Calendar.OCTOBER, -1, Calendar.SUNDAY, 2000 * 3600);
+ Calendar.MARCH, -1, Calendar.SUNDAY, 3000 * 3600,
+ Calendar.OCTOBER, -1, Calendar.SUNDAY, 3000 * 3600);
timezones0.put("Asia/Yekaterinburg", tz);
tz = new SimpleTimeZone(5000 * 3600, "PLT");
timezones0.put("PLT", tz);
+ timezones0.put("Asia/Aqtobe", tz);
timezones0.put("Asia/Ashgabat", tz);
timezones0.put("Asia/Dushanbe", tz);
timezones0.put("Asia/Karachi", tz);
timezones0.put("Asia/Samarkand", tz);
timezones0.put("Asia/Tashkent", tz);
- timezones0.put("Indian/Chagos", tz);
timezones0.put("Indian/Kerguelen", tz);
timezones0.put("Indian/Maldives", tz);
tz = new SimpleTimeZone(5500 * 3600, "IST");
@@ -644,18 +654,17 @@ public abstract class TimeZone implements java.io.Serializable, Cloneable
tz = new SimpleTimeZone(6000 * 3600, "BST");
timezones0.put("BST", tz);
timezones0.put("Antarctica/Mawson", tz);
+ timezones0.put("Antarctica/Vostok", tz);
+ timezones0.put("Asia/Almaty", tz);
timezones0.put("Asia/Colombo", tz);
timezones0.put("Asia/Dhaka", tz);
+ timezones0.put("Asia/Qyzylorda", tz);
timezones0.put("Asia/Thimphu", tz);
- tz = new SimpleTimeZone
- (6000 * 3600, "Asia/Almaty",
- Calendar.MARCH, -1, Calendar.SUNDAY, 0 * 3600,
- Calendar.OCTOBER, -1, Calendar.SUNDAY, 0 * 3600);
- timezones0.put("Asia/Almaty", tz);
+ timezones0.put("Indian/Chagos", tz);
tz = new SimpleTimeZone
(6000 * 3600, "Asia/Novosibirsk",
- Calendar.MARCH, -1, Calendar.SUNDAY, 2000 * 3600,
- Calendar.OCTOBER, -1, Calendar.SUNDAY, 2000 * 3600);
+ Calendar.MARCH, -1, Calendar.SUNDAY, 3000 * 3600,
+ Calendar.OCTOBER, -1, Calendar.SUNDAY, 3000 * 3600);
timezones0.put("Asia/Novosibirsk", tz);
timezones0.put("Asia/Omsk", tz);
tz = new SimpleTimeZone(6500 * 3600, "Asia/Rangoon");
@@ -665,41 +674,55 @@ public abstract class TimeZone implements java.io.Serializable, Cloneable
timezones0.put("VST", tz);
timezones0.put("Antarctica/Davis", tz);
timezones0.put("Asia/Bangkok", tz);
- timezones0.put("Asia/Hovd", tz);
timezones0.put("Asia/Jakarta", tz);
timezones0.put("Asia/Phnom_Penh", tz);
+ timezones0.put("Asia/Pontianak", tz);
timezones0.put("Asia/Saigon", tz);
timezones0.put("Asia/Vientiane", tz);
timezones0.put("Indian/Christmas", tz);
tz = new SimpleTimeZone
+ (7000 * 3600, "Asia/Hovd",
+ Calendar.MARCH, -1, Calendar.SATURDAY, 2000 * 3600,
+ Calendar.SEPTEMBER, -1, Calendar.SATURDAY, 2000 * 3600);
+ timezones0.put("Asia/Hovd", tz);
+ tz = new SimpleTimeZone
(7000 * 3600, "Asia/Krasnoyarsk",
- Calendar.MARCH, -1, Calendar.SUNDAY, 2000 * 3600,
- Calendar.OCTOBER, -1, Calendar.SUNDAY, 2000 * 3600);
+ Calendar.MARCH, -1, Calendar.SUNDAY, 3000 * 3600,
+ Calendar.OCTOBER, -1, Calendar.SUNDAY, 3000 * 3600);
timezones0.put("Asia/Krasnoyarsk", tz);
tz = new SimpleTimeZone(8000 * 3600, "CTT");
timezones0.put("CTT", tz);
timezones0.put("Antarctica/Casey", tz);
timezones0.put("Asia/Brunei", tz);
- timezones0.put("Asia/Chungking", tz);
+ timezones0.put("Asia/Chongqing", tz);
timezones0.put("Asia/Harbin", tz);
timezones0.put("Asia/Hong_Kong", tz);
timezones0.put("Asia/Kashgar", tz);
timezones0.put("Asia/Kuala_Lumpur", tz);
timezones0.put("Asia/Kuching", tz);
- timezones0.put("Asia/Macao", tz);
+ timezones0.put("Asia/Macau", tz);
+ timezones0.put("Asia/Makassar", tz);
timezones0.put("Asia/Manila", tz);
timezones0.put("Asia/Shanghai", tz);
timezones0.put("Asia/Singapore", tz);
timezones0.put("Asia/Taipei", tz);
- timezones0.put("Asia/Ujung_Pandang", tz);
- timezones0.put("Asia/Ulaanbaatar", tz);
timezones0.put("Asia/Urumqi", tz);
timezones0.put("Australia/Perth", tz);
tz = new SimpleTimeZone
(8000 * 3600, "Asia/Irkutsk",
- Calendar.MARCH, -1, Calendar.SUNDAY, 2000 * 3600,
- Calendar.OCTOBER, -1, Calendar.SUNDAY, 2000 * 3600);
+ Calendar.MARCH, -1, Calendar.SUNDAY, 3000 * 3600,
+ Calendar.OCTOBER, -1, Calendar.SUNDAY, 3000 * 3600);
timezones0.put("Asia/Irkutsk", tz);
+ tz = new SimpleTimeZone
+ (8000 * 3600, "Asia/Ulaanbaatar",
+ Calendar.MARCH, -1, Calendar.SATURDAY, 2000 * 3600,
+ Calendar.SEPTEMBER, -1, Calendar.SATURDAY, 2000 * 3600);
+ timezones0.put("Asia/Ulaanbaatar", tz);
+ tz = new SimpleTimeZone
+ (9000 * 3600, "Asia/Choibalsan",
+ Calendar.MARCH, -1, Calendar.SATURDAY, 2000 * 3600,
+ Calendar.SEPTEMBER, -1, Calendar.SATURDAY, 2000 * 3600);
+ timezones0.put("Asia/Choibalsan", tz);
tz = new SimpleTimeZone(9000 * 3600, "JST");
timezones0.put("JST", tz);
timezones0.put("Asia/Dili", tz);
@@ -710,13 +733,13 @@ public abstract class TimeZone implements java.io.Serializable, Cloneable
timezones0.put("Pacific/Palau", tz);
tz = new SimpleTimeZone
(9000 * 3600, "Asia/Yakutsk",
- Calendar.MARCH, -1, Calendar.SUNDAY, 2000 * 3600,
- Calendar.OCTOBER, -1, Calendar.SUNDAY, 2000 * 3600);
+ Calendar.MARCH, -1, Calendar.SUNDAY, 3000 * 3600,
+ Calendar.OCTOBER, -1, Calendar.SUNDAY, 3000 * 3600);
timezones0.put("Asia/Yakutsk", tz);
tz = new SimpleTimeZone
(9500 * 3600, "Australia/Adelaide",
- Calendar.OCTOBER, -1, Calendar.SUNDAY, 2000 * 3600,
- Calendar.MARCH, -1, Calendar.SUNDAY, 2000 * 3600);
+ Calendar.OCTOBER, -1, Calendar.SUNDAY, 3000 * 3600,
+ Calendar.MARCH, -1, Calendar.SUNDAY, 3000 * 3600);
timezones0.put("Australia/Adelaide", tz);
timezones0.put("Australia/Broken_Hill", tz);
tz = new SimpleTimeZone(9500 * 3600, "ACT");
@@ -732,31 +755,32 @@ public abstract class TimeZone implements java.io.Serializable, Cloneable
timezones0.put("Pacific/Truk", tz);
timezones0.put("Pacific/Yap", tz);
tz = new SimpleTimeZone
- (10000 * 3600, "Asia/Vladivostok",
- Calendar.MARCH, -1, Calendar.SUNDAY, 2000 * 3600,
- Calendar.OCTOBER, -1, Calendar.SUNDAY, 2000 * 3600);
+ (10000 * 3600, "Asia/Sakhalin",
+ Calendar.MARCH, -1, Calendar.SUNDAY, 3000 * 3600,
+ Calendar.OCTOBER, -1, Calendar.SUNDAY, 3000 * 3600);
+ timezones0.put("Asia/Sakhalin", tz);
timezones0.put("Asia/Vladivostok", tz);
tz = new SimpleTimeZone
(10000 * 3600, "Australia/Hobart",
- Calendar.OCTOBER, 1, Calendar.SUNDAY, 2000 * 3600,
- Calendar.MARCH, -1, Calendar.SUNDAY, 2000 * 3600);
+ Calendar.OCTOBER, 1, Calendar.SUNDAY, 3000 * 3600,
+ Calendar.MARCH, -1, Calendar.SUNDAY, 3000 * 3600);
timezones0.put("Australia/Hobart", tz);
tz = new SimpleTimeZone
(10000 * 3600, "AET",
- Calendar.OCTOBER, -1, Calendar.SUNDAY, 2000 * 3600,
- Calendar.MARCH, -1, Calendar.SUNDAY, 2000 * 3600);
+ Calendar.OCTOBER, -1, Calendar.SUNDAY, 3000 * 3600,
+ Calendar.MARCH, -1, Calendar.SUNDAY, 3000 * 3600);
timezones0.put("AET", tz);
timezones0.put("Australia/Melbourne", tz);
timezones0.put("Australia/Sydney", tz);
tz = new SimpleTimeZone
(10500 * 3600, "Australia/Lord_Howe",
- Calendar.OCTOBER, -1, Calendar.SUNDAY, 2000 * 3600,
- Calendar.MARCH, -1, Calendar.SUNDAY, 2000 * 3600, 500 * 3600);
+ Calendar.OCTOBER, -1, Calendar.SUNDAY, 2000 * 3600,
+ Calendar.MARCH, -1, Calendar.SUNDAY, 2000 * 3600, 500 * 3600);
timezones0.put("Australia/Lord_Howe", tz);
tz = new SimpleTimeZone
(11000 * 3600, "Asia/Magadan",
- Calendar.MARCH, -1, Calendar.SUNDAY, 2000 * 3600,
- Calendar.OCTOBER, -1, Calendar.SUNDAY, 2000 * 3600);
+ Calendar.MARCH, -1, Calendar.SUNDAY, 3000 * 3600,
+ Calendar.OCTOBER, -1, Calendar.SUNDAY, 3000 * 3600);
timezones0.put("Asia/Magadan", tz);
tz = new SimpleTimeZone(11000 * 3600, "SST");
timezones0.put("SST", tz);
@@ -769,16 +793,16 @@ public abstract class TimeZone implements java.io.Serializable, Cloneable
timezones0.put("Pacific/Norfolk", tz);
tz = new SimpleTimeZone
(12000 * 3600, "NST",
- Calendar.OCTOBER, 1, Calendar.SUNDAY, 2000 * 3600,
- Calendar.MARCH, 3, Calendar.SUNDAY, 2000 * 3600);
+ Calendar.OCTOBER, 1, Calendar.SUNDAY, 3000 * 3600,
+ Calendar.MARCH, 3, Calendar.SUNDAY, 3000 * 3600);
timezones0.put("NST", tz);
timezones0.put("Antarctica/McMurdo", tz);
timezones0.put("Antarctica/South_Pole", tz);
timezones0.put("Pacific/Auckland", tz);
tz = new SimpleTimeZone
(12000 * 3600, "Asia/Anadyr",
- Calendar.MARCH, -1, Calendar.SUNDAY, 2000 * 3600,
- Calendar.OCTOBER, -1, Calendar.SUNDAY, 2000 * 3600);
+ Calendar.MARCH, -1, Calendar.SUNDAY, 3000 * 3600,
+ Calendar.OCTOBER, -1, Calendar.SUNDAY, 3000 * 3600);
timezones0.put("Asia/Anadyr", tz);
timezones0.put("Asia/Kamchatka", tz);
tz = new SimpleTimeZone(12000 * 3600, "Pacific/Fiji");
@@ -792,8 +816,8 @@ public abstract class TimeZone implements java.io.Serializable, Cloneable
timezones0.put("Pacific/Wallis", tz);
tz = new SimpleTimeZone
(12750 * 3600, "Pacific/Chatham",
- Calendar.OCTOBER, 1, Calendar.SUNDAY, 2750 * 3600,
- Calendar.MARCH, 3, Calendar.SUNDAY, 2750 * 3600);
+ Calendar.OCTOBER, 1, Calendar.SUNDAY, 3750 * 3600,
+ Calendar.MARCH, 3, Calendar.SUNDAY, 3750 * 3600);
timezones0.put("Pacific/Chatham", tz);
tz = new SimpleTimeZone(13000 * 3600, "Pacific/Enderbury");
timezones0.put("Pacific/Enderbury", tz);
diff --git a/libjava/classpath/java/util/Vector.java b/libjava/classpath/java/util/Vector.java
index e26d7aa..67549f0 100644
--- a/libjava/classpath/java/util/Vector.java
+++ b/libjava/classpath/java/util/Vector.java
@@ -164,10 +164,10 @@ public class Vector extends AbstractList
}
/**
- * Copies the contents of a provided array into the Vector. If the
- * array is too large to fit in the Vector, an IndexOutOfBoundsException
- * is thrown without modifying the array. Old elements in the Vector are
- * overwritten by the new elements.
+ * Copies the contents of the Vector into the provided array. If the
+ * array is too small to fit all the elements in the Vector, an
+ * {@link IndexOutOfBoundsException} is thrown without modifying the array.
+ * Old elements in the array are overwritten by the new elements.
*
* @param a target array for the copy
* @throws IndexOutOfBoundsException the array is not large enough
diff --git a/libjava/classpath/java/util/jar/JarFile.java b/libjava/classpath/java/util/jar/JarFile.java
index a9ad21e..7ccbc60 100644
--- a/libjava/classpath/java/util/jar/JarFile.java
+++ b/libjava/classpath/java/util/jar/JarFile.java
@@ -1,5 +1,5 @@
/* JarFile.java - Representation of a jar file
- Copyright (C) 2000, 2003, 2004 Free Software Foundation, Inc.
+ Copyright (C) 2000, 2003, 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -351,7 +351,7 @@ public class JarFile extends ZipFile
synchronized(jarfile)
{
- if (!jarfile.signaturesRead)
+ if (jarfile.verify && !jarfile.signaturesRead)
try
{
jarfile.readSignatures();
@@ -408,7 +408,7 @@ public class JarFile extends ZipFile
jarEntry.attr = manifest.getAttributes(name);
}
- if (!signaturesRead)
+ if (verify && !signaturesRead)
try
{
readSignatures();
diff --git a/libjava/classpath/java/util/logging/Logger.java b/libjava/classpath/java/util/logging/Logger.java
index ae985a9..367faad 100644
--- a/libjava/classpath/java/util/logging/Logger.java
+++ b/libjava/classpath/java/util/logging/Logger.java
@@ -577,7 +577,8 @@ public class Logger
public void log(Level level, String message)
{
- log(level, message, (Object[]) null);
+ if (isLoggable(level))
+ log(level, message, (Object[]) null);
}
@@ -585,12 +586,15 @@ public class Logger
String message,
Object param)
{
- StackTraceElement caller = getCallerStackFrame();
- logp(level,
- caller != null ? caller.getClassName() : "<unknown>",
- caller != null ? caller.getMethodName() : "<unknown>",
- message,
- param);
+ if (isLoggable(level))
+ {
+ StackTraceElement caller = getCallerStackFrame();
+ logp(level,
+ caller != null ? caller.getClassName() : "<unknown>",
+ caller != null ? caller.getMethodName() : "<unknown>",
+ message,
+ param);
+ }
}
@@ -598,12 +602,15 @@ public class Logger
String message,
Object[] params)
{
- StackTraceElement caller = getCallerStackFrame();
- logp(level,
- caller != null ? caller.getClassName() : "<unknown>",
- caller != null ? caller.getMethodName() : "<unknown>",
- message,
- params);
+ if (isLoggable(level))
+ {
+ StackTraceElement caller = getCallerStackFrame();
+ logp(level,
+ caller != null ? caller.getClassName() : "<unknown>",
+ caller != null ? caller.getMethodName() : "<unknown>",
+ message,
+ params);
+ }
}
@@ -611,12 +618,15 @@ public class Logger
String message,
Throwable thrown)
{
- StackTraceElement caller = getCallerStackFrame();
- logp(level,
- caller != null ? caller.getClassName() : "<unknown>",
- caller != null ? caller.getMethodName() : "<unknown>",
- message,
- thrown);
+ if (isLoggable(level))
+ {
+ StackTraceElement caller = getCallerStackFrame();
+ logp(level,
+ caller != null ? caller.getClassName() : "<unknown>",
+ caller != null ? caller.getMethodName() : "<unknown>",
+ message,
+ thrown);
+ }
}
diff --git a/libjava/classpath/java/util/zip/DeflaterHuffman.java b/libjava/classpath/java/util/zip/DeflaterHuffman.java
index d040dde..32c10b6 100644
--- a/libjava/classpath/java/util/zip/DeflaterHuffman.java
+++ b/libjava/classpath/java/util/zip/DeflaterHuffman.java
@@ -1,5 +1,5 @@
/* DeflaterHuffman.java --
- Copyright (C) 2001, 2004 Free Software Foundation, Inc.
+ Copyright (C) 2001, 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -59,7 +59,7 @@ class DeflaterHuffman
private static final int[] BL_ORDER =
{ 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 };
- private static String bit4Reverse =
+ private static final String bit4Reverse =
"\000\010\004\014\002\012\006\016\001\011\005\015\003\013\007\017";
class Tree {
diff --git a/libjava/classpath/java/util/zip/DeflaterOutputStream.java b/libjava/classpath/java/util/zip/DeflaterOutputStream.java
index b10100d..4321c0f 100644
--- a/libjava/classpath/java/util/zip/DeflaterOutputStream.java
+++ b/libjava/classpath/java/util/zip/DeflaterOutputStream.java
@@ -1,5 +1,5 @@
/* DeflaterOutputStream.java - Output filter for compressing.
- Copyright (C) 1999, 2000, 2001, 2004 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2000, 2001, 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -100,7 +100,7 @@ public class DeflaterOutputStream extends FilterOutputStream
*/
public DeflaterOutputStream(OutputStream out)
{
- this(out, new Deflater(), 512);
+ this(out, new Deflater(), 4096);
}
/**
@@ -111,7 +111,7 @@ public class DeflaterOutputStream extends FilterOutputStream
*/
public DeflaterOutputStream(OutputStream out, Deflater defl)
{
- this(out, defl, 512);
+ this(out, defl, 4096);
}
/**
diff --git a/libjava/classpath/java/util/zip/ZipEntry.java b/libjava/classpath/java/util/zip/ZipEntry.java
index ae21997..9b7afa0 100644
--- a/libjava/classpath/java/util/zip/ZipEntry.java
+++ b/libjava/classpath/java/util/zip/ZipEntry.java
@@ -39,7 +39,6 @@ exception statement from your version. */
package java.util.zip;
import java.util.Calendar;
-import java.util.Date;
/**
* This class represents a member of a zip archive. ZipFile and
@@ -173,7 +172,7 @@ public class ZipEntry implements ZipConstants, Cloneable
Calendar cal = getCalendar();
synchronized (cal)
{
- cal.setTime(new Date(time));
+ cal.setTimeInMillis(time);
dostime = (cal.get(Calendar.YEAR) - 1980 & 0x7f) << 25
| (cal.get(Calendar.MONTH) + 1) << 21
| (cal.get(Calendar.DAY_OF_MONTH)) << 16
@@ -190,12 +189,12 @@ public class ZipEntry implements ZipConstants, Cloneable
*/
public long getTime()
{
+ // The extra bytes might contain the time (posix/unix extension)
+ parseExtra();
+
if ((known & KNOWN_TIME) == 0)
return -1;
- // The extra bytes might contain the time (posix/unix extension)
- parseExtra ();
-
int sec = 2 * (dostime & 0x1f);
int min = (dostime >> 5) & 0x3f;
int hrs = (dostime >> 11) & 0x1f;
@@ -209,7 +208,7 @@ public class ZipEntry implements ZipConstants, Cloneable
synchronized (cal)
{
cal.set(year, mon, day, hrs, min, sec);
- return cal.getTime().getTime();
+ return cal.getTimeInMillis();
}
}
catch (RuntimeException ex)
@@ -367,10 +366,10 @@ public class ZipEntry implements ZipConstants, Cloneable
catch (ArrayIndexOutOfBoundsException ex)
{
/* be lenient */
- return;
}
known |= KNOWN_EXTRA;
+ return;
}
/**
diff --git a/libjava/classpath/java/util/zip/ZipFile.java b/libjava/classpath/java/util/zip/ZipFile.java
index 33f67c7..0243abe 100644
--- a/libjava/classpath/java/util/zip/ZipFile.java
+++ b/libjava/classpath/java/util/zip/ZipFile.java
@@ -48,6 +48,7 @@ import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.RandomAccessFile;
+import java.io.UnsupportedEncodingException;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Iterator;
@@ -284,7 +285,15 @@ public class ZipFile implements ZipConstants
buffer = new byte[needBuffer];
raf.readFully(buffer, 0, nameLen);
- String name = new String(buffer, 0, 0, nameLen);
+ String name;
+ try
+ {
+ name = new String(buffer, 0, nameLen, "UTF-8");
+ }
+ catch (UnsupportedEncodingException uee)
+ {
+ throw new AssertionError(uee);
+ }
ZipEntry entry = new ZipEntry(name);
entry.setMethod(method);
@@ -301,7 +310,14 @@ public class ZipFile implements ZipConstants
if (commentLen > 0)
{
raf.readFully(buffer, 0, commentLen);
- entry.setComment(new String(buffer, 0, commentLen));
+ try
+ {
+ entry.setComment(new String(buffer, 0, commentLen, "UTF-8"));
+ }
+ catch (UnsupportedEncodingException uee)
+ {
+ throw new AssertionError(uee);
+ }
}
entry.offset = offset;
entries.put(name, entry);
@@ -317,6 +333,10 @@ public class ZipFile implements ZipConstants
*/
public void close() throws IOException
{
+ RandomAccessFile raf = this.raf;
+ if (raf == null)
+ return;
+
synchronized (raf)
{
closed = true;
diff --git a/libjava/classpath/java/util/zip/ZipInputStream.java b/libjava/classpath/java/util/zip/ZipInputStream.java
index 5732523..4539828 100644
--- a/libjava/classpath/java/util/zip/ZipInputStream.java
+++ b/libjava/classpath/java/util/zip/ZipInputStream.java
@@ -1,5 +1,5 @@
/* ZipInputStream.java --
- Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+ Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -41,6 +41,7 @@ package java.util.zip;
import java.io.EOFException;
import java.io.IOException;
import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
/**
* This is a FilterInputStream that reads the files in an zip archive
@@ -171,7 +172,15 @@ public class ZipInputStream extends InflaterInputStream implements ZipConstants
byte[] buffer = new byte[nameLen];
readFully(buffer);
- String name = new String(buffer);
+ String name;
+ try
+ {
+ name = new String(buffer, "UTF-8");
+ }
+ catch (UnsupportedEncodingException uee)
+ {
+ throw new AssertionError(uee);
+ }
entry = createZipEntry(name);
entryAtEOF = false;
diff --git a/libjava/classpath/java/util/zip/ZipOutputStream.java b/libjava/classpath/java/util/zip/ZipOutputStream.java
index 5699ff0..5c593b2 100644
--- a/libjava/classpath/java/util/zip/ZipOutputStream.java
+++ b/libjava/classpath/java/util/zip/ZipOutputStream.java
@@ -1,5 +1,5 @@
/* ZipOutputStream.java --
- Copyright (C) 2001, 2004 Free Software Foundation, Inc.
+ Copyright (C) 2001, 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -40,6 +40,7 @@ package java.util.zip;
import java.io.IOException;
import java.io.OutputStream;
+import java.io.UnsupportedEncodingException;
import java.util.Enumeration;
import java.util.Vector;
@@ -102,7 +103,14 @@ public class ZipOutputStream extends DeflaterOutputStream implements ZipConstant
public void setComment(String comment)
{
byte[] commentBytes;
- commentBytes = comment.getBytes();
+ try
+ {
+ commentBytes = comment.getBytes("UTF-8");
+ }
+ catch (UnsupportedEncodingException uee)
+ {
+ throw new AssertionError(uee);
+ }
if (commentBytes.length > 0xffff)
throw new IllegalArgumentException("Comment too long.");
zipComment = commentBytes;
@@ -226,7 +234,15 @@ public class ZipOutputStream extends DeflaterOutputStream implements ZipConstant
writeLeInt(0);
writeLeInt(0);
}
- byte[] name = entry.getName().getBytes();
+ byte[] name;
+ try
+ {
+ name = entry.getName().getBytes("UTF-8");
+ }
+ catch (UnsupportedEncodingException uee)
+ {
+ throw new AssertionError(uee);
+ }
if (name.length > 0xffff)
throw new ZipException("Name too long.");
byte[] extra = entry.getExtra();
@@ -357,15 +373,30 @@ public class ZipOutputStream extends DeflaterOutputStream implements ZipConstant
writeLeInt((int)entry.getCompressedSize());
writeLeInt((int)entry.getSize());
- byte[] name = entry.getName().getBytes();
+ byte[] name;
+ try
+ {
+ name = entry.getName().getBytes("UTF-8");
+ }
+ catch (UnsupportedEncodingException uee)
+ {
+ throw new AssertionError(uee);
+ }
if (name.length > 0xffff)
throw new ZipException("Name too long.");
byte[] extra = entry.getExtra();
if (extra == null)
extra = new byte[0];
- String strComment = entry.getComment();
- byte[] comment = strComment != null
- ? strComment.getBytes() : new byte[0];
+ String str = entry.getComment();
+ byte[] comment;
+ try
+ {
+ comment = str != null ? str.getBytes("UTF-8") : new byte[0];
+ }
+ catch (UnsupportedEncodingException uee)
+ {
+ throw new AssertionError(uee);
+ }
if (comment.length > 0xffff)
throw new ZipException("Comment too long.");