summaryrefslogtreecommitdiff
path: root/gnu
diff options
context:
space:
mode:
Diffstat (limited to 'gnu')
-rw-r--r--gnu/classpath/Configuration.java113
-rw-r--r--gnu/java/awt/peer/gtk/GdkGraphics.java4
-rw-r--r--gnu/java/awt/peer/gtk/GdkGraphics2D.java15
-rw-r--r--gnu/java/awt/peer/gtk/GtkButtonPeer.java8
-rw-r--r--gnu/java/awt/peer/gtk/GtkCheckboxPeer.java2
-rw-r--r--gnu/java/awt/peer/gtk/GtkClipboard.java91
-rw-r--r--gnu/java/awt/peer/gtk/GtkComponentPeer.java68
-rw-r--r--gnu/java/awt/peer/gtk/GtkDialogPeer.java11
-rw-r--r--gnu/java/awt/peer/gtk/GtkFileDialogPeer.java1
-rw-r--r--gnu/java/awt/peer/gtk/GtkFramePeer.java92
-rw-r--r--gnu/java/awt/peer/gtk/GtkGenericPeer.java2
-rw-r--r--gnu/java/awt/peer/gtk/GtkImagePainter.java4
-rw-r--r--gnu/java/awt/peer/gtk/GtkLabelPeer.java2
-rw-r--r--gnu/java/awt/peer/gtk/GtkListPeer.java2
-rw-r--r--gnu/java/awt/peer/gtk/GtkMenuBarPeer.java21
-rw-r--r--gnu/java/awt/peer/gtk/GtkMenuComponentPeer.java15
-rw-r--r--gnu/java/awt/peer/gtk/GtkMenuItemPeer.java32
-rw-r--r--gnu/java/awt/peer/gtk/GtkTextAreaPeer.java2
-rw-r--r--gnu/java/awt/peer/gtk/GtkTextFieldPeer.java2
-rw-r--r--gnu/java/io/EncodingManager.java272
-rw-r--r--gnu/java/net/protocol/file/Connection.java185
-rw-r--r--gnu/java/net/protocol/file/Handler.java5
-rw-r--r--gnu/java/rmi/server/UnicastServer.java5
-rw-r--r--gnu/java/rmi/server/UnicastServerRef.java11
-rw-r--r--gnu/regexp/RE.java23
-rw-r--r--gnu/regexp/RETokenLookAhead.java (renamed from gnu/java/net/content/text/plain.java)96
26 files changed, 569 insertions, 515 deletions
diff --git a/gnu/classpath/Configuration.java b/gnu/classpath/Configuration.java
new file mode 100644
index 000000000..6969b5c4d
--- /dev/null
+++ b/gnu/classpath/Configuration.java
@@ -0,0 +1,113 @@
+/* gnu.classpath.Configuration
+ Copyright (C) 1998, 2001, 2003 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath;
+
+/**
+ * This file defines compile-time constants that can be accessed by
+ * java code. It is pre-processed by configure.
+ */
+public interface Configuration
+{
+ /**
+ * The value of CLASSPATH_HOME is the location that the classpath
+ * libraries and support files where installed in. It is set according to
+ * the argument for --prefix given to configure and used to set the
+ * System property gnu.classpath.home.
+ */
+ String CLASSPATH_HOME = "/home/gandalf/projects/java/classpath/generics-build";
+
+ /**
+ * The release version number of GNU Classpath.
+ * It is set according to the value of 'version' in the configure[.in] file
+ * and used to set the System property gnu.classpath.version.
+ */
+ String CLASSPATH_VERSION = "0.11+cvs";
+
+ /**
+ * The value of DEBUG is substituted according to whether the
+ * "--enable-debug" argument was passed to configure. Code
+ * which is made conditional based on the value of this flag - typically
+ * code that generates debugging output - will be removed by the optimizer
+ * in a non-debug build.
+ */
+ boolean DEBUG = false;
+
+ /**
+ * The value of LOAD_LIBRARY is substituted according to whether the
+ * "--enable-load-library" or "--disable-load-library" argument was passed
+ * to configure. By default, configure should define this is as true.
+ * If set to false, loadLibrary() calls to load native function
+ * implementations, typically found in static initializers of classes
+ * which contain native functions, will be omitted. This is useful for
+ * runtimes which pre-link their native function implementations and do
+ * not require additional shared libraries to be loaded.
+ */
+ boolean INIT_LOAD_LIBRARY = true;
+
+ /**
+ * Set to true if the VM provides a native method to implement
+ * Proxy.getProxyClass completely, including argument verification.
+ * If this is true, HAVE_NATIVE_GET_PROXY_DATA and
+ * HAVE_NATIVE_GENERATE_PROXY_CLASS should be false.
+ * @see java.lang.reflect.Proxy
+ */
+ boolean HAVE_NATIVE_GET_PROXY_CLASS = false;
+
+ /**
+ * Set to true if the VM provides a native method to implement
+ * the first part of Proxy.getProxyClass: generation of the array
+ * of methods to convert, and verification of the arguments.
+ * If this is true, HAVE_NATIVE_GET_PROXY_CLASS should be false.
+ * @see java.lang.reflect.Proxy
+ */
+ boolean HAVE_NATIVE_GET_PROXY_DATA = false;
+
+ /**
+ * Set to true if the VM provides a native method to implement
+ * the second part of Proxy.getProxyClass: conversion of an array of
+ * methods into an actual proxy class.
+ * If this is true, HAVE_NATIVE_GET_PROXY_CLASS should be false.
+ * @see java.lang.reflect.Proxy
+ */
+ boolean HAVE_NATIVE_GENERATE_PROXY_CLASS = false;
+
+ /**
+ * Name of default AWT peer library.
+ */
+ String default_awt_peer_toolkit = "gnu.java.awt.peer.gtk.GtkToolkit";
+}
diff --git a/gnu/java/awt/peer/gtk/GdkGraphics.java b/gnu/java/awt/peer/gtk/GdkGraphics.java
index c374ba218..4f2ccb86c 100644
--- a/gnu/java/awt/peer/gtk/GdkGraphics.java
+++ b/gnu/java/awt/peer/gtk/GdkGraphics.java
@@ -116,7 +116,6 @@ public class GdkGraphics extends Graphics
// public Graphics create (int x, int y, int width, int height)
// {
// GdkGraphics g = new GdkGraphics (this);
-// System.out.println ("translating by: " + x +" " + y);
// g.translate (x, y);
// g.clipRect (0, 0, width, height);
@@ -350,7 +349,6 @@ public class GdkGraphics extends Graphics
public Rectangle getClipBounds ()
{
-// System.out.println ("returning CLIP: " + clip);
return new Rectangle (clip.x, clip.y, clip.width, clip.height);
}
@@ -396,7 +394,7 @@ public class GdkGraphics extends Graphics
public void setColor (Color c)
{
if (c == null)
- color = new Color (0, 0, 0);
+ color = Color.BLACK;
else
color = c;
diff --git a/gnu/java/awt/peer/gtk/GdkGraphics2D.java b/gnu/java/awt/peer/gtk/GdkGraphics2D.java
index 0986960b8..768b35e8d 100644
--- a/gnu/java/awt/peer/gtk/GdkGraphics2D.java
+++ b/gnu/java/awt/peer/gtk/GdkGraphics2D.java
@@ -85,6 +85,8 @@ public class GdkGraphics2D extends Graphics2D
private RenderingHints hints;
private BufferedImage bimage;
+ private Composite comp;
+
private Stack stateStack;
native private void initState (GtkComponentPeer component);
@@ -268,6 +270,7 @@ public class GdkGraphics2D extends Graphics2D
private Shape clip;
private AffineTransform transform;
private Font font;
+ private Composite comp;
DrawState (GdkGraphics2D g)
{
this.paint = g.paint;
@@ -278,6 +281,7 @@ public class GdkGraphics2D extends Graphics2D
if (g.transform != null)
this.transform = (AffineTransform) g.transform.clone();
this.font = g.font;
+ this.comp = g.comp;
}
public void restore(GdkGraphics2D g)
{
@@ -288,6 +292,7 @@ public class GdkGraphics2D extends Graphics2D
g.clip = this.clip;
g.transform = this.transform;
g.font = this.font;
+ g.comp = this.comp;
}
}
@@ -771,6 +776,9 @@ public class GdkGraphics2D extends Graphics2D
public void setColor (Color c)
{
+ if (c == null)
+ c = Color.BLACK;
+
fg = c;
paint = c;
cairoSetRGBColor (fg.getRed() / 255.0,
@@ -1259,6 +1267,8 @@ public class GdkGraphics2D extends Graphics2D
public void setComposite(Composite comp)
{
+ this.comp = comp;
+
if (comp instanceof AlphaComposite)
{
AlphaComposite a = (AlphaComposite) comp;
@@ -1345,7 +1355,10 @@ public class GdkGraphics2D extends Graphics2D
public Composite getComposite()
{
- throw new java.lang.UnsupportedOperationException ();
+ if (comp == null)
+ return AlphaComposite.SrcOver;
+ else
+ return comp;
}
public FontRenderContext getFontRenderContext ()
diff --git a/gnu/java/awt/peer/gtk/GtkButtonPeer.java b/gnu/java/awt/peer/gtk/GtkButtonPeer.java
index db8aed608..5281b9a8c 100644
--- a/gnu/java/awt/peer/gtk/GtkButtonPeer.java
+++ b/gnu/java/awt/peer/gtk/GtkButtonPeer.java
@@ -52,13 +52,13 @@ public class GtkButtonPeer extends GtkComponentPeer
{
native void create (String label);
- public native void connectJObject ();
public native void connectSignals ();
- native void gtkSetFont (String name, int style, int size);
+ native void gtkWidgetModifyFont (String name, int style, int size);
native void gtkSetLabel (String label);
native void gtkWidgetSetForeground (int red, int green, int blue);
native void gtkActivate ();
+ native void gtkWidgetRequestFocus ();
public GtkButtonPeer (Button b)
{
@@ -86,8 +86,8 @@ public class GtkButtonPeer extends GtkComponentPeer
if (!me.isConsumed ()
&& (me.getModifiersEx () & MouseEvent.BUTTON1_DOWN_MASK) != 0
&& awtComponent.getBounds().contains(p))
- postActionEvent (((Button)awtComponent).getActionCommand (),
- me.getModifiersEx ());
+ postActionEvent (((Button) awtComponent).getActionCommand (),
+ me.getModifiersEx ());
}
if (e.getID () == KeyEvent.KEY_PRESSED)
diff --git a/gnu/java/awt/peer/gtk/GtkCheckboxPeer.java b/gnu/java/awt/peer/gtk/GtkCheckboxPeer.java
index 361136f08..a6fd1bac1 100644
--- a/gnu/java/awt/peer/gtk/GtkCheckboxPeer.java
+++ b/gnu/java/awt/peer/gtk/GtkCheckboxPeer.java
@@ -55,7 +55,7 @@ public class GtkCheckboxPeer extends GtkComponentPeer
public native void create (GtkCheckboxGroupPeer group);
public native void nativeSetCheckboxGroup (GtkCheckboxGroupPeer group);
public native void connectSignals ();
- native void gtkSetFont (String name, int style, int size);
+ native void gtkWidgetModifyFont (String name, int style, int size);
native void gtkButtonSetLabel (String label);
native void gtkToggleButtonSetActive (boolean is_active);
diff --git a/gnu/java/awt/peer/gtk/GtkClipboard.java b/gnu/java/awt/peer/gtk/GtkClipboard.java
index 86678f8ab..f9348aca3 100644
--- a/gnu/java/awt/peer/gtk/GtkClipboard.java
+++ b/gnu/java/awt/peer/gtk/GtkClipboard.java
@@ -60,15 +60,13 @@ public class GtkClipboard extends Clipboard
static boolean hasSelection = false;
- protected
- GtkClipboard ()
+ protected GtkClipboard()
{
- super ("System Clipboard");
- initNativeState ();
+ super("System Clipboard");
+ initNativeState();
}
- public Transferable
- getContents (Object requestor)
+ public Transferable getContents(Object requestor)
{
synchronized (this)
{
@@ -77,72 +75,76 @@ public class GtkClipboard extends Clipboard
}
/* Java doesn't own the selection, so we need to ask X11 */
+ // XXX: Does this hold with Swing too ?
synchronized (selectionLock)
{
- requestStringConversion ();
+ requestStringConversion();
+
try
{
- selectionLock.wait (SELECTION_RECEIVED_TIMEOUT);
+ selectionLock.wait(SELECTION_RECEIVED_TIMEOUT);
}
catch (InterruptedException e)
{
return null;
}
- return (selection == null) ? null : new StringSelection (selection);
+ return selection == null ? null : new StringSelection(selection);
}
}
- void
- stringSelectionReceived (String newSelection)
+ void stringSelectionReceived(String newSelection)
{
synchronized (selectionLock)
{
selection = newSelection;
- selectionLock.notify ();
+ selectionLock.notify();
}
}
/* convert Java clipboard data into a String suitable for sending
to another application */
- synchronized String
- stringSelectionHandler () throws IOException
+ synchronized String stringSelectionHandler() throws IOException
{
String selection = null;
- try {
- if (contents.isDataFlavorSupported (DataFlavor.stringFlavor))
- selection = (String)contents.getTransferData (DataFlavor.stringFlavor);
- else if (contents.isDataFlavorSupported (DataFlavor.plainTextFlavor))
- {
- StringBuffer sbuf = new StringBuffer ();
- InputStreamReader reader;
- char readBuf[] = new char[512];
- int numChars;
+ try
+ {
+ if (contents.isDataFlavorSupported(DataFlavor.stringFlavor))
+ selection = (String)contents.getTransferData(DataFlavor.stringFlavor);
+ else if (contents.isDataFlavorSupported(DataFlavor.plainTextFlavor))
+ {
+ StringBuffer sbuf = new StringBuffer();
+ InputStreamReader reader;
+ char readBuf[] = new char[512];
+ int numChars;
- reader = new InputStreamReader
- ((InputStream)
- contents.getTransferData (DataFlavor.plainTextFlavor), "UNICODE");
+ reader = new InputStreamReader
+ ((InputStream)
+ contents.getTransferData(DataFlavor.plainTextFlavor), "UNICODE");
- while (true)
- {
- numChars = reader.read (readBuf);
- if (numChars == -1)
- break;
- sbuf.append (readBuf, 0, numChars);
- }
+ while (true)
+ {
+ numChars = reader.read(readBuf);
+ if (numChars == -1)
+ break;
+ sbuf.append(readBuf, 0, numChars);
+ }
- selection = new String (sbuf);
- }
- } catch (Exception e) { }
+ selection = new String(sbuf);
+ }
+ }
+ catch (Exception e)
+ {
+ }
return selection;
}
- public synchronized void
- setContents (Transferable contents, ClipboardOwner owner)
+ public synchronized void setContents(Transferable contents,
+ ClipboardOwner owner)
{
- selectionGet ();
+ selectionGet();
this.contents = contents;
this.owner = owner;
@@ -150,20 +152,19 @@ public class GtkClipboard extends Clipboard
hasSelection = true;
}
- synchronized
- void selectionClear ()
+ synchronized void selectionClear()
{
hasSelection = false;
if (owner != null)
{
- owner.lostOwnership (this, contents);
+ owner.lostOwnership(this, contents);
owner = null;
contents = null;
}
}
- native void initNativeState ();
- native static void requestStringConversion ();
- native static void selectionGet ();
+ native void initNativeState();
+ native static void requestStringConversion();
+ native static void selectionGet();
}
diff --git a/gnu/java/awt/peer/gtk/GtkComponentPeer.java b/gnu/java/awt/peer/gtk/GtkComponentPeer.java
index bcdb950ff..e4e4f08f4 100644
--- a/gnu/java/awt/peer/gtk/GtkComponentPeer.java
+++ b/gnu/java/awt/peer/gtk/GtkComponentPeer.java
@@ -77,6 +77,8 @@ public class GtkComponentPeer extends GtkGenericPeer
Insets insets;
+ boolean isInRepaint;
+
/* this isEnabled differs from Component.isEnabled, in that it
knows if a parent is disabled. In that case Component.isEnabled
may return true, but our isEnabled will always return false */
@@ -97,10 +99,7 @@ public class GtkComponentPeer extends GtkGenericPeer
native void gtkWidgetRequestFocus ();
native void gtkWidgetDispatchKeyEvent (int id, long when, int mods,
int keyCode, int keyLocation);
- native void gtkSetFont (String name, int style, int size);
- native void gtkWidgetQueueDrawArea(int x, int y, int width, int height);
- native void addExposeFilter();
- native void removeExposeFilter();
+ native void gtkWidgetRepaintArea(int x, int y, int width, int height);
void create ()
{
@@ -134,8 +133,6 @@ public class GtkComponentPeer extends GtkGenericPeer
setComponentBounds ();
- Rectangle bounds = awtComponent.getBounds ();
- setBounds (bounds.x, bounds.y, bounds.width, bounds.height);
setVisibleAndEnabled ();
}
@@ -154,15 +151,27 @@ public class GtkComponentPeer extends GtkGenericPeer
gtkWidgetSetParent (p);
}
+ void beginNativeRepaint ()
+ {
+ isInRepaint = true;
+ }
+
+ void endNativeRepaint ()
+ {
+ isInRepaint = false;
+ }
+
/*
* Set the bounds of this peer's AWT Component based on dimensions
* returned by the native windowing system. Most Components impose
- * their dimensions on the peers so the default implementation does
- * nothing. However some peers, like GtkFileDialogPeer, need to
- * pass their size back to the AWT Component.
+ * their dimensions on the peers which is what the default
+ * implementation does. However some peers, like GtkFileDialogPeer,
+ * need to pass their size back to the AWT Component.
*/
void setComponentBounds ()
{
+ Rectangle bounds = awtComponent.getBounds ();
+ setBounds (bounds.x, bounds.y, bounds.width, bounds.height);
}
void setVisibleAndEnabled ()
@@ -265,8 +274,8 @@ public class GtkComponentPeer extends GtkGenericPeer
// Some peers like GtkFileDialogPeer are repainted by Gtk itself
if (g == null)
break;
-
- g.setClip (((PaintEvent)event).getUpdateRect());
+
+ g.setClip (((PaintEvent) event).getUpdateRect());
if (id == PaintEvent.PAINT)
awtComponent.paint (g);
@@ -310,21 +319,6 @@ public class GtkComponentPeer extends GtkGenericPeer
public void paint (Graphics g)
{
- Component parent = awtComponent.getParent();
- GtkComponentPeer parentPeer = null;
- if ((parent instanceof Container) && !parent.isLightweight())
- parentPeer = (GtkComponentPeer) parent.getPeer();
-
- addExposeFilter();
- if (parentPeer != null)
- parentPeer.addExposeFilter();
-
- Rectangle clip = g.getClipBounds();
- gtkWidgetQueueDrawArea(clip.x, clip.y, clip.width, clip.height);
-
- removeExposeFilter();
- if (parentPeer != null)
- parentPeer.removeExposeFilter();
}
public Dimension preferredSize ()
@@ -371,8 +365,11 @@ public class GtkComponentPeer extends GtkGenericPeer
public void repaint (long tm, int x, int y, int width, int height)
{
+ beginNativeRepaint ();
+ gtkWidgetRepaintArea (x, y, width, height);
+ endNativeRepaint ();
q.postEvent (new PaintEvent (awtComponent, PaintEvent.UPDATE,
- new Rectangle (x, y, width, height)));
+ new Rectangle (x, y, width, height)));
}
public void requestFocus ()
@@ -426,8 +423,14 @@ public class GtkComponentPeer extends GtkGenericPeer
if (parent instanceof Window && !lightweightChild)
{
Insets insets = ((Window) parent).getInsets ();
- // Convert from Java coordinates to GTK coordinates.
- setNativeBounds (x - insets.left, y - insets.top, width, height);
+ GtkWindowPeer peer = (GtkWindowPeer) parent.getPeer ();
+ int menuBarHeight = 0;
+ if (peer instanceof GtkFramePeer)
+ menuBarHeight = ((GtkFramePeer) peer).getMenuBarHeight ();
+
+ // Convert from Java coordinates to GTK coordinates.
+ setNativeBounds (x - insets.left, y - insets.top + menuBarHeight,
+ width, height);
}
else
setNativeBounds (x, y, width, height);
@@ -448,7 +451,7 @@ public class GtkComponentPeer extends GtkGenericPeer
// FIXME: This should really affect the widget tree below me.
// Currently this is only handled if the call is made directly on
// a text widget, which implements setFont() itself.
- gtkSetFont(f.getName(), f.getStyle(), f.getSize());
+ gtkWidgetModifyFont(f.getName(), f.getStyle(), f.getSize());
}
public void setForeground (Color c)
@@ -488,8 +491,9 @@ public class GtkComponentPeer extends GtkGenericPeer
protected void postExposeEvent (int x, int y, int width, int height)
{
- q.postEvent (new PaintEvent (awtComponent, PaintEvent.PAINT,
- new Rectangle (x, y, width, height)));
+ if (!isInRepaint)
+ q.postEvent (new PaintEvent (awtComponent, PaintEvent.PAINT,
+ new Rectangle (x, y, width, height)));
}
protected void postKeyEvent (int id, long when, int mods,
diff --git a/gnu/java/awt/peer/gtk/GtkDialogPeer.java b/gnu/java/awt/peer/gtk/GtkDialogPeer.java
index 1d6ce8b8b..53b57d474 100644
--- a/gnu/java/awt/peer/gtk/GtkDialogPeer.java
+++ b/gnu/java/awt/peer/gtk/GtkDialogPeer.java
@@ -75,11 +75,12 @@ public class GtkDialogPeer extends GtkWindowPeer
protected void postExposeEvent (int x, int y, int width, int height)
{
- q.postEvent (new PaintEvent (awtComponent, PaintEvent.PAINT,
- new Rectangle (x + insets.left,
- y + insets.top,
- width, height)));
- }
+ if (!isInRepaint)
+ q.postEvent (new PaintEvent (awtComponent, PaintEvent.PAINT,
+ new Rectangle (x + insets.left,
+ y + insets.top,
+ width, height)));
+ }
void create ()
{
diff --git a/gnu/java/awt/peer/gtk/GtkFileDialogPeer.java b/gnu/java/awt/peer/gtk/GtkFileDialogPeer.java
index 12e5a434c..7adf72cf2 100644
--- a/gnu/java/awt/peer/gtk/GtkFileDialogPeer.java
+++ b/gnu/java/awt/peer/gtk/GtkFileDialogPeer.java
@@ -94,6 +94,7 @@ public class GtkFileDialogPeer extends GtkDialogPeer implements FileDialogPeer
awtComponent.getY (),
dims[0], dims[1]);
}
+ super.setComponentBounds ();
}
public void setFile (String fileName)
diff --git a/gnu/java/awt/peer/gtk/GtkFramePeer.java b/gnu/java/awt/peer/gtk/GtkFramePeer.java
index e1a877eed..4916a7d0a 100644
--- a/gnu/java/awt/peer/gtk/GtkFramePeer.java
+++ b/gnu/java/awt/peer/gtk/GtkFramePeer.java
@@ -39,6 +39,7 @@ exception statement from your version. */
package gnu.java.awt.peer.gtk;
import java.awt.Component;
+import java.awt.Container;
import java.awt.Frame;
import java.awt.Graphics;
import java.awt.Graphics2D;
@@ -57,51 +58,69 @@ public class GtkFramePeer extends GtkWindowPeer
private int menuBarHeight;
private MenuBarPeer menuBar;
native int getMenuBarHeight (MenuBarPeer bar);
-
+ native void setMenuBarWidth (MenuBarPeer bar, int width);
native void setMenuBarPeer (MenuBarPeer bar);
native void removeMenuBarPeer ();
- native void moveLayout (int offset);
- native void gtkLayoutSetVisible (boolean vis);
+ native void gtkFixedSetVisible (boolean visible);
+
+ int getMenuBarHeight ()
+ {
+ return menuBar == null ? 0 : getMenuBarHeight (menuBar);
+ }
public void setMenuBar (MenuBar bar)
{
- if (bar == null)
- {
- if (menuBar != null)
+ if (bar == null && menuBar != null)
{
- gtkLayoutSetVisible(false);
- removeMenuBarPeer();
+ // We're removing the menubar.
+ gtkFixedSetVisible (false);
menuBar = null;
- moveLayout(menuBarHeight);
+ removeMenuBarPeer ();
insets.top -= menuBarHeight;
- menuBarHeight = 0;
- awtComponent.doLayout();
- gtkLayoutSetVisible(true);
+ menuBarHeight = 0;
+ awtComponent.validate ();
+ gtkFixedSetVisible (true);
}
- }
- else
- {
- gtkLayoutSetVisible(false);
- int oldHeight = 0;
- if (menuBar != null)
+ else if (bar != null && menuBar == null)
+ {
+ // We're adding a menubar where there was no menubar before.
+ gtkFixedSetVisible (false);
+ menuBar = (MenuBarPeer) ((MenuBar) bar).getPeer();
+ setMenuBarPeer (menuBar);
+ int menuBarWidth =
+ awtComponent.getWidth () - insets.left - insets.right;
+ setMenuBarWidth (menuBar, menuBarWidth);
+ menuBarHeight = getMenuBarHeight ();
+ insets.top += menuBarHeight;
+ awtComponent.validate ();
+ gtkFixedSetVisible (true);
+ }
+ else if (bar != null && menuBar != null)
{
+ // We're swapping the menubar.
+ gtkFixedSetVisible (false);
removeMenuBarPeer();
- oldHeight = menuBarHeight;
- insets.top -= menuBarHeight;
+ int oldHeight = menuBarHeight;
+ int menuBarWidth =
+ awtComponent.getWidth () - insets.left - insets.right;
+ menuBar = (MenuBarPeer) ((MenuBar) bar).getPeer ();
+ setMenuBarPeer (menuBar);
+ setMenuBarWidth (menuBar, menuBarWidth);
+ menuBarHeight = getMenuBarHeight ();
+ if (oldHeight != menuBarHeight)
+ {
+ insets.top += (menuBarHeight - oldHeight);
+ awtComponent.validate ();
+ }
+ gtkFixedSetVisible (true);
}
- menuBar = (MenuBarPeer) ((MenuBar) bar).getPeer();
- setMenuBarPeer(menuBar);
- menuBarHeight = getMenuBarHeight (menuBar);
- if (oldHeight != menuBarHeight)
- moveLayout(oldHeight - menuBarHeight);
- insets.top += menuBarHeight;
- awtComponent.doLayout();
- gtkLayoutSetVisible(true);
- }
}
public void setBounds (int x, int y, int width, int height)
{
+ if (menuBar != null)
+ setMenuBarWidth (menuBar, width - insets.left - insets.right);
+
nativeSetBounds (x, y,
width - insets.left - insets.right,
height - insets.top - insets.bottom
@@ -206,15 +225,19 @@ public class GtkFramePeer extends GtkWindowPeer
|| frame_width != awtComponent.getWidth()
|| frame_height != awtComponent.getHeight())
{
+ if (frame_width != awtComponent.getWidth() && menuBar != null)
+ setMenuBarWidth (menuBar, width);
+
setBoundsCallback ((Window) awtComponent,
frame_x,
frame_y,
frame_width,
frame_height);
}
+
awtComponent.validate();
}
-
+
protected void postMouseEvent(int id, long when, int mods, int x, int y,
int clickCount, boolean popupTrigger)
{
@@ -225,10 +248,11 @@ public class GtkFramePeer extends GtkWindowPeer
protected void postExposeEvent (int x, int y, int width, int height)
{
- q.postEvent (new PaintEvent (awtComponent, PaintEvent.PAINT,
- new Rectangle (x + insets.left,
- y + insets.top,
- width, height)));
+ if (!isInRepaint)
+ q.postEvent (new PaintEvent (awtComponent, PaintEvent.PAINT,
+ new Rectangle (x + insets.left,
+ y + insets.top,
+ width, height)));
}
public int getState ()
diff --git a/gnu/java/awt/peer/gtk/GtkGenericPeer.java b/gnu/java/awt/peer/gtk/GtkGenericPeer.java
index f7a7b2270..657e830bf 100644
--- a/gnu/java/awt/peer/gtk/GtkGenericPeer.java
+++ b/gnu/java/awt/peer/gtk/GtkGenericPeer.java
@@ -82,4 +82,6 @@ public class GtkGenericPeer
// Let's assume this will never wrap.
return next_native_state++;
}
+
+ native void gtkWidgetModifyFont (String name, int style, int size);
}
diff --git a/gnu/java/awt/peer/gtk/GtkImagePainter.java b/gnu/java/awt/peer/gtk/GtkImagePainter.java
index d15cb4a4a..107c236c0 100644
--- a/gnu/java/awt/peer/gtk/GtkImagePainter.java
+++ b/gnu/java/awt/peer/gtk/GtkImagePainter.java
@@ -75,7 +75,7 @@ public class GtkImagePainter implements Runnable, ImageConsumer
s_width = s_height = 0;
clip = null;
- new Thread (this).start ();
+ run ();
}
public
@@ -105,7 +105,7 @@ public class GtkImagePainter implements Runnable, ImageConsumer
s_height = Math.abs (sy2 - sy1);
clip = new Rectangle (sx1, sy1, s_width, s_height);
- new Thread (this).start ();
+ run ();
}
public void
diff --git a/gnu/java/awt/peer/gtk/GtkLabelPeer.java b/gnu/java/awt/peer/gtk/GtkLabelPeer.java
index c28b7f597..b500a9910 100644
--- a/gnu/java/awt/peer/gtk/GtkLabelPeer.java
+++ b/gnu/java/awt/peer/gtk/GtkLabelPeer.java
@@ -47,7 +47,7 @@ public class GtkLabelPeer extends GtkComponentPeer
implements LabelPeer
{
native void create (String text, float alignment);
- native void gtkSetFont (String name, int style, int size);
+ native void gtkWidgetModifyFont (String name, int style, int size);
native void nativeSetAlignment (float alignment);
native public void setText (String text);
diff --git a/gnu/java/awt/peer/gtk/GtkListPeer.java b/gnu/java/awt/peer/gtk/GtkListPeer.java
index a85aba952..6447d3e37 100644
--- a/gnu/java/awt/peer/gtk/GtkListPeer.java
+++ b/gnu/java/awt/peer/gtk/GtkListPeer.java
@@ -60,7 +60,7 @@ public class GtkListPeer extends GtkComponentPeer
native void create (int rows);
native void connectJObject ();
native void connectSignals ();
- native void gtkSetFont (String name, int style, int size);
+ native void gtkWidgetModifyFont (String name, int style, int size);
native void gtkWidgetRequestFocus ();
native void getSize (int rows, int visibleRows, int dims[]);
diff --git a/gnu/java/awt/peer/gtk/GtkMenuBarPeer.java b/gnu/java/awt/peer/gtk/GtkMenuBarPeer.java
index 404628180..90ad0c01b 100644
--- a/gnu/java/awt/peer/gtk/GtkMenuBarPeer.java
+++ b/gnu/java/awt/peer/gtk/GtkMenuBarPeer.java
@@ -38,8 +38,10 @@ exception statement from your version. */
package gnu.java.awt.peer.gtk;
+import java.awt.Font;
import java.awt.Menu;
import java.awt.MenuBar;
+import java.awt.MenuComponent;
import java.awt.peer.MenuBarPeer;
import java.awt.peer.MenuPeer;
@@ -53,18 +55,25 @@ public class GtkMenuBarPeer extends GtkMenuComponentPeer
public GtkMenuBarPeer (MenuBar target)
{
super (target);
- create ();
}
- /* In Gnome, help menus are no longer right flushed. */
- public void addHelpMenu (Menu menu)
+ void setFont ()
{
- addMenu (menu);
+ MenuComponent mc = (MenuComponent) awtWidget;
+ Font f = mc.getFont ();
+
+ if (f == null)
+ mc.setFont (new Font ("Dialog", Font.PLAIN, 12));
}
- public void addMenu (Menu menu)
+ // FIXME: remove this method or replace it with one that does
+ // something useful.
+ /* In Gnome, help menus are no longer right flushed. */
+ native void nativeSetHelpMenu(MenuPeer menuPeer);
+
+ public void addHelpMenu (Menu menu)
{
- addMenu ((MenuPeer) menu.getPeer ());
+ // nativeSetHelpMenu((MenuPeer) menu.getPeer());
}
native public void delMenu (int index);
diff --git a/gnu/java/awt/peer/gtk/GtkMenuComponentPeer.java b/gnu/java/awt/peer/gtk/GtkMenuComponentPeer.java
index 92f022306..dd061ed37 100644
--- a/gnu/java/awt/peer/gtk/GtkMenuComponentPeer.java
+++ b/gnu/java/awt/peer/gtk/GtkMenuComponentPeer.java
@@ -38,15 +38,28 @@ exception statement from your version. */
package gnu.java.awt.peer.gtk;
+import java.awt.Font;
+import java.awt.MenuComponent;
import java.awt.peer.MenuComponentPeer;
public class GtkMenuComponentPeer extends GtkGenericPeer
implements MenuComponentPeer
{
+ void create ()
+ {
+ throw new RuntimeException ();
+ }
+
+ void setFont ()
+ {
+ }
+
public GtkMenuComponentPeer (Object awtWidget)
{
super (awtWidget);
+ create ();
+ setFont ();
}
-
+
public native void dispose();
}
diff --git a/gnu/java/awt/peer/gtk/GtkMenuItemPeer.java b/gnu/java/awt/peer/gtk/GtkMenuItemPeer.java
index 55581d1c6..d58916614 100644
--- a/gnu/java/awt/peer/gtk/GtkMenuItemPeer.java
+++ b/gnu/java/awt/peer/gtk/GtkMenuItemPeer.java
@@ -38,9 +38,11 @@ exception statement from your version. */
package gnu.java.awt.peer.gtk;
+import java.awt.Font;
import java.awt.Menu;
import java.awt.MenuBar;
import java.awt.MenuItem;
+import java.awt.MenuComponent;
import java.awt.peer.MenuItemPeer;
import java.awt.peer.MenuComponentPeer;
import java.awt.peer.MenuBarPeer;
@@ -50,12 +52,17 @@ public class GtkMenuItemPeer extends GtkMenuComponentPeer
implements MenuItemPeer
{
native void create (String label);
- public native void connectSignals ();
+ native void connectSignals ();
+ native void gtkWidgetModifyFont (String name, int style, int size);
+
+ void create ()
+ {
+ create (((MenuItem) awtWidget).getLabel());
+ }
public GtkMenuItemPeer (MenuItem item)
{
super (item);
- create (item.getLabel ());
setEnabled (item.isEnabled ());
setParent (item);
@@ -63,6 +70,21 @@ public class GtkMenuItemPeer extends GtkMenuComponentPeer
connectSignals();
}
+ void setFont ()
+ {
+ MenuComponent mc = ((MenuComponent) awtWidget);
+ Font f = mc.getFont ();
+
+ if (f == null)
+ {
+ MenuComponent parent = (MenuComponent) mc.getParent ();
+ Font pf = parent.getFont ();
+ gtkWidgetModifyFont (pf.getName (), pf.getStyle (), pf.getSize ());
+ }
+ else
+ gtkWidgetModifyFont(f.getName(), f.getStyle(), f.getSize());
+ }
+
void setParent (MenuItem item)
{
// add ourself differently, based on what type of parent we have
@@ -89,10 +111,8 @@ public class GtkMenuItemPeer extends GtkMenuComponentPeer
setEnabled (true);
}
- public void setEnabled (boolean b)
- {
- // do nothing, for now.
- }
+ native public void setEnabled (boolean b);
+
native public void setLabel (String label);
protected void postMenuActionEvent ()
diff --git a/gnu/java/awt/peer/gtk/GtkTextAreaPeer.java b/gnu/java/awt/peer/gtk/GtkTextAreaPeer.java
index b08728b2b..651118d84 100644
--- a/gnu/java/awt/peer/gtk/GtkTextAreaPeer.java
+++ b/gnu/java/awt/peer/gtk/GtkTextAreaPeer.java
@@ -52,7 +52,7 @@ public class GtkTextAreaPeer extends GtkTextComponentPeer
native void create (int width, int height, int scrollbarVisibility);
- native void gtkSetFont (String name, int style, int size);
+ native void gtkWidgetModifyFont (String name, int style, int size);
native void gtkWidgetRequestFocus ();
void create ()
diff --git a/gnu/java/awt/peer/gtk/GtkTextFieldPeer.java b/gnu/java/awt/peer/gtk/GtkTextFieldPeer.java
index d4a702deb..73d92cbaa 100644
--- a/gnu/java/awt/peer/gtk/GtkTextFieldPeer.java
+++ b/gnu/java/awt/peer/gtk/GtkTextFieldPeer.java
@@ -84,7 +84,7 @@ public class GtkTextFieldPeer extends GtkTextComponentPeer
native int gtkEntryGetBorderWidth ();
- native void gtkSetFont (String name, int style, int size);
+ native void gtkWidgetModifyFont (String name, int style, int size);
public GtkTextFieldPeer (TextField tf)
{
diff --git a/gnu/java/io/EncodingManager.java b/gnu/java/io/EncodingManager.java
index b55138b47..0c56d3b7a 100644
--- a/gnu/java/io/EncodingManager.java
+++ b/gnu/java/io/EncodingManager.java
@@ -1,5 +1,5 @@
/* EncodingManager.java -- Manages character encoding translators
- Copyright (C) 1998, 1999 Free Software Foundation, Inc.
+ Copyright (C) 1998, 1999, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -42,13 +42,12 @@ import java.lang.reflect.Constructor;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
+import java.security.AccessController;
import java.util.Hashtable;
import java.util.StringTokenizer;
import gnu.java.io.decode.Decoder;
import gnu.java.io.encode.Encoder;
-
-
-import java.io.FileOutputStream;
+import gnu.java.security.action.GetPropertyAction;
/**
* This class is used to create new instances of Decoders for a specified
@@ -101,75 +100,65 @@ private static Decoder default_decoder_instance;
private static Encoder default_encoder_instance;
/**
- * This is our hash table of previously loaded <code>Decoder</code> classes
- */
-private static Hashtable decoder_cons;
-
-/**
* This is hash table of cached instances of <code>Decoder</code> objects
*/
private static Hashtable decoder_instances;
/**
- * This is our hash table of previously loaded <code>Encoder</code> classes
- */
-private static Hashtable encoder_cons;
-
-/**
* This is hash table of cached instances of <code>Encoder</code> objects
*/
private static Hashtable encoder_instances;
+/**
+ * Helper method to get system properties in the proper security context.
+ */
+private static String getSystemProperty(String propName, String defaultValue)
+{
+ GetPropertyAction getProp = new GetPropertyAction(propName, defaultValue);
+ return (String)AccessController.doPrivileged(getProp);
+}
static
{
// Initialize hashtables
- decoder_cons = new Hashtable();
- encoder_cons = new Hashtable();
decoder_instances = new Hashtable();
encoder_instances = new Hashtable();
// Find the system default decoder search path
- encoding_path = System.getProperty("file.encoding.pkg");
+ encoding_path = getSystemProperty("file.encoding.pkg", null);
if (encoding_path == null)
encoding_path = "gnu.java.io";
else
encoding_path = encoding_path + ":gnu.java.io";
// Find the system default encoding name
- String default_encoding = System.getProperty("file.encoding","8859_1");
+ String default_encoding = getSystemProperty("file.encoding", "8859_1");
// Load the class
try
{
// First the Decoder side
- default_decoder_cons = findDecoderConstructor(default_encoding, true);
+ default_decoder_cons = findDecoderConstructor(default_encoding);
- Object[] objs = new Object[1];
- objs[0] = null;
+ Object[] objs = new Object[] { null };
default_decoder_instance =
(Decoder)default_decoder_cons.newInstance(objs);
// Now the Encoder side
- default_encoder_cons = findEncoderConstructor(default_encoding, true);
-
- objs = new Object[1];
- objs[0] = null;
+ default_encoder_cons = findEncoderConstructor(default_encoding);
default_encoder_instance =
(Encoder)default_encoder_cons.newInstance(objs);
// Add items to the hashtable;
- decoder_cons.put(default_encoding, default_decoder_cons);
- encoder_cons.put(default_encoding, default_encoder_cons);
decoder_instances.put(default_encoding, default_decoder_instance);
encoder_instances.put(default_encoding, default_encoder_instance);
}
catch(Exception e)
{
- throw new Error("Cannot load system default encoding '" +
- default_encoding + "': " + e.getMessage());
+ throw new Error("Cannot load system default encoding: " +
+ default_encoding, e);
}
}
@@ -185,15 +174,12 @@ static
*
* @exception UnsupportedEncodingException If a <code>Decoder</code> for this encoding cannot be found.
*/
-private static Constructor
-findDecoderConstructor(String encoding, boolean cache)
- throws UnsupportedEncodingException
+private static Constructor findDecoderConstructor(String encoding)
+ throws UnsupportedEncodingException
{
// First check for an aliased encoding name
- String alias = System.getProperty("gnu.java.io.encoding_scheme_alias." +
- encoding);
- if (alias != null)
- encoding = alias;
+ encoding = getSystemProperty("gnu.java.io.encoding_scheme_alias." +
+ encoding, encoding);
StringTokenizer st = new StringTokenizer(encoding_path, ":");
@@ -203,16 +189,7 @@ findDecoderConstructor(String encoding, boolean cache)
try
{
Class cls = Class.forName(classname);
-
- Class[] params = new Class[1];
- params[0] = InputStream.class;
-
- Constructor cons = cls.getConstructor(params);
-
- if (cache)
- decoder_cons.put(encoding, cons);
-
- return(cons);
+ return cls.getConstructor(new Class[] { InputStream.class });
}
catch(Exception e) { ; }
}
@@ -228,15 +205,12 @@ findDecoderConstructor(String encoding, boolean cache)
*
* @exception UnsupportedEncodingException If a <code>Encoder</code> for this encoding cannot be found.
*/
-private static Constructor
-findEncoderConstructor(String encoding, boolean cache)
- throws UnsupportedEncodingException
+private static Constructor findEncoderConstructor(String encoding)
+ throws UnsupportedEncodingException
{
// First check for an aliased encoding name
- String alias = System.getProperty("gnu.java.io.encoding_scheme_alias." +
- encoding);
- if (alias != null)
- encoding = alias;
+ encoding = getSystemProperty("gnu.java.io.encoding_scheme_alias." +
+ encoding, encoding);
StringTokenizer st = new StringTokenizer(encoding_path, ":");
@@ -246,16 +220,7 @@ findEncoderConstructor(String encoding, boolean cache)
try
{
Class cls = Class.forName(classname);
-
- Class[] params = new Class[1];
- params[0] = OutputStream.class;
-
- Constructor cons = cls.getConstructor(params);
-
- if (cache)
- encoder_cons.put(encoding, cons);
-
- return(cons);
+ return cls.getConstructor(new Class[] { OutputStream.class });
}
catch(Exception e) { ; }
}
@@ -273,10 +238,9 @@ findEncoderConstructor(String encoding, boolean cache)
*
* @return An instance of the default <code>Decoder</code>.
*/
-public static Decoder
-getDecoder()
+public static Decoder getDecoder()
{
- return(default_decoder_instance);
+ return default_decoder_instance;
}
/*************************************************************************/
@@ -299,40 +263,16 @@ getDecoder()
*
* @exception UnsupportedEncodingException If a <code>Decoder</code> for the named encoding cannot be found
*/
-public static Decoder
-getDecoder(String encoding) throws UnsupportedEncodingException
-{
- return(getDecoder(encoding, true));
-}
-
-/*************************************************************************/
-
-/**
- * This method returns the default instance of the <code>Decoder</code>
- * for the named encoding. This must be used only for calling the static
- * byte array conversion methods. Calling any instance methods on this
- * object will result in a <code>NullPointerException</code>
- *
- * @param encoding The name of the encoding to retrieve a <code>Decoder</code> for.
- * @param cache <code>true</code> to cache this encoding, <code>false</code> otherwise
- *
- * @return An instance of the <code>Decoder</code> for the named encoding.
- *
- * @exception UnsupportedEncodingException If a <code>Decoder</code> for the named encoding cannot be found
- */
-public static Decoder
-getDecoder(String encoding, boolean cache) throws UnsupportedEncodingException
+public static Decoder getDecoder(String encoding)
+ throws UnsupportedEncodingException
{
Decoder dec = (Decoder)decoder_instances.get(encoding);
if (dec != null)
- return(dec);
+ return dec;
- dec = getDecoder(null, encoding, cache);
-
- if (cache)
- decoder_instances.put(encoding, dec);
-
- return(dec);
+ dec = getDecoder(null, encoding);
+ decoder_instances.put(encoding, dec);
+ return dec;
}
/*************************************************************************/
@@ -344,23 +284,17 @@ getDecoder(String encoding, boolean cache) throws UnsupportedEncodingException
*
* @param in The <code>InputStream</code> to read from
*/
-public static Decoder
-getDecoder(InputStream in)
+public static Decoder getDecoder(InputStream in)
{
- Object[] params = new Object[1];
- params[0] = in;
-
- Decoder dec = null;
try
{
- dec = (Decoder)default_decoder_cons.newInstance(params);
+ Object[] params = new Object[] { in };
+ return (Decoder)default_decoder_cons.newInstance(params);
}
catch(Exception e)
{
- throw new Error("Unexpected problems with default decoder");
+ throw new Error("Unexpected problems with default decoder", e);
}
-
- return(dec);
}
/*************************************************************************/
@@ -380,43 +314,20 @@ getDecoder(InputStream in)
*
* @exception UnsupportedEncodingException If a <code>Decoder</code> for this encoding cannot be found
*/
-public static Decoder
-getDecoder(InputStream in, String encoding) throws UnsupportedEncodingException
-{
- return(getDecoder(in, encoding, true));
-}
-
-/*************************************************************************/
-
-/**
- * This method returns a <code>Decoder</code> object that can read from
- * the specified <code>InputStream</code> using the named encoding
- *
- * @param in The <code>InputStream</code> to read from
- * @param encoding The name of the character encoding scheme to use
- * @param cache <code>true</code> to cache the returned <code>Decoder</code>, <code>false</code> otherwise.
- *
- * @exception UnsupportedEncodingException If a <code>Decoder</code> for this encoding cannot be found
- */
-public static Decoder
-getDecoder(InputStream in, String encoding, boolean cache)
- throws UnsupportedEncodingException
+public static Decoder getDecoder(InputStream in, String encoding)
+ throws UnsupportedEncodingException
{
- Constructor cons = findDecoderConstructor(encoding, cache);
- Object[] params = new Object[1];
- params[0] = in;
+ Constructor cons = findDecoderConstructor(encoding);
- Decoder dec = null;
try
{
- dec = (Decoder)cons.newInstance(params);
+ return (Decoder)cons.newInstance(new Object[] { in });
}
catch(Exception e)
{
- throw new UnsupportedEncodingException(encoding + ": " + e.getMessage());
+ throw (UnsupportedEncodingException)
+ new UnsupportedEncodingException(encoding).initCause(e);
}
-
- return(dec);
}
/*************************************************************************/
@@ -429,10 +340,9 @@ getDecoder(InputStream in, String encoding, boolean cache)
*
* @return An instance of the default <code>Encoder</code>.
*/
-public static Encoder
-getEncoder()
+public static Encoder getEncoder()
{
- return(default_encoder_instance);
+ return default_encoder_instance;
}
/*************************************************************************/
@@ -455,40 +365,16 @@ getEncoder()
*
* @exception UnsupportedEncodingException If a <code>Encoder</code> for the named encoding cannot be found
*/
-public static Encoder
-getEncoder(String encoding) throws UnsupportedEncodingException
-{
- return(getEncoder(encoding, true));
-}
-
-/*************************************************************************/
-
-/**
- * This method returns the default instance of the <code>Encoder</code>
- * for the named encoding. This must be used only for calling the static
- * byte array conversion methods. Calling any instance methods on this
- * object will result in a <code>NullPointerException</code>
- *
- * @param encoding The name of the encoding to retrieve a <code>Encoder</code> for.
- * @param cache <code>true</code> to cache this encoding, <code>false</code> otherwise
- *
- * @return An instance of the <code>Encoder</code> for the named encoding.
- *
- * @exception UnsupportedEncodingException If a <code>Encoder</code> for the named encoding cannot be found
- */
-public static Encoder
-getEncoder(String encoding, boolean cache) throws UnsupportedEncodingException
+public static Encoder getEncoder(String encoding)
+ throws UnsupportedEncodingException
{
Encoder enc = (Encoder)encoder_instances.get(encoding);
if (enc != null)
- return(enc);
+ return enc;
- enc = getEncoder(null, encoding, cache);
-
- if (cache)
- encoder_instances.put(encoding, enc);
-
- return(enc);
+ enc = getEncoder(null, encoding);
+ encoder_instances.put(encoding, enc);
+ return enc;
}
/*************************************************************************/
@@ -500,23 +386,17 @@ getEncoder(String encoding, boolean cache) throws UnsupportedEncodingException
*
* @param out The <code>OutputStream</code> to read from
*/
-public static Encoder
-getEncoder(OutputStream out)
+public static Encoder getEncoder(OutputStream out)
{
- Object[] params = new Object[1];
- params[0] = out;
-
- Encoder enc = null;
try
{
- enc = (Encoder)default_encoder_cons.newInstance(params);
+ Object[] params = new Object[] { out };
+ return (Encoder)default_encoder_cons.newInstance(params);
}
catch(Exception e)
{
- throw new Error("Unexpected problems with default decoder");
+ throw new Error("Unexpected problems with default decoder", e);
}
-
- return(enc);
}
/*************************************************************************/
@@ -536,44 +416,20 @@ getEncoder(OutputStream out)
*
* @exception UnsupportedEncodingException If an <code>Encoder</code> for this encoding cannot be found
*/
-public static Encoder
-getEncoder(OutputStream in, String encoding) throws UnsupportedEncodingException
+public static Encoder getEncoder(OutputStream out, String encoding)
+ throws UnsupportedEncodingException
{
- return(getEncoder(in, encoding, true));
-}
-
-/*************************************************************************/
+ Constructor cons = findEncoderConstructor(encoding);
-/**
- * This method returns an <code>Encoder</code> object that can write to
- * the specified <code>OutputStream</code> using the named encoding
- *
- * @param in The <code>OutputStream</code> to read from
- * @param encoding The name of the character encoding scheme to use
- * @param cache <code>true</code> to cache the returned <code>Encoder</code>, <code>false</code> otherwise.
- *
- * @exception UnsupportedEncodingException If a <code>Decoder</code> for this encoding cannot be found
- */
-public static Encoder
-getEncoder(OutputStream out, String encoding, boolean cache)
- throws UnsupportedEncodingException
-{
- Constructor cons = findEncoderConstructor(encoding, cache);
- Object[] params = new Object[1];
- params[0] = out;
-
- Encoder enc = null;
try
{
- enc = (Encoder)cons.newInstance(params);
+ return (Encoder)cons.newInstance(new Object[] { out });
}
catch(Exception e)
{
- throw new UnsupportedEncodingException(encoding + ": " + e.getMessage());
+ throw (UnsupportedEncodingException)
+ new UnsupportedEncodingException(encoding).initCause(e);
}
-
- return(enc);
}
} // class EncodingManager
-
diff --git a/gnu/java/net/protocol/file/Connection.java b/gnu/java/net/protocol/file/Connection.java
index 0dc223cf0..2754717bb 100644
--- a/gnu/java/net/protocol/file/Connection.java
+++ b/gnu/java/net/protocol/file/Connection.java
@@ -37,8 +37,11 @@ exception statement from your version. */
package gnu.java.net.protocol.file;
+import gnu.java.security.action.GetPropertyAction;
+
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
+import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
@@ -50,10 +53,10 @@ import java.net.ProtocolException;
import java.net.URL;
import java.net.URLConnection;
import java.security.Permission;
-import java.util.AbstractSet;
-import java.util.Iterator;
-import java.util.Set;
-import java.util.NoSuchElementException;
+import java.security.AccessController;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Locale;
/**
* This subclass of java.net.URLConnection models a URLConnection via
@@ -71,6 +74,15 @@ public class Connection extends URLConnection
private static final String DEFAULT_PERMISSION = "read";
/**
+ * HTTP-style DateFormat, used to format the last-modified header.
+ */
+ private static SimpleDateFormat dateFormat
+ = new SimpleDateFormat("EEE, dd MMM yyyy hh:mm:ss 'GMT'",
+ new Locale ("En", "Us", "Unix"));
+
+ private static String lineSeparator;
+
+ /**
* This is a File object for this connection
*/
private File file;
@@ -111,11 +123,38 @@ public class Connection extends URLConnection
// If not connected, then file needs to be openned.
file = new File (getURL().getFile());
- if (doInput)
- inputStream = new BufferedInputStream(new FileInputStream(file));
+
+ if (! file.isDirectory())
+ {
+ if (doInput)
+ inputStream = new BufferedInputStream(new FileInputStream(file));
- if (doOutput)
- outputStream = new BufferedOutputStream(new FileOutputStream(file));
+ if (doOutput)
+ outputStream = new BufferedOutputStream(new FileOutputStream(file));
+ }
+ else
+ {
+ if (doInput)
+ {
+ if (lineSeparator == null)
+ {
+ GetPropertyAction getProperty = new GetPropertyAction("line.separator");
+ lineSeparator = (String) AccessController.doPrivileged(getProperty);
+ }
+
+ StringBuffer sb = new StringBuffer();
+ String[] files = file.list();
+
+ for (int index = 0; index < files.length; ++index)
+ sb.append(files[index]).append(lineSeparator);
+
+ inputStream = new ByteArrayInputStream(sb.toString().getBytes());
+ }
+
+ if (doOutput)
+ throw new ProtocolException
+ ("file: protocol does not support output on directories");
+ }
connected = true;
}
@@ -178,6 +217,35 @@ public class Connection extends URLConnection
return -1;
}
}
+
+ /**
+ * Get an http-style header field. Just handle a few common ones.
+ */
+ public String getHeaderField(String field)
+ {
+ try
+ {
+ if (!connected)
+ connect();
+
+ if (field.equals("content-type"))
+ return guessContentTypeFromName(file.getName());
+ else if (field.equals("content-length"))
+ return Long.toString(file.length());
+ else if (field.equals("last-modified"))
+ {
+ synchronized (dateFormat)
+ {
+ return dateFormat.format(new Date(file.lastModified()));
+ }
+ }
+ }
+ catch (IOException e)
+ {
+ // Fall through.
+ }
+ return null;
+ }
/**
* Get the length of content.
@@ -211,105 +279,4 @@ public class Connection extends URLConnection
{
return permission;
}
-
- /**
- * Does the resource pointed to actually exist?
- */
- public final boolean exists()
- {
- if (file == null)
- return false;
-
- return file.exists();
- }
-
- /**
- * Is the resource pointed to a directory?
- */
- public final boolean isDirectory()
- {
- return file.isDirectory();
- }
-
- /**
- * Get a listing of the directory, if it is a directory.
- *
- * @return a set which can supply an iteration of the
- * contents of the directory.
- *
- * @throws IllegalStateException if this is not pointing
- * to a directory.
- */
- public Set getListing()
- {
- if (!file.isDirectory())
- throw new IllegalStateException ("this is not a directory");
-
- final File[] directoryList = file.listFiles();
- return new AbstractSet()
- {
- File[] dirList = directoryList;
-
- public int size()
- {
- return dirList.length;
- }
-
- public Iterator iterator()
- {
- return new Iterator()
- {
- int index = 0;
-
- public boolean hasNext()
- {
- return index < dirList.length;
- }
-
- public Object next()
- {
- try
- {
- String value = dirList [index++].getName();
- return value;
- }
- catch (ArrayIndexOutOfBoundsException e)
- {
- throw new NoSuchElementException ("no more content");
- }
- }
-
- public void remove()
- {
- try
- {
- File[] newDirList = new File [dirList.length - 1];
- int realIndex = index - 1;
-
- if (realIndex < 1)
- {
- System.arraycopy (dirList, 1, newDirList, 0,
- dirList.length - 1);
- index--;
- }
- else
- {
- System.arraycopy (dirList, 0, newDirList, 0, realIndex);
-
- if (index < dirList.length - 1)
- System.arraycopy (dirList, index,
- newDirList, realIndex,
- dirList.length - realIndex);
- }
- dirList = newDirList;
- }
- catch (ArrayIndexOutOfBoundsException e)
- {
- throw new NoSuchElementException("no more content");
- }
- }
- };
- }
- };
- }
}
diff --git a/gnu/java/net/protocol/file/Handler.java b/gnu/java/net/protocol/file/Handler.java
index 06ab3922b..18f91720e 100644
--- a/gnu/java/net/protocol/file/Handler.java
+++ b/gnu/java/net/protocol/file/Handler.java
@@ -79,9 +79,8 @@ public class Handler extends URLStreamHandler
// Reset the protocol (and implicitly the handler) for this URL.
// Then have the URL attempt the connection again, as it will
// get the changed handler the next time around.
- // N.B.: FTP protocol is not supported by default in GNU Classpath
- // but it does not matter because setURL will keep the current protocol
- // if "ftp" is not available.
+ // If the ftp protocol handler is not installed, an
+ // exception will be thrown from the new openConnection() call.
setURL (url, "ftp", url.getHost(), url.getPort(), url.getFile(),
url.getRef());
return url.openConnection();
diff --git a/gnu/java/rmi/server/UnicastServer.java b/gnu/java/rmi/server/UnicastServer.java
index ace43f018..423095404 100644
--- a/gnu/java/rmi/server/UnicastServer.java
+++ b/gnu/java/rmi/server/UnicastServer.java
@@ -46,6 +46,7 @@ import java.net.InetAddress;
import java.util.Hashtable;
import java.net.UnknownHostException;
import java.rmi.Remote;
+import java.rmi.ServerError;
import java.rmi.server.ObjID;
import java.rmi.server.UnicastRemoteObject;
import java.rmi.server.UID;
@@ -136,6 +137,10 @@ private static void incomingMessageCall(UnicastConnection conn) throws IOExcepti
returnval = e;
returncode = RETURN_NACK;
}
+ catch (Error e) {
+ returnval = new ServerError ("An Error is thrown while processing the invocation on the server", e);
+ returncode = RETURN_NACK;
+ }
}
else {
returnval = new NoSuchObjectException("");
diff --git a/gnu/java/rmi/server/UnicastServerRef.java b/gnu/java/rmi/server/UnicastServerRef.java
index 3e9529c59..1c5823a70 100644
--- a/gnu/java/rmi/server/UnicastServerRef.java
+++ b/gnu/java/rmi/server/UnicastServerRef.java
@@ -284,7 +284,16 @@ public Object incomingMessageCall(UnicastConnection conn, int method, long hash)
try{
ret = meth.invoke(myself, args);
}catch(InvocationTargetException e){
- throw (Exception)(e.getTargetException());
+ Throwable cause = e.getTargetException();
+ if (cause instanceof Exception) {
+ throw (Exception)cause;
+ }
+ else if (cause instanceof Error) {
+ throw (Error)cause;
+ }
+ else {
+ throw new Error("The remote method threw a java.lang.Throwable that is neither java.lang.Exception nor java.lang.Error.", e);
+ }
}
return ret;
}
diff --git a/gnu/regexp/RE.java b/gnu/regexp/RE.java
index fdc00feb3..d782975e9 100644
--- a/gnu/regexp/RE.java
+++ b/gnu/regexp/RE.java
@@ -492,8 +492,25 @@ public class RE extends REToken {
else if ((unit.ch == '(') && (syntax.get(RESyntax.RE_NO_BK_PARENS) ^ unit.bk)) {
boolean pure = false;
boolean comment = false;
+ boolean lookAhead = false;
+ boolean negativelh = false;
if ((index+1 < pLength) && (pattern[index] == '?')) {
switch (pattern[index+1]) {
+ case '!':
+ if (syntax.get(RESyntax.RE_LOOKAHEAD)) {
+ pure = true;
+ negativelh = true;
+ lookAhead = true;
+ index += 2;
+ }
+ break;
+ case '=':
+ if (syntax.get(RESyntax.RE_LOOKAHEAD)) {
+ pure = true;
+ lookAhead = true;
+ index += 2;
+ }
+ break;
case ':':
if (syntax.get(RESyntax.RE_PURE_GROUPING)) {
pure = true;
@@ -539,10 +556,14 @@ public class RE extends REToken {
numSubs++;
}
- int useIndex = (pure) ? 0 : nextSub + numSubs;
+ int useIndex = (pure || lookAhead) ? 0 : nextSub + numSubs;
currentToken = new RE(String.valueOf(pattern,index,endIndex-index).toCharArray(),cflags,syntax,useIndex,nextSub + numSubs);
numSubs += ((RE) currentToken).getNumSubs();
+ if (lookAhead) {
+ currentToken = new RETokenLookAhead(currentToken,negativelh);
+ }
+
index = nextIndex;
} // not a comment
} // subexpression
diff --git a/gnu/java/net/content/text/plain.java b/gnu/regexp/RETokenLookAhead.java
index a4ff3cd2f..650bb351b 100644
--- a/gnu/java/net/content/text/plain.java
+++ b/gnu/regexp/RETokenLookAhead.java
@@ -1,5 +1,5 @@
-/* plain.java -- Content Handler for text/plain type
- Copyright (C) 1998 Free Software Foundation, Inc.
+/* gnu/regexp/RETokenLookAhead.java
+ Copyright (C) 1998-2001, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -7,7 +7,7 @@ GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
-
+
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
@@ -35,55 +35,53 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
-
-package gnu.java.net.content.text;
-
-import java.net.ContentHandler;
-import java.net.URLConnection;
-import java.io.IOException;
+package gnu.regexp;
/**
- * This class is the ContentHandler for the text/plain MIME type. It
- * simply returns an InputStream object of the text being read.
- *
- * @version 0.1
- *
- * @author Aaron M. Renn (arenn@urbanophile.com)
- */
-public class plain extends ContentHandler
-{
-
-/*************************************************************************/
-
-/*
- * Constructors
+ * @since gnu.regexp 1.1.3
+ * @author Shashank Bapat
*/
-
-/**
- * Default do nothing constructor
- */
-public
-plain()
+final class RETokenLookAhead extends REToken
{
- ;
+ REToken re;
+ boolean negative;
+
+ RETokenLookAhead(REToken re, boolean negative) throws REException {
+ super(0);
+ this.re = re;
+ this.negative = negative;
+ }
+
+ boolean match(CharIndexed input, REMatch mymatch)
+ {
+ REMatch trymatch = (REMatch)mymatch.clone();
+ REMatch trymatch1 = (REMatch)mymatch.clone();
+ REMatch newMatch = null;
+ if (re.match(input, trymatch)) {
+ if (negative) return false;
+ if (next(input, trymatch1))
+ newMatch = trymatch1;
+ }
+
+ if (newMatch != null) {
+ if (negative) return false;
+ //else
+ mymatch.assignFrom(newMatch);
+ return true;
+ }
+ else { // no match
+ if (negative)
+ return next(input, mymatch);
+ //else
+ return false;
+ }
+ }
+
+ void dump(StringBuffer os) {
+ os.append("(?");
+ os.append(negative ? '!' : '=');
+ re.dumpAll(os);
+ os.append(')');
+ }
}
-/*************************************************************************/
-
-/**
- * Returns an InputStream as the content for this object
- *
- * @param url_con The URLConnection to get the content of
- *
- * @return An InputStream for that connection
- *
- * @exception IOException If an error occurs
- */
-public Object
-getContent(URLConnection url_con) throws IOException
-{
- return(url_con.getInputStream());
-}
-
-} // class plain
-