summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.externalToolBuilders/Autogen.launch11
-rw-r--r--.externalToolBuilders/Configure.launch10
-rw-r--r--AUTHORS1
-rw-r--r--ChangeLog522
-rw-r--r--examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/RequestTest.java6
-rw-r--r--examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/ourUserExceptionHelper.java11
-rw-r--r--gnu/CORBA/CDR/BigEndianInputStream.java61
-rw-r--r--gnu/CORBA/CDR/BigEndianOutputStream.java62
-rw-r--r--gnu/CORBA/CDR/LittleEndianInputStream.java633
-rw-r--r--gnu/CORBA/CDR/LittleEndianOutputStream.java253
-rw-r--r--gnu/CORBA/CDR/abstractDataInputStream.java392
-rw-r--r--gnu/CORBA/CDR/abstractDataOutputStream.java185
-rw-r--r--gnu/CORBA/CDR/aligningInputStream.java4
-rw-r--r--gnu/CORBA/CDR/aligningOutputStream.java4
-rw-r--r--gnu/CORBA/CDR/cdrInput.java183
-rw-r--r--gnu/CORBA/CDR/cdrOutput.java60
-rw-r--r--gnu/CORBA/CDR/encapsulatedOutput.java20
-rw-r--r--gnu/CORBA/CDR/uncObjectInputStream.java70
-rw-r--r--gnu/CORBA/CDR/uncObjectOutputStream.java73
-rw-r--r--gnu/CORBA/DefinitionKindHolder.java91
-rw-r--r--gnu/CORBA/Functional_ORB.java431
-rw-r--r--gnu/CORBA/GIOP/ErrorMessage.java4
-rw-r--r--gnu/CORBA/GIOP/MessageHeader.java70
-rw-r--r--gnu/CORBA/GIOP/cxCodeSet.java4
-rw-r--r--gnu/CORBA/GIOP/v1_2/RequestHeader.java4
-rw-r--r--gnu/CORBA/IOR.java33
-rw-r--r--gnu/CORBA/IOR_Delegate.java4
-rw-r--r--gnu/CORBA/ServiceRequestAdapter.java159
-rw-r--r--gnu/CORBA/SetOverrideTypeHolder.java90
-rw-r--r--gnu/CORBA/Simple_delegate.java7
-rw-r--r--gnu/CORBA/binaryReply.java1
-rw-r--r--gnu/CORBA/gnuNVList.java12
-rw-r--r--gnu/CORBA/gnuRequest.java50
-rw-r--r--gnu/CORBA/streamReadyHolder.java120
-rw-r--r--gnu/CORBA/universalHolder.java8
-rw-r--r--gnu/java/awt/GradientPaintContext.java164
-rw-r--r--gnu/java/awt/peer/gtk/GdkGraphics.java169
-rw-r--r--gnu/java/awt/peer/gtk/GdkGraphics2D.java31
-rw-r--r--gnu/java/awt/peer/gtk/GtkComponentPeer.java46
-rw-r--r--gnu/java/awt/peer/gtk/GtkContainerPeer.java11
-rw-r--r--gnu/java/awt/peer/gtk/GtkFramePeer.java37
-rw-r--r--gnu/java/awt/peer/gtk/GtkImage.java560
-rw-r--r--gnu/java/awt/peer/gtk/GtkImageConsumer.java155
-rw-r--r--gnu/java/awt/peer/gtk/GtkImagePainter.java267
-rw-r--r--gnu/java/awt/peer/gtk/GtkToolkit.java68
-rw-r--r--gnu/java/nio/channels/FileChannelImpl.java11
-rw-r--r--include/Makefile.am2
-rw-r--r--include/gnu_java_awt_peer_gtk_GdkGraphics.h3
-rw-r--r--include/gnu_java_awt_peer_gtk_GtkFramePeer.h3
-rw-r--r--include/gnu_java_awt_peer_gtk_GtkImage.h42
-rw-r--r--include/gnu_java_awt_peer_gtk_GtkImagePainter.h19
-rw-r--r--java/awt/Component.java4
-rw-r--r--java/awt/GradientPaint.java108
-rw-r--r--java/awt/image/BufferedImage.java12
-rw-r--r--java/awt/image/DirectColorModel.java2
-rw-r--r--java/awt/image/IndexColorModel.java463
-rw-r--r--java/io/FileInputStream.java2
-rw-r--r--java/io/FileOutputStream.java2
-rw-r--r--java/io/ObjectInputStream.java4
-rw-r--r--java/io/RandomAccessFile.java2
-rw-r--r--java/net/ServerSocket.java32
-rw-r--r--java/util/Calendar.java1
-rw-r--r--java/util/LinkedHashMap.java1
-rw-r--r--java/util/TimeZone.java356
-rw-r--r--javax/swing/AbstractButton.java2
-rw-r--r--javax/swing/ActionMap.java3
-rw-r--r--javax/swing/ImageIcon.java2
-rw-r--r--javax/swing/JButton.java1
-rw-r--r--javax/swing/JComponent.java4
-rw-r--r--javax/swing/JFileChooser.java7
-rw-r--r--javax/swing/JInternalFrame.java6
-rw-r--r--javax/swing/JLayeredPane.java11
-rw-r--r--javax/swing/JList.java78
-rw-r--r--javax/swing/JMenu.java2
-rw-r--r--javax/swing/JPopupMenu.java3
-rw-r--r--javax/swing/JRadioButton.java1
-rw-r--r--javax/swing/JScrollPane.java2
-rw-r--r--javax/swing/JSpinner.java2
-rw-r--r--javax/swing/JTabbedPane.java2
-rw-r--r--javax/swing/JTextArea.java1
-rw-r--r--javax/swing/JToggleButton.java1
-rw-r--r--javax/swing/JToolTip.java2
-rw-r--r--javax/swing/JTree.java76
-rw-r--r--javax/swing/JViewport.java2
-rw-r--r--javax/swing/LayoutFocusTraversalPolicy.java2
-rw-r--r--javax/swing/SpinnerDateModel.java4
-rw-r--r--javax/swing/SwingUtilities.java12
-rw-r--r--javax/swing/TransferHandler.java2
-rw-r--r--javax/swing/plaf/basic/BasicCheckBoxUI.java10
-rw-r--r--javax/swing/plaf/basic/BasicFileChooserUI.java25
-rw-r--r--javax/swing/plaf/basic/BasicInternalFrameTitlePane.java40
-rw-r--r--javax/swing/plaf/basic/BasicInternalFrameUI.java4
-rw-r--r--javax/swing/plaf/basic/BasicListUI.java14
-rw-r--r--javax/swing/plaf/basic/BasicMenuUI.java7
-rw-r--r--javax/swing/plaf/basic/BasicOptionPaneUI.java21
-rw-r--r--javax/swing/plaf/basic/BasicProgressBarUI.java6
-rw-r--r--javax/swing/plaf/basic/BasicSliderUI.java22
-rw-r--r--javax/swing/plaf/basic/BasicSplitPaneUI.java44
-rw-r--r--javax/swing/plaf/basic/BasicTabbedPaneUI.java22
-rw-r--r--javax/swing/plaf/basic/BasicTableUI.java22
-rw-r--r--javax/swing/plaf/basic/BasicTextUI.java3
-rw-r--r--javax/swing/plaf/metal/MetalSplitPaneUI.java22
-rw-r--r--javax/swing/text/DefaultStyledDocument.java11
-rw-r--r--javax/swing/text/PlainDocument.java4
-rw-r--r--javax/swing/text/PlainView.java2
-rw-r--r--lib/Makefile.am8
-rw-r--r--native/jni/gtk-peer/Makefile.am2
-rw-r--r--native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c156
-rw-r--r--native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkFramePeer.c66
-rw-r--r--native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkImage.c592
-rw-r--r--native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkImagePainter.c168
-rw-r--r--org/omg/CORBA/DefinitionKindHelper.java137
-rw-r--r--org/omg/CORBA/DynValue.java88
-rw-r--r--org/omg/CORBA/FieldNameHelper.java116
-rw-r--r--org/omg/CORBA/IdentifierHelper.java116
-rw-r--r--org/omg/CORBA/ORB.java119
-rw-r--r--org/omg/CORBA/ParameterMode.java170
-rw-r--r--org/omg/CORBA/ParameterModeHelper.java125
-rw-r--r--org/omg/CORBA/ParameterModeHolder.java (renamed from gnu/java/awt/peer/gtk/GtkOffScreenImage.java)79
-rw-r--r--org/omg/CORBA/RepositoryIdHelper.java116
-rw-r--r--org/omg/CORBA/SendingContext/RunTimeOperations.java57
-rw-r--r--org/omg/CORBA/SendingContext/Runtime.java60
-rw-r--r--org/omg/CORBA/ServerRequest.java16
-rw-r--r--org/omg/CORBA/SetOverrideTypeHelper.java128
-rw-r--r--org/omg/CORBA/UnknownUserException.java87
-rw-r--r--org/omg/CORBA/ValueBaseHelper.java20
-rw-r--r--org/omg/CORBA/VersionSpecHelper.java116
-rw-r--r--org/omg/CORBA/package.html43
-rw-r--r--org/omg/CORBA/portable/BoxedValueHelper.java76
-rw-r--r--org/omg/CORBA/portable/ValueFactory.java62
-rw-r--r--org/omg/CORBA_2_3/ORB.java130
-rw-r--r--org/omg/CORBA_2_3/portable/Delegate.java67
-rw-r--r--org/omg/CORBA_2_3/portable/InputStream.java189
-rw-r--r--org/omg/CORBA_2_3/portable/ObjectImpl.java82
-rw-r--r--org/omg/CORBA_2_3/portable/OutputStream.java145
-rw-r--r--org/omg/CORBA_2_3/portable/package.html46
-rw-r--r--org/omg/CosNaming/BindingIteratorHelper.java4
-rw-r--r--org/omg/CosNaming/BindingListHelper.java4
-rw-r--r--org/omg/CosNaming/BindingType.java7
-rw-r--r--org/omg/CosNaming/BindingTypeHelper.java4
-rw-r--r--org/omg/CosNaming/IstringHelper.java120
-rw-r--r--org/omg/CosNaming/NameComponent.java7
-rw-r--r--org/omg/CosNaming/NameComponentHelper.java4
-rw-r--r--org/omg/CosNaming/NameHelper.java4
-rw-r--r--org/omg/CosNaming/NamingContextExtHelper.java4
-rw-r--r--org/omg/CosNaming/NamingContextHelper.java4
-rw-r--r--org/omg/CosNaming/NamingContextPackage/AlreadyBound.java7
-rw-r--r--org/omg/CosNaming/NamingContextPackage/CannotProceed.java7
-rw-r--r--org/omg/CosNaming/NamingContextPackage/InvalidName.java7
-rw-r--r--org/omg/CosNaming/NamingContextPackage/NotEmpty.java6
-rw-r--r--org/omg/CosNaming/NamingContextPackage/NotFound.java7
-rw-r--r--org/omg/CosNaming/NamingContextPackage/NotFoundReason.java7
-rw-r--r--org/omg/CosNaming/_BindingIteratorImplBase.java29
-rw-r--r--org/omg/CosNaming/_BindingIteratorStub.java7
-rw-r--r--org/omg/CosNaming/_NamingContextExtImplBase.java48
-rw-r--r--org/omg/CosNaming/_NamingContextExtStub.java7
-rw-r--r--org/omg/CosNaming/_NamingContextImplBase.java54
-rw-r--r--org/omg/CosNaming/_NamingContextStub.java19
-rw-r--r--org/omg/Messaging/SYNC_WITH_TRANSPORT.java74
-rw-r--r--org/omg/Messaging/SyncScopeHelper.java121
-rw-r--r--org/omg/Messaging/package.html64
-rw-r--r--org/omg/stub/java/rmi/_Remote_Stub.java65
-rw-r--r--org/omg/stub/java/rmi/package.html48
163 files changed, 9037 insertions, 1817 deletions
diff --git a/.externalToolBuilders/Autogen.launch b/.externalToolBuilders/Autogen.launch
new file mode 100644
index 000000000..2f6a39d18
--- /dev/null
+++ b/.externalToolBuilders/Autogen.launch
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<launchConfiguration type="org.eclipse.ui.externaltools.ProgramBuilderLaunchConfigurationType">
+<booleanAttribute key="org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND" value="false"/>
+<stringAttribute key="org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS" value="./autogen.sh"/>
+<stringAttribute key="org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS" value="full,incremental,"/>
+<stringAttribute key="org.eclipse.debug.core.ATTR_REFRESH_SCOPE" value="${project}"/>
+<stringAttribute key="org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY" value="${build_project}"/>
+<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="/bin/sh"/>
+<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/>
+<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/>
+</launchConfiguration>
diff --git a/.externalToolBuilders/Configure.launch b/.externalToolBuilders/Configure.launch
new file mode 100644
index 000000000..acf9b358c
--- /dev/null
+++ b/.externalToolBuilders/Configure.launch
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<launchConfiguration type="org.eclipse.ui.externaltools.ProgramBuilderLaunchConfigurationType">
+<booleanAttribute key="org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND" value="false"/>
+<stringAttribute key="org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS" value="full,incremental,"/>
+<stringAttribute key="org.eclipse.debug.core.ATTR_REFRESH_SCOPE" value="${project}"/>
+<stringAttribute key="org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY" value="${build_project}"/>
+<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${build_project}/configure"/>
+<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/>
+<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/>
+</launchConfiguration>
diff --git a/AUTHORS b/AUTHORS
index 141bd9e2d..53255d1c3 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -15,6 +15,7 @@ Paul Fisher (rao@gnu.org)
Anthony Green (green@redhat.com)
Jochen Hoenicke (Jochen.Hoenicke@Informatik.Uni-Oldenburg.de)
Brian Jones (cbj@gnu.org)
+Roman Kennke (roman@kennke.org)
Michael Koch (konqueror@gmx.de)
John Keiser (jkeiser@iname.com)
John Leuner (jewel@debian.org)
diff --git a/ChangeLog b/ChangeLog
index b72c364ae..61aec1b1d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,521 @@
+2005-06-04 Tom Tromey <tromey@redhat.com>
+
+ * javax/swing/plaf/basic/BasicListUI.java (focusListener): Use
+ correct type.
+ (listDataListener, listSelectionListener, mouseInputListener,
+ propertyChangeListener): Likewise.
+ * javax/swing/plaf/basic/BasicMenuUI.java (ChangeHandler): Now
+ public and deprecated.
+ * javax/swing/plaf/basic/BasicTabbedPaneUI.java
+ (TabbedPaneLayout): Now public.
+ * javax/swing/plaf/basic/BasicOptionPaneUI.java
+ (ButtonActionListener): Now public.
+ (PropertyChangeHandler): Likewise.
+ (ButtonAreaLayout): Likewise.
+ * javax/swing/plaf/basic/BasicInternalFrameTitlePane.java
+ (TitlePaneLayout): Now public.
+ (PropertyChangeHandler): Likewise.
+ * javax/swing/plaf/basic/BasicCheckBoxUI.java
+ (getPropertyPrefix): New method.
+ * javax/swing/plaf/basic/BasicProgressBarUI.java (ChangeHandler):
+ Now public.
+ * javax/swing/plaf/basic/BasicSliderUI.java (ComponentHandler):
+ Now public.
+ * javax/swing/plaf/basic/BasicSplitPaneUI.java
+ (BasicVerticalLayoutManager): Now public.
+ (FocusHandler): Likewise.
+ (BasicHorizontalLayoutManager): Likewise.
+ * javax/swing/plaf/basic/BasicFileChooserUI.java
+ (AcceptAllFileFilter): New public constructor.
+ (BasicFileView): Likewise.
+ * javax/swing/plaf/basic/BasicInternalFrameUI.java
+ (BorderListener.RESIZE_NONE): Now final.
+
+2005-06-04 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * org/omg/CORBA/DefinitionKindHelper.java,
+ org/omg/CORBA/FieldNameHelper.java,
+ org/omg/CORBA/IdentifierHelper.java,
+ org/omg/CORBA/ParameterMode.java,
+ org/omg/CORBA/ParameterModeHelper.java,
+ org/omg/CORBA/ParameterModeHolder.java,
+ org/omg/CORBA/RepositoryIdHelper.java,
+ org/omg/CORBA/SetOverrideTypeHelper.java,
+ org/omg/CORBA/VersionSpecHelper.java,
+ gnu/CORBA/SetOverrideTypeHolder.java,
+ gnu/CORBA/DefinitionKindHolder.java: New files.
+
+2005-06-04 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * org/omg/stub/java/rmi/_Remote_Stub.java,
+ org/omg/stub/java/rmi/package.html: New package.
+
+2005-06-04 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * org/omg/Messaging/SyncScopeHelper.java
+ org/omg/Messaging/SYNC_WITH_TRANSPORT.java
+ org/omg/Messaging/package.html: New package.
+
+2005-06-04 Michael Koch <konqueror@gmx.de>
+
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkImage.c
+ (Java_gnu_java_awt_peer_gtk_GtkImage_loadPixbuf):
+ Fixed method declaration format.
+ (Java_gnu_java_awt_peer_gtk_GtkImage_drawPixelsScaled):
+ Likewise.
+
+2005-06-03 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * AUTHORS (Roman Kennke): New author.
+
+2005-06-03 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * org/omg/CORBA/portable/BoxedValueHelper.java,
+ org/omg/CORBA_2_3/portable/OutputStream.java,
+ org/omg/CORBA_2_3/portable/Delegate.java,
+ org/omg/CORBA_2_3/portable/ObjectImpl.java,
+ org/omg/CORBA_2_3/portable/package.html: New files.
+
+2005-06-03 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * org/omg/CosNaming/NamingContextPackage/AlreadyBound.java,
+ org/omg/CosNaming/NamingContextPackage/CannotProceed.java,
+ org/omg/CosNaming/NamingContextPackage/InvalidName.java,
+ org/omg/CosNaming/NamingContextPackage/NotEmpty.java,
+ org/omg/CosNaming/NamingContextPackage/NotFound.java,
+ org/omg/CosNaming/NamingContextPackage/NotFoundReason.java:
+ Added SerialVersionUID.
+
+2005-06-03 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * gnu/CORBA/GIOP/uncObjectInputStream.java,
+ gnu/CORBA/GIOP/uncObjectInputStream/uncObjectOutputStream.java:
+ Deleting files.
+ * gnu/CORBA/CDR/uncObjectInputStream.java,
+ gnu/CORBA/CDR/uncObjectInputStream/uncObjectOutputStream.java:
+ Adding files.
+
+2005-06-03 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * gnu/CORBA/Functional_ORB.java,
+ gnu/CORBA/IOR_Delegate.java,
+ gnu/CORBA/Simple_delegate.java,
+ gnu/CORBA/universalHolder.java,
+ gnu/CORBA/CDR/aligningInputStream.java,
+ gnu/CORBA/CDR/aligningOutputStream.java,
+ gnu/CORBA/CDR/cdrInput.java,
+ gnu/CORBA/CDR/cdrOutput.java,
+ gnu/CORBA/CDR/encapsulatedOutput.java,
+ gnu/CORBA/GIOP/ErrorMessage.java,
+ gnu/CORBA/GIOP/MessageHeader.java,
+ gnu/CORBA/GIOP/cxCodeSet.java,
+ gnu/CORBA/GIOP/v1_2/RequestHeader.java,
+ org/omg/CosNaming/BindingIteratorHelper.java,
+ org/omg/CosNaming/BindingListHelper.java,
+ org/omg/CosNaming/BindingTypeHelper.java,
+ org/omg/CosNaming/NameComponentHelper.java,
+ org/omg/CosNaming/NameHelper.java,
+ org/omg/CosNaming/NamingContextExtHelper.java,
+ org/omg/CosNaming/NamingContextHelper.java:
+ Initialise instances of org.omg.SystemException, thrown
+ after catching the other exception, with InitCause.
+
+2005-06-03 Roman Kennke <roman@kennke.org>
+
+ * javax/swing/plaf/basic/BasicListUI.java
+ (damageLayout): Check for list beeing null before revalidating
+ it.
+
+2005-06-03 Roman Kennke <roman@kennke.org>
+
+ * javax/swing/text/PlainDocument.java
+ (removeUpdate): Fixed indices in text buffer access.
+ * javax/swing/text/PlainView.java
+ (drawLine): Simplified element access.
+
+2005-06-03 Roman Kennke <roman@kennke.org>
+
+ * javax/swing/JTextArea.java
+ (constructor): Set preferredSize to a sane default.
+
+2005-06-03 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * gnu/CORBA/GIOP/uncObjectInputStream.java,
+ gnu/CORBA/GIOP/uncObjectInputStream/uncObjectOutputStream.java: New streams.
+ * org/omg/CORBA/ValueBaseHelper.java: Removing inner classes,
+ using uncObjectInputStream, uncObjectOutputStream instead.
+ * org/omg/CORBA_2_3/portable (read_value): Delegate call to
+ ValueBaseHelper.
+
+2005-06-03 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * org/omg/CORBA/SendingContext/Runtime.java,
+ org/omg/CORBA/SendingContext/RunTimeOperations.java:
+ Fixing the package statement.
+
+2005-06-03 Roman Kennke <roman@kennke.org>
+
+ * javax/swing/SwingUtilites.java
+ (replaceUIActionMap): Fixed loop again. Now correctly, I hope.
+ * javax/swing/ActionMap.java
+ (setParent): Make sure we don't build a loop.
+ * javax/swing/plaf/basic/BasicTextUI.java
+ (createActionMap): Create ActionMapUIResource instead of
+ plain ActionMap.
+
+2005-06-03 Sven de Marothy <sven@physto.se>
+
+ * gnu/java/awt/peer/gtk/GdkGraphics.java:
+ Removed declarations for the previously removed native methods.
+
+2005-06-03 Roman Kennke <roman@kennke.org>
+
+ * javax/swing/SwingUtilites.java
+ (replaceUIActionMap): Fixed condition in while loop that caused
+ infinite looping.
+
+2005-06-03 Roman Kennke <roman@kennke.org>
+
+ * javax/swing/plaf/basic/BasicTableUI.java
+ (uninstallDefault): Don't set properties to null, this corrupts
+ component state.
+
+2005-06-02 Andrew John Hughes <gnu_andrew@member.fsf.org>
+
+ * lib/Makefile.am:
+ Fix permissions problem with creation of META-INF tree.
+
+2005-06-02 Sven de Marothy <sven@physto.se>
+
+ * java/awt/Component.java
+ (setBackgroundColor): Return if the color equals the existing bgcolor.
+
+2005-06-02 Sven de Marothy <sven@physto.se>
+
+ * gnu/java/awt/peer/gtk/GdkGraphics2D.java:
+ (drawImage): Remove reference to GtkOffScreenImage.
+ * gnu/java/awt/peer/gtk/GtkImageConsumer.java:
+ Add additional comments.
+
+2005-06-02 Sven de Marothy <sven@physto.se>
+
+ * gnu/java/awt/peer/gtk/GdkGraphics.java:
+ (GdkGraphics): New constructor.
+ (drawImage): Reimplemented.
+ * gnu/java/awt/peer/gtk/GtkComponentPeer.java:
+ (checkImage,createImage): Reimplemented.
+ (prepareImage): Just call the GdkToolkit method.
+ * gnu/java/awt/peer/gtk/GtkFramePeer.java:
+ (setIconImage): Reimplemented.
+ * gnu/java/awt/peer/gtk/GtkImage.java: Reimplemented.
+ * gnu/java/awt/peer/gtk/GtkToolkit.java:
+ (checkImage): Change handling of GtkImage.
+ (createImage): Reimplemented for GtkImage.
+ (getColorModel): Return the actual native color model.
+ (prepareImage): Reimplemented.
+ * include/Makefile.am,
+ * native/jni/gtk-peer/Makefile.am: Removed old files, added new ones.
+ * include/gnu_java_awt_peer_gtk_GdkGraphics.h,
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c:
+ (initFromImage): New method.
+ (copyPixmap, flip_pixbuf, copyAndScalePixmap): Removed.
+ * include/gnu_java_awt_peer_gtk_GtkFramePeer.h,
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkFramePeer.c:
+ (nativeSetIconImage): New method.
+ (nativeSetIconImageFromData,nativeSetIconImageFromDecoder): Removed.
+ * gnu/java/awt/peer/gtk/GtkImageConsumer.java,
+ * include/gnu_java_awt_peer_gtk_GtkImage.h,
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkImage.c:
+ New files.
+ * gnu/java/awt/peer/gtk/GtkImagePainter.java,
+ * gnu/java/awt/peer/gtk/GtkOffScreenImage.java,
+ * include/gnu_java_awt_peer_gtk_GtkImagePainter.h,
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkImagePainter.c:
+ Removed files.
+
+2005-06-01 Tom Tromey <tromey@redhat.com>
+
+ * java/io/ObjectInputStream.java (currentLoader): Fixed typo.
+
+2005-06-01 Tom Tromey <tromey@redhat.com>
+
+ * org/omg/CosNaming/IstringHelper.java: Changed non-ascii
+ characters.
+
+2005-06-01 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * org/omg/SendingContext/package.html,
+ org/omg/SendingContext/RunTimeOperations.java,
+ org/omg/SendingContext/Runtime.java: New package.
+
+2005-06-01 Roman Kennke <roman@kennke.org>
+
+ * javax/swing/text/DefaultStyledDocument.java
+ (setLogicalStyle): Implemented this method.
+
+2005-06-01 Sven de Marothy <sven@physto.se>
+
+ * java/util/GregorianCalendar.java
+ (setTimeInMillis): Recompute time fields.
+
+2005-06-01 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * org/omg/CosNaming/BindingType.java,
+ org/omg/CosNaming/NameComponent.java,
+ org/omg/CosNaming/_BindingIteratorStub.java,
+ org/omg/CosNaming/_NamingContextStub.java,
+ org/omg/CosNaming/_NamingContextExtStub.java,
+ org/omg/CosNaming/_BindingIteratorImplBase.java,
+ org/omg/CosNaming/_NamingContextImplBase.java: Added SerialVersionUID.
+
+2005-06-01 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * org/omg/CosNaming/IstringHelper.java: New class.
+
+2005-06-01 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * gnu/CORBA/CDR/cdrInput.java (read_wstring): Correcting
+ check for native encoding.
+
+2005-06-01 Roman Kennke <roman@kennke.org>
+
+ * javax/swing/plaf/basic/BasicFileChooserUI.java
+ (installComponents): Changed layout of main panel from GridBagLayout
+ to BorderLayout (as is the case in Suns JDK). This fixes
+ bug#13244.
+
+2005-06-01 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * gnu/CORBA/Functional_ORB.java (serveStep),
+ gnu/CORBA/gnuRequest.java (submit),
+ gnu/CORBA/CDR/cdrInput.java (read_encapsulation): Correcting
+ data read loop.
+
+2005-06-01 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * gnu/CORBA/Functional_ORG.java (getFreePort): Remember
+ the port number in the local variable.
+
+2005-06-01 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * examples/gnu/classpath/examples/CORBA/SimpleCommunication/
+ communication/ourUserExceptionHelper.java (extract): New method.
+ * examples/gnu/classpath/examples/CORBA/SimpleCommunication/
+ communication/RequestTest.java:Use helper extract method.
+
+2005-06-01 Roman Kennke <roman@kennke.org>
+
+ * javax/swing/JPopupMenu.java
+ (insert): Do not check for index == -1 at this point, this is done
+ in java.awt.Container. Catching -1 indices here disturbes the
+ Container.addImpl which leads to bug #13247 for example.
+
+2005-06-01 Roman Kennke <roman@kennke.org>
+
+ * javax/swing/text/PlainDocument.java
+ (removeUpdate): Fixed indices in call to rootElement.replace().
+
+2005-06-01 Roman Kennke <roman@kennke.org>
+
+ * javax/swing/JComponent.java
+ (processKeyEvent): Call super.processKeyEvent() so that KeyEvents
+ are delivered to registered KeyListeners.
+
+2005-05-31 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * org/omg/CORBA_2_3/ORB.java,
+ org/omg/CORBA_2_3/portable/InputStream.java,
+ org/omg/CORBA/portable/ValueFactory.java: New classes.
+
+2005-05-31 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * org/omg.CORBA/DynValue.java (declaration): Inherit from DynAny,
+ org.omg.CORBA.Object. (set_members): Declare it may throw InvalidSeq.
+
+2005-06-01 Sven de Marothy <sven@physto.se>
+
+ * java/util/TimeZone (getDefaultTimeZone): Reimplemented.
+ (parseTime, getDateParams): New private methods.
+
+2005-06-01 David Gilbert <david.gilbert@object-refinery.com>
+
+ * gnu/java/awt/GradientPaintContext.java: New file.
+ * java/awt/GradientPaint.java: Implemented.
+ * java/awt/image/IndexColorModel.java: Reimplemented.
+
+2005-05-31 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * gnu/CORBA/CDR/BigEndianInputStream.java,
+ gnu/CORBA/CDR/BigEndianOutputStream.java,
+ gnu/CORBA/CDR/LittleEndianInputStream.java,
+ gnu/CORBA/CDR/LittleEndianOutputStream.java: New streams.
+ gnu/CORBA/CDR/abstractDataInputStream.java,
+ gnu/CORBA/CDR/abstractDataOutputStream.java: New interfaces.
+ * gnu/CORBA/IOR.java: Implemented parsing of the Little
+ Endian encoded IOR references.
+ * gnu/CORBA/Functional_ORB.java,
+ gnu/CORBA/binaryReply.java,
+ gnu/CORBA/gnuRequest.java,
+ gnu/CORBA/CDR/cdrInput.java,
+ gnu/CORBA/CDR/cdrOutput.java,
+ gnu/CORBA/CDR/encapsulatedOutput.java,
+ gnu/CORBA/GIOP/MessageHeader.java: Implemented support
+ for Big and Little Endian.
+ * org/omg/CORBA/package.html: Documentation update.
+
+2005-05-31 Jeroen Frijters <jeroen@frijters.net>
+
+ * java/net/ServerSocket.java
+ (bound): Removed.
+ (local): New field.
+ (bind): Cache local socket address.
+ (getInetAddress, getLocalPort, getLocalSocketAddress, isBound):
+ Use cached local socket address.
+ (close): bound field was removed.
+
+2005-05-31 Jeroen Frijters <jeroen@frijters.net>
+
+ * gnu/java/nio/channels/FileChannelImpl.java
+ (FileChannelImpl()): Removed.
+ (FileChannelImpl(File,int)): Made private.
+ (create): New method.
+ * java/io/FileInputStream.java,
+ java/io/FileOutputStream.java,
+ java/io/RandomAccessFile.java:
+ Updated construction of FileChannelImpl instance.
+
+2005-05-31 Sven de Marothy <sven@physto.se>
+
+ * java/awt/image/BufferedImage.java:
+ (ImageProducer): Use Vector instead of HashMap.
+ * java/awt/image/DirectColorModel.java:
+ (getAlpha): Default to 255 (opaque).
+
+2005-05-30 Roman Kennke <roman@kennke.org>
+
+ * javax/swing/JTree.java
+ (getNextMatch): Implemented new method.
+
+2005-05-30 Roman Kennke <roman@kennke.org>
+
+ * javax/swing/plaf/metal/MetalSplitPaneUI.java:
+ (createUI): Do not share one instance of MetalSplitPaneUI
+ between multiple JSplitPanes.
+
+2005-05-30 Roman Kennke <roman@kennke.org>
+
+ * javax/swing/JComponent.java:
+ Made JComponent.AccessibleJComponent implement
+ AccessibleExtendedComponent.
+
+2005-05-30 Roman Kennke <roman@kennke.org>
+
+ * javax/swing/JButton.java
+ (constructor): Set initial actionCommand equal to the buttons label.
+
+2005-05-30 Roman Kennke <roman@kennke.org>
+
+ * javax/swing/JList.java
+ (getNextMatch): Implemented new method.
+ (getCellBounds): Implemented new method.
+
+2005-05-30 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * gnu/CORBA/Functional_ORB.java (serve, portServer, serveStep):
+ Implemented support for the subsequent invocations reusing the same
+ socket.
+ * gnu/CORBA/GIOP/MessageHeader.java (read): throw
+ NO_IMPLEMENT, not MARSHAL for Little Endian request.
+
+2005-05-30 Roman Kennke <roman@kennke.org>
+
+ * javax/swing/JLayeredPane.java
+ (putLayer): Implemented new method.
+
+2005-05-30 Roman Kennke <roman@kennke.org>
+
+ * javax/swing/JFileChooser.java:
+ Fixed values of some constant fields.
+
+2005-05-30 Roman Kennke <roman@kennke.org>
+
+ * javax/swing/SwingUtilities.java:
+ (getWindowAncestor): This method has to be static instead of
+ non-static.
+
+2005-05-29 Michael Koch <konqueror@gmx.de>
+
+ * java/util/LinkedHashMap.java (access): Set 'root.pred'.
+
+2005-05-29 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * org/omg/CosNaming/_BindingIteratorImplBase.java ,
+ org/omg/CosNaming/_NamingContextExtImplBase.java,
+ org/omg/CosNaming/_NamingContextImplBase.java: Inherit from
+ DynamicImplementation.
+ * gnu/CORBA/ServiceRequestAdapter.java: New class.
+ * gnu/CORBA/gnuNVList.java (add, add_item):
+ Replacing null by constructed instance.
+
+2005-05-29 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * org/omg/CORBA/Functional_ORB.java (serve, useProperties, init):
+ Implementing the property-configurable time-outs.
+
+2005-05-29 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * gnu/CORBA/gnuRequest.java (p_invoke): Wrap the received UserException into
+ UnknownUserException.
+ * gnu/CORBA/streamReadyHolder.java: New wrapper for UserException.
+ * org/omg/CORBA/UnknownUserException.java: New exception.
+
+2005-05-27 Roman Kennke <roman@kennke.org>
+
+ * javax/swing/AbstractButton.java:
+ Bumped up serialVersionUID(s) to JDK1.4 compatibility.
+ * javax/swing/ImageIcon.java: Likewise.
+ * javax/swing/JFileChooser.java: Likewise.
+ * javax/swing/JInternalFrame.java: Likewise.
+ * javax/swing/JMenu.java: Likewise.
+ * javax/swing/JRadioButton.java: Likewise.
+ * javax/swing/JScrollPane.java: Likewise.
+ * javax/swing/JSpinner.java: Likewise.
+ * javax/swing/JTabbedPane.java: Likewise.
+ * javax/swing/ImageIcons.java: Likewise.
+ * javax/swing/JToggleButton.java: Likewise.
+ * javax/swing/JToolTip.java: Likewise.
+ * javax/swing/JViewPort.java: Likewise.
+ * javax/swing/LayoutFocusTraversalPolicy.java: Likewise.
+ * javax/swing/SpinnerDateModel.java: Likewise.
+ * javax/swing/TransferHandler.java: Likewise.
+
+2005-05-27 Thomas Fitzsimmons <fitzsim@redhat.com>
+
+ * gnu/java/awt/peer/gtk/GtkContainerPeer.java (setFont): Handle
+ lightweight peers specially.
+
+2005-05-27 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * omg/org/CORBA/ORB.java (create_recursive_sequence_tc): New method.
+
+2005-05-27 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * omg/org/CORBA/DynValue.java: New interface.
+
+2005-05-27 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * omg/org/CORBA/package.html: Documentation update.
+
+2005-05-26 Audrius Meskauskas <AudriusA@Bioinformatics.org>
+
+ * org/omg/CORBA/ORB.java (create_basic_dyn_any):
+ Declare it may throw an InconsistentTypeCode.
+ (create_dyn_any): Remove wrong exception declaration.
+ (create_operation_list, create_abstract_interface_tc,
+ create_native_tc, get_service_information): Implementing these methods.
+ * org/omg/CORBA/ServerRequest.java (result, except, params, op_name):
+ Marking deprecated.
+
2005-05-26 Andrew John Hughes <gnu_andrew@member.fsf.org>
* gnu/java/net/protocol/http/HTTPURLConnection.java:
@@ -42,6 +560,10 @@
2005-05-25 Thomas Fitzsimmons <fitzsim@redhat.com>
+ * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkScrollBarPeer.c
+ (create): Prevent min == max scrollbars.
+ (setValues): Likewise.
+
* java/awt/Component.java (enableInputMethods): Implement.
2005-05-25 Audrius Meskauskas <AudriusA@Bioinformatics.org>
diff --git a/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/RequestTest.java b/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/RequestTest.java
index 3c56a3876..977fb4282 100644
--- a/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/RequestTest.java
+++ b/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/RequestTest.java
@@ -16,6 +16,7 @@ import org.omg.CORBA.Request;
import org.omg.CORBA.ShortHolder;
import org.omg.CORBA.StringHolder;
import org.omg.CORBA.TCKind;
+import org.omg.CORBA.UnknownUserException;
/**
* This code uses CORBA to call various methods of the remote object,
@@ -226,9 +227,10 @@ public class RequestTest
rq.add_in_arg().insert_long(123);
rq.invoke();
- ourUserException ou = (ourUserException) rq.env().exception();
+ UnknownUserException uku = (UnknownUserException) rq.env().exception();
+ ourUserException our_exception = ourUserExceptionHelper.extract(uku.except);
- System.out.println(" Our user exception, field " + ou.ourField +
+ System.out.println(" Our user exception, field " + our_exception.ourField +
", has been thrown on remote side."
);
}
diff --git a/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/ourUserExceptionHelper.java b/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/ourUserExceptionHelper.java
index a5b2fa671..415adff1f 100644
--- a/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/ourUserExceptionHelper.java
+++ b/examples/gnu/classpath/examples/CORBA/SimpleCommunication/communication/ourUserExceptionHelper.java
@@ -68,6 +68,15 @@ public abstract class ourUserExceptionHelper
}
/**
+ * Extract the exception from the given Any where it might be
+ * wrapped.
+ */
+ public static ourUserException extract(Any a)
+ {
+ return read(a.create_input_stream());
+ }
+
+ /**
* Read the exception from the CDR stream.
*/
public static ourUserException read(org.omg.CORBA.portable.InputStream istream)
@@ -104,4 +113,4 @@ public abstract class ourUserExceptionHelper
ostream.write_string(id());
ostream.write_long(value.ourField);
}
-}
+} \ No newline at end of file
diff --git a/gnu/CORBA/CDR/BigEndianInputStream.java b/gnu/CORBA/CDR/BigEndianInputStream.java
new file mode 100644
index 000000000..8218b0347
--- /dev/null
+++ b/gnu/CORBA/CDR/BigEndianInputStream.java
@@ -0,0 +1,61 @@
+/* BigEndianInputStream.java --
+ Copyright (C) 2005 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.CORBA.CDR;
+
+import java.io.DataInputStream;
+import java.io.InputStream;
+
+/**
+ * As java uses Big Endian by default, this class is directly derived
+ * form DataInputStream.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class BigEndianInputStream
+ extends DataInputStream
+ implements abstractDataInputStream
+{
+ /**
+ * Delegates to the parent constructor.
+ */
+ public BigEndianInputStream(InputStream in)
+ {
+ super(in);
+ }
+} \ No newline at end of file
diff --git a/gnu/CORBA/CDR/BigEndianOutputStream.java b/gnu/CORBA/CDR/BigEndianOutputStream.java
new file mode 100644
index 000000000..fe80bbc4f
--- /dev/null
+++ b/gnu/CORBA/CDR/BigEndianOutputStream.java
@@ -0,0 +1,62 @@
+/* BigEndianOutputStream.java --
+ Copyright (C) 2005 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.CORBA.CDR;
+
+import java.io.DataOutputStream;
+import java.io.OutputStream;
+
+/**
+ * A stream to read the data in Big Endian format. This class is
+ * directly derived from DataOutputStream that uses the Big
+ * Endian.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class BigEndianOutputStream
+ extends DataOutputStream
+ implements abstractDataOutputStream
+{
+ /**
+ * Delegate functionality to the parent constructor.
+ */
+ public BigEndianOutputStream(OutputStream out)
+ {
+ super(out);
+ }
+} \ No newline at end of file
diff --git a/gnu/CORBA/CDR/LittleEndianInputStream.java b/gnu/CORBA/CDR/LittleEndianInputStream.java
new file mode 100644
index 000000000..412608b0b
--- /dev/null
+++ b/gnu/CORBA/CDR/LittleEndianInputStream.java
@@ -0,0 +1,633 @@
+/* LittleEndianInputStream.java --
+ Copyright (C) 1998, 1999, 2000, 2001, 2003, 2005 Free Software Foundation
+
+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.CORBA.CDR;
+
+import java.io.DataInput;
+import java.io.EOFException;
+import java.io.FilterInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.PushbackInputStream;
+
+/**
+ * This class reads data in the Little Endian format. It reuses
+ * code from GNU Classpath DataInputStream.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ * @author Warren Levy (warrenl@cygnus.com)
+ * @author Aaron M. Renn (arenn@urbanophile.com)
+ */
+public class LittleEndianInputStream
+ extends FilterInputStream
+ implements abstractDataInputStream
+{
+ // Byte buffer, used to make primitive read calls more efficient.
+ byte[] buf = new byte[ 8 ];
+
+ /**
+ * This constructor initializes a new <code>DataInputStream</code>
+ * to read from the specified subordinate stream.
+ *
+ * @param in The subordinate <code>InputStream</code> to read from
+ */
+ public LittleEndianInputStream(InputStream in)
+ {
+ super(in);
+ }
+
+ /**
+ * This method reads bytes from the underlying stream into the specified
+ * byte array buffer. It will attempt to fill the buffer completely, but
+ * may return a short count if there is insufficient data remaining to be
+ * read to fill the buffer.
+ *
+ * @param b The buffer into which bytes will be read.
+ *
+ * @return The actual number of bytes read, or -1 if end of stream reached
+ * before reading any bytes.
+ *
+ * @exception IOException If an error occurs.
+ */
+ public int read(byte[] b)
+ throws IOException
+ {
+ return in.read(b, 0, b.length);
+ }
+
+ /**
+ * This method reads bytes from the underlying stream into the specified
+ * byte array buffer. It will attempt to read <code>len</code> bytes and
+ * will start storing them at position <code>off</code> into the buffer.
+ * This method can return a short count if there is insufficient data
+ * remaining to be read to complete the desired read length.
+ *
+ * @param b The buffer into which bytes will be read.
+ * @param off The offset into the buffer to start storing bytes.
+ * @param len The requested number of bytes to read.
+ *
+ * @return The actual number of bytes read, or -1 if end of stream reached
+ * before reading any bytes.
+ *
+ * @exception IOException If an error occurs.
+ */
+ public int read(byte[] b, int off, int len)
+ throws IOException
+ {
+ return in.read(b, off, len);
+ }
+
+ /**
+ * This method reads a Java boolean value from an input stream. It does
+ * so by reading a single byte of data. If that byte is zero, then the
+ * value returned is <code>false</code>. If the byte is non-zero, then
+ * the value returned is <code>true</code>.
+ * <p>
+ * This method can read a <code>boolean</code> written by an object
+ * implementing the <code>writeBoolean()</code> method in the
+ * <code>DataOutput</code> interface.
+ *
+ * @return The <code>boolean</code> value read
+ *
+ * @exception EOFException If end of file is reached before reading
+ * the boolean
+ * @exception IOException If any other error occurs
+ *
+ * @see DataOutput#writeBoolean
+ */
+ public boolean readBoolean()
+ throws IOException
+ {
+ return convertToBoolean(in.read());
+ }
+
+ /**
+ * This method reads a Java byte value from an input stream. The value
+ * is in the range of -128 to 127.
+ * <p>
+ * This method can read a <code>byte</code> written by an object
+ * implementing the <code>writeByte()</code> method in the
+ * <code>DataOutput</code> interface.
+ *
+ * @return The <code>byte</code> value read
+ *
+ * @exception EOFException If end of file is reached before reading the byte
+ * @exception IOException If any other error occurs
+ *
+ * @see DataOutput#writeByte
+ */
+ public byte readByte()
+ throws IOException
+ {
+ return convertToByte(in.read());
+ }
+
+ /**
+ * This method reads a Java <code>char</code> value from an input stream.
+ * It operates by reading two bytes from the stream and converting them to
+ * a single 16-bit Java <code>char</code>. The two bytes are stored most
+ * significant byte first (i.e., "big endian") regardless of the native
+ * host byte ordering.
+ * <p>
+ * As an example, if <code>byte1</code> and <code>byte2</code>
+ * represent the first and second byte read from the stream
+ * respectively, they will be transformed to a <code>char</code> in
+ * the following manner:
+ * <p>
+ * <code>(char)(((byte1 &amp; 0xFF) &lt;&lt; 8) | (byte2 &amp; 0xFF)</code>
+ * <p>
+ * This method can read a <code>char</code> written by an object
+ * implementing the <code>writeChar()</code> method in the
+ * <code>DataOutput</code> interface.
+ *
+ * @return The <code>char</code> value read
+ *
+ * @exception EOFException If end of file is reached before reading the char
+ * @exception IOException If any other error occurs
+ *
+ * @see DataOutput#writeChar
+ */
+ public char readChar()
+ throws IOException
+ {
+ readFully(buf, 0, 2);
+ return convertToChar(buf);
+ }
+
+ /**
+ * This method reads a Java double value from an input stream. It operates
+ * by first reading a <code>long</code> value from the stream by calling the
+ * <code>readLong()</code> method in this interface, then converts
+ * that <code>long</code> to a <code>double</code> using the
+ * <code>longBitsToDouble</code> method in the class
+ * <code>java.lang.Double</code>
+ * <p>
+ * This method can read a <code>double</code> written by an object
+ * implementing the <code>writeDouble()</code> method in the
+ * <code>DataOutput</code> interface.
+ *
+ * @return The <code>double</code> value read
+ *
+ * @exception EOFException If end of file is reached before reading
+ * the double
+ * @exception IOException If any other error occurs
+ *
+ * @see DataOutput#writeDouble
+ * @see java.lang.Double#longBitsToDouble
+ */
+ public double readDouble()
+ throws IOException
+ {
+ return Double.longBitsToDouble(readLong());
+ }
+
+ /**
+ * This method reads a Java float value from an input stream. It
+ * operates by first reading an <code>int</code> value from the
+ * stream by calling the <code>readInt()</code> method in this
+ * interface, then converts that <code>int</code> to a
+ * <code>float</code> using the <code>intBitsToFloat</code> method
+ * in the class <code>java.lang.Float</code>
+ * <p>
+ * This method can read a <code>float</code> written by an object
+ * implementing the <code>writeFloat()</code> method in the
+ * <code>DataOutput</code> interface.
+ *
+ * @return The <code>float</code> value read
+ *
+ * @exception EOFException If end of file is reached before reading the float
+ * @exception IOException If any other error occurs
+ *
+ * @see DataOutput#writeFloat
+ * @see java.lang.Float#intBitsToFloat
+ */
+ public float readFloat()
+ throws IOException
+ {
+ return Float.intBitsToFloat(readInt());
+ }
+
+ /**
+ * This method reads raw bytes into the passed array until the array is
+ * full. Note that this method blocks until the data is available and
+ * throws an exception if there is not enough data left in the stream to
+ * fill the buffer. Note also that zero length buffers are permitted.
+ * In this case, the method will return immediately without reading any
+ * bytes from the stream.
+ *
+ * @param b The buffer into which to read the data
+ *
+ * @exception EOFException If end of file is reached before filling the
+ * buffer
+ * @exception IOException If any other error occurs
+ */
+ public void readFully(byte[] b)
+ throws IOException
+ {
+ readFully(b, 0, b.length);
+ }
+
+ /**
+ * This method reads raw bytes into the passed array <code>buf</code>
+ * starting
+ * <code>offset</code> bytes into the buffer. The number of bytes read
+ * will be
+ * exactly <code>len</code>. Note that this method blocks until the data is
+ * available and throws an exception if there is not enough data left in
+ * the stream to read <code>len</code> bytes. Note also that zero length
+ * buffers are permitted. In this case, the method will return immediately
+ * without reading any bytes from the stream.
+ *
+ * @param buf The buffer into which to read the data
+ * @param offset The offset into the buffer to start storing data
+ * @param len The number of bytes to read into the buffer
+ *
+ * @exception EOFException If end of file is reached before filling the
+ * buffer
+ * @exception IOException If any other error occurs
+ */
+ public void readFully(byte[] buf, int offset, int len)
+ throws IOException
+ {
+ if (len < 0)
+ throw new IndexOutOfBoundsException("Negative length: " + len);
+
+ while (len > 0)
+ {
+ // in.read will block until some data is available.
+ int numread = in.read(buf, offset, len);
+ if (numread < 0)
+ throw new EOFException();
+ len -= numread;
+ offset += numread;
+ }
+ }
+
+ /**
+ * This method reads a Java <code>int</code> value from an input stream
+ * It operates by reading four bytes from the stream and converting them to
+ * a single Java <code>int</code>. The bytes are stored most
+ * significant byte first (i.e., "big endian") regardless of the native
+ * host byte ordering.
+ * <p>
+ * As an example, if <code>byte1</code> through <code>byte4</code> represent
+ * the first four bytes read from the stream, they will be
+ * transformed to an <code>int</code> in the following manner:
+ * <p>
+ * <code>(int)(((byte1 &amp; 0xFF) &lt;&lt; 24) + ((byte2 &amp; 0xFF) &lt;&lt; 16) +
+ * ((byte3 &amp; 0xFF)&lt;&lt; 8) + (byte4 &amp; 0xFF)))</code>
+ * <p>
+ * The value returned is in the range of -2147483648 to 2147483647.
+ * <p>
+ * This method can read an <code>int</code> written by an object
+ * implementing the <code>writeInt()</code> method in the
+ * <code>DataOutput</code> interface.
+ *
+ * @return The <code>int</code> value read
+ *
+ * @exception EOFException If end of file is reached before reading the int
+ * @exception IOException If any other error occurs
+ *
+ * @see DataOutput#writeInt
+ */
+ public int readInt()
+ throws IOException
+ {
+ readFully(buf, 0, 4);
+ return convertToInt(buf);
+ }
+
+ /**
+ * This method reads the next line of text data from an input
+ * stream. It operates by reading bytes and converting those bytes
+ * to <code>char</code> values by treating the byte read as the low
+ * eight bits of the <code>char</code> and using 0 as the high eight
+ * bits. Because of this, it does not support the full 16-bit
+ * Unicode character set.
+ * <p>
+ * The reading of bytes ends when either the end of file or a line
+ * terminator is encountered. The bytes read are then returned as a
+ * <code>String</code> A line terminator is a byte sequence
+ * consisting of either <code>\r</code>, <code>\n</code> or
+ * <code>\r\n</code>. These termination charaters are discarded and
+ * are not returned as part of the string.
+ * <p>
+ * This method can read data that was written by an object implementing the
+ * <code>writeLine()</code> method in <code>DataOutput</code>.
+ *
+ * @return The line read as a <code>String</code>
+ *
+ * @exception IOException If an error occurs
+ *
+ * @see DataOutput
+ *
+ * @deprecated
+ */
+ public String readLine()
+ throws IOException
+ {
+ StringBuffer strb = new StringBuffer();
+
+ while (true)
+ {
+ int c = in.read();
+ if (c == -1) // got an EOF
+ return strb.length() > 0 ? strb.toString() : null;
+ if (c == '\r')
+ {
+ int next_c = in.read();
+ if (next_c != '\n' && next_c != -1)
+ {
+ if (!(in instanceof PushbackInputStream))
+ in = new PushbackInputStream(in);
+ ((PushbackInputStream) in).unread(next_c);
+ }
+ break;
+ }
+ if (c == '\n')
+ break;
+ strb.append((char) c);
+ }
+
+ return strb.length() > 0 ? strb.toString() : "";
+ }
+
+ /**
+ * This method reads a Java <code>long</code> value from an input stream
+ * It operates by reading eight bytes from the stream and converting them to
+ * a single Java <code>long</code>. The bytes are stored most
+ * significant byte first (i.e., "big endian") regardless of the native
+ * host byte ordering.
+ * <p>
+ * As an example, if <code>byte1</code> through <code>byte8</code> represent
+ * the first eight bytes read from the stream, they will be
+ * transformed to an <code>long</code> in the following manner:
+ * <p>
+ * <code>(long)(((byte1 &amp; 0xFF) &lt;&lt; 56) + ((byte2 &amp; 0xFF) &lt;&lt; 48) +
+ * ((byte3 &amp; 0xFF) &lt;&lt; 40) + ((byte4 &amp; 0xFF) &lt;&lt; 32) +
+ * ((byte5 &amp; 0xFF) &lt;&lt; 24) + ((byte6 &amp; 0xFF) &lt;&lt; 16) +
+ * ((byte7 &amp; 0xFF) &lt;&lt; 8) + (byte8 &amp; 0xFF)))
+ * </code>
+ * <p>
+ * The value returned is in the range of -9223372036854775808 to
+ * 9223372036854775807.
+ * <p>
+ * This method can read an <code>long</code> written by an object
+ * implementing the <code>writeLong()</code> method in the
+ * <code>DataOutput</code> interface.
+ *
+ * @return The <code>long</code> value read
+ *
+ * @exception EOFException If end of file is reached before reading the long
+ * @exception IOException If any other error occurs
+ *
+ * @see DataOutput#writeLong
+ */
+ public long readLong()
+ throws IOException
+ {
+ readFully(buf, 0, 8);
+ return convertToLong(buf);
+ }
+
+ /**
+ * This method reads a signed 16-bit value into a Java in from the
+ * stream. It operates by reading two bytes from the stream and
+ * converting them to a single 16-bit Java <code>short</code>. The
+ * two bytes are stored most significant byte first (i.e., "big
+ * endian") regardless of the native host byte ordering.
+ * <p>
+ * As an example, if <code>byte1</code> and <code>byte2</code>
+ * represent the first and second byte read from the stream
+ * respectively, they will be transformed to a <code>short</code>. in
+ * the following manner:
+ * <p>
+ * <code>(short)(((byte1 &amp; 0xFF) &lt;&lt; 8) | (byte2 &amp; 0xFF))</code>
+ * <p>
+ * The value returned is in the range of -32768 to 32767.
+ * <p>
+ * This method can read a <code>short</code> written by an object
+ * implementing the <code>writeShort()</code> method in the
+ * <code>DataOutput</code> interface.
+ *
+ * @return The <code>short</code> value read
+ *
+ * @exception EOFException If end of file is reached before reading the value
+ * @exception IOException If any other error occurs
+ *
+ * @see DataOutput#writeShort
+ */
+ public short readShort()
+ throws IOException
+ {
+ readFully(buf, 0, 2);
+ return convertToShort(buf);
+ }
+
+ /**
+ * This method reads 8 unsigned bits into a Java <code>int</code>
+ * value from the stream. The value returned is in the range of 0 to
+ * 255.
+ * <p>
+ * This method can read an unsigned byte written by an object
+ * implementing the <code>writeUnsignedByte()</code> method in the
+ * <code>DataOutput</code> interface.
+ *
+ * @return The unsigned bytes value read as a Java <code>int</code>.
+ *
+ * @exception EOFException If end of file is reached before reading the value
+ * @exception IOException If any other error occurs
+ *
+ * @see DataOutput#writeByte
+ */
+ public int readUnsignedByte()
+ throws IOException
+ {
+ return convertToUnsignedByte(in.read());
+ }
+
+ /**
+ * This method reads 16 unsigned bits into a Java int value from the stream.
+ * It operates by reading two bytes from the stream and converting them to
+ * a single Java <code>int</code> The two bytes are stored most
+ * significant byte first (i.e., "big endian") regardless of the native
+ * host byte ordering.
+ * <p>
+ * As an example, if <code>byte1</code> and <code>byte2</code>
+ * represent the first and second byte read from the stream
+ * respectively, they will be transformed to an <code>int</code> in
+ * the following manner:
+ * <p>
+ * <code>(int)(((byte1 &amp; 0xFF) &lt;&lt; 8) + (byte2 &amp; 0xFF))</code>
+ * <p>
+ * The value returned is in the range of 0 to 65535.
+ * <p>
+ * This method can read an unsigned short written by an object
+ * implementing the <code>writeUnsignedShort()</code> method in the
+ * <code>DataOutput</code> interface.
+ *
+ * @return The unsigned short value read as a Java <code>int</code>
+ *
+ * @exception EOFException If end of file is reached before reading the value
+ * @exception IOException If any other error occurs
+ *
+ * @see DataOutput#writeShort
+ */
+ public int readUnsignedShort()
+ throws IOException
+ {
+ readFully(buf, 0, 2);
+ return convertToUnsignedShort(buf);
+ }
+
+ /**
+ * This method attempts to skip and discard the specified number of bytes
+ * in the input stream. It may actually skip fewer bytes than requested.
+ * This method will not skip any bytes if passed a negative number of bytes
+ * to skip.
+ *
+ * @param n The requested number of bytes to skip.
+ *
+ * @return The requested number of bytes to skip.
+ *
+ * @exception IOException If an error occurs.
+ * @specnote The JDK docs claim that this returns the number of bytes
+ * actually skipped. The JCL claims that this method can throw an
+ * EOFException. Neither of these appear to be true in the JDK 1.3's
+ * implementation. This tries to implement the actual JDK behaviour.
+ */
+ public int skipBytes(int n)
+ throws IOException
+ {
+ if (n <= 0)
+ return 0;
+ try
+ {
+ return (int) in.skip(n);
+ }
+ catch (EOFException x)
+ {
+ // do nothing.
+ }
+ return n;
+ }
+
+ protected boolean convertToBoolean(int b)
+ throws EOFException
+ {
+ if (b < 0)
+ throw new EOFException();
+
+ return (b != 0);
+ }
+
+ protected byte convertToByte(int i)
+ throws EOFException
+ {
+ if (i < 0)
+ throw new EOFException();
+
+ return (byte) i;
+ }
+
+ protected int convertToUnsignedByte(int i)
+ throws EOFException
+ {
+ if (i < 0)
+ throw new EOFException();
+
+ return (i & 0xFF);
+ }
+
+ /**
+ * Less significant byte first.
+ */
+ protected char convertToChar(byte[] buf)
+ {
+ return (char) ((buf [ 1 ] << 8) | (buf [ 0 ] & 0xff));
+ }
+
+ /**
+ * Less significant byte first.
+ */
+ protected short convertToShort(byte[] buf)
+ {
+ return (short) ((buf [ 1 ] << 8) | (buf [ 0 ] & 0xff));
+ }
+
+ /**
+ * Less significant byte first.
+ */
+ protected int convertToUnsignedShort(byte[] buf)
+ {
+ return (((buf [ 1 ] & 0xff) << 8) | (buf [ 0 ] & 0xff));
+ }
+
+ /**
+ * Less significant byte first.
+ */
+ protected int convertToInt(byte[] buf)
+ {
+ return (((buf [ 3 ] & 0xff) << 24) | ((buf [ 2 ] & 0xff) << 16) |
+ ((buf [ 1 ] & 0xff) << 8) | (buf [ 0 ] & 0xff));
+ }
+
+ /**
+ * Less significant byte first.
+ */
+ protected long convertToLong(byte[] buf)
+ {
+ return (((long) (buf [ 7 ] & 0xff) << 56) |
+ ((long) (buf [ 6 ] & 0xff) << 48) |
+ ((long) (buf [ 5 ] & 0xff) << 40) |
+ ((long) (buf [ 4 ] & 0xff) << 32) |
+ ((long) (buf [ 3 ] & 0xff) << 24) |
+ ((long) (buf [ 2 ] & 0xff) << 16) |
+ ((long) (buf [ 1 ] & 0xff) << 8) | ((long) (buf [ 0 ] & 0xff)));
+ }
+
+ /**
+ * This should never be called.
+ *
+ * @throws InternalError, always.
+ */
+ public String readUTF()
+ {
+ throw new InternalError();
+ }
+} \ No newline at end of file
diff --git a/gnu/CORBA/CDR/LittleEndianOutputStream.java b/gnu/CORBA/CDR/LittleEndianOutputStream.java
new file mode 100644
index 000000000..7ff8263db
--- /dev/null
+++ b/gnu/CORBA/CDR/LittleEndianOutputStream.java
@@ -0,0 +1,253 @@
+/* LittleEndianOutputStream.java --
+ Copyright (C) 1998, 2001, 2003, 2005 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.CORBA.CDR;
+
+import java.io.FilterOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+
+/**
+ * This stream writes data in the Little Endian format
+ * (less significant byte first). This is opposite to the
+ * usual data presentation in java platform.
+ *
+ * This class reuses code from DataOutputStream.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ * @author Aaron M. Renn (arenn@urbanophile.com)
+ * @author Tom Tromey (tromey@cygnus.com)
+ */
+public class LittleEndianOutputStream
+ extends FilterOutputStream
+ implements abstractDataOutputStream
+{
+ /**
+ * This method initializes an instance of <code>DataOutputStream</code> to
+ * write its data to the specified underlying <code>OutputStream</code>
+ *
+ * @param out The subordinate <code>OutputStream</code> to which this
+ * object will write
+ */
+ public LittleEndianOutputStream(OutputStream out)
+ {
+ super(out);
+ }
+
+ /**
+ * This method flushes any unwritten bytes to the underlying stream.
+ *
+ * @exception IOException If an error occurs.
+ */
+ public void flush()
+ throws IOException
+ {
+ out.flush();
+ }
+
+ /**
+ * This method writes the specified byte (passed as an <code>int</code>)
+ * to the underlying output stream.
+ *
+ * @param value The <code>byte</code> to write, passed as an <code>int</code>.
+ *
+ * @exception IOException If an error occurs.
+ */
+ public synchronized void write(int value)
+ throws IOException
+ {
+ out.write(value);
+ }
+
+ /**
+ * This method writes <code>len</code> bytes from the specified byte array
+ * <code>buf</code> starting at position <code>offset</code> into the
+ * buffer to the underlying output stream.
+ *
+ * @param buf The byte array to write from.
+ * @param offset The index into the byte array to start writing from.
+ * @param len The number of bytes to write.
+ *
+ * @exception IOException If an error occurs.
+ */
+ public synchronized void write(byte[] buf, int offset, int len)
+ throws IOException
+ {
+ out.write(buf, offset, len);
+ }
+
+ /**
+ * This method writes a Java boolean value to an output stream. If
+ * <code>value</code> is <code>true</code>, a byte with the value of
+ * 1 will be written, otherwise a byte with the value of 0 will be
+ * written.
+ *
+ * The value written can be read using the <code>readBoolean</code>
+ * method in <code>DataInput</code>.
+ *
+ * @param value The <code>boolean</code> value to write to the stream
+ *
+ * @exception IOException If an error occurs
+ *
+ * @see DataInput#readBoolean
+ */
+ public void writeBoolean(boolean value)
+ throws IOException
+ {
+ write(value ? 1 : 0);
+ }
+
+ /**
+ * This method writes a Java byte value to an output stream. The
+ * byte to be written will be in the lowest 8 bits of the
+ * <code>int</code> value passed.
+ *
+ * The value written can be read using the <code>readByte</code> or
+ * <code>readUnsignedByte</code> methods in <code>DataInput</code>.
+ *
+ * @param value The <code>byte</code> to write to the stream, passed as
+ * the low eight bits of an <code>int</code>.
+ *
+ * @exception IOException If an error occurs
+ *
+ * @see DataInput#readByte
+ * @see DataInput#readUnsignedByte
+ */
+ public void writeByte(int value)
+ throws IOException
+ {
+ write(value & 0xff);
+ }
+
+ /**
+ * This method writes a Java short value to an output stream.
+ *
+ * @param value The <code>short</code> value to write to the stream,
+ * passed as an <code>int</code>.
+ *
+ * @exception IOException If an error occurs
+ */
+ public synchronized void writeShort(int value)
+ throws IOException
+ {
+ write((byte) (0xff & value));
+ write((byte) (0xff & (value >> 8)));
+ }
+
+ /**
+ * Writes char in Little Endian.
+ */
+ public synchronized void writeChar(int value)
+ throws IOException
+ {
+ write((byte) (0xff & value));
+ write((byte) (0xff & (value >> 8)));
+ }
+
+ /**
+ * Writes int in Little Endian.
+ */
+ public synchronized void writeInt(int value)
+ throws IOException
+ {
+ write((byte) (0xff & value));
+ write((byte) (0xff & (value >> 8)));
+ write((byte) (0xff & (value >> 16)));
+ write((byte) (0xff & (value >> 24)));
+ }
+
+ /**
+ * Writes long in Little Endian.
+ */
+ public synchronized void writeLong(long value)
+ throws IOException
+ {
+ write((byte) (0xff & value));
+ write((byte) (0xff & (value >> 8)));
+ write((byte) (0xff & (value >> 16)));
+ write((byte) (0xff & (value >> 24)));
+ write((byte) (0xff & (value >> 32)));
+ write((byte) (0xff & (value >> 40)));
+ write((byte) (0xff & (value >> 48)));
+ write((byte) (0xff & (value >> 56)));
+ }
+
+ /**
+ * This method writes a Java <code>float</code> value to the stream. This
+ * value is written by first calling the method
+ * <code>Float.floatToIntBits</code>
+ * to retrieve an <code>int</code> representing the floating point number,
+ * then writing this <code>int</code> value to the stream exactly the same
+ * as the <code>writeInt()</code> method does.
+ *
+ * @param value The <code>float</code> value to write to the stream
+ *
+ * @exception IOException If an error occurs
+ *
+ * @see writeInt
+ * @see DataInput#readFloat
+ * @see Float#floatToIntBits
+ */
+ public void writeFloat(float value)
+ throws IOException
+ {
+ writeInt(Float.floatToIntBits(value));
+ }
+
+ /**
+ * This method writes a Java <code>double</code> value to the stream. This
+ * value is written by first calling the method
+ * <code>Double.doubleToLongBits</code>
+ * to retrieve an <code>long</code> representing the floating point number,
+ * then writing this <code>long</code> value to the stream exactly the same
+ * as the <code>writeLong()</code> method does.
+ *
+ * @param value The <code>double</code> value to write to the stream
+ *
+ * @exception IOException If an error occurs
+ *
+ * @see writeLong
+ * @see DataInput#readDouble
+ * @see Double#doubleToLongBits
+ */
+ public void writeDouble(double value)
+ throws IOException
+ {
+ writeLong(Double.doubleToLongBits(value));
+ }
+} \ No newline at end of file
diff --git a/gnu/CORBA/CDR/abstractDataInputStream.java b/gnu/CORBA/CDR/abstractDataInputStream.java
new file mode 100644
index 000000000..4da48bb27
--- /dev/null
+++ b/gnu/CORBA/CDR/abstractDataInputStream.java
@@ -0,0 +1,392 @@
+/* abstractDataInputStream.java --
+ Copyright (C) 2005 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.CORBA.CDR;
+
+import java.io.IOException;
+
+/**
+ * Some data input stream that can be either Big or
+ * Little Endian.
+ *
+ * This class reuses code from GNU Classpath DataInputStream.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ * @author Warren Levy (warrenl@cygnus.com)
+ * @author Aaron M. Renn (arenn@urbanophile.com)
+ */
+public interface abstractDataInputStream
+{
+ /**
+ * This method reads bytes from the underlying stream into the specified
+ * byte array buffer. It will attempt to fill the buffer completely, but
+ * may return a short count if there is insufficient data remaining to be
+ * read to fill the buffer.
+ *
+ * @param b The buffer into which bytes will be read.
+ *
+ * @return The actual number of bytes read, or -1 if end of stream reached
+ * before reading any bytes.
+ *
+ * @exception IOException If an error occurs.
+ */
+ int read(byte[] b)
+ throws IOException;
+
+ /**
+ * This method reads bytes from the underlying stream into the specified
+ * byte array buffer. It will attempt to read <code>len</code> bytes and
+ * will start storing them at position <code>off</code> into the buffer.
+ * This method can return a short count if there is insufficient data
+ * remaining to be read to complete the desired read length.
+ *
+ * @param b The buffer into which bytes will be read.
+ * @param off The offset into the buffer to start storing bytes.
+ * @param len The requested number of bytes to read.
+ *
+ * @return The actual number of bytes read, or -1 if end of stream reached
+ * before reading any bytes.
+ *
+ * @exception IOException If an error occurs.
+ */
+ int read(byte[] b, int off, int len)
+ throws IOException;
+
+ /**
+ * This method reads a Java boolean value from an input stream. It does
+ * so by reading a single byte of data. If that byte is zero, then the
+ * value returned is <code>false</code>. If the byte is non-zero, then
+ * the value returned is <code>true</code>.
+ * <p>
+ * This method can read a <code>boolean</code> written by an object
+ * implementing the <code>writeBoolean()</code> method in the
+ * <code>DataOutput</code> interface.
+ *
+ * @return The <code>boolean</code> value read
+ *
+ * @exception EOFException If end of file is reached before reading
+ * the boolean
+ * @exception IOException If any other error occurs
+ *
+ * @see DataOutput#writeBoolean
+ */
+ boolean readBoolean()
+ throws IOException;
+
+ /**
+ * This method reads a Java byte value from an input stream. The value
+ * is in the range of -128 to 127.
+ * <p>
+ * This method can read a <code>byte</code> written by an object
+ * implementing the <code>writeByte()</code> method in the
+ * <code>DataOutput</code> interface.
+ *
+ * @return The <code>byte</code> value read
+ *
+ * @exception EOFException If end of file is reached before reading the byte
+ * @exception IOException If any other error occurs
+ *
+ * @see DataOutput#writeByte
+ */
+ byte readByte()
+ throws IOException;
+
+ /**
+ * This method reads a Java <code>char</code> value from an input stream.
+ * It operates by reading two bytes from the stream and converting them to
+ * a single 16-bit Java <code>char</code>. The two bytes are stored most
+ * significant byte first (i.e., "big endian") regardless of the native
+ * host byte ordering.
+ * <p>
+ * As an example, if <code>byte1</code> and <code>byte2</code>
+ * represent the first and second byte read from the stream
+ * respectively, they will be transformed to a <code>char</code> in
+ * the following manner:
+ * <p>
+ * <code>(char)(((byte1 &amp; 0xFF) &lt;&lt; 8) | (byte2 &amp; 0xFF)</code>
+ * <p>
+ * This method can read a <code>char</code> written by an object
+ * implementing the <code>writeChar()</code> method in the
+ * <code>DataOutput</code> interface.
+ *
+ * @return The <code>char</code> value read
+ *
+ * @exception EOFException If end of file is reached before reading the char
+ * @exception IOException If any other error occurs
+ *
+ * @see DataOutput#writeChar
+ */
+ char readChar()
+ throws IOException;
+
+ /**
+ * This method reads a Java double value from an input stream. It operates
+ * by first reading a <code>long</code> value from the stream by calling the
+ * <code>readLong()</code> method in this interface, then converts
+ * that <code>long</code> to a <code>double</code> using the
+ * <code>longBitsToDouble</code> method in the class
+ * <code>java.lang.Double</code>
+ * <p>
+ * This method can read a <code>double</code> written by an object
+ * implementing the <code>writeDouble()</code> method in the
+ * <code>DataOutput</code> interface.
+ *
+ * @return The <code>double</code> value read
+ *
+ * @exception EOFException If end of file is reached before reading
+ * the double
+ * @exception IOException If any other error occurs
+ *
+ * @see DataOutput#writeDouble
+ * @see java.lang.Double#longBitsToDouble
+ */
+ double readDouble()
+ throws IOException;
+
+ /**
+ * This method reads a Java float value from an input stream. It
+ * operates by first reading an <code>int</code> value from the
+ * stream by calling the <code>readInt()</code> method in this
+ * interface, then converts that <code>int</code> to a
+ * <code>float</code> using the <code>intBitsToFloat</code> method
+ * in the class <code>java.lang.Float</code>
+ * <p>
+ * This method can read a <code>float</code> written by an object
+ * implementing the <code>writeFloat()</code> method in the
+ * <code>DataOutput</code> interface.
+ *
+ * @return The <code>float</code> value read
+ *
+ * @exception EOFException If end of file is reached before reading the float
+ * @exception IOException If any other error occurs
+ *
+ * @see DataOutput#writeFloat
+ * @see java.lang.Float#intBitsToFloat
+ */
+ float readFloat()
+ throws IOException;
+
+ /**
+ * This method reads raw bytes into the passed array until the array is
+ * full. Note that this method blocks until the data is available and
+ * throws an exception if there is not enough data left in the stream to
+ * fill the buffer. Note also that zero length buffers are permitted.
+ * In this case, the method will return immediately without reading any
+ * bytes from the stream.
+ *
+ * @param b The buffer into which to read the data
+ *
+ * @exception EOFException If end of file is reached before filling the
+ * buffer
+ * @exception IOException If any other error occurs
+ */
+ void readFully(byte[] b)
+ throws IOException;
+
+ /**
+ * This method reads a Java <code>int</code> value from an input stream
+ * It operates by reading four bytes from the stream and converting them to
+ * a single Java <code>int</code>. The bytes are stored most
+ * significant byte first (i.e., "big endian") regardless of the native
+ * host byte ordering.
+ * <p>
+ * As an example, if <code>byte1</code> through <code>byte4</code> represent
+ * the first four bytes read from the stream, they will be
+ * transformed to an <code>int</code> in the following manner:
+ * <p>
+ * <code>(int)(((byte1 &amp; 0xFF) &lt;&lt; 24) + ((byte2 &amp; 0xFF) &lt;&lt; 16) +
+ * ((byte3 &amp; 0xFF)&lt;&lt; 8) + (byte4 &amp; 0xFF)))</code>
+ * <p>
+ * The value returned is in the range of -2147483648 to 2147483647.
+ * <p>
+ * This method can read an <code>int</code> written by an object
+ * implementing the <code>writeInt()</code> method in the
+ * <code>DataOutput</code> interface.
+ *
+ * @return The <code>int</code> value read
+ *
+ * @exception EOFException If end of file is reached before reading the int
+ * @exception IOException If any other error occurs
+ *
+ * @see DataOutput#writeInt
+ */
+ int readInt()
+ throws IOException;
+
+ /**
+ * This method reads a Java <code>long</code> value from an input stream
+ * It operates by reading eight bytes from the stream and converting them to
+ * a single Java <code>long</code>. The bytes are stored most
+ * significant byte first (i.e., "big endian") regardless of the native
+ * host byte ordering.
+ * <p>
+ * As an example, if <code>byte1</code> through <code>byte8</code> represent
+ * the first eight bytes read from the stream, they will be
+ * transformed to an <code>long</code> in the following manner:
+ * <p>
+ * <code>(long)(((byte1 &amp; 0xFF) &lt;&lt; 56) + ((byte2 &amp; 0xFF) &lt;&lt; 48) +
+ * ((byte3 &amp; 0xFF) &lt;&lt; 40) + ((byte4 &amp; 0xFF) &lt;&lt; 32) +
+ * ((byte5 &amp; 0xFF) &lt;&lt; 24) + ((byte6 &amp; 0xFF) &lt;&lt; 16) +
+ * ((byte7 &amp; 0xFF) &lt;&lt; 8) + (byte8 &amp; 0xFF)))
+ * </code>
+ * <p>
+ * The value returned is in the range of -9223372036854775808 to
+ * 9223372036854775807.
+ * <p>
+ * This method can read an <code>long</code> written by an object
+ * implementing the <code>writeLong()</code> method in the
+ * <code>DataOutput</code> interface.
+ *
+ * @return The <code>long</code> value read
+ *
+ * @exception EOFException If end of file is reached before reading the long
+ * @exception IOException If any other error occurs
+ *
+ * @see DataOutput#writeLong
+ */
+ long readLong()
+ throws IOException;
+
+ /**
+ * This method reads a signed 16-bit value into a Java in from the
+ * stream. It operates by reading two bytes from the stream and
+ * converting them to a single 16-bit Java <code>short</code>. The
+ * two bytes are stored most significant byte first (i.e., "big
+ * endian") regardless of the native host byte ordering.
+ * <p>
+ * As an example, if <code>byte1</code> and <code>byte2</code>
+ * represent the first and second byte read from the stream
+ * respectively, they will be transformed to a <code>short</code>. in
+ * the following manner:
+ * <p>
+ * <code>(short)(((byte1 &amp; 0xFF) &lt;&lt; 8) | (byte2 &amp; 0xFF))</code>
+ * <p>
+ * The value returned is in the range of -32768 to 32767.
+ * <p>
+ * This method can read a <code>short</code> written by an object
+ * implementing the <code>writeShort()</code> method in the
+ * <code>DataOutput</code> interface.
+ *
+ * @return The <code>short</code> value read
+ *
+ * @exception EOFException If end of file is reached before reading the value
+ * @exception IOException If any other error occurs
+ *
+ * @see DataOutput#writeShort
+ */
+ short readShort()
+ throws IOException;
+
+ /**
+ * This method reads 8 unsigned bits into a Java <code>int</code>
+ * value from the stream. The value returned is in the range of 0 to
+ * 255.
+ * <p>
+ * This method can read an unsigned byte written by an object
+ * implementing the <code>writeUnsignedByte()</code> method in the
+ * <code>DataOutput</code> interface.
+ *
+ * @return The unsigned bytes value read as a Java <code>int</code>.
+ *
+ * @exception EOFException If end of file is reached before reading the value
+ * @exception IOException If any other error occurs
+ *
+ * @see DataOutput#writeByte
+ */
+ int readUnsignedByte()
+ throws IOException;
+
+ /**
+ * This method reads 16 unsigned bits into a Java int value from the stream.
+ * It operates by reading two bytes from the stream and converting them to
+ * a single Java <code>int</code> The two bytes are stored most
+ * significant byte first (i.e., "big endian") regardless of the native
+ * host byte ordering.
+ * <p>
+ * As an example, if <code>byte1</code> and <code>byte2</code>
+ * represent the first and second byte read from the stream
+ * respectively, they will be transformed to an <code>int</code> in
+ * the following manner:
+ * <p>
+ * <code>(int)(((byte1 &amp; 0xFF) &lt;&lt; 8) + (byte2 &amp; 0xFF))</code>
+ * <p>
+ * The value returned is in the range of 0 to 65535.
+ * <p>
+ * This method can read an unsigned short written by an object
+ * implementing the <code>writeUnsignedShort()</code> method in the
+ * <code>DataOutput</code> interface.
+ *
+ * @return The unsigned short value read as a Java <code>int</code>
+ *
+ * @exception EOFException If end of file is reached before reading the value
+ * @exception IOException If any other error occurs
+ *
+ * @see DataOutput#writeShort
+ */
+ int readUnsignedShort()
+ throws IOException;
+
+ /**
+ * Read a single byte.
+ *
+ * @return a byte, extracted from the stream or -1 if
+ * EOF has been reached.
+ * @throws IOException
+ */
+ public int read()
+ throws IOException;
+
+ /**
+ * This method attempts to skip and discard the specified number of bytes
+ * in the input stream. It may actually skip fewer bytes than requested.
+ * This method will not skip any bytes if passed a negative number of bytes
+ * to skip.
+ *
+ * @param n The requested number of bytes to skip.
+ *
+ * @return The requested number of bytes to skip.
+ *
+ * @exception IOException If an error occurs.
+ * @specnote The JDK docs claim that this returns the number of bytes
+ * actually skipped. The JCL claims that this method can throw an
+ * EOFException. Neither of these appear to be true in the JDK 1.3's
+ * implementation. This tries to implement the actual JDK behaviour.
+ */
+ int skipBytes(int n)
+ throws IOException;
+} \ No newline at end of file
diff --git a/gnu/CORBA/CDR/abstractDataOutputStream.java b/gnu/CORBA/CDR/abstractDataOutputStream.java
new file mode 100644
index 000000000..b54dc0f7f
--- /dev/null
+++ b/gnu/CORBA/CDR/abstractDataOutputStream.java
@@ -0,0 +1,185 @@
+/* abstractDataOutputStream.java --
+ Copyright (C) 2005 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.CORBA.CDR;
+
+import java.io.IOException;
+
+/**
+ * An abstract data output stream that could write data in either
+ * Big Endian or Little Endian format.
+ *
+ * This class reuses code from GNU Classpath DataOutputStream.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ * @author Warren Levy (warrenl@cygnus.com)
+ * @author Aaron M. Renn (arenn@urbanophile.com)
+ */
+public interface abstractDataOutputStream
+{
+ /**
+ * This method flushes any unwritten bytes to the underlying stream.
+ *
+ * @exception IOException If an error occurs.
+ */
+ void flush()
+ throws IOException;
+
+ /**
+ * This method writes the specified byte (passed as an <code>int</code>)
+ * to the underlying output stream.
+ *
+ * @param value The <code>byte</code> to write, passed as an <code>int</code>.
+ *
+ * @exception IOException If an error occurs.
+ */
+ void write(int value)
+ throws IOException;
+
+ /**
+ * This method writes <code>len</code> bytes from the specified byte array
+ * <code>buf</code> starting at position <code>offset</code> into the
+ * buffer to the underlying output stream.
+ *
+ * @param buf The byte array to write from.
+ * @param offset The index into the byte array to start writing from.
+ * @param len The number of bytes to write.
+ *
+ * @exception IOException If an error occurs.
+ */
+ void write(byte[] buf, int offset, int len)
+ throws IOException;
+
+ /**
+ * Write the complete byte array.
+ * @throws IOException
+ */
+ void write(byte[] buf)
+ throws IOException;
+
+ /**
+ * This method writes a Java boolean value to an output stream. If
+ * <code>value</code> is <code>true</code>, a byte with the value of
+ * 1 will be written, otherwise a byte with the value of 0 will be
+ * written.
+ *
+ * The value written can be read using the <code>readBoolean</code>
+ * method in <code>DataInput</code>.
+ *
+ * @param value The <code>boolean</code> value to write to the stream
+ *
+ * @exception IOException If an error occurs
+ */
+ void writeBoolean(boolean value)
+ throws IOException;
+
+ /**
+ * This method writes a Java byte value to an output stream. The
+ * byte to be written will be in the lowest 8 bits of the
+ * <code>int</code> value passed.
+ *
+ * The value written can be read using the <code>readByte</code> or
+ * <code>readUnsignedByte</code> methods in <code>DataInput</code>.
+ *
+ * @param value The <code>byte</code> to write to the stream, passed as
+ * the low eight bits of an <code>int</code>.
+ *
+ * @exception IOException If an error occurs
+ */
+ void writeByte(int value)
+ throws IOException;
+
+ /**
+ * This method writes a Java short value to an output stream. The
+ * char to be written will be in the lowest 16 bits of the <code>int</code>
+ * value passed.
+ *
+ * @exception IOException If an error occurs
+ */
+ void writeShort(int value)
+ throws IOException;
+
+ /**
+ * This method writes a Java char value to an output stream. The
+ * char to be written will be in the lowest 16 bits of the <code>int</code>
+ * value passed.
+ *
+ * @exception IOException If an error occurs
+ */
+ void writeChar(int value)
+ throws IOException;
+
+ /**
+ * This method writes a Java int value to an output stream.
+ *
+ * @param value The <code>int</code> value to write to the stream
+ *
+ * @exception IOException If an error occurs
+ */
+ void writeInt(int value)
+ throws IOException;
+
+ /**
+ * This method writes a Java long value to an output stream.
+ *
+ * @param value The <code>long</code> value to write to the stream
+ *
+ * @exception IOException If an error occurs
+ */
+ void writeLong(long value)
+ throws IOException;
+
+ /**
+ * This method writes a Java <code>float</code> value to the stream.
+ * @param value The <code>float</code> value to write to the stream
+ *
+ * @exception IOException If an error occurs
+ */
+ void writeFloat(float value)
+ throws IOException;
+
+ /**
+ * This method writes a Java <code>double</code> value to the stream.
+ *
+ * @param value The <code>double</code> value to write to the stream
+ *
+ * @exception IOException If an error occurs
+ */
+ void writeDouble(double value)
+ throws IOException;
+} \ No newline at end of file
diff --git a/gnu/CORBA/CDR/aligningInputStream.java b/gnu/CORBA/CDR/aligningInputStream.java
index 798b3acea..c29a52cfa 100644
--- a/gnu/CORBA/CDR/aligningInputStream.java
+++ b/gnu/CORBA/CDR/aligningInputStream.java
@@ -106,7 +106,9 @@ public class aligningInputStream
}
catch (Exception ex)
{
- throw new BAD_PARAM("Unable to align at " + alignment);
+ BAD_PARAM p = new BAD_PARAM("Unable to align at " + alignment);
+ p.initCause(ex);
+ throw p;
}
}
diff --git a/gnu/CORBA/CDR/aligningOutputStream.java b/gnu/CORBA/CDR/aligningOutputStream.java
index b4a96f8bb..f4009c47c 100644
--- a/gnu/CORBA/CDR/aligningOutputStream.java
+++ b/gnu/CORBA/CDR/aligningOutputStream.java
@@ -100,7 +100,9 @@ public class aligningOutputStream
}
catch (Exception ex)
{
- throw new BAD_PARAM("Unable to align at " + alignment);
+ BAD_PARAM p = new BAD_PARAM("Unable to align at " + alignment);
+ p.initCause(ex);
+ throw p;
}
}
diff --git a/gnu/CORBA/CDR/cdrInput.java b/gnu/CORBA/CDR/cdrInput.java
index 03be3363b..644e01930 100644
--- a/gnu/CORBA/CDR/cdrInput.java
+++ b/gnu/CORBA/CDR/cdrInput.java
@@ -62,6 +62,7 @@ import org.omg.CORBA.TypeCodePackage.Bounds;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.ObjectImpl;
+import java.io.DataInput;
import java.io.DataInputStream;
import java.io.EOFException;
import java.io.IOException;
@@ -93,7 +94,13 @@ public abstract class cdrInput
* This instance is used to convert primitive data types into the
* byte sequences.
*/
- protected DataInputStream b;
+ protected abstractDataInputStream b;
+
+ /**
+ * The input stream, from where the data are actually
+ * being read.
+ */
+ protected java.io.InputStream actual_stream;
/**
* The associated orb, if any.
@@ -137,7 +144,16 @@ public abstract class cdrInput
private boolean wide_native;
/**
- * Creates the stream.
+ * If true, the stream expect
+ * the multi-byte data in the form "less significant byte
+ * first" (Little Endian). This is the opposite to the
+ * java standard (Big Endian).
+ */
+ private boolean little_endian;
+
+ /**
+ * Creates the stream. The stream reads Big Endian by
+ * default.
*
* @param readFrom a stream to read CORBA input from.
*/
@@ -157,13 +173,33 @@ public abstract class cdrInput
}
/**
+ * Set the Big Endian or Little Endian encoding.
+ * The stream reads Big Endian by default.
+ *
+ * @param use_little_endian if true, the stream expect
+ * the multi-byte data in the form "less significant byte
+ * first" (Little Endian). This is the opposite to the
+ * java standard (Big Endian).
+ */
+ public void setBigEndian(boolean use_big_endian)
+ {
+ little_endian = !use_big_endian;
+ setInputStream(actual_stream);
+ }
+
+ /**
* Set the input stream that receives the CORBA input.
*
* @param readFrom the stream.
*/
public void setInputStream(java.io.InputStream readFrom)
{
- b = new DataInputStream(readFrom);
+ if (little_endian)
+ b = new LittleEndianInputStream(readFrom);
+ else
+ b = new BigEndianInputStream(readFrom);
+
+ actual_stream = readFrom;
}
/**
@@ -209,7 +245,9 @@ public abstract class cdrInput
}
catch (EOFException ex)
{
- throw new MARSHAL(UNEXP_EOF);
+ MARSHAL t = new MARSHAL(UNEXP_EOF);
+ t.initCause(ex);
+ throw t;
}
catch (IOException ex)
{
@@ -230,7 +268,9 @@ public abstract class cdrInput
}
catch (EOFException ex)
{
- throw new MARSHAL(UNEXP_EOF);
+ MARSHAL t = new MARSHAL(UNEXP_EOF);
+ t.initCause(ex);
+ throw t;
}
catch (IOException ex)
@@ -260,7 +300,9 @@ public abstract class cdrInput
}
catch (EOFException ex)
{
- throw new MARSHAL(UNEXP_EOF);
+ MARSHAL t = new MARSHAL(UNEXP_EOF);
+ t.initCause(ex);
+ throw t;
}
}
@@ -276,7 +318,9 @@ public abstract class cdrInput
}
catch (EOFException ex)
{
- throw new MARSHAL(UNEXP_EOF);
+ MARSHAL t = new MARSHAL(UNEXP_EOF);
+ t.initCause(ex);
+ throw t;
}
}
@@ -292,7 +336,9 @@ public abstract class cdrInput
}
catch (EOFException ex)
{
- throw new MARSHAL(UNEXP_EOF);
+ MARSHAL t = new MARSHAL(UNEXP_EOF);
+ t.initCause(ex);
+ throw t;
}
}
@@ -344,7 +390,9 @@ public abstract class cdrInput
}
catch (IOException ex)
{
- throw new BAD_OPERATION(ex.toString());
+ BAD_OPERATION bad = new BAD_OPERATION();
+ bad.initCause(ex);
+ throw bad;
}
}
@@ -394,7 +442,9 @@ public abstract class cdrInput
}
catch (EOFException ex)
{
- throw new MARSHAL(UNEXP_EOF);
+ MARSHAL t = new MARSHAL(UNEXP_EOF);
+ t.initCause(ex);
+ throw t;
}
catch (IOException ex)
{
@@ -416,7 +466,9 @@ public abstract class cdrInput
}
catch (EOFException ex)
{
- throw new MARSHAL(UNEXP_EOF);
+ MARSHAL t = new MARSHAL(UNEXP_EOF);
+ t.initCause(ex);
+ throw t;
}
catch (IOException ex)
@@ -436,11 +488,13 @@ public abstract class cdrInput
if (narrow_native)
return (char) b.read();
else
- return (char) new InputStreamReader(b, narrow_charset).read();
+ return (char) new InputStreamReader((InputStream) b, narrow_charset).read();
}
catch (EOFException ex)
{
- throw new MARSHAL(UNEXP_EOF);
+ MARSHAL t = new MARSHAL(UNEXP_EOF);
+ t.initCause(ex);
+ throw t;
}
catch (IOException ex)
@@ -463,13 +517,16 @@ public abstract class cdrInput
}
else
{
- InputStreamReader reader = new InputStreamReader(b, narrow_charset);
+ InputStreamReader reader =
+ new InputStreamReader((InputStream) b, narrow_charset);
reader.read(x, offset, length);
}
}
catch (EOFException ex)
{
- throw new MARSHAL(UNEXP_EOF);
+ MARSHAL t = new MARSHAL(UNEXP_EOF);
+ t.initCause(ex);
+ throw t;
}
catch (IOException ex)
@@ -490,7 +547,9 @@ public abstract class cdrInput
}
catch (EOFException ex)
{
- throw new MARSHAL(UNEXP_EOF);
+ MARSHAL t = new MARSHAL(UNEXP_EOF);
+ t.initCause(ex);
+ throw t;
}
catch (IOException ex)
@@ -514,7 +573,9 @@ public abstract class cdrInput
}
catch (EOFException ex)
{
- throw new MARSHAL(UNEXP_EOF);
+ MARSHAL t = new MARSHAL(UNEXP_EOF);
+ t.initCause(ex);
+ throw t;
}
catch (IOException ex)
@@ -524,8 +585,10 @@ public abstract class cdrInput
}
/**
- * Read the encapsulated stream. The endian flag is already extracted from
- * the returned stream.
+ * Read the encapsulated stream.
+ * If the encapsulated sequence appears to be in the
+ * Little endian format, the flag of the returned stream
+ * is set to read Little endian.
*/
public cdrBufInput read_encapsulation()
{
@@ -538,7 +601,7 @@ public abstract class cdrInput
reading:
while (n < r.length)
{
- n = read(r, n, r.length - n);
+ n += read(r, n, r.length - n);
}
cdrBufInput capsule = new cdrBufInput(r);
@@ -546,17 +609,18 @@ public abstract class cdrInput
int endian = capsule.read_octet();
- // TODO FIXME implement little endian.
if (endian != 0)
{
- throw new NO_IMPLEMENT("Little endian not supported.");
+ capsule.setBigEndian(false);
}
return capsule;
}
catch (EOFException ex)
{
- throw new MARSHAL(UNEXP_EOF);
+ MARSHAL t = new MARSHAL(UNEXP_EOF);
+ t.initCause(ex);
+ throw t;
}
catch (IOException ex)
@@ -578,7 +642,9 @@ public abstract class cdrInput
}
catch (EOFException ex)
{
- throw new MARSHAL(UNEXP_EOF);
+ MARSHAL t = new MARSHAL(UNEXP_EOF);
+ t.initCause(ex);
+ throw t;
}
catch (IOException ex)
@@ -599,7 +665,9 @@ public abstract class cdrInput
}
catch (EOFException ex)
{
- throw new MARSHAL(UNEXP_EOF);
+ MARSHAL t = new MARSHAL(UNEXP_EOF);
+ t.initCause(ex);
+ throw t;
}
catch (IOException ex)
@@ -623,7 +691,9 @@ public abstract class cdrInput
}
catch (EOFException ex)
{
- throw new MARSHAL(UNEXP_EOF);
+ MARSHAL t = new MARSHAL(UNEXP_EOF);
+ t.initCause(ex);
+ throw t;
}
catch (IOException ex)
@@ -644,7 +714,9 @@ public abstract class cdrInput
}
catch (EOFException ex)
{
- throw new MARSHAL(UNEXP_EOF);
+ MARSHAL t = new MARSHAL(UNEXP_EOF);
+ t.initCause(ex);
+ throw t;
}
catch (IOException ex)
@@ -668,7 +740,9 @@ public abstract class cdrInput
}
catch (EOFException ex)
{
- throw new MARSHAL(UNEXP_EOF);
+ MARSHAL t = new MARSHAL(UNEXP_EOF);
+ t.initCause(ex);
+ throw t;
}
catch (IOException ex)
@@ -713,7 +787,9 @@ public abstract class cdrInput
}
catch (EOFException ex)
{
- throw new MARSHAL(UNEXP_EOF);
+ MARSHAL t = new MARSHAL(UNEXP_EOF);
+ t.initCause(ex);
+ throw t;
}
catch (IOException ex)
@@ -733,7 +809,9 @@ public abstract class cdrInput
}
catch (EOFException ex)
{
- throw new MARSHAL(UNEXP_EOF);
+ MARSHAL t = new MARSHAL(UNEXP_EOF);
+ t.initCause(ex);
+ throw t;
}
catch (IOException ex)
@@ -753,7 +831,9 @@ public abstract class cdrInput
}
catch (EOFException ex)
{
- throw new MARSHAL(UNEXP_EOF);
+ MARSHAL t = new MARSHAL(UNEXP_EOF);
+ t.initCause(ex);
+ throw t;
}
catch (IOException ex)
@@ -780,7 +860,9 @@ public abstract class cdrInput
}
catch (EOFException ex)
{
- throw new MARSHAL(UNEXP_EOF);
+ MARSHAL t = new MARSHAL(UNEXP_EOF);
+ t.initCause(ex);
+ throw t;
}
catch (IOException ex)
@@ -801,7 +883,9 @@ public abstract class cdrInput
}
catch (EOFException ex)
{
- throw new MARSHAL(UNEXP_EOF);
+ MARSHAL t = new MARSHAL(UNEXP_EOF);
+ t.initCause(ex);
+ throw t;
}
catch (IOException ex)
@@ -825,7 +909,9 @@ public abstract class cdrInput
}
catch (EOFException ex)
{
- throw new MARSHAL(UNEXP_EOF);
+ MARSHAL t = new MARSHAL(UNEXP_EOF);
+ t.initCause(ex);
+ throw t;
}
catch (IOException ex)
@@ -860,7 +946,9 @@ public abstract class cdrInput
}
catch (EOFException ex)
{
- throw new MARSHAL(UNEXP_EOF);
+ MARSHAL t = new MARSHAL(UNEXP_EOF);
+ t.initCause(ex);
+ throw t;
}
catch (IOException ex)
@@ -944,11 +1032,13 @@ public abstract class cdrInput
if (wide_native)
return (char) b.readShort();
else
- return (char) new InputStreamReader(b, wide_charset).read();
+ return (char) new InputStreamReader((InputStream) b, wide_charset).read();
}
catch (EOFException ex)
{
- throw new MARSHAL(UNEXP_EOF);
+ MARSHAL t = new MARSHAL(UNEXP_EOF);
+ t.initCause(ex);
+ throw t;
}
catch (IOException ex)
{
@@ -974,13 +1064,16 @@ public abstract class cdrInput
}
else
{
- InputStreamReader reader = new InputStreamReader(b, wide_charset);
+ InputStreamReader reader =
+ new InputStreamReader((InputStream) b, wide_charset);
reader.read(x, offset, length);
}
}
catch (EOFException ex)
{
- throw new MARSHAL(UNEXP_EOF);
+ MARSHAL t = new MARSHAL(UNEXP_EOF);
+ t.initCause(ex);
+ throw t;
}
catch (IOException ex)
@@ -1001,7 +1094,7 @@ public abstract class cdrInput
public String read_wstring()
{
// Native encoding or word oriented data.
- if (wide_charset == null || giop.until_inclusive(1, 1))
+ if (wide_native || giop.until_inclusive(1, 1))
return read_wstring_UTF_16();
try
{
@@ -1015,7 +1108,9 @@ public abstract class cdrInput
}
catch (EOFException ex)
{
- throw new MARSHAL(UNEXP_EOF);
+ MARSHAL t = new MARSHAL(UNEXP_EOF);
+ t.initCause(ex);
+ throw t;
}
catch (IOException ex)
@@ -1069,7 +1164,9 @@ public abstract class cdrInput
}
catch (EOFException ex)
{
- throw new MARSHAL(UNEXP_EOF);
+ MARSHAL t = new MARSHAL(UNEXP_EOF);
+ t.initCause(ex);
+ throw t;
}
catch (IOException ex)
@@ -1126,4 +1223,4 @@ public abstract class cdrInput
{
return read_Object();
}
-}
+} \ No newline at end of file
diff --git a/gnu/CORBA/CDR/cdrOutput.java b/gnu/CORBA/CDR/cdrOutput.java
index e675d7d6c..30efaa854 100644
--- a/gnu/CORBA/CDR/cdrOutput.java
+++ b/gnu/CORBA/CDR/cdrOutput.java
@@ -88,7 +88,7 @@ public abstract class cdrOutput
* This instance is used to convert primitive data types into the
* byte sequences.
*/
- protected DataOutputStream b;
+ protected abstractDataOutputStream b;
/**
* The associated orb, if any.
@@ -131,6 +131,17 @@ public abstract class cdrOutput
private boolean wide_native;
/**
+ * If true, the Little Endian encoding is used to write the
+ * data. Otherwise, the Big Endian encoding is used.
+ */
+ private boolean little_endian;
+
+ /**
+ * The stream whre the data are actually written.
+ */
+ private java.io.OutputStream actual_stream;
+
+ /**
* Creates the stream.
*
* @param writeTo a stream to write CORBA output to.
@@ -193,7 +204,12 @@ public abstract class cdrOutput
*/
public void setOutputStream(java.io.OutputStream writeTo)
{
- b = new DataOutputStream(writeTo);
+ if (little_endian)
+ b = new LittleEndianOutputStream(writeTo);
+ else
+ b = new BigEndianOutputStream(writeTo);
+
+ actual_stream = writeTo;
}
/**
@@ -206,6 +222,19 @@ public abstract class cdrOutput
}
/**
+ * Specify if the stream should use the Big Endian (usual for java)
+ * or Little Encoding. The default is Big Endian.
+ *
+ * @param use_big_endian if true, use Big Endian, if false,
+ * use Little Endian.
+ */
+ public void setBigEndian(boolean use_big_endian)
+ {
+ little_endian = !use_big_endian;
+ setOutputStream(actual_stream);
+ }
+
+ /**
* Align the curretn position at the given natural boundary.
*/
public abstract void align(int boundary);
@@ -219,11 +248,14 @@ public abstract class cdrOutput
* It is not allowed to write to the current stream directly
* before the encapsulation stream is closed.
*
+ * The encoding (Big/Little Endian) inside the encapsulated
+ * sequence is the same as used into the parent stream.
+ *
* @return the encapsulated stream.
*/
public cdrOutput createEncapsulation()
{
- return new encapsulatedOutput(this);
+ return new encapsulatedOutput(this, !little_endian);
}
/**
@@ -407,7 +439,8 @@ public abstract class cdrOutput
b.write(x);
else
{
- OutputStreamWriter ow = new OutputStreamWriter(b, narrow_charset);
+ OutputStreamWriter ow =
+ new OutputStreamWriter((OutputStream) b, narrow_charset);
ow.write(x);
ow.flush();
}
@@ -438,7 +471,8 @@ public abstract class cdrOutput
}
else
{
- OutputStreamWriter ow = new OutputStreamWriter(b, narrow_charset);
+ OutputStreamWriter ow =
+ new OutputStreamWriter((OutputStream) b, narrow_charset);
ow.write(chars, offset, length);
ow.flush();
}
@@ -672,7 +706,9 @@ public abstract class cdrOutput
}
catch (IOException ex)
{
- throw new MARSHAL("IOException while writing the data");
+ MARSHAL t = new MARSHAL();
+ t.initCause(ex);
+ throw t;
}
}
@@ -691,7 +727,9 @@ public abstract class cdrOutput
}
catch (IOException ex)
{
- throw new MARSHAL("IOException while writing the data");
+ MARSHAL t = new MARSHAL();
+ t.initCause(ex);
+ throw t;
}
}
@@ -835,7 +873,8 @@ public abstract class cdrOutput
b.writeShort(x);
else
{
- OutputStreamWriter ow = new OutputStreamWriter(b, wide_charset);
+ OutputStreamWriter ow =
+ new OutputStreamWriter((OutputStream) b, wide_charset);
ow.write(x);
ow.flush();
}
@@ -872,7 +911,8 @@ public abstract class cdrOutput
}
else
{
- OutputStreamWriter ow = new OutputStreamWriter(b, wide_charset);
+ OutputStreamWriter ow =
+ new OutputStreamWriter((OutputStream) b, wide_charset);
ow.write(chars, offset, length);
ow.flush();
}
@@ -920,4 +960,4 @@ public abstract class cdrOutput
Unexpected.error(ex);
}
}
-}
+} \ No newline at end of file
diff --git a/gnu/CORBA/CDR/encapsulatedOutput.java b/gnu/CORBA/CDR/encapsulatedOutput.java
index 656bf066f..e4673b099 100644
--- a/gnu/CORBA/CDR/encapsulatedOutput.java
+++ b/gnu/CORBA/CDR/encapsulatedOutput.java
@@ -57,6 +57,11 @@ public class encapsulatedOutput
public static final byte BIG_ENDIAN = 0;
/**
+ * The Little Endian (least siginificant byte first flag).
+ */
+ public static final byte LITTLE_ENDIAN = 1;
+
+ /**
* The byte buffer.
*/
public final aligningOutputStream buffer;
@@ -67,16 +72,17 @@ public class encapsulatedOutput
public final org.omg.CORBA.portable.OutputStream parent;
/**
- * Create the EncapsulationOutput with the default buffer size
- * and the given parent stream.
- */
- public encapsulatedOutput(org.omg.CORBA.portable.OutputStream _parent)
+ * Create the EncapsulationOutput with the given parent stream
+ * and the specified encoding.
+ */
+ public encapsulatedOutput(org.omg.CORBA.portable.OutputStream _parent,
+ boolean use_big_endian)
{
super();
buffer = new aligningOutputStream();
setOutputStream(buffer);
parent = _parent;
- write(BIG_ENDIAN);
+ write(use_big_endian?BIG_ENDIAN:LITTLE_ENDIAN);
}
/**
@@ -109,7 +115,9 @@ public class encapsulatedOutput
}
catch (IOException ex)
{
- throw new InternalError();
+ InternalError err = new InternalError();
+ err.initCause(ex);
+ throw err;
}
}
diff --git a/gnu/CORBA/CDR/uncObjectInputStream.java b/gnu/CORBA/CDR/uncObjectInputStream.java
new file mode 100644
index 000000000..b912f5d2c
--- /dev/null
+++ b/gnu/CORBA/CDR/uncObjectInputStream.java
@@ -0,0 +1,70 @@
+/* uncObjectInputStream.java --
+ Copyright (C) 2005 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.CORBA.CDR;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectInputStream;
+
+/**
+ * An object input stream that cannot be closed. Used in cases where
+ * it represents only part of the input data.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public class uncObjectInputStream
+ extends ObjectInputStream
+{
+ /**
+ * Delegate call to super class constructor.
+ */
+ public uncObjectInputStream(InputStream in)
+ throws IOException
+ {
+ super(in);
+ }
+
+ /**
+ * Do not close the stream, return without action.
+ */
+ public void close()
+ {
+ // Do nothing.
+ }
+} \ No newline at end of file
diff --git a/gnu/CORBA/CDR/uncObjectOutputStream.java b/gnu/CORBA/CDR/uncObjectOutputStream.java
new file mode 100644
index 000000000..3aa8582bb
--- /dev/null
+++ b/gnu/CORBA/CDR/uncObjectOutputStream.java
@@ -0,0 +1,73 @@
+/* uncObjectOutputStream.java --
+ Copyright (C) 2005 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.CORBA.CDR;
+
+import java.io.IOException;
+import java.io.ObjectOutputStream;
+import java.io.OutputStream;
+
+/**
+ * The Uncloseable Object Output Stream is used in cases when
+ * it is necessary to write the data and leave the stream opened.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public class uncObjectOutputStream
+ extends ObjectOutputStream
+{
+ /**
+ * Delegate call to super class constructor.
+ */
+ public uncObjectOutputStream(OutputStream out)
+ throws IOException
+ {
+ super(out);
+ }
+
+ /**
+ * Do not close, just flush.
+ *
+ * @throws IOException if the flush() throws it.
+ */
+ public void close()
+ throws IOException
+ {
+ flush();
+ }
+} \ No newline at end of file
diff --git a/gnu/CORBA/DefinitionKindHolder.java b/gnu/CORBA/DefinitionKindHolder.java
new file mode 100644
index 000000000..dc6dcc0be
--- /dev/null
+++ b/gnu/CORBA/DefinitionKindHolder.java
@@ -0,0 +1,91 @@
+/* DefinitionKindHolder.java --
+ Copyright (C) 2005 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.CORBA;
+
+import org.omg.CORBA.DefinitionKind;
+import org.omg.CORBA.DefinitionKindHelper;
+
+
+/**
+ * The definition kind holder. This class is not included in the original
+ * API specification, so we place it outside the org.omg namespace.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public class DefinitionKindHolder
+ implements org.omg.CORBA.portable.Streamable
+{
+ /**
+ * The stored value.
+ */
+ public DefinitionKind value;
+
+ /**
+ * Create the initialised instance.
+ * @param initialValue
+ */
+ public DefinitionKindHolder(DefinitionKind initialValue)
+ {
+ value = initialValue;
+ }
+
+ /**
+ * Read from the CDR stream.
+ */
+ public void _read(org.omg.CORBA.portable.InputStream in)
+ {
+ value = DefinitionKindHelper.read(in);
+ }
+
+ /**
+ * Get the typecode.
+ */
+ public org.omg.CORBA.TypeCode _type()
+ {
+ return DefinitionKindHelper.type();
+ }
+
+ /**
+ * Write into the CDR stream.
+ */
+ public void _write(org.omg.CORBA.portable.OutputStream out)
+ {
+ DefinitionKindHelper.write(out, value);
+ }
+}
diff --git a/gnu/CORBA/Functional_ORB.java b/gnu/CORBA/Functional_ORB.java
index b26b5aa8c..437f420c4 100644
--- a/gnu/CORBA/Functional_ORB.java
+++ b/gnu/CORBA/Functional_ORB.java
@@ -103,6 +103,11 @@ public class Functional_ORB
extends Thread
{
/**
+ * The number of the currently running parallel threads.
+ */
+ private int running_threads;
+
+ /**
* The port on that this portServer is listening for requests.
*/
int s_port;
@@ -113,6 +118,12 @@ public class Functional_ORB
ServerSocket service;
/**
+ * True if the serving node must shutdown due
+ * call of the close_now().
+ */
+ boolean terminated;
+
+ /**
* Create a new portServer, serving on specific port.
*/
portServer(int _port)
@@ -127,30 +138,32 @@ public class Functional_ORB
*/
public void run()
{
- boolean terminated;
-
try
{
service = new ServerSocket(s_port);
}
catch (IOException ex)
{
- throw new BAD_OPERATION("Unable to open the server socket.");
+ BAD_OPERATION bad =
+ new BAD_OPERATION("Unable to open the server socket.");
+ bad.initCause(ex);
+ throw bad;
}
while (running)
{
try
{
- serve(service);
+ serve(this, service);
}
catch (SocketException ex)
{
- // Thrown when the service is closed by
+ // May be thrown when the service is closed by
// the close_now().
- return;
+ if (terminated)
+ return;
}
- catch (IOException iex)
+ catch (Exception iex)
{
// Wait 5 seconds. Do not terminate the
// service due potentially transient error.
@@ -172,6 +185,7 @@ public class Functional_ORB
{
try
{
+ terminated = true;
service.close();
}
catch (Exception ex)
@@ -217,11 +231,73 @@ public class Functional_ORB
public static final String NAME_SERVICE = "NameService";
/**
+ * The if the client has once opened a socket, it should start sending
+ * the message header in a given time. Otherwise the server will close the
+ * socket. This prevents server hang when the client opens the socket,
+ * but does not send any message, usually due crash on the client side.
+ */
+ public static String START_READING_MESSAGE =
+ "gnu.classpath.CORBA.TOUT_START_READING_MESSAGE";
+
+ /**
+ * If the client has started to send the request message, the socket time
+ * out changes to the specified value.
+ */
+ public static String WHILE_READING = "gnu.classpath.CORBA.TOUT_WHILE_READING";
+
+ /**
+ * If the message body is received, the time out changes to the
+ * specifice value. This must be longer, as includes time, required to
+ * process the received task. We make it 40 minutes.
+ */
+ public static String AFTER_RECEIVING =
+ "gnu.classpath.CORBA.TOUT_AFTER_RECEIVING";
+
+ /**
* The address of the local host.
*/
public final String LOCAL_HOST;
/**
+ * The if the client has once opened a socket, it should start sending
+ * the message header in a given time. Otherwise the server will close the
+ * socket. This prevents server hang when the client opens the socket,
+ * but does not send any message, usually due crash on the client side.
+ */
+ private int TOUT_START_READING_MESSAGE = 20 * 1000;
+
+ // (Here and below, we use * to make meaning of the constant clearler).
+
+ /**
+ * If the client has started to send the request message, the socket time
+ * out changes to the specified value.
+ */
+ private int TOUT_WHILE_READING = 2 * 60 * 1000;
+
+ /**
+ * If the message body is received, the time out changes to the
+ * specifice value. This must be longer, as includes time, required to
+ * process the received task. We make it 40 minutes.
+ */
+ private int TOUT_AFTER_RECEIVING = 40 * 60 * 1000;
+
+ /**
+ * Some clients tend to submit multiple requests over the
+ * same socket. The server waits for the next request on
+ * the same socket for the duration, specified
+ * below. The default time is seven seconds.
+ */
+ public int TANDEM_REQUESTS = 7000;
+
+ /**
+ * If the maximal number of threads per object is reached,
+ * the server waits for the given time interval before checking
+ * again maybe some threads are already complete.
+ * Thr default time is 0.5 second.
+ */
+ public int PAUSE_ON_THREAD_OVERLOAD = 500;
+
+ /**
* The map of the already conncted objects.
*/
protected final Connected_objects connected_objects = new Connected_objects();
@@ -280,6 +356,14 @@ public class Functional_ORB
protected LinkedList freed_ports = new LinkedList();
/**
+ * The maximal allowed number of the currently running parallel
+ * threads per object. For security reasons, this is made private and
+ * unchangeable. After exceeding this limit, the NO_RESOURCES
+ * is thrown back to the client.
+ */
+ private int MAX_RUNNING_THREADS = 256;
+
+ /**
* Create the instance of the Functional ORB.
*/
public Functional_ORB()
@@ -290,7 +374,10 @@ public class Functional_ORB
}
catch (UnknownHostException ex)
{
- throw new BAD_OPERATION("Unable to resolve the local host address.");
+ BAD_OPERATION bad =
+ new BAD_OPERATION("Unable to open the server socket.");
+ bad.initCause(ex);
+ throw bad;
}
}
@@ -329,6 +416,7 @@ public class Functional_ORB
throws BAD_OPERATION
{
ServerSocket s;
+ int a_port;
try
{
@@ -349,14 +437,14 @@ public class Functional_ORB
// OK then, use a new port.
}
- for (int i = Port; i < Port + 20; i++)
+ for (a_port = Port; a_port < Port + 20; a_port++)
{
try
{
- s = new ServerSocket(i);
+ s = new ServerSocket(a_port);
s.close();
- Port = i + 1;
- return s.getLocalPort();
+ Port = a_port + 1;
+ return a_port;
}
catch (IOException ex)
{
@@ -368,12 +456,16 @@ public class Functional_ORB
{
// Try any port.
s = new ServerSocket();
+ a_port = s.getLocalPort();
s.close();
- return s.getLocalPort();
+ return a_port;
}
- catch (IOException ex1)
+ catch (IOException ex)
{
- throw new NO_RESOURCES("Unable to open the server socket");
+ NO_RESOURCES bad =
+ new NO_RESOURCES("Unable to open the server socket.");
+ bad.initCause(ex);
+ throw bad;
}
}
@@ -508,16 +600,16 @@ public class Functional_ORB
{
Delegate delegate = ((ObjectImpl) object)._get_delegate();
if (delegate instanceof Simple_delegate)
- {
- byte[] key = ((Simple_delegate) delegate).getIor().key;
- rmKey = connected_objects.get(key);
- }
+ {
+ byte[] key = ((Simple_delegate) delegate).getIor().key;
+ rmKey = connected_objects.get(key);
+ }
}
// Try to find and disconned the object that is not an instance of the
// object implementation.
if (rmKey == null)
- rmKey = connected_objects.getKey(object);
+ rmKey = connected_objects.getKey(object);
// Disconnect the object on any success.
if (rmKey != null)
@@ -646,7 +738,9 @@ public class Functional_ORB
}
catch (Exception ex)
{
- throw new InvalidName(name + ":" + ex.getMessage());
+ InvalidName err = new InvalidName(name);
+ err.initCause(ex);
+ throw err;
}
if (object != null)
return object;
@@ -784,7 +878,7 @@ public class Functional_ORB
protected org.omg.CORBA.Object find_connected_object(byte[] key)
{
Connected_objects.cObject ref = connected_objects.get(key);
- return ref==null?null:ref.object;
+ return ref == null ? null : ref.object;
}
/**
@@ -820,6 +914,15 @@ public class Functional_ORB
if (para [ i ] [ 0 ].equals(NS_HOST))
ns_host = para [ i ] [ 1 ];
+ if (para [ i ] [ 0 ].equals(START_READING_MESSAGE))
+ TOUT_START_READING_MESSAGE = Integer.parseInt(para [ i ] [ 1 ]);
+
+ if (para [ i ] [ 0 ].equals(WHILE_READING))
+ TOUT_WHILE_READING = Integer.parseInt(para [ i ] [ 1 ]);
+
+ if (para [ i ] [ 0 ].equals(AFTER_RECEIVING))
+ TOUT_AFTER_RECEIVING = Integer.parseInt(para [ i ] [ 1 ]);
+
try
{
if (para [ i ] [ 0 ].equals(NS_PORT))
@@ -827,10 +930,13 @@ public class Functional_ORB
}
catch (NumberFormatException ex)
{
- throw new BAD_PARAM("Invalid " + NS_PORT +
- "property, unable to parse '" +
- props.getProperty(NS_PORT) + "'"
- );
+ BAD_PARAM bad =
+ new BAD_PARAM("Invalid " + NS_PORT +
+ "property, unable to parse '" +
+ props.getProperty(NS_PORT) + "'"
+ );
+ bad.initCause(ex);
+ throw bad;
}
}
}
@@ -991,6 +1097,7 @@ public class Functional_ORB
handler.getBuffer().buffer.writeTo(out);
MessageHeader msh_reply = new MessageHeader();
+
msh_reply.version = msh_request.version;
msh_reply.message_type = MessageHeader.REPLY;
msh_reply.message_size = out.buffer.size();
@@ -1002,127 +1109,205 @@ public class Functional_ORB
}
/**
- * Contains a single servicing step.
+ * Contains a single servicing task.
+ *
+ * Normally, each task matches a single remote invocation.
+ * However under frequent tandem submissions the same
+ * task may span over several invocations.
*
* @param serverSocket the ORB server socket.
*
* @throws MARSHAL
* @throws IOException
*/
- private void serve(ServerSocket serverSocket)
+ private void serve(final portServer p, ServerSocket serverSocket)
throws MARSHAL, IOException
{
- Socket service = null;
- try
- {
- service = serverSocket.accept();
- service.setKeepAlive(true);
+ final Socket service;
+ service = serverSocket.accept();
- InputStream in = service.getInputStream();
-
- MessageHeader msh_request = new MessageHeader();
- msh_request.read(in);
+ // Tell the server there are no more resources.
+ while (p.running_threads >= MAX_RUNNING_THREADS)
+ {
+ serveStep(service, true);
+ }
- if (max_version != null)
- if (!msh_request.version.until_inclusive(max_version.major,
- max_version.minor
- )
- )
+ new Thread()
+ {
+ public void run()
+ {
+ try
{
- OutputStream out = service.getOutputStream();
- new ErrorMessage(max_version).write(out);
- service.close();
- return;
+ synchronized (p)
+ {
+ p.running_threads++;
+ }
+ serveStep(service, false);
}
+ finally
+ {
+ synchronized (p)
+ {
+ p.running_threads--;
+ }
+ }
+ }
+ }.start();
+ }
- byte[] r = new byte[ msh_request.message_size ];
-
- int n = 0;
-
- reading:
- while (n < r.length)
- {
- n = in.read(r, n, r.length - n);
- }
-
- if (msh_request.message_type == MessageHeader.REQUEST)
+ /**
+ * A single servicing step, when the client socket is alrady open.
+ *
+ * Normally, each task matches a single remote invocation.
+ * However under frequent tandem submissions the same
+ * task may span over several invocations.
+ *
+ * @param service the opened client socket.
+ * @param no_resources if true, the "NO RESOURCES" exception
+ * is thrown to the client.
+ */
+ private void serveStep(Socket service, boolean no_resources)
+ {
+ try
+ {
+ Serving:
+ while (true)
{
- RequestHeader rh_request;
-
- cdrBufInput cin = new cdrBufInput(r);
- cin.setOrb(this);
- cin.setVersion(msh_request.version);
- cin.setOffset(msh_request.getHeaderSize());
-
- rh_request = msh_request.create_request_header();
+ InputStream in = service.getInputStream();
+ service.setSoTimeout(TOUT_START_READING_MESSAGE);
- // Read header and auto set the charset.
- rh_request.read(cin);
+ MessageHeader msh_request = new MessageHeader();
- // in 1.2 and higher, align the current position at
- // 8 octet boundary.
- if (msh_request.version.since_inclusive(1, 2))
- cin.align(8);
+ try
+ {
+ msh_request.read(in);
+ }
+ catch (MARSHAL ex)
+ {
+ // This exception may be thrown due closing the connection.
+ return;
+ }
- // find the target object.
- InvokeHandler target =
- (InvokeHandler) find_connected_object(rh_request.object_key);
+ if (max_version != null)
+ if (!msh_request.version.until_inclusive(max_version.major,
+ max_version.minor
+ )
+ )
+ {
+ OutputStream out = service.getOutputStream();
+ new ErrorMessage(max_version).write(out);
+ return;
+ }
- // Prepare the reply header. This must be done in advance,
- // as the size must be known for handler to set alignments
- // correctly.
- ReplyHeader rh_reply = msh_request.create_reply_header();
+ byte[] r = new byte[ msh_request.message_size ];
- // TODO log errors about not existing objects and methods.
- bufferedResponseHandler handler =
- new bufferedResponseHandler(this, msh_request, rh_reply);
+ int n = 0;
- SystemException sysEx = null;
+ service.setSoTimeout(TOUT_WHILE_READING);
- try
- {
- if (target == null)
- throw new OBJECT_NOT_EXIST();
- target._invoke(rh_request.operation, cin, handler);
- }
- catch (SystemException ex)
+ reading:
+ while (n < r.length)
{
- sysEx = ex;
-
- org.omg.CORBA.portable.OutputStream ech =
- handler.createExceptionReply();
- ObjectCreator.writeSystemException(ech, ex);
+ n += in.read(r, n, r.length - n);
}
- catch (Exception except)
- {
- sysEx =
- new UNKNOWN("Unknown", 2, CompletionStatus.COMPLETED_MAYBE);
- org.omg.CORBA.portable.OutputStream ech =
- handler.createExceptionReply();
+ service.setSoTimeout(TOUT_AFTER_RECEIVING);
- ObjectCreator.writeSystemException(ech, sysEx);
+ if (msh_request.message_type == MessageHeader.REQUEST)
+ {
+ RequestHeader rh_request;
+
+ cdrBufInput cin = new cdrBufInput(r);
+ cin.setOrb(this);
+ cin.setVersion(msh_request.version);
+ cin.setOffset(msh_request.getHeaderSize());
+ cin.setBigEndian(msh_request.isBigEndian());
+
+ rh_request = msh_request.create_request_header();
+
+ // Read header and auto set the charset.
+ rh_request.read(cin);
+
+ // in 1.2 and higher, align the current position at
+ // 8 octet boundary.
+ if (msh_request.version.since_inclusive(1, 2))
+ cin.align(8);
+
+ // find the target object.
+ InvokeHandler target =
+ (InvokeHandler) find_connected_object(rh_request.object_key);
+
+ // Prepare the reply header. This must be done in advance,
+ // as the size must be known for handler to set alignments
+ // correctly.
+ ReplyHeader rh_reply = msh_request.create_reply_header();
+
+ // TODO log errors about not existing objects and methods.
+ bufferedResponseHandler handler =
+ new bufferedResponseHandler(this, msh_request, rh_reply);
+
+ SystemException sysEx = null;
+
+ try
+ {
+ if (no_resources)
+ throw new NO_RESOURCES();
+ if (target == null)
+ throw new OBJECT_NOT_EXIST();
+ target._invoke(rh_request.operation, cin, handler);
+ }
+ catch (SystemException ex)
+ {
+ sysEx = ex;
+
+ org.omg.CORBA.portable.OutputStream ech =
+ handler.createExceptionReply();
+ ObjectCreator.writeSystemException(ech, ex);
+ }
+ catch (Exception except)
+ {
+ sysEx =
+ new UNKNOWN("Unknown", 2, CompletionStatus.COMPLETED_MAYBE);
+
+ org.omg.CORBA.portable.OutputStream ech =
+ handler.createExceptionReply();
+
+ ObjectCreator.writeSystemException(ech, sysEx);
+ }
+
+ // Write the response.
+ if (rh_request.isResponseExpected())
+ {
+ OutputStream sou = service.getOutputStream();
+ respond_to_client(sou, msh_request, rh_request, handler,
+ sysEx
+ );
+ }
}
+ else
+ ;
- // Write the response.
- if (rh_request.isResponseExpected())
+ // TODO log error: "Not a request message."
+ if (service != null && !service.isClosed())
{
- respond_to_client(service.getOutputStream(), msh_request,
- rh_request, handler, sysEx
- );
+ // Wait for the subsequent invocations on the
+ // same socket for 2 minutes.
+ service.setSoTimeout(TANDEM_REQUESTS);
}
+ else
+ return;
}
- else
- ;
-
- // TODO log error: "Not a request message."
}
- finally
+ catch (SocketException ex)
{
- if (service != null && !service.isClosed())
- {
- service.close();
- }
+ // OK.
+ return;
+ }
+ catch (IOException ioex)
+ {
+ // Network error, probably transient.
+ // TODO log it.
+ return;
}
}
@@ -1140,6 +1325,18 @@ public class Functional_ORB
{
if (props.containsKey(NS_PORT))
ns_port = Integer.parseInt(props.getProperty(NS_PORT));
+
+ if (props.containsKey(START_READING_MESSAGE))
+ TOUT_START_READING_MESSAGE =
+ Integer.parseInt(props.getProperty(START_READING_MESSAGE));
+
+ if (props.containsKey(WHILE_READING))
+ TOUT_WHILE_READING =
+ Integer.parseInt(props.getProperty(WHILE_READING));
+
+ if (props.containsKey(AFTER_RECEIVING))
+ TOUT_AFTER_RECEIVING =
+ Integer.parseInt(props.getProperty(AFTER_RECEIVING));
}
catch (NumberFormatException ex)
{
@@ -1240,6 +1437,4 @@ public class Functional_ORB
running = false;
super.finalize();
}
-}
-
-
+} \ No newline at end of file
diff --git a/gnu/CORBA/GIOP/ErrorMessage.java b/gnu/CORBA/GIOP/ErrorMessage.java
index fdba54f4b..0da5f649c 100644
--- a/gnu/CORBA/GIOP/ErrorMessage.java
+++ b/gnu/CORBA/GIOP/ErrorMessage.java
@@ -89,7 +89,9 @@ public class ErrorMessage
}
catch (IOException ex)
{
- throw new MARSHAL(ex.toString());
+ MARSHAL t = new MARSHAL();
+ t.initCause(ex);
+ throw t;
}
}
}
diff --git a/gnu/CORBA/GIOP/MessageHeader.java b/gnu/CORBA/GIOP/MessageHeader.java
index aef00e37a..7640b6bfd 100644
--- a/gnu/CORBA/GIOP/MessageHeader.java
+++ b/gnu/CORBA/GIOP/MessageHeader.java
@@ -38,16 +38,23 @@ exception statement from your version. */
package gnu.CORBA.GIOP;
+import gnu.CORBA.CDR.BigEndianOutputStream;
+import gnu.CORBA.CDR.LittleEndianInputStream;
+import gnu.CORBA.CDR.LittleEndianOutputStream;
+import gnu.CORBA.CDR.abstractDataOutputStream;
import gnu.CORBA.Version;
+import org.omg.CORBA.MARSHAL;
+import org.omg.CORBA.portable.IDLEntity;
+
import java.io.DataInputStream;
-import java.io.DataOutputStream;
import java.io.IOException;
+import java.io.OutputStream;
import java.util.Arrays;
-
-import org.omg.CORBA.MARSHAL;
-import org.omg.CORBA.portable.IDLEntity;
+import gnu.CORBA.CDR.BigEndianInputStream;
+import gnu.CORBA.CDR.abstractDataInputStream;
+import java.io.InputStream;
/**
* The GIOP message header.
@@ -142,7 +149,7 @@ public class MessageHeader
*/
public MessageHeader()
{
- version = new Version(1,0);
+ version = new Version(1, 0);
}
/**
@@ -166,6 +173,20 @@ public class MessageHeader
}
/**
+ * Set the encoding to use.
+ *
+ * @param use_big_endian if true (default), the Big Endian
+ * encoding is used. If false, the Little Endian encoding is used.
+ */
+ public void setBigEndian(boolean use_big_endian)
+ {
+ if (use_big_endian)
+ flags = (byte) (flags & ~1);
+ else
+ flags = (byte) (flags | 1);
+ }
+
+ /**
* Get the size of the message header itself. So far, it is always 12 bytes.
*/
public int getHeaderSize()
@@ -250,27 +271,32 @@ public class MessageHeader
{
try
{
- DataInputStream din = new DataInputStream(istream);
-
byte[] xMagic = new byte[ MAGIC.length ];
- din.read(xMagic);
+ istream.read(xMagic);
if (!Arrays.equals(xMagic, MAGIC))
throw new MARSHAL("Not a GIOP message");
- version = Version.read_version(din);
+ version = Version.read_version(istream);
- flags = (byte) din.read();
+ abstractDataInputStream din;
- /** TODO implement support for the little endian. */
- if (!isBigEndian())
- throw new MARSHAL("Little endian unsupported.");
+ flags = (byte) istream.read();
+
+ // This checks the bit in the byte we have just received.
+ if (isBigEndian())
+ din = new BigEndianInputStream(istream);
+ else
+ din = new LittleEndianInputStream(istream);
message_type = (byte) din.read();
+
message_size = din.readInt();
}
catch (IOException ex)
{
- throw new MARSHAL(ex.toString());
+ MARSHAL t = new MARSHAL();
+ t.initCause(ex);
+ throw t;
}
}
@@ -295,22 +321,30 @@ public class MessageHeader
{
try
{
- DataOutputStream dout = new DataOutputStream(out);
+ abstractDataOutputStream dout;
+
+ if (isBigEndian())
+ dout = new BigEndianOutputStream(out);
+ else
+ dout = new LittleEndianOutputStream(out);
// Write magic sequence.
dout.write(MAGIC);
// Write version number.
- version.write(dout);
+ version.write((OutputStream) dout);
dout.write(flags);
dout.write(message_type);
+
dout.writeInt(message_size);
}
catch (IOException ex)
{
- throw new MARSHAL(ex.toString());
+ MARSHAL t = new MARSHAL();
+ t.initCause(ex);
+ throw t;
}
}
-}
+} \ No newline at end of file
diff --git a/gnu/CORBA/GIOP/cxCodeSet.java b/gnu/CORBA/GIOP/cxCodeSet.java
index 487a134a7..0fbf00bfe 100644
--- a/gnu/CORBA/GIOP/cxCodeSet.java
+++ b/gnu/CORBA/GIOP/cxCodeSet.java
@@ -160,7 +160,9 @@ public class cxCodeSet
}
catch (IOException ex)
{
- throw new InternalError();
+ InternalError t = new InternalError();
+ t.initCause(ex);
+ throw t;
}
}
diff --git a/gnu/CORBA/GIOP/v1_2/RequestHeader.java b/gnu/CORBA/GIOP/v1_2/RequestHeader.java
index 081bfcaf0..184893bb3 100644
--- a/gnu/CORBA/GIOP/v1_2/RequestHeader.java
+++ b/gnu/CORBA/GIOP/v1_2/RequestHeader.java
@@ -163,7 +163,9 @@ public class RequestHeader
}
catch (IOException ex)
{
- throw new MARSHAL(ex.toString());
+ MARSHAL t = new MARSHAL();
+ t.initCause(ex);
+ throw t;
}
}
diff --git a/gnu/CORBA/IOR.java b/gnu/CORBA/IOR.java
index 08f79f57b..056009f06 100644
--- a/gnu/CORBA/IOR.java
+++ b/gnu/CORBA/IOR.java
@@ -64,9 +64,6 @@ import java.io.IOException;
* decoding the IOR information from/to the stringified references,
* usually returned by {@link org.omg.CORBA.ORB#String object_to_string()}.
*
- * TODO the current implementation supports the IOP version 1.0 only.
- * TODO Little Endian (lower byte first) encoding, if anybody needs it.
- *
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*
* @see org.mog.CORBA.Object.object_to_string(Object forObject)
@@ -276,6 +273,14 @@ public class IOR
public byte[] key;
/**
+ * True if the profile was encoded using the Big Endian or
+ * the encoding is not known.
+ *
+ * false if it was encoded using the Little Endian.
+ */
+ public boolean Big_Endian = true;
+
+ /**
* Create an empty instance, initialising the code sets to default
* values.
*/
@@ -345,10 +350,6 @@ public class IOR
*
* @param c a stream to read from.
* @throws IOException if the stream throws it.
- * @throws BAD_PARAM, minor code 10, if the stream contents
- * requires to switch into currently unsupported Little Endian mode.
- *
- * FIXME TODO Implement Little Endian mode.
*/
public void _read(cdrInput c)
throws IOException, BAD_PARAM
@@ -357,9 +358,10 @@ public class IOR
endian = c.read_long();
if (endian != 0)
- throw new BAD_PARAM("Little endian is not yet supported", FAILED,
- CompletionStatus.COMPLETED_NO
- );
+ {
+ Big_Endian = false;
+ c.setBigEndian(false);
+ }
_read_no_endian(c);
}
@@ -371,8 +373,6 @@ public class IOR
*
* @param c a stream to read from.
* @throws IOException if the stream throws it.
- * @throws BAD_PARAM, minor code 10, if the stream contents
- * requires to switch into currently unsupported Little Endian mode.
*/
public void _read_no_endian(cdrInput c)
throws IOException, BAD_PARAM
@@ -402,7 +402,8 @@ public class IOR
try
{
- n_components = profile.read_long();
+ if (Internet.version.since_inclusive(1, 1))
+ n_components = profile.read_long();
for (int t = 0; t < n_components; t++)
{
@@ -487,6 +488,10 @@ public class IOR
b.append(Id);
b.append(" at ");
b.append(Internet);
+
+ if (!Big_Endian)
+ b.append(" (Little endian) ");
+
b.append(" Key ");
for (int i = 0; i < key.length; i++)
@@ -526,4 +531,4 @@ public class IOR
return b.toString();
}
-}
+} \ No newline at end of file
diff --git a/gnu/CORBA/IOR_Delegate.java b/gnu/CORBA/IOR_Delegate.java
index 799704dc5..5b02fc2db 100644
--- a/gnu/CORBA/IOR_Delegate.java
+++ b/gnu/CORBA/IOR_Delegate.java
@@ -211,7 +211,9 @@ public class IOR_Delegate
}
catch (IOException ex)
{
- throw new MARSHAL(ex + " while reading the forwarding info");
+ MARSHAL t = new MARSHAL("Cant read forwarding info");
+ t.initCause(ex);
+ throw t;
}
request.request.setIor(forwarded);
diff --git a/gnu/CORBA/ServiceRequestAdapter.java b/gnu/CORBA/ServiceRequestAdapter.java
new file mode 100644
index 000000000..f584eb7a3
--- /dev/null
+++ b/gnu/CORBA/ServiceRequestAdapter.java
@@ -0,0 +1,159 @@
+/* ServiceRequestConverter.java --
+ Copyright (C) 2005 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.CORBA;
+
+import gnu.CORBA.CDR.cdrBufOutput;
+
+import org.omg.CORBA.ARG_IN;
+import org.omg.CORBA.ARG_INOUT;
+import org.omg.CORBA.ARG_OUT;
+import org.omg.CORBA.Any;
+import org.omg.CORBA.Bounds;
+import org.omg.CORBA.ServerRequest;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.InvokeHandler;
+import org.omg.CORBA.portable.OutputStream;
+import org.omg.CORBA.portable.ResponseHandler;
+import org.omg.CORBA.portable.Streamable;
+
+/**
+ * This class exists to handle obsolete invocation style using
+ * ServerRequest.
+ *
+ * @deprecated The method {@link ObjectImpl#_invoke} is much faster.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class ServiceRequestAdapter
+ implements ResponseHandler
+{
+ /**
+ * A buffer for writing the response.
+ */
+ cdrBufOutput reply = new cdrBufOutput();
+
+ /**
+ * If set to true, an exception has been thrown during the invocation.
+ */
+ boolean isException;
+
+ public OutputStream createExceptionReply()
+ {
+ isException = true;
+ return reply;
+ }
+
+ public OutputStream createReply()
+ {
+ isException = false;
+ return reply;
+ }
+
+ /**
+ * The old style invocation using the currently deprecated server
+ * request class.
+ *
+ * @param request a server request, containg the invocation information.
+ * @param target the invocation target
+ * @param result the result holder with the set suitable streamable to read
+ * the result or null for void.
+ */
+ public static void invoke(ServerRequest request, InvokeHandler target,
+ Streamable result
+ )
+ {
+ try
+ {
+ int IN = ARG_IN.value;
+ int OUT = ARG_OUT.value;
+
+ // Write all arguments to the buffer output stream.
+ cdrBufOutput buffer = new cdrBufOutput();
+ gnuNVList args = new gnuNVList();
+ request.arguments(args);
+
+ for (int i = 0; i < args.count(); i++)
+ {
+ if ((args.item(i).flags() & IN) != 0)
+ {
+ args.item(i).value().write_value(buffer);
+ }
+ }
+
+ ServiceRequestAdapter h = new ServiceRequestAdapter();
+
+ target._invoke(request.operation(), buffer.create_input_stream(), h);
+
+ InputStream in = h.reply.create_input_stream();
+
+ if (h.isException)
+ {
+ // Write the exception information
+ gnuAny exc = new gnuAny();
+ universalHolder uku = new universalHolder(h.reply);
+ exc.insert_Streamable(uku);
+ request.set_exception(exc);
+ }
+ else
+ {
+ if (result != null)
+ {
+ result._read(in);
+ gnuAny r = new gnuAny();
+ r.insert_Streamable(result);
+ request.set_result(r);
+ };
+
+ // Unpack the arguments
+ for (int i = 0; i < args.count(); i++)
+ {
+ if ((args.item(i).flags() & OUT) != 0)
+ {
+ Any a = args.item(i).value();
+ a.read_value(in, a.type());
+ }
+ }
+ }
+ }
+ catch (Bounds ex)
+ {
+ throw new InternalError();
+ }
+ }
+} \ No newline at end of file
diff --git a/gnu/CORBA/SetOverrideTypeHolder.java b/gnu/CORBA/SetOverrideTypeHolder.java
new file mode 100644
index 000000000..d1fcc18f3
--- /dev/null
+++ b/gnu/CORBA/SetOverrideTypeHolder.java
@@ -0,0 +1,90 @@
+/* SetOverrideTypeHolder.java --
+ Copyright (C) 2005 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.CORBA;
+
+import org.omg.CORBA.SetOverrideType;
+import org.omg.CORBA.SetOverrideTypeHelper;
+
+/**
+ * The holder for SetOverrideType.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public class SetOverrideTypeHolder
+ implements org.omg.CORBA.portable.Streamable
+{
+ /**
+ * The stored SetOverrideType value.
+ */
+ public SetOverrideType value;
+
+ /**
+ * Create the initialised instance.
+ *
+ * @param initialValue the initial value.
+ */
+ public SetOverrideTypeHolder(SetOverrideType initialValue)
+ {
+ value = initialValue;
+ }
+
+ /**
+ * Fill in the {@link value} by data from the CDR stream.
+ */
+ public void _read(org.omg.CORBA.portable.InputStream in)
+ {
+ value = SetOverrideTypeHelper.read(in);
+ }
+
+ /**
+ * Get the typecode of the SetOverrideType.
+ */
+ public org.omg.CORBA.TypeCode _type()
+ {
+ return SetOverrideTypeHelper.type();
+ }
+
+ /**
+ * Write the stored value into the CDR stream.
+ */
+ public void _write(org.omg.CORBA.portable.OutputStream out)
+ {
+ SetOverrideTypeHelper.write(out, value);
+ }
+} \ No newline at end of file
diff --git a/gnu/CORBA/Simple_delegate.java b/gnu/CORBA/Simple_delegate.java
index 9d6aab060..662dfef18 100644
--- a/gnu/CORBA/Simple_delegate.java
+++ b/gnu/CORBA/Simple_delegate.java
@@ -238,13 +238,12 @@ public class Simple_delegate
}
/**
- * Not implemented for this delegate.
+ * This should never be called this type delegate.
*
- * @throws NO_IMPLEMENT, always.
+ * @throws InternalError, always.
*/
public Request request(org.omg.CORBA.Object target, String operation)
{
- /**@todo Implement this org.omg.CORBA.portable.Delegate abstract method*/
- throw new java.lang.UnsupportedOperationException("Method request() not yet implemented.");
+ throw new InternalError();
}
}
diff --git a/gnu/CORBA/binaryReply.java b/gnu/CORBA/binaryReply.java
index 44d9e8dc8..6d3c19291 100644
--- a/gnu/CORBA/binaryReply.java
+++ b/gnu/CORBA/binaryReply.java
@@ -89,6 +89,7 @@ class binaryReply
in.setOffset(header.getHeaderSize());
in.setVersion(header.version);
in.setOrb(orb);
+ in.setBigEndian(header.isBigEndian());
return in;
}
}
diff --git a/gnu/CORBA/gnuNVList.java b/gnu/CORBA/gnuNVList.java
index f61afd7a6..e423df3b4 100644
--- a/gnu/CORBA/gnuNVList.java
+++ b/gnu/CORBA/gnuNVList.java
@@ -74,13 +74,13 @@ public class gnuNVList
/** {@inheritDoc} */
public NamedValue add(int a_flags)
{
- return add_value(null, null, a_flags);
+ return add_value(null, new gnuAny(), a_flags);
}
/** {@inheritDoc} */
public NamedValue add_item(String a_name, int a_flags)
{
- return add_value(a_name, null, a_flags);
+ return add_value(a_name, new gnuAny(), a_flags);
}
/** {@inheritDoc} */
@@ -93,17 +93,17 @@ public class gnuNVList
list.add(n);
return n;
}
-
+
/**
* Add the given named value to the list directly.
- *
+ *
* @param value the named vaue to add.
*/
public void add(NamedValue value)
{
list.add(value);
- }
-
+ }
+
/** {@inheritDoc} */
public int count()
diff --git a/gnu/CORBA/gnuRequest.java b/gnu/CORBA/gnuRequest.java
index 0665e919b..745b350d5 100644
--- a/gnu/CORBA/gnuRequest.java
+++ b/gnu/CORBA/gnuRequest.java
@@ -69,6 +69,7 @@ import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;
+import org.omg.CORBA.UnknownUserException;
/**
* The implementation of the CORBA request.
@@ -172,13 +173,26 @@ public class gnuRequest
private ORB orb;
/**
+ * The encoding, used to send the message.
+ *
+ * The default encoding is inherited from the set IOR
+ * (that string reference can be encoded in either Big or
+ * Little endian). If the IOR encoding is not known
+ * (for example, by obtaining the reference from the naming
+ * service), the Big Endian is used.
+ */
+ private boolean Big_endian = true;
+
+ /**
* Set the IOR data, sufficient to find the invocation target.
+ * This also sets default endian encoding for invocations.
*
* @see IOR.parse(String)
*/
public void setIor(IOR an_ior)
{
ior = an_ior;
+ setBigEndian(ior.Big_Endian);
}
/**
@@ -200,6 +214,22 @@ public class gnuRequest
}
/**
+ * Set the encoding that will be used to send the message.
+ * The default encoding is inherited from the set IOR
+ * (that string reference can be encoded in either Big or
+ * Little endian). If the IOR encoding is not known
+ * (for example, by obtaining the reference from the naming
+ * service), the Big Endian is used.
+ *
+ * @param use_big_endian true to use the Big Endian, false
+ * to use the Little Endian encoding.
+ */
+ public void setBigEndian(boolean use_big_endian)
+ {
+ Big_endian = use_big_endian;
+ }
+
+ /**
* The the method name to invoke.
*
* @param operation the method name.
@@ -220,6 +250,7 @@ public class gnuRequest
m_parameter_buffer.setVersion(ior.Internet.version);
m_parameter_buffer.setCodeSet(cxCodeSet.negotiate(ior.CodeSets));
m_parameter_buffer.setOrb(orb);
+ m_parameter_buffer.setBigEndian(Big_endian);
return m_parameter_buffer;
}
@@ -574,6 +605,8 @@ public class gnuRequest
{
gnu.CORBA.GIOP.MessageHeader header = new gnu.CORBA.GIOP.MessageHeader();
+ header.setBigEndian(Big_endian);
+
// The byte order will be Big Endian by default.
header.message_type = gnu.CORBA.GIOP.MessageHeader.REQUEST;
header.version = useVersion(ior.Internet.version);
@@ -590,6 +623,7 @@ public class gnuRequest
request_part.setVersion(header.version);
request_part.setCodeSet(cxCodeSet.negotiate(ior.CodeSets));
request_part.setOrb(orb);
+ request_part.setBigEndian(header.isBigEndian());
// This also sets the stream encoding to the encoding, specified
// in the header.
@@ -638,7 +672,7 @@ public class gnuRequest
reading:
while (n < r.length)
{
- n = socketInput.read(r, n, r.length - n);
+ n += socketInput.read(r, n, r.length - n);
}
socketInput.close();
return new binaryReply(orb, response_header, r);
@@ -786,17 +820,15 @@ public class gnuRequest
input.align(8);
align = false;
}
- input.mark(2000);
- String uxId = input.read_string();
- input.reset();
+ // Prepare an Any that will hold the exception.
+ gnuAny exc = new gnuAny();
+
+ exc.insert_Streamable(new streamReadyHolder(input));
- UserException uex = ObjectCreator.readUserException(uxId, input);
+ UnknownUserException unuex = new UnknownUserException(exc);
+ m_environment.exception(unuex);
- if (uex == null)
- m_environment.exception(new UserException(uxId));
- else
- m_environment.exception(uex);
break;
case ReplyHeader.LOCATION_FORWARD_PERM :
diff --git a/gnu/CORBA/streamReadyHolder.java b/gnu/CORBA/streamReadyHolder.java
new file mode 100644
index 000000000..db35495c0
--- /dev/null
+++ b/gnu/CORBA/streamReadyHolder.java
@@ -0,0 +1,120 @@
+/* streamReadyHolder.java --
+ Copyright (C) 2005 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.CORBA;
+
+import org.omg.CORBA.MARSHAL;
+import org.omg.CORBA.NO_IMPLEMENT;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+import org.omg.CORBA.portable.Streamable;
+
+import java.io.IOException;
+
+/**
+ * A holder that stores the input stream, from that the holder data
+ * can be read. There is no way to write the data into this holder.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class streamReadyHolder
+ implements Streamable
+{
+ /**
+ * The stream, holding the data for this holder.
+ */
+ protected final InputStream stream;
+
+ /**
+ * Create a holder that will read from the given stream.
+ *
+ * @param a_stream a stream.
+ */
+ public streamReadyHolder(InputStream a_stream)
+ {
+ stream = a_stream;
+ }
+
+ /**
+ * This method is not in use, should never be called.
+ */
+ public TypeCode _type()
+ {
+ throw new NO_IMPLEMENT();
+ }
+
+ /**
+ * Writes the data from the stored stream into the provided
+ * output stream till the end of the input stream is reached.
+ *
+ * @throws MARSHAL if the IOException is thrown during operation.
+ */
+ public void _write(OutputStream output)
+ {
+ try
+ {
+ int d = stream.read();
+
+ while (d >= 0)
+ {
+ output.write(d);
+ d = stream.read();
+ }
+ }
+ catch (IOException ex)
+ {
+ throw new MARSHAL(ex + ":" + ex.getMessage());
+ }
+ }
+
+ /**
+ * This method is not in use, should never be called.
+ */
+ public void _read(InputStream input)
+ {
+ throw new NO_IMPLEMENT();
+ }
+
+ /**
+ * Get the input stream that has been passed in constructor.
+ */
+ InputStream getInputStream()
+ {
+ return stream;
+ }
+} \ No newline at end of file
diff --git a/gnu/CORBA/universalHolder.java b/gnu/CORBA/universalHolder.java
index 6cfab80d2..1a5226c3e 100644
--- a/gnu/CORBA/universalHolder.java
+++ b/gnu/CORBA/universalHolder.java
@@ -109,7 +109,9 @@ class universalHolder
}
catch (IOException ex)
{
- throw new MARSHAL(ex.getClass().getName() + ":" + ex.getMessage());
+ MARSHAL t = new MARSHAL();
+ t.initCause(ex);
+ throw t;
}
}
@@ -139,7 +141,9 @@ class universalHolder
}
catch (IOException ex)
{
- throw new MARSHAL(ex.getClass().getName() + ":" + ex.getMessage());
+ MARSHAL t = new MARSHAL();
+ t.initCause(ex);
+ throw t;
}
}
diff --git a/gnu/java/awt/GradientPaintContext.java b/gnu/java/awt/GradientPaintContext.java
new file mode 100644
index 000000000..6073917cd
--- /dev/null
+++ b/gnu/java/awt/GradientPaintContext.java
@@ -0,0 +1,164 @@
+/* GradientPaintContext.java --
+ Copyright (C) 2005, 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.java.awt;
+
+import java.awt.geom.Point2D;
+import java.awt.image.ColorModel;
+import java.awt.image.Raster;
+import java.awt.image.WritableRaster;
+import java.awt.PaintContext;
+import java.awt.Color;
+
+/**
+ * A {@link PaintContext} used by the {@link GradientPaint} class.
+ */
+public class GradientPaintContext implements PaintContext
+{
+
+ // This implementation follows the technique described in
+ // "Java(tm) 2D Graphics" by Jonathan Knudsen (O'Reilly 1999).
+
+ /** The x-coordinate of the anchor point for color 1. */
+ private final float x1;
+
+ /** The y-coordinate of the anchor point for color 1. */
+ private final float y1;
+
+ /** Color 1. */
+ private final Color c1;
+
+ /** The x-coordinate of the anchor point for color 2. */
+ private final float x2;
+
+ /** The y-coordinate of the anchor point for color 2. */
+ private final float y2;
+
+ /** Color 2. */
+ private final Color c2;
+
+ /** A flag indicating whether the gradient is cyclic or acyclic. */
+ private final boolean cyclic;
+
+ /** The length of the gradient line - computed from the two anchor points. */
+ private final double length;
+
+ /**
+ * Creates a new instance.
+ *
+ * @param x1 the x-coordinate for the anchor point for color 1.
+ * @param y1 the y-coordinate for the anchor point for color 1.
+ * @param c1 color 1.
+ * @param x2 the x-coordinate for the anchor point for color 2.
+ * @param y2 the y-coordinate for the anchor point for color 2.
+ * @param c2 color 2.
+ * @param cyclic a flag that determines whether the gradient is cyclic
+ * or acyclic.
+ */
+ public GradientPaintContext(float x1, float y1, Color c1,
+ float x2, float y2, Color c2, boolean cyclic)
+ {
+ this.x1 = x1;
+ this.y1 = y1;
+ this.c1 = c1;
+ this.x2 = x2;
+ this.y2 = y2;
+ this.c2 = c2;
+ this.cyclic = cyclic;
+ length = Point2D.distance(x1, y1, x2, y2);
+ }
+
+ /**
+ * Return the color model of this context. It may be different from the
+ * hint specified during createContext, as not all contexts can generate
+ * color patterns in an arbitrary model.
+ *
+ * @return the context color model
+ */
+ public ColorModel getColorModel()
+ {
+ return ColorModel.getRGBdefault();
+ }
+
+ /**
+ * Return a raster containing the colors for the graphics operation.
+ *
+ * @param x the x-coordinate, in device space
+ * @param y the y-coordinate, in device space
+ * @param w the width, in device space
+ * @param h the height, in device space
+ * @return a raster for the given area and color
+ */
+ public Raster getRaster(int x, int y, int w, int h) {
+ ColorModel cm = getColorModel();
+ WritableRaster raster = cm.createCompatibleWritableRaster(w, h);
+ int[] data = new int[w * h * 4];
+ double pd2 = (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);
+ for (int r = 0; r < h; r++) {
+ for (int c = 0; c < w; c++) {
+ double u = 0.0;
+ if (pd2 != 0)
+ u = (((x + c) - x1) * (x2 - x1) + ((y + r) - y1) * (y2 - y1))
+ / Math.sqrt(pd2);
+ double ratio = u / length;
+ if (cyclic)
+ ratio = Math.abs(ratio - Math.floor((ratio + 1.0) / 2.0) * 2.0);
+ else
+ ratio = Math.max(0.0, Math.min(1.0, ratio));
+ int base = (r * w + c) * 4;
+ data[base] = (int) (c1.getRed() + ratio * (c2.getRed() - c1.getRed()));
+ data[base + 1]
+ = (int) (c1.getGreen() + ratio * (c2.getGreen() - c1.getGreen()));
+ data[base + 2]
+ = (int) (c1.getBlue() + ratio * (c2.getBlue() - c1.getBlue()));
+ data[base + 3]
+ = (int) (c1.getAlpha() + ratio * (c2.getAlpha() - c1.getAlpha()));
+ }
+ }
+ raster.setPixels(0, 0, w, h, data);
+ return raster;
+ }
+
+ /**
+ * Release the resources allocated for the paint (none in this
+ * implementation).
+ */
+ public void dispose() {
+ // nothing to do
+ }
+
+}
diff --git a/gnu/java/awt/peer/gtk/GdkGraphics.java b/gnu/java/awt/peer/gtk/GdkGraphics.java
index 70b3abca7..c870dc1d4 100644
--- a/gnu/java/awt/peer/gtk/GdkGraphics.java
+++ b/gnu/java/awt/peer/gtk/GdkGraphics.java
@@ -58,6 +58,7 @@ public class GdkGraphics extends Graphics
GtkComponentPeer component;
Font font;
Rectangle clip;
+ GtkImage image;
int xOffset = 0;
int yOffset = 0;
@@ -66,6 +67,7 @@ public class GdkGraphics extends Graphics
native void initState (GtkComponentPeer component);
native void initState (int width, int height);
+ native void initFromImage (GtkImage image);
native void copyState (GdkGraphics g);
GdkGraphics (GdkGraphics g)
@@ -87,10 +89,21 @@ public class GdkGraphics extends Graphics
font = new Font ("Dialog", Font.PLAIN, 12);
}
+ GdkGraphics (GtkImage image)
+ {
+ this.image = image;
+ initFromImage (image);
+ color = Color.black;
+ clip = new Rectangle (0, 0,
+ image.getWidth(null), image.getHeight(null));
+ font = new Font ("Dialog", Font.PLAIN, 12);
+ }
+
GdkGraphics (GtkComponentPeer component)
{
this.component = component;
font = component.awtComponent.getFont ();
+ color = Color.black;
if (component.isRealized ())
initComponentGraphics ();
@@ -129,169 +142,57 @@ public class GdkGraphics extends Graphics
public native void dispose();
- native void copyPixmap (Graphics g, int x, int y, int width, int height);
- native void copyAndScalePixmap (Graphics g, boolean flip_x, boolean flip_y,
- int src_x, int src_y,
- int src_width, int src_height,
- int dest_x, int dest_y,
- int dest_width, int dest_height);
public boolean drawImage (Image img, int x, int y,
Color bgcolor, ImageObserver observer)
{
- if (component != null && ! component.isRealized ())
- return false;
-
- if (img instanceof GtkOffScreenImage)
- {
- int width = img.getWidth (null);
- int height = img.getHeight (null);
- copyPixmap (img.getGraphics (),
- x, y, width, height);
- return true;
- }
-
- GtkImage image = (GtkImage) img;
- new GtkImagePainter (image, this, x, y, -1, -1, bgcolor, observer);
- return image.isLoaded ();
+ return drawImage(img, x, y, img.getWidth(null), img.getHeight(null),
+ bgcolor, observer);
}
public boolean drawImage (Image img, int x, int y, ImageObserver observer)
{
- if (component != null && ! component.isRealized ())
- return false;
-
- if (img instanceof GtkOffScreenImage)
- {
- int width = img.getWidth (null);
- int height = img.getHeight (null);
- copyPixmap (img.getGraphics (),
- x, y, width, height);
- return true;
- }
-
- if (component != null)
- return drawImage (img, x, y, component.getBackground (), observer);
- else
- return drawImage (img, x, y, SystemColor.window, observer);
+ return drawImage (img, x, y, null, observer);
}
public boolean drawImage (Image img, int x, int y, int width, int height,
Color bgcolor, ImageObserver observer)
{
- if (component != null && ! component.isRealized ())
- return false;
-
- if (img instanceof GtkOffScreenImage)
- {
- copyAndScalePixmap (img.getGraphics (), false, false,
- 0, 0, img.getWidth (null), img.getHeight (null),
- x, y, width, height);
- return true;
- }
-
- GtkImage image = (GtkImage) img;
- new GtkImagePainter (image, this, x, y, width, height, bgcolor, observer);
- return image.isLoaded ();
+ if (img instanceof GtkImage)
+ return ((GtkImage)img).drawImage (this, x, y, width, height,
+ bgcolor, observer);
+ else
+ return (new GtkImage(img.getSource())).drawImage (this, x, y,
+ width, height,
+ bgcolor, observer);
}
public boolean drawImage (Image img, int x, int y, int width, int height,
ImageObserver observer)
{
- if (component != null && ! component.isRealized ())
- return false;
-
- if (component != null)
- return drawImage (img, x, y, width, height, component.getBackground (),
- observer);
- else
- return drawImage (img, x, y, width, height, SystemColor.window,
- observer);
+ return drawImage (img, x, y, width, height, null, observer);
}
public boolean drawImage (Image img, int dx1, int dy1, int dx2, int dy2,
int sx1, int sy1, int sx2, int sy2,
Color bgcolor, ImageObserver observer)
{
- if (component != null && ! component.isRealized ())
- return false;
-
- if (img instanceof GtkOffScreenImage)
- {
- int dx_start, dy_start, d_width, d_height;
- int sx_start, sy_start, s_width, s_height;
- boolean x_flip = false;
- boolean y_flip = false;
-
- if (dx1 < dx2)
- {
- dx_start = dx1;
- d_width = dx2 - dx1;
- }
- else
- {
- dx_start = dx2;
- d_width = dx1 - dx2;
- x_flip ^= true;
- }
- if (dy1 < dy2)
- {
- dy_start = dy1;
- d_height = dy2 - dy1;
- }
- else
- {
- dy_start = dy2;
- d_height = dy1 - dy2;
- y_flip ^= true;
- }
- if (sx1 < sx2)
- {
- sx_start = sx1;
- s_width = sx2 - sx1;
- }
- else
- {
- sx_start = sx2;
- s_width = sx1 - sx2;
- x_flip ^= true;
- }
- if (sy1 < sy2)
- {
- sy_start = sy1;
- s_height = sy2 - sy1;
- }
- else
- {
- sy_start = sy2;
- s_height = sy1 - sy2;
- y_flip ^= true;
- }
-
- copyAndScalePixmap (img.getGraphics (), x_flip, y_flip,
- sx_start, sy_start, s_width, s_height,
- dx_start, dy_start, d_width, d_height);
- return true;
- }
-
- GtkImage image = (GtkImage) img;
- new GtkImagePainter (image, this, dx1, dy1, dx2, dy2,
- sx1, sy1, sx2, sy2, bgcolor, observer);
- return image.isLoaded ();
+ if (img instanceof GtkImage)
+ return ((GtkImage)img).drawImage(this, dx1, dy1, dx2, dy2,
+ sx1, sy1, sx2, sy2, bgcolor, observer);
+ else
+ return (new GtkImage(img.getSource())).drawImage(this, dx1, dy1,
+ dx2, dy2,
+ sx1, sy1, sx2, sy2,
+ bgcolor, observer);
}
public boolean drawImage (Image img, int dx1, int dy1, int dx2, int dy2,
int sx1, int sy1, int sx2, int sy2,
ImageObserver observer)
{
- if (component != null && ! component.isRealized ())
- return false;
-
- if (component != null)
- return drawImage (img, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2,
- component.getBackground (), observer);
- else
- return drawImage (img, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2,
- SystemColor.window, observer);
+ return drawImage (img, dx1, dy1, dx2, dy2,
+ sx1, sy1, sx2, sy2,
+ null, observer);
}
public native void drawLine(int x1, int y1, int x2, int y2);
diff --git a/gnu/java/awt/peer/gtk/GdkGraphics2D.java b/gnu/java/awt/peer/gtk/GdkGraphics2D.java
index 6c04f7834..0ddc1c7a8 100644
--- a/gnu/java/awt/peer/gtk/GdkGraphics2D.java
+++ b/gnu/java/awt/peer/gtk/GdkGraphics2D.java
@@ -510,21 +510,22 @@ public class GdkGraphics2D extends Graphics2D
if (img == null)
return false;
- if (img instanceof GtkOffScreenImage
- && img.getGraphics() instanceof GdkGraphics2D
- && (xform == null || xform.getType() == AffineTransform.TYPE_IDENTITY
- || xform.getType() == AffineTransform.TYPE_TRANSLATION))
- {
- // we are being asked to flush a double buffer from Gdk
- GdkGraphics2D g2 = (GdkGraphics2D) img.getGraphics();
- gdkDrawDrawable(g2, (int) xform.getTranslateX(),
- (int) xform.getTranslateY());
-
- updateBufferedImage();
-
- return true;
- }
- else
+ // FIXME: I'll fix this, /Sven
+// if (img instanceof GtkOffScreenImage
+// && img.getGraphics() instanceof GdkGraphics2D
+// && (xform == null || xform.getType() == AffineTransform.TYPE_IDENTITY
+// || xform.getType() == AffineTransform.TYPE_TRANSLATION))
+// {
+// // we are being asked to flush a double buffer from Gdk
+// GdkGraphics2D g2 = (GdkGraphics2D) img.getGraphics();
+// gdkDrawDrawable(g2, (int) xform.getTranslateX(),
+// (int) xform.getTranslateY());
+
+// updateBufferedImage();
+
+// return true;
+// }
+// else
{
// In this case, xform is an AffineTransform that transforms bounding
// box of the specified image from image space to user space. However
diff --git a/gnu/java/awt/peer/gtk/GtkComponentPeer.java b/gnu/java/awt/peer/gtk/GtkComponentPeer.java
index e3e7afb19..3a1bf8b66 100644
--- a/gnu/java/awt/peer/gtk/GtkComponentPeer.java
+++ b/gnu/java/awt/peer/gtk/GtkComponentPeer.java
@@ -198,33 +198,21 @@ public class GtkComponentPeer extends GtkGenericPeer
public int checkImage (Image image, int width, int height,
ImageObserver observer)
{
- GtkImage i = (GtkImage) image;
- return i.checkImage ();
+ return getToolkit().checkImage(image, width, height, observer);
}
public Image createImage (ImageProducer producer)
{
- GtkImage image = new GtkImage (producer, null);
- producer.startProduction (image);
- return image;
+ return new GtkImage (producer);
}
public Image createImage (int width, int height)
{
- Graphics g;
- if (GtkToolkit.useGraphics2D ())
- {
- Graphics2D g2 = new GdkGraphics2D (width, height);
- g2.setBackground (getBackground ());
- g = g2;
- }
- else
- g = new GdkGraphics (width, height);
-
+ GtkImage image = new GtkImage (width, height);
+ Graphics g = image.getGraphics();
g.setColor(getBackground());
g.fillRect(0, 0, width, height);
-
- return new GtkOffScreenImage (null, g, width, height);
+ return image;
}
public void disable ()
@@ -353,29 +341,7 @@ public class GtkComponentPeer extends GtkGenericPeer
public boolean prepareImage (Image image, int width, int height,
ImageObserver observer)
{
- GtkImage i = (GtkImage) image;
-
- if (i.isLoaded ()) return true;
-
- class PrepareImage extends Thread
- {
- GtkImage image;
- ImageObserver observer;
-
- PrepareImage (GtkImage image, ImageObserver observer)
- {
- this.image = image;
- image.setObserver (observer);
- }
-
- public void run ()
- {
- image.source.startProduction (image);
- }
- }
-
- new PrepareImage (i, observer).start ();
- return false;
+ return getToolkit().prepareImage(image, width, height, observer);
}
public void print (Graphics g)
diff --git a/gnu/java/awt/peer/gtk/GtkContainerPeer.java b/gnu/java/awt/peer/gtk/GtkContainerPeer.java
index 61551835e..e4aea64c9 100644
--- a/gnu/java/awt/peer/gtk/GtkContainerPeer.java
+++ b/gnu/java/awt/peer/gtk/GtkContainerPeer.java
@@ -115,9 +115,14 @@ public class GtkContainerPeer extends GtkComponentPeer
Component[] components = ((Container) awtComponent).getComponents();
for (int i = 0; i < components.length; i++)
{
- GtkComponentPeer peer = (GtkComponentPeer) components[i].getPeer();
- if (peer != null && ! peer.awtComponent.isFontSet())
- peer.setFont(f);
+ if (components[i].isLightweight ())
+ components[i].setFont (f);
+ else
+ {
+ GtkComponentPeer peer = (GtkComponentPeer) components[i].getPeer();
+ if (peer != null && ! peer.awtComponent.isFontSet())
+ peer.setFont(f);
+ }
}
}
diff --git a/gnu/java/awt/peer/gtk/GtkFramePeer.java b/gnu/java/awt/peer/gtk/GtkFramePeer.java
index b22a25e88..53e06bc08 100644
--- a/gnu/java/awt/peer/gtk/GtkFramePeer.java
+++ b/gnu/java/awt/peer/gtk/GtkFramePeer.java
@@ -166,36 +166,17 @@ public class GtkFramePeer extends GtkWindowPeer
setIconImage(frame.getIconImage());
}
- native void nativeSetIconImageFromDecoder (GdkPixbufDecoder decoder);
- native void nativeSetIconImageFromData (int[] pixels, int width, int height);
+ native void nativeSetIconImage (GtkImage image);
+
public void setIconImage (Image image)
{
- if (image != null && image instanceof GtkImage)
- {
- GtkImage img = (GtkImage) image;
- // FIXME: Image should be loaded, but if not, do image loading here.
- if (img.isLoaded())
- {
- if (img.getSource() instanceof GdkPixbufDecoder)
- {
- nativeSetIconImageFromDecoder((GdkPixbufDecoder) img.getSource());
- }
- else
- {
- int[] pixels = img.getPixelCache();
- ColorModel model = img.getColorModel();
- int[] data = new int[pixels.length * 4];
- for (int i = 0; i < pixels.length; i++)
- {
- data[i * 4] = model.getRed(pixels[i]);
- data[i * 4 + 1] = model.getGreen(pixels[i]);
- data[i * 4 + 2] = model.getBlue(pixels[i]);
- data[i * 4 + 3] = model.getAlpha(pixels[i]);
- }
- nativeSetIconImageFromData(data, img.getWidth(null), img.getHeight(null));
- }
- }
- }
+ if (image != null)
+ {
+ if (image instanceof GtkImage)
+ nativeSetIconImage((GtkImage) image);
+ else
+ nativeSetIconImage(new GtkImage(image.getSource()));
+ }
}
public Graphics getGraphics ()
diff --git a/gnu/java/awt/peer/gtk/GtkImage.java b/gnu/java/awt/peer/gtk/GtkImage.java
index 510646c5a..9b794b4aa 100644
--- a/gnu/java/awt/peer/gtk/GtkImage.java
+++ b/gnu/java/awt/peer/gtk/GtkImage.java
@@ -1,5 +1,5 @@
/* GtkImage.java
- Copyright (C) 1999, 2002, 2003 Free Software Foundation, Inc.
+ Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -39,306 +39,420 @@ exception statement from your version. */
package gnu.java.awt.peer.gtk;
import java.awt.Graphics;
+import java.awt.Color;
import java.awt.Image;
import java.awt.image.ColorModel;
+import java.awt.image.DirectColorModel;
+import java.awt.image.MemoryImageSource;
import java.awt.image.ImageConsumer;
import java.awt.image.ImageObserver;
import java.awt.image.ImageProducer;
+import java.io.File;
+import java.io.IOException;
import java.util.Hashtable;
import java.util.Vector;
-
-public class GtkImage extends Image implements ImageConsumer
+import gnu.classpath.RawData;
+
+/**
+ * GtkImage - wraps a GdkPixbuf or GdkPixmap.
+ *
+ * The constructor GtkImage(int, int) creates an 'off-screen' GdkPixmap,
+ * this can be drawn to (it's a GdkDrawable), and correspondingly, you can
+ * create a GdkGraphics object for it.
+ *
+ * This corresponds to the Image implementation returned by
+ * Component.createImage(int, int).
+ *
+ * A GdkPixbuf is 'on-screen' and the gdk cannot draw to it,
+ * this is used for the other constructors (and other createImage methods), and
+ * corresponds to the Image implementations returned by the Toolkit.createImage
+ * methods, and is basically immutable.
+ *
+ * @author Sven de Marothy
+ */
+public class GtkImage extends Image
{
int width = -1, height = -1;
- Hashtable props = null;
- boolean isLoaded = false;
- boolean isCacheable = true;
- boolean loading = false;
-
- Vector widthObservers = new Vector ();
- Vector heightObservers = new Vector ();
- Vector propertyObservers = new Vector ();
+ /**
+ * Properties.
+ */
+ Hashtable props;
+
+ /**
+ * Loaded or not flag, for asynchronous compatibility.
+ */
+ boolean isLoaded;
+
+ /**
+ * Pointer to the GdkPixbuf
+ */
+ RawData pixmap;
+
+ /**
+ * Observer queue.
+ */
+ Vector observers;
+
+ /**
+ * If offScreen is set, a GdkBitmap is wrapped and not a Pixbuf.
+ */
+ boolean offScreen;
+
+ /**
+ * Original source, if created from an ImageProducer.
+ */
ImageProducer source;
- ImageObserver observer;
- Graphics g;
-
- /* Variables in which we stored cached data, if possible.
- An image is cached if the following properties are true:
- 1. The ColorModel passed into setColorModel is the same ColorModel
- passed to all invocations of setPixels.
- 2. The image contains a single frame.
-
- */
- int[] pixelCache;
- ColorModel model;
-
- public
- GtkImage (ImageProducer producer, Graphics g)
+ /*
+ * The 32-bit AABBGGRR format the GDK uses.
+ */
+ static ColorModel nativeModel = new DirectColorModel(32,
+ 0x000000FF,
+ 0x0000FF00,
+ 0x00FF0000,
+ 0xFF000000);
+
+ /**
+ * Returns a copy of the pixel data as a java array.
+ */
+ private native int[] getPixels();
+
+ /**
+ * Sets the pixel data from a java array.
+ */
+ private native void setPixels(int[] pixels);
+
+ /**
+ * Loads an image using gdk-pixbuf.
+ */
+ private native boolean loadPixbuf(String name);
+
+ /**
+ * Allocates a Gtk Pixbuf or pixmap
+ */
+ private native void createPixmap();
+
+ /**
+ * Frees the above.
+ */
+ private native void freePixmap();
+
+ /**
+ * Sets the pixmap to scaled copy of src image. hints are rendering hints.
+ */
+ private native void createScaledPixmap(GtkImage src, int hints);
+
+ /**
+ * Draws the image, optionally scaled and composited.
+ */
+ private native void drawPixelsScaled (GdkGraphics gc,
+ int bg_red, int bg_green, int bg_blue,
+ int x, int y, int width, int height,
+ boolean composite);
+
+ /**
+ * Draws the image, optionally scaled flipped and composited.
+ */
+ private native void drawPixelsScaledFlipped (GdkGraphics gc,
+ int bg_red, int bg_green,
+ int bg_blue,
+ boolean flipX, boolean flipY,
+ int srcX, int srcY,
+ int srcWidth, int srcHeight,
+ int dstX, int dstY,
+ int dstWidth, int dstHeight,
+ boolean composite);
+
+ /**
+ * Constructs a GtkImage from an ImageProducer. Asynchronity is handled in
+ * the following manner:
+ * A GtkImageConsumer gets the image data, and calls setImage() when
+ * completely finished. The GtkImage is not considered loaded until the
+ * GtkImageConsumer is completely finished. We go for all "all or nothing".
+ */
+ public GtkImage (ImageProducer producer)
{
+ isLoaded = false;
+ observers = new Vector();
source = producer;
- this.g = g;
+ source.startProduction(new GtkImageConsumer(this, source));
+ offScreen = false;
+ }
- if (source != null)
- source.addConsumer (this);
+ /**
+ * Constructs a GtkImage by loading a given file.
+ *
+ * @throws IllegalArgumentException if the image could not be loaded.
+ */
+ public GtkImage (String filename)
+ {
+ File f = new File(filename);
+ try
+ {
+ if (loadPixbuf(f.getCanonicalPath()) != true)
+ throw new IllegalArgumentException("Couldn't load image: "+filename);
+ }
+ catch(IOException e)
+ {
+ throw new IllegalArgumentException("Couldn't load image: "+filename);
+ }
+
+ isLoaded = true;
+ observers = null;
+ offScreen = false;
+ props = new Hashtable();
}
- public void setObserver (ImageObserver observer)
+ /**
+ * Constructs an empty GtkImage.
+ */
+ public GtkImage (int width, int height)
{
- this.observer = observer;
+ this.width = width;
+ this.height = height;
+ props = new Hashtable();
+ isLoaded = true;
+ observers = null;
+ offScreen = true;
+ createPixmap();
}
- public synchronized int[]
- getPixelCache ()
+ /**
+ * Constructs a scaled version of the src bitmap, using the GDK.
+ */
+ private GtkImage (GtkImage src, int width, int height, int hints)
{
- return pixelCache;
+ this.width = width;
+ this.height = height;
+ props = new Hashtable();
+ isLoaded = true;
+ observers = null;
+ offScreen = false;
+
+ // Use the GDK scaling method.
+ createScaledPixmap(src, hints);
}
- public synchronized ColorModel
- getColorModel ()
+ /**
+ * Callback from the image consumer.
+ */
+ public void setImage(int width, int height,
+ int[] pixels, Hashtable properties)
{
- return model;
+ this.width = width;
+ this.height = height;
+ props = (properties != null) ? properties : new Hashtable();
+ isLoaded = true;
+ deliver();
+ createPixmap();
+ setPixels(pixels);
}
- public synchronized int
- getWidth (ImageObserver observer)
+ // java.awt.Image methods ////////////////////////////////////////////////
+
+ public synchronized int getWidth (ImageObserver observer)
{
- if (width == -1)
- widthObservers.addElement (observer);
-
+ if (addObserver(observer))
+ return -1;
+
return width;
}
- public synchronized int
- getHeight (ImageObserver observer)
+ public synchronized int getHeight (ImageObserver observer)
{
- if (height == -1)
- heightObservers.addElement (observer);
+ if (addObserver(observer))
+ return -1;
return height;
}
-
- public ImageProducer
- getSource ()
- {
- return source;
- }
- public Graphics
- getGraphics ()
- {
- return g;
- }
-
- public synchronized Object
- getProperty (String name, ImageObserver observer)
+ public synchronized Object getProperty (String name, ImageObserver observer)
{
- if (props == null)
- {
- propertyObservers.addElement (observer);
- return null;
- }
+ if (addObserver(observer))
+ return UndefinedProperty;
Object value = props.get (name);
return (value == null) ? UndefinedProperty : value;
}
- public synchronized void
- flush ()
+ /**
+ * Returns the source of this image.
+ */
+ public ImageProducer getSource ()
{
- isLoaded = false;
- isCacheable = true;
- width = height = -1;
- props = null;
- pixelCache = null;
- model = null;
-
- if (source != null)
- {
- source.removeConsumer (this);
- source.addConsumer (this);
- }
+ return new MemoryImageSource(width, height, nativeModel, getPixels(),
+ 0, width);
}
- public boolean
- isLoaded ()
+ /**
+ * Creates a GdkGraphics context for this pixmap.
+ */
+ public Graphics getGraphics ()
{
- return isLoaded;
+ if (!isLoaded)
+ return null;
+ if (offScreen)
+ return new GdkGraphics(this);
+ else
+ throw new IllegalAccessError("This method only works for off-screen"
+ +" Images.");
}
-
- /* ImageConsumer methods */
-
- public synchronized void
- setDimensions (int width, int height)
+
+ /**
+ * Returns a scaled instance of this pixmap.
+ */
+ public Image getScaledInstance(int width,
+ int height,
+ int hints)
{
- pixelCache = new int[width*height];
+ if (width <= 0 || height <= 0)
+ throw new IllegalArgumentException("Width and height of scaled bitmap"+
+ "must be >= 0");
- this.width = width;
- this.height = height;
-
- for (int i = 0; i < widthObservers.size (); i++)
- {
- ImageObserver io = (ImageObserver) widthObservers.elementAt (i);
- if (io != null)
- io.imageUpdate (this, ImageObserver.WIDTH, -1, -1, width, height);
- }
-
- for (int i = 0; i < heightObservers.size (); i++)
- {
- ImageObserver io = (ImageObserver) heightObservers.elementAt (i);
- if (io != null)
- io.imageUpdate (this, ImageObserver.HEIGHT, -1, -1, width, height);
- }
-
- if (observer != null)
- observer.imageUpdate (this,
- (ImageObserver.WIDTH
- | ImageObserver.HEIGHT),
- -1, -1, width, height);
+ return new GtkImage(this, width, height, hints);
}
- public synchronized void
- setProperties (Hashtable props)
+ /**
+ * If the image is loaded and comes from an ImageProducer,
+ * regenerate the image from there.
+ *
+ * I have no idea if this is ever actually used. Since GtkImage can't be
+ * instantiated directly, how is the user to know if it was created from
+ * an ImageProducer or not?
+ */
+ public synchronized void flush ()
{
- this.props = props;
-
- for (int i = 0; i < propertyObservers.size (); i++)
+ if (isLoaded && source != null)
{
- ImageObserver io = (ImageObserver) propertyObservers.elementAt (i);
- if (io != null)
- io.imageUpdate (this, ImageObserver.PROPERTIES, -1, -1, width, height);
+ observers = new Vector();
+ isLoaded = false;
+ freePixmap();
+ source.startProduction(new GtkImageConsumer(this, source));
}
}
- public synchronized void
- setColorModel (ColorModel model)
- {
- if (this.model == null || this.model.equals(model))
- this.model = model;
- else
- isCacheable = false;
- }
-
- public synchronized void
- setHints (int flags)
+ public void finalize()
{
+ if (isLoaded)
+ freePixmap();
}
- public synchronized void
- setPixels (int x, int y, int width, int height, ColorModel cm, byte[] pixels,
- int offset, int scansize)
+ /**
+ * Returns the image status, used by GtkToolkit
+ */
+ public int checkImage (ImageObserver observer)
{
- setPixels (x, y, width, height, cm, convertPixels (pixels), offset,
- scansize);
+ if (addObserver(observer))
+ return 0;
- if (observer != null)
- observer.imageUpdate (this,
- ImageObserver.SOMEBITS,
- x, y, width, height);
+ return ImageObserver.ALLBITS | ImageObserver.WIDTH | ImageObserver.HEIGHT;
}
- public synchronized void
- setPixels (int x, int y, int width, int height, ColorModel cm, int[] pixels,
- int offset, int scansize)
- {
- loading = true;
+ // Drawing methods ////////////////////////////////////////////////
- if (!isCacheable)
- return;
-
- if (!cm.equals(model) || pixelCache == null)
+ /**
+ * Draws an image with eventual scaling/transforming.
+ */
+ public boolean drawImage (GdkGraphics g, int dx1, int dy1, int dx2, int dy2,
+ int sx1, int sy1, int sx2, int sy2,
+ Color bgcolor, ImageObserver observer)
+ {
+ if (addObserver(observer))
+ return false;
+
+ boolean flipX = (dx1 > dx2)^(sx1 > sx2);
+ boolean flipY = (dy1 > dy2)^(sy1 > sy2);
+ int dstWidth = Math.abs (dx2 - dx1);
+ int dstHeight = Math.abs (dy2 - dy1);
+ int srcWidth = Math.abs (sx2 - sx1);
+ int srcHeight = Math.abs (sy2 - sy1);
+ int srcX = (sx1 < sx2) ? sx1 : sx2;
+ int srcY = (sy1 < sy2) ? sy1 : sy2;
+ int dstX = (dx1 < dx2) ? dx1 : dx2;
+ int dstY = (dy1 < dy2) ? dy1 : dy2;
+
+ // Clipping. This requires the dst to be scaled as well,
+ if (srcWidth + srcX > width)
{
- isCacheable = false;
- return;
- }
+ dstWidth = (int)((double)dstWidth * (double)(width - srcX)/(double)srcWidth);
+ srcWidth = width - srcX;
+ }
- if (scansize == width && height == 1)
- {
- // Copy contents of pixels array into pixel cache.
- System.arraycopy (pixels, offset,
- pixelCache, y * this.width + x,
- pixels.length - offset);
- }
- else // skip over scansize-width for each row
+ if (srcHeight + srcY > height)
{
- for (int i = 0; i < height; i++)
- System.arraycopy (pixels, offset + (i * scansize),
- pixelCache, (y + i) * this.width + x,
- width);
+ dstHeight = (int)((double)dstHeight * (double)(width - srcY)/(double)srcHeight);
+ srcHeight = height - srcY;
}
+
+ if(bgcolor != null)
+ drawPixelsScaledFlipped (g, bgcolor.getRed (), bgcolor.getGreen (),
+ bgcolor.getBlue (),
+ flipX, flipY,
+ srcX, srcY,
+ srcWidth, srcHeight,
+ dstX, dstY,
+ dstWidth, dstHeight,
+ true);
+ else
+ drawPixelsScaledFlipped (g, 0, 0, 0, flipX, flipY,
+ srcX, srcY, srcWidth, srcHeight,
+ dstX, dstY, dstWidth, dstHeight,
+ false);
+ return true;
}
- public synchronized void
- imageComplete (int status)
+ /**
+ * Draws an image to the GdkGraphics context, at (x,y) scaled to
+ * width and height, with optional compositing with a background color.
+ */
+ public boolean drawImage (GdkGraphics g, int x, int y, int width, int height,
+ Color bgcolor, ImageObserver observer)
{
- if (status == ImageConsumer.STATICIMAGEDONE && isCacheable)
- isLoaded = true;
+ if (addObserver(observer))
+ return false;
- if (status == ImageConsumer.SINGLEFRAME)
- isCacheable = false;
-
- if (observer != null)
- {
- if (status == ImageConsumer.IMAGEERROR)
- observer.imageUpdate (null,
- ImageObserver.ERROR,
- -1, -1, -1, -1);
- else
- observer.imageUpdate (null,
- ImageObserver.ALLBITS,
- -1, -1, -1, -1);
- }
+ if(bgcolor != null)
+ drawPixelsScaled(g, bgcolor.getRed (), bgcolor.getGreen (),
+ bgcolor.getBlue (), x, y, width, height, true);
+ else
+ drawPixelsScaled(g, 0, 0, 0, x, y, width, height, false);
- if (source != null && status != ImageConsumer.SINGLEFRAME)
- source.removeConsumer (this);
+ return true;
}
- public synchronized void
- startProduction (GtkImagePainter painter)
- {
- if (isLoaded)
- {
- painter.setDimensions (width, height);
- painter.setPixels (0, 0, width, height, model, pixelCache, 0, width);
- }
- else
- {
- if (source != null)
- {
- source.startProduction (painter);
- source.removeConsumer (painter);
- }
- }
- }
+ // Private methods ////////////////////////////////////////////////
- private int[]
- convertPixels (byte[] pixels)
+ /**
+ * Delivers notifications to all queued observers.
+ */
+ private void deliver()
{
- int ret[] = new int[pixels.length];
+ int flags = ImageObserver.HEIGHT |
+ ImageObserver.WIDTH |
+ ImageObserver.PROPERTIES |
+ ImageObserver.ALLBITS;
- for (int i = 0; i < pixels.length; i++)
- ret[i] = pixels[i];
-
- return ret;
- }
+ for(int i=0; i < observers.size(); i++)
+ ((ImageObserver)observers.elementAt(i)).
+ imageUpdate(this, flags, 0, 0, width, height);
- synchronized int
- checkImage ()
+ observers = null;
+ }
+
+ /**
+ * Adds an observer, if we need to.
+ * @return true if an observer was added.
+ */
+ private boolean addObserver(ImageObserver observer)
{
- int bits = 0;
-
- if (width != -1)
- bits |= ImageObserver.WIDTH;
- if (height != -1)
- bits |= ImageObserver.HEIGHT;
- if (props != null)
- bits |= ImageObserver.PROPERTIES;
- if (loading)
- bits |= ImageObserver.SOMEBITS;
- if (isLoaded)
- bits |= ImageObserver.ALLBITS;
-
- return bits;
+ if (!isLoaded)
+ {
+ if(observer != null)
+ if (!observers.contains (observer))
+ observers.addElement (observer);
+ return true;
+ }
+ return false;
}
}
diff --git a/gnu/java/awt/peer/gtk/GtkImageConsumer.java b/gnu/java/awt/peer/gtk/GtkImageConsumer.java
new file mode 100644
index 000000000..93743fe1a
--- /dev/null
+++ b/gnu/java/awt/peer/gtk/GtkImageConsumer.java
@@ -0,0 +1,155 @@
+/* GtkImageConsumer.java
+ Copyright (C) 2005 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.java.awt.peer.gtk;
+
+import java.awt.Graphics;
+import java.awt.Image;
+import java.awt.image.ColorModel;
+import java.awt.image.DirectColorModel;
+import java.awt.image.ImageConsumer;
+import java.awt.image.ImageObserver;
+import java.awt.image.ImageProducer;
+import java.util.Hashtable;
+import java.util.Vector;
+
+/**
+ * Helper class to GtkImage. Sits and gathers pixels for a GtkImage and then
+ * calls GtkImage.setImage().
+ *
+ * @author Sven de Marothy
+ */
+public class GtkImageConsumer implements ImageConsumer
+{
+ private GtkImage target;
+ private int width, height;
+ private Hashtable properties;
+ private int[] pixelCache = null;
+ private ImageProducer source;
+
+ public GtkImageConsumer(GtkImage target, ImageProducer source)
+ {
+ this.target = target;
+ this.source = source;
+ }
+
+ public synchronized void imageComplete (int status)
+ {
+ source.removeConsumer(this);
+ target.setImage(width, height, pixelCache, properties);
+ }
+
+ public synchronized void setColorModel (ColorModel model)
+ {
+ // This method is to inform on what the most used color model
+ // in the image is, for optimization reasons. We ignore this
+ // information.
+ }
+
+ public synchronized void setDimensions (int width, int height)
+ {
+ pixelCache = new int[width*height];
+
+ this.width = width;
+ this.height = height;
+ }
+
+ public synchronized void setHints (int flags)
+ {
+ // This method informs us in which order the pixels are
+ // delivered, for progressive-loading support, etc.
+ // Since we wait until it's all loaded, we can ignore the hints.
+ }
+
+ public synchronized void setPixels (int x, int y, int width, int height,
+ ColorModel cm, byte[] pixels,
+ int offset, int scansize)
+ {
+ setPixels (x, y, width, height, cm, convertPixels (pixels), offset,
+ scansize);
+ }
+
+ public synchronized void setPixels (int x, int y, int width, int height,
+ ColorModel cm, int[] pixels,
+ int offset, int scansize)
+ {
+ if (pixelCache == null)
+ return; // Not sure this should ever happen.
+
+ if (cm.equals(GtkImage.nativeModel))
+ for (int i = 0; i < height; i++)
+ System.arraycopy (pixels, offset + (i * scansize),
+ pixelCache, (y + i) * this.width + x,
+ width);
+ else
+ {
+ for (int i = 0; i < height; i++)
+ for (int j = 0; j < width; j++)
+ {
+ // get in AARRGGBB and convert to AABBGGRR
+ int pix = cm.getRGB(pixels[offset + (i * scansize) + x + j]);
+ byte b = (byte)(pix & 0xFF);
+ byte r = (byte)(((pix & 0x00FF0000) >> 16) & 0xFF);
+ pix &= 0xFF00FF00;
+ pix |= ((b & 0xFF) << 16);
+ pix |= (r & 0xFF);
+ pixelCache[(y + i) * this.width + x + j] = pix;
+ }
+ }
+ }
+
+ /**
+ * This is an old method, no idea if it's correct.
+ */
+ private int[] convertPixels (byte[] pixels)
+ {
+ int ret[] = new int[pixels.length];
+
+ for (int i = 0; i < pixels.length; i++)
+ ret[i] = pixels[i] & 0xFF;
+
+ return ret;
+ }
+
+ public synchronized void setProperties (Hashtable props)
+ {
+ this.properties = props;
+ }
+}
+
+
diff --git a/gnu/java/awt/peer/gtk/GtkImagePainter.java b/gnu/java/awt/peer/gtk/GtkImagePainter.java
deleted file mode 100644
index 9f2ecb7dc..000000000
--- a/gnu/java/awt/peer/gtk/GtkImagePainter.java
+++ /dev/null
@@ -1,267 +0,0 @@
-/* GtkImagePainter.java
- Copyright (C) 1999, 2000 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.java.awt.peer.gtk;
-
-import java.awt.Color;
-import java.awt.Rectangle;
-import java.awt.image.ColorModel;
-import java.awt.image.ImageConsumer;
-import java.awt.image.ImageObserver;
-import java.util.Hashtable;
-
-public class GtkImagePainter implements Runnable, ImageConsumer
-{
- GtkImage image;
- GdkGraphics gc;
- int startX, startY;
- int redBG;
- int greenBG;
- int blueBG;
- double affine[];
- int width, height;
- boolean flipX, flipY;
- Rectangle clip;
- int s_width, s_height;
- ImageObserver observer;
-
- public
- GtkImagePainter (GtkImage image, GdkGraphics gc, int x, int y,
- int width, int height, Color bgcolor, ImageObserver o)
- {
- this.image = image;
- this.gc = (GdkGraphics) gc.create ();
- startX = x;
- startY = y;
- redBG = bgcolor.getRed ();
- greenBG = bgcolor.getGreen ();
- blueBG = bgcolor.getBlue ();
- this.width = width;
- this.height = height;
- flipX = flipY = false;
- s_width = s_height = 0;
- clip = null;
- observer = o;
-
- run ();
- }
-
- public
- GtkImagePainter (GtkImage image, GdkGraphics gc,
- int dx1, int dy1, int dx2, int dy2,
- int sx1, int sy1, int sx2, int sy2,
- Color bgcolor, ImageObserver o)
- {
- this.image = image;
- this.gc = (GdkGraphics) gc.create ();
- startX = (dx1 < dx2) ? dx1 : dx2;
- startY = dy1;
- redBG = bgcolor.getRed ();
- greenBG = bgcolor.getGreen ();
- blueBG = bgcolor.getBlue ();
- observer = o;
-
- this.width = Math.abs (dx2 - dx1);
- this.height = Math.abs (dy2 - dy1);
-
- flipX = ((dx1 > dx2 && sx2 > sx1)
- || (dx1 < dx2 && sx2 < sx1));
-
- flipY = ((dy1 > dy2 && sy2 > sy1)
- || (dy1 < dy2 && sy2 < sy1));
-
- s_width = Math.abs (sx2 - sx1);
- s_height = Math.abs (sy2 - sy1);
- clip = new Rectangle (sx1, sy1, s_width, s_height);
-
- run ();
- }
-
- public void
- run ()
- {
- image.startProduction (this);
- gc.dispose ();
- }
-
- /* Convert pixel data into a format that gdkrgb can understand */
- static int[]
- convertPixels (int[] pixels, ColorModel model)
- {
- if (pixels == null || model == null)
- {
- return null;
- }
-
- if (model.equals (ColorModel.getRGBdefault ()))
- return pixels;
-
- int ret[] = new int[pixels.length];
-
- for (int i = 0; i < pixels.length; i++)
- ret[i] = model.getRGB (pixels[i]);
-
- return ret;
- }
-
- static int[]
- convertPixels (byte[] pixels, ColorModel model)
- {
- if (pixels == null || model == null)
- {
- return null;
- }
-
- int ret[] = new int[pixels.length];
-
- for (int i = 0; i < pixels.length; i++)
- ret[i] = model.getRGB (pixels[i]);
-
- return ret;
- }
-
- native void
- drawPixels (GdkGraphics gc, int bg_red, int bg_green, int bg_blue,
- int x, int y, int width, int height, int[] pixels, int offset,
- int scansize, double affine[]);
-
-
- public void
- setPixels (int x, int y, int width, int height, ColorModel model,
- int[] pixels, int offset, int scansize)
- {
- if (clip != null)
- {
- Rectangle r;
- r = clip.intersection (new Rectangle (x, y, width, height));
- if (r.width == 0 && r.height == 0)
- return;
-
- offset += r.y * scansize + r.x;
-
- width = r.width;
- height = r.height;
- x = r.x;
- y = r.y;
- }
-
- drawPixels (gc, redBG, greenBG, blueBG,
- startX + x, startY + y,
- width, height, convertPixels (pixels, model), offset,
- scansize, affine);
- }
-
- public void
- setPixels (int x, int y, int width, int height, ColorModel model,
- byte[] pixels, int offset, int scansize)
- {
- setPixels (x, y, width, height, ColorModel.getRGBdefault(),
- convertPixels (pixels, model), offset, scansize);
- }
-
- public void
- setDimensions (int width, int height)
- {
- if (!flipX && !flipY &&
- ((this.width == -1 && this.height == -1)
- || (this.width == width && this.height == height)))
- return;
-
- affine = new double[6];
- affine[1] = affine[2] = affine[4] = affine[5] = 0;
-
- if (clip != null)
- {
- affine[0] = this.width / (double) s_width;
- affine[3] = this.height / (double) s_height;
- }
- else
- {
- affine[0] = this.width / (double) width;
- affine[3] = this.height / (double) height;
- }
-
- if (flipX)
- {
- affine[0] = -affine[0];
- affine[4] = this.width;
- }
-
- if (flipY)
- {
- affine[3] = -affine[3];
- affine[5] = this.height;
- }
-
- if (affine[0] == 1 && affine[3] == 1)
- affine = null;
- }
-
- public void
- setProperties (Hashtable props)
- {
- }
-
- public void
- setColorModel (ColorModel model)
- {
- }
-
- public void
- setHints (int flags)
- {
- }
-
- public void
- imageComplete (int status)
- {
- image.imageComplete(status);
-
- if (observer != null)
- {
- if (status == ImageConsumer.IMAGEERROR)
- observer.imageUpdate (null,
- ImageObserver.ERROR,
- -1, -1, -1, -1);
- else
- observer.imageUpdate (null,
- ImageObserver.ALLBITS,
- -1, -1, -1, -1);
- }
- }
-}
diff --git a/gnu/java/awt/peer/gtk/GtkToolkit.java b/gnu/java/awt/peer/gtk/GtkToolkit.java
index 3bbbe27ac..5c0ab5438 100644
--- a/gnu/java/awt/peer/gtk/GtkToolkit.java
+++ b/gnu/java/awt/peer/gtk/GtkToolkit.java
@@ -53,6 +53,7 @@ import java.awt.font.FontRenderContext;
import java.awt.im.InputMethodHighlight;
import java.awt.image.BufferedImage;
import java.awt.image.ColorModel;
+import java.awt.image.DirectColorModel;
import java.awt.image.ImageConsumer;
import java.awt.image.ImageObserver;
import java.awt.image.ImageProducer;
@@ -140,9 +141,7 @@ public class GtkToolkit extends gnu.java.awt.ClasspathToolkit
| ImageObserver.HEIGHT;
if (image instanceof GtkImage)
- {
- status = ((GtkImage) image).checkImage ();
- }
+ return ((GtkImage) image).checkImage (observer);
if (observer != null)
observer.imageUpdate (image, status,
@@ -250,12 +249,7 @@ public class GtkToolkit extends gnu.java.awt.ClasspathToolkit
if (useGraphics2D())
return bufferedImageOrError(GdkPixbufDecoder.createBufferedImage (filename));
else
- {
- GdkPixbufDecoder d = new GdkPixbufDecoder (filename);
- GtkImage image = new GtkImage (d, null);
- d.startProduction (image);
- return image;
- }
+ return new GtkImage (filename);
}
public Image createImage (URL url)
@@ -265,8 +259,7 @@ public class GtkToolkit extends gnu.java.awt.ClasspathToolkit
else
{
GdkPixbufDecoder d = new GdkPixbufDecoder (url);
- GtkImage image = new GtkImage (d, null);
- d.startProduction (image);
+ GtkImage image = new GtkImage (d);
return image;
}
}
@@ -276,11 +269,7 @@ public class GtkToolkit extends gnu.java.awt.ClasspathToolkit
if (useGraphics2D())
return bufferedImageOrError(GdkPixbufDecoder.createBufferedImage (producer));
else
- {
- GtkImage image = new GtkImage (producer, null);
- producer.startProduction (image);
- return image;
- }
+ return new GtkImage (producer);
}
public Image createImage (byte[] imagedata, int imageoffset,
@@ -295,8 +284,7 @@ public class GtkToolkit extends gnu.java.awt.ClasspathToolkit
GdkPixbufDecoder d = new GdkPixbufDecoder (imagedata,
imageoffset,
imagelength);
- GtkImage image = new GtkImage (d, null);
- d.startProduction (image);
+ GtkImage image = new GtkImage (d);
return image;
}
}
@@ -312,9 +300,18 @@ public class GtkToolkit extends gnu.java.awt.ClasspathToolkit
return new GdkPixbufDecoder(url);
}
+ /**
+ * Returns the native color model (which isn't the same as the default
+ * ARGB color model, but doesn't have to be).
+ */
public ColorModel getColorModel ()
{
- return ColorModel.getRGBdefault ();
+ /* Return the GDK-native ABGR format */
+ return new DirectColorModel(32,
+ 0x000000FF,
+ 0x0000FF00,
+ 0x00FF0000,
+ 0xFF000000);
}
public String[] getFontList ()
@@ -410,34 +407,13 @@ public class GtkToolkit extends gnu.java.awt.ClasspathToolkit
public boolean prepareImage (Image image, int width, int height,
ImageObserver observer)
{
+ /* GtkImages are always prepared, as long as they're loaded. */
if (image instanceof GtkImage)
- {
- GtkImage i = (GtkImage) image;
-
- if (i.isLoaded ()) return true;
-
- class PrepareImage extends Thread
- {
- GtkImage image;
- ImageObserver observer;
-
- PrepareImage (GtkImage image, ImageObserver observer)
- {
- this.image = image;
- image.setObserver (observer);
- }
-
- public void run ()
- {
- image.source.startProduction (image);
- }
- }
-
- new PrepareImage (i, observer).start ();
- return false;
- }
- else
- return true;
+ return ((((GtkImage)image).checkImage (observer) &
+ ImageObserver.ALLBITS) != 0);
+
+ /* Assume anything else is too */
+ return true;
}
public native void sync();
diff --git a/gnu/java/nio/channels/FileChannelImpl.java b/gnu/java/nio/channels/FileChannelImpl.java
index 715e80a2f..664e93c87 100644
--- a/gnu/java/nio/channels/FileChannelImpl.java
+++ b/gnu/java/nio/channels/FileChannelImpl.java
@@ -97,12 +97,17 @@ public final class FileChannelImpl extends FileChannel
private int mode;
- public FileChannelImpl ()
+ /* Open a file. MODE is a combination of the above mode flags. */
+ /* This is a static factory method, so that VM implementors can decide
+ * substitute subclasses of FileChannelImpl. */
+ public static FileChannelImpl create(File file, int mode)
+ throws FileNotFoundException
{
+ return new FileChannelImpl(file, mode);
}
- /* Open a file. MODE is a combination of the above mode flags. */
- public FileChannelImpl (File file, int mode) throws FileNotFoundException
+ private FileChannelImpl(File file, int mode)
+ throws FileNotFoundException
{
final String path = file.getPath();
fd = open (path, mode);
diff --git a/include/Makefile.am b/include/Makefile.am
index 67f66e4c8..512b038c3 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -46,7 +46,7 @@ $(top_srcdir)/include/gnu_java_awt_peer_gtk_GtkEmbeddedWindowPeer.h \
$(top_srcdir)/include/gnu_java_awt_peer_gtk_GtkFileDialogPeer.h \
$(top_srcdir)/include/gnu_java_awt_peer_gtk_GtkFramePeer.h \
$(top_srcdir)/include/gnu_java_awt_peer_gtk_GtkGenericPeer.h \
-$(top_srcdir)/include/gnu_java_awt_peer_gtk_GtkImagePainter.h \
+$(top_srcdir)/include/gnu_java_awt_peer_gtk_GtkImage.h \
$(top_srcdir)/include/gnu_java_awt_peer_gtk_GtkLabelPeer.h \
$(top_srcdir)/include/gnu_java_awt_peer_gtk_GtkListPeer.h \
$(top_srcdir)/include/gnu_java_awt_peer_gtk_GtkMenuBarPeer.h \
diff --git a/include/gnu_java_awt_peer_gtk_GdkGraphics.h b/include/gnu_java_awt_peer_gtk_GdkGraphics.h
index 7d786297b..aa2a29873 100644
--- a/include/gnu_java_awt_peer_gtk_GdkGraphics.h
+++ b/include/gnu_java_awt_peer_gtk_GdkGraphics.h
@@ -12,13 +12,12 @@ extern "C"
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics_initState__Lgnu_java_awt_peer_gtk_GtkComponentPeer_2 (JNIEnv *env, jobject, jobject);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics_initState__II (JNIEnv *env, jobject, jint, jint);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics_initFromImage (JNIEnv *env, jobject, jobject);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics_copyState (JNIEnv *env, jobject, jobject);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics_connectSignals (JNIEnv *env, jobject, jobject);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics_clearRect (JNIEnv *env, jobject, jint, jint, jint, jint);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics_copyArea (JNIEnv *env, jobject, jint, jint, jint, jint, jint, jint);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics_dispose (JNIEnv *env, jobject);
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics_copyPixmap (JNIEnv *env, jobject, jobject, jint, jint, jint, jint);
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics_copyAndScalePixmap (JNIEnv *env, jobject, jobject, jboolean, jboolean, jint, jint, jint, jint, jint, jint, jint, jint);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics_drawLine (JNIEnv *env, jobject, jint, jint, jint, jint);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics_drawArc (JNIEnv *env, jobject, jint, jint, jint, jint, jint, jint);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics_fillArc (JNIEnv *env, jobject, jint, jint, jint, jint, jint, jint);
diff --git a/include/gnu_java_awt_peer_gtk_GtkFramePeer.h b/include/gnu_java_awt_peer_gtk_GtkFramePeer.h
index 27f8e83f3..f3831312a 100644
--- a/include/gnu_java_awt_peer_gtk_GtkFramePeer.h
+++ b/include/gnu_java_awt_peer_gtk_GtkFramePeer.h
@@ -15,8 +15,7 @@ JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkFramePeer_setMenuBarWidth (
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkFramePeer_setMenuBarPeer (JNIEnv *env, jobject, jobject);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkFramePeer_removeMenuBarPeer (JNIEnv *env, jobject);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkFramePeer_gtkFixedSetVisible (JNIEnv *env, jobject, jboolean);
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkFramePeer_nativeSetIconImageFromDecoder (JNIEnv *env, jobject, jobject);
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkFramePeer_nativeSetIconImageFromData (JNIEnv *env, jobject, jintArray, jint, jint);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkFramePeer_nativeSetIconImage (JNIEnv *env, jobject, jobject);
#ifdef __cplusplus
}
diff --git a/include/gnu_java_awt_peer_gtk_GtkImage.h b/include/gnu_java_awt_peer_gtk_GtkImage.h
new file mode 100644
index 000000000..5304ecda8
--- /dev/null
+++ b/include/gnu_java_awt_peer_gtk_GtkImage.h
@@ -0,0 +1,42 @@
+#ifndef __gnu_java_awt_peer_gtk_GtkImage__
+#define __gnu_java_awt_peer_gtk_GtkImage__
+#include <jni.h>
+
+#ifdef __cplusplus
+
+extern "C" {
+#endif
+
+JNIEXPORT jintArray JNICALL Java_gnu_java_awt_peer_gtk_GtkImage_getPixels
+ (JNIEnv *, jobject);
+
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkImage_setPixels
+ (JNIEnv *, jobject, jintArray);
+
+JNIEXPORT jboolean JNICALL Java_gnu_java_awt_peer_gtk_GtkImage_loadPixbuf
+ (JNIEnv *, jobject, jstring);
+
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkImage_createPixmap
+ (JNIEnv *, jobject);
+
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkImage_freePixmap
+ (JNIEnv *, jobject);
+
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkImage_createScaledPixmap
+ (JNIEnv *, jobject, jobject, jint);
+
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkImage_drawPixelsScaled
+ (JNIEnv *, jobject, jobject, jint, jint, jint, jint, jint, jint, jint, jboolean);
+
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkImage_drawPixelsScaledFlipped
+ (JNIEnv *, jobject, jobject, jint, jint, jint,
+ jboolean, jboolean,
+ jint, jint, jint, jint,
+ jint, jint, jint, jint,
+ jboolean);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
+
diff --git a/include/gnu_java_awt_peer_gtk_GtkImagePainter.h b/include/gnu_java_awt_peer_gtk_GtkImagePainter.h
deleted file mode 100644
index 18f430b1a..000000000
--- a/include/gnu_java_awt_peer_gtk_GtkImagePainter.h
+++ /dev/null
@@ -1,19 +0,0 @@
-/* DO NOT EDIT THIS FILE - it is machine generated */
-
-#ifndef __gnu_java_awt_peer_gtk_GtkImagePainter__
-#define __gnu_java_awt_peer_gtk_GtkImagePainter__
-
-#include <jni.h>
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkImagePainter_drawPixels (JNIEnv *env, jobject, jobject, jint, jint, jint, jint, jint, jint, jint, jintArray, jint, jint, jdoubleArray);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __gnu_java_awt_peer_gtk_GtkImagePainter__ */
diff --git a/java/awt/Component.java b/java/awt/Component.java
index 32693c3ca..77f53356d 100644
--- a/java/awt/Component.java
+++ b/java/awt/Component.java
@@ -1005,6 +1005,10 @@ 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 is null, inherit from closest ancestor whose bg is set.
if (c == null && parent != null)
c = parent.getBackground();
diff --git a/java/awt/GradientPaint.java b/java/awt/GradientPaint.java
index f008b93f8..8660dbb8d 100644
--- a/java/awt/GradientPaint.java
+++ b/java/awt/GradientPaint.java
@@ -1,5 +1,5 @@
/* GradientPaint.java --
- Copyright (C) 2002 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2005, Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -42,9 +42,11 @@ import java.awt.geom.AffineTransform;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import java.awt.image.ColorModel;
+import gnu.java.awt.GradientPaintContext;
/**
- * STUB CLASS ONLY
+ * A paint object that can be used to color a region by blending two colors.
+ * Instances of this class are immutable.
*/
public class GradientPaint implements Paint
{
@@ -56,18 +58,48 @@ public class GradientPaint implements Paint
private final Color c2;
private final boolean cyclic;
+ /**
+ * Creates a new acyclic <code>GradientPaint</code>.
+ *
+ * @param x1 the x-coordinate of the anchor point for color 1.
+ * @param y1 the y-coordinate of the anchor point for color 1.
+ * @param c1 color 1 (<code>null</code> not permitted).
+ * @param x2 the x-coordinate of the anchor point for color 2.
+ * @param y2 the y-coordinate of the anchor point for color 2.
+ * @param c2 the second color (<code>null</code> not permitted).
+ */
public GradientPaint(float x1, float y1, Color c1,
float x2, float y2, Color c2)
{
this(x1, y1, c1, x2, y2, c2, false);
}
+ /**
+ * Creates a new acyclic <code>GradientPaint</code>.
+ *
+ * @param p1 anchor point 1 (<code>null</code> not permitted).
+ * @param c1 color 1 (<code>null</code> not permitted).
+ * @param p2 anchor point 2 (<code>null</code> not permitted).
+ * @param c2 color 2 (<code>null</code> not permitted).
+ */
public GradientPaint(Point2D p1, Color c1, Point2D p2, Color c2)
{
this((float) p1.getX(), (float) p1.getY(), c1,
(float) p2.getX(), (float) p2.getY(), c2, false);
}
+ /**
+ * Creates a new cyclic or acyclic <code>GradientPaint</code>.
+ *
+ * @param x1 the x-coordinate of the anchor point for color 1.
+ * @param y1 the y-coordinate of the anchor point for color 1.
+ * @param c1 color 1 (<code>null</code> not permitted).
+ * @param x2 the x-coordinate of the anchor point for color 2.
+ * @param y2 the y-coordinate of the anchor point for color 2.
+ * @param c2 the second color (<code>null</code> not permitted).
+ * @param cyclic a flag that controls whether the gradient is cyclic or
+ * acyclic.
+ */
public GradientPaint(float x1, float y1, Color c1,
float x2, float y2, Color c2, boolean cyclic)
{
@@ -82,6 +114,16 @@ public class GradientPaint implements Paint
this.cyclic = cyclic;
}
+ /**
+ * Creates a new cyclic or acyclic <code>GradientPaint</code>.
+ *
+ * @param p1 anchor point 1 (<code>null</code> not permitted).
+ * @param c1 color 1 (<code>null</code> not permitted).
+ * @param p2 anchor point 2 (<code>null</code> not permitted).
+ * @param c2 color 2 (<code>null</code> not permitted).
+ * @param cyclic a flag that controls whether the gradient is cyclic or
+ * acyclic.
+ */
public GradientPaint(Point2D p1, Color c1, Point2D p2, Color c2,
boolean cyclic)
{
@@ -89,41 +131,99 @@ public class GradientPaint implements Paint
(float) p2.getX(), (float) p2.getY(), c2, cyclic);
}
+ /**
+ * Returns a point with the same coordinates as the anchor point for color 1.
+ * Note that if you modify this point, the <code>GradientPaint</code> remains
+ * unchanged.
+ *
+ * @return A point with the same coordinates as the anchor point for color 1.
+ */
public Point2D getPoint1()
{
return new Point2D.Float(x1, y1);
}
+ /**
+ * Returns the first color.
+ *
+ * @return The color (never <code>null</code>).
+ */
public Color getColor1()
{
return c1;
}
+ /**
+ * Returns a point with the same coordinates as the anchor point for color 2.
+ * Note that if you modify this point, the <code>GradientPaint</code> remains
+ * unchanged.
+ *
+ * @return A point with the same coordinates as the anchor point for color 2.
+ */
public Point2D getPoint2()
{
return new Point2D.Float(x2, y2);
}
+ /**
+ * Returns the second color.
+ *
+ * @return The color (never <code>null</code>).
+ */
public Color getColor2()
{
return c2;
}
+ /**
+ * Returns <code>true</code> if this <code>GradientPaint</code> instance is
+ * cyclic, and <code>false</code> otherwise.
+ *
+ * @return A boolean.
+ */
public boolean isCyclic()
{
return cyclic;
}
+ /**
+ * Returns the {@link PaintContext} used to generate the color pattern.
+ *
+ * @param cm the color model, used as a hint (ignored in this
+ * implementation).
+ * @param deviceBounds the device space bounding box of the painted area.
+ * @param userBounds the user space bounding box of the painted area.
+ * @param xform the transformation from user space to device space.
+ * @param hints any hints for choosing between rendering alternatives.
+ *
+ * @return The context for performing the paint
+ */
public PaintContext createContext(ColorModel cm, Rectangle deviceBounds,
Rectangle2D userBounds,
AffineTransform xform,
RenderingHints hints)
{
- throw new Error("not implemented");
+ Point2D xp1 = xform.transform(getPoint1(), null);
+ Point2D xp2 = xform.transform(getPoint2(), null);
+ return new GradientPaintContext((float) xp1.getX(), (float) xp1.getY(), c1,
+ (float) xp2.getX(), (float) xp2.getY(), c2, cyclic);
}
+ /**
+ * Returns the transparency code for this <code>GradientPaint</code> instance.
+ * This is derived from the two {@link Color} objects used in creating this
+ * object: if both colors are opaque, this method returns
+ * {@link Transparency#OPAQUE}, otherwise it returns
+ * {@link Transparency#TRANSLUCENT}.
+ *
+ * @return {@link Transparency#OPAQUE} or {@link Transparency#TRANSLUCENT}.
+ */
public int getTransparency()
{
- throw new Error("not implemented");
+ if (c1.getAlpha() == 255 && c2.getAlpha() == 255)
+ return Transparency.OPAQUE;
+ else
+ return Transparency.TRANSLUCENT;
}
+
} // class GradientPaint
diff --git a/java/awt/image/BufferedImage.java b/java/awt/image/BufferedImage.java
index 723eeeb77..b3ba12c8e 100644
--- a/java/awt/image/BufferedImage.java
+++ b/java/awt/image/BufferedImage.java
@@ -448,11 +448,12 @@ public class BufferedImage extends Image
{
return new ImageProducer() {
- HashSet consumers = new HashSet();
+ Vector consumers = new Vector();
public void addConsumer(ImageConsumer ic)
{
- consumers.add(ic);
+ if(!consumers.contains(ic))
+ consumers.add(ic);
}
public boolean isConsumer(ImageConsumer ic)
@@ -462,7 +463,7 @@ public class BufferedImage extends Image
public void removeConsumer(ImageConsumer ic)
{
- consumers.remove(ic);
+ consumers.remove(ic);
}
public void startProduction(ImageConsumer ic)
@@ -480,10 +481,9 @@ public class BufferedImage extends Image
consumers.add(ic);
- Iterator i = consumers.iterator();
- while(i.hasNext())
+ for(int i=0;i<consumers.size();i++)
{
- ImageConsumer c = (ImageConsumer) i.next();
+ ImageConsumer c = (ImageConsumer) consumers.elementAt(i);
c.setHints(ImageConsumer.SINGLEPASS);
c.setDimensions(getWidth(), getHeight());
c.setPixels(x, y, width, height, model, pixels, offset, stride);
diff --git a/java/awt/image/DirectColorModel.java b/java/awt/image/DirectColorModel.java
index b1aa6c0d3..da39fc931 100644
--- a/java/awt/image/DirectColorModel.java
+++ b/java/awt/image/DirectColorModel.java
@@ -160,7 +160,7 @@ public class DirectColorModel extends PackedColorModel
public final int getAlpha(int pixel)
{
if (!hasAlpha())
- return 0;
+ return 255;
return extractAndScaleSample(pixel, 3);
}
diff --git a/java/awt/image/IndexColorModel.java b/java/awt/image/IndexColorModel.java
index 2a8a7887e..3dafe5b53 100644
--- a/java/awt/image/IndexColorModel.java
+++ b/java/awt/image/IndexColorModel.java
@@ -1,5 +1,5 @@
/* IndexColorModel.java -- Java class for interpreting Pixel objects
- Copyright (C) 1999 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -35,99 +35,156 @@ 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 java.awt.image;
+import gnu.java.awt.Buffers;
+
import java.awt.color.ColorSpace;
import java.math.BigInteger;
/**
* Color model similar to pseudo visual in X11.
- *
+ * <br><br>
* This color model maps linear pixel values to actual RGB and alpha colors.
* Thus, pixel values are indexes into the color map. Each color component is
* an 8-bit unsigned value.
- *
- * The IndexColorModel supports a map of valid pixels, allowing the
- * representation of holes in the the color map. The valid map is represented
- * as a BigInteger where each bit indicates the validity of the map entry with
- * the same index.
- *
+ * <br><br>
+ * The <code>IndexColorModel</code> supports a map of valid pixels, allowing
+ * the representation of holes in the the color map. The valid map is
+ * represented as a {@link BigInteger} where each bit indicates the validity
+ * of the map entry with the same index.
+ * <br><br>
* Colors can have alpha components for transparency support. If alpha
* component values aren't given, color values are opaque. The model also
* supports a reserved pixel value to represent completely transparent colors,
* no matter what the actual color component values are.
- *
- * IndexColorModel supports anywhere from 1 to 16 bit index values. The
- * allowed transfer types are DataBuffer.TYPE_BYTE and DataBuffer.TYPE_USHORT.
+ * <br><br>
+ * <code>IndexColorModel</code> supports anywhere from 1 to 16 bit index
+ * values. The allowed transfer types are {@link DataBuffer#TYPE_BYTE} and
+ * {@link DataBuffer#TYPE_USHORT}.
*
* @author C. Brian Jones (cbj@gnu.org)
*/
public class IndexColorModel extends ColorModel
{
private int map_size;
- private boolean opaque;
+ private boolean opaque; // no alpha, but doesn't account for trans
private int trans = -1;
private int[] rgb;
private BigInteger validBits = BigInteger.ZERO;
/**
- * Each array much contain <code>size</code> elements. For each
- * array, the i-th color is described by reds[i], greens[i],
- * blues[i], alphas[i], unless alphas is not specified, then all the
- * colors are opaque except for the transparent color.
+ * Creates a new indexed color model for <code>size</code> color elements
+ * with no alpha component. Each array must contain at least
+ * <code>size</code> elements. For each array, the i-th color is described
+ * by reds[i], greens[i] and blues[i].
*
- * @param bits the number of bits needed to represent <code>size</code> colors
- * @param size the number of colors in the color map
- * @param reds the red component of all colors
- * @param greens the green component of all colors
- * @param blues the blue component of all colors
+ * @param bits the number of bits needed to represent <code>size</code>
+ * colors.
+ * @param size the number of colors in the color map.
+ * @param reds the red component of all colors.
+ * @param greens the green component of all colors.
+ * @param blues the blue component of all colors.
+ *
+ * @throws IllegalArgumentException if <code>bits</code> &lt; 1 or
+ * <code>bits</code> &gt; 16.
+ * @throws NullPointerException if any of the arrays is <code>null</code>.
+ * @throws ArrayIndexOutOfBoundsException if <code>size</code> is greater
+ * than the length of the component arrays.
*/
public IndexColorModel(int bits, int size, byte[] reds, byte[] greens,
byte[] blues)
{
- this (bits, size, reds, greens, blues, (byte[]) null);
+ this(bits, size, reds, greens, blues, (byte[]) null);
}
/**
- * Each array much contain <code>size</code> elements. For each
- * array, the i-th color is described by reds[i], greens[i],
- * blues[i], alphas[i], unless alphas is not specified, then all the
- * colors are opaque except for the transparent color.
+ * Creates a new indexed color model for <code>size</code> color elements.
+ * Each array must contain at least <code>size</code> elements. For each
+ * array, the i-th color is described by reds[i], greens[i] and blues[i].
+ * All the colors are opaque except for the transparent color.
*
- * @param bits the number of bits needed to represent <code>size</code> colors
+ * @param bits the number of bits needed to represent <code>size</code>
+ * colors
* @param size the number of colors in the color map
* @param reds the red component of all colors
* @param greens the green component of all colors
* @param blues the blue component of all colors
- * @param trans the index of the transparent color
+ * @param trans the index of the transparent color (use -1 for no
+ * transparent color).
+ *
+ * @throws IllegalArgumentException if <code>bits</code> &lt; 1 or
+ * <code>bits</code> &gt; 16.
+ * @throws NullPointerException if any of the arrays is <code>null</code>.
+ * @throws ArrayIndexOutOfBoundsException if <code>size</code> is greater
+ * than the length of the component arrays.
*/
public IndexColorModel(int bits, int size, byte[] reds, byte[] greens,
byte[] blues, int trans)
{
- this (bits, size, reds, greens, blues, (byte[]) null);
- this.trans = trans;
+ super(bits, nArray(8, (0 <= trans && trans < size) ? 4 : 3),
+ ColorSpace.getInstance(ColorSpace.CS_sRGB),
+ (0 <= trans && trans < size), // hasAlpha
+ false, OPAQUE,
+ Buffers.smallestAppropriateTransferType(bits));
+ if (bits < 1)
+ throw new IllegalArgumentException("bits < 1");
+ if (bits > 16)
+ throw new IllegalArgumentException("bits > 16");
+ if (size < 1)
+ throw new IllegalArgumentException("size < 1");
+ map_size = size;
+ if (0 <= trans && trans < size) {
+ this.trans = trans;
+ transparency = BITMASK;
+ }
+ rgb = new int[size];
+ for (int i = 0; i < size; i++)
+ {
+ rgb[i] = (0xff000000
+ | ((reds[i] & 0xff) << 16)
+ | ((greens[i] & 0xff) << 8)
+ | (blues[i] & 0xff));
+ }
+ // Generate a bigint with 1's for every pixel
+ validBits = validBits.setBit(size).subtract(BigInteger.ONE);
}
/**
- * Each array much contain <code>size</code> elements. For each
- * array, the i-th color is described by reds[i], greens[i],
- * blues[i], alphas[i], unless alphas is not specified, then all the
- * colors are opaque except for the transparent color.
+ * Creates a new indexed color model for <code>size</code> color elements
+ * including alpha. Each array must contain at least <code>size</code>
+ * elements. For each array, the i-th color is described
+ * by reds[i], greens[i], blues[i] and alphas[i].
*
- * @param bits the number of bits needed to represent <code>size</code> colors
- * @param size the number of colors in the color map
- * @param reds the red component of all colors
- * @param greens the green component of all colors
- * @param blues the blue component of all colors
- * @param alphas the alpha component of all colors
+ * @param bits the number of bits needed to represent <code>size</code>
+ * colors.
+ * @param size the number of colors in the color map.
+ * @param reds the red component of all colors.
+ * @param greens the green component of all colors.
+ * @param blues the blue component of all colors.
+ * @param alphas the alpha component of all colors (<code>null</code>
+ * permitted).
+ *
+ * @throws IllegalArgumentException if <code>bits</code> &lt; 1 or
+ * <code>bits</code> &gt; 16.
+ * @throws NullPointerException if <code>reds</code>, <code>greens</code> or
+ * <code>blues</code> is <code>null</code>.
+ * @throws ArrayIndexOutOfBoundsException if <code>size</code> is greater
+ * than the length of the component arrays.
*/
public IndexColorModel(int bits, int size, byte[] reds, byte[] greens,
byte[] blues, byte[] alphas)
{
- // FIXME: This super() constructor should not be used since it can give
- // the wrong value for hasAlpha() which is final and cannot be overloaded
- super(bits);
+ super(bits, nArray(8, (alphas == null ? 3 : 4)),
+ ColorSpace.getInstance(ColorSpace.CS_sRGB),
+ (alphas != null), false, TRANSLUCENT,
+ Buffers.smallestAppropriateTransferType(bits));
+ if (bits < 1)
+ throw new IllegalArgumentException("bits < 1");
+ if (bits > 16)
+ throw new IllegalArgumentException("bits > 16");
+ if (size < 1)
+ throw new IllegalArgumentException("size < 1");
map_size = size;
opaque = (alphas == null);
@@ -141,16 +198,25 @@ public class IndexColorModel extends ColorModel
| ((greens[i] & 0xff) << 8)
| (blues[i] & 0xff));
}
+ transparency = OPAQUE;
}
else
{
+ byte alphaZero = (byte) 0x00;
+ byte alphaOne = (byte) 0xFF;
for (int i = 0; i < size; i++)
{
+ alphaZero = (byte) (alphaZero | alphas[i]);
+ alphaOne = (byte) (alphaOne & alphas[i]);
rgb[i] = ((alphas[i] & 0xff) << 24
| ((reds[i] & 0xff) << 16)
| ((greens[i] & 0xff) << 8)
| (blues[i] & 0xff));
}
+ if ((alphaZero == (byte) 0x00) || (alphaOne == (byte) 0xFF))
+ transparency = BITMASK;
+ else
+ transparency = TRANSLUCENT;
}
// Generate a bigint with 1's for every pixel
@@ -158,61 +224,85 @@ public class IndexColorModel extends ColorModel
}
/**
- * Each array much contain <code>size</code> elements. For each
- * array, the i-th color is described by reds[i], greens[i],
- * blues[i], alphas[i], unless alphas is not specified, then all the
- * colors are opaque except for the transparent color.
+ * Creates a new indexed color model using the color components in
+ * <code>cmap</code>. If <code>hasAlpha</code> is <code>true</code> then
+ * <code>cmap</code> contains an alpha component after each of the red, green
+ * and blue components.
*
- * @param bits the number of bits needed to represent <code>size</code> colors
+ * @param bits the number of bits needed to represent <code>size</code>
+ * colors
* @param size the number of colors in the color map
* @param cmap packed color components
* @param start the offset of the first color component in <code>cmap</code>
* @param hasAlpha <code>cmap</code> has alpha values
- * @throws IllegalArgumentException if bits < 1, bits > 16, or size < 1.
+ * @throws IllegalArgumentException if bits &lt; 1, bits &gt; 16, or size
+ * &lt; 1.
+ * @throws NullPointerException if <code>cmap</code> is <code>null</code>.
*/
- public IndexColorModel (int bits, int size, byte[] cmap, int start,
- boolean hasAlpha)
+ public IndexColorModel(int bits, int size, byte[] cmap, int start,
+ boolean hasAlpha)
{
- this (bits, size, cmap, start, hasAlpha, -1);
+ this(bits, size, cmap, start, hasAlpha, -1);
}
/**
* Construct an IndexColorModel from an array of red, green, blue, and
- * optional alpha components. The component values are interleaved as RGB(A).
+ * optional alpha components. The component values are interleaved as RGB(A).
*
- * @param bits the number of bits needed to represent <code>size</code> colors
+ * @param bits the number of bits needed to represent <code>size</code>
+ * colors
* @param size the number of colors in the color map
* @param cmap interleaved color components
* @param start the offset of the first color component in <code>cmap</code>
* @param hasAlpha <code>cmap</code> has alpha values
* @param trans the index of the transparent color
- * @throws IllegalArgumentException if bits < 1, bits > 16, or size < 1.
+ * @throws IllegalArgumentException if bits &lt; 1, bits &gt; 16, or size
+ * &lt; 1.
+ * @throws NullPointerException if <code>cmap</code> is <code>null</code>.
*/
- public IndexColorModel (int bits, int size, byte[] cmap, int start,
- boolean hasAlpha, int trans)
+ public IndexColorModel(int bits, int size, byte[] cmap, int start,
+ boolean hasAlpha, int trans)
{
- super (bits);
+ super(bits, nArray(8, hasAlpha || (0 <= trans && trans < size) ? 4 : 3),
+ ColorSpace.getInstance(ColorSpace.CS_sRGB),
+ hasAlpha || (0 <= trans && trans < size), false, OPAQUE,
+ Buffers.smallestAppropriateTransferType(bits));
+ if (bits < 1)
+ throw new IllegalArgumentException("bits < 1");
if (bits > 16)
throw new IllegalArgumentException("bits > 16");
if (size < 1)
throw new IllegalArgumentException("size < 1");
map_size = size;
opaque = !hasAlpha;
- this.trans = trans;
+ if (0 <= trans && trans < size)
+ this.trans = trans;
rgb = new int[size];
if (hasAlpha)
{
- for (int i = 0; i < size; i++)
+ int alpha;
+ int alphaZero = 0x00; // use to detect all zeros
+ int alphaOne = 0xff; // use to detect all ones
+ for (int i = 0; i < size; i++) {
+ alpha = cmap[4 * i + 3 + start] & 0xff;
+ alphaZero = alphaZero | alpha;
+ alphaOne = alphaOne & alpha;
rgb[i] =
- // alpha
- ((cmap[4 * i + 3 + start] & 0xff) << 24
+ ( alpha << 24
// red
| ((cmap[4 * i + start] & 0xff) << 16)
// green
| ((cmap[4 * i + 1 + start] & 0xff) << 8)
// blue
| (cmap[4 * i + 2 + start] & 0xff));
+ }
+ if (alphaZero == 0)
+ transparency = BITMASK;
+ else if (alphaOne == 255)
+ transparency = (trans != -1 ? BITMASK : OPAQUE);
+ else
+ transparency = TRANSLUCENT;
}
else
{
@@ -224,6 +314,8 @@ public class IndexColorModel extends ColorModel
| ((cmap[3 * i + 1 + start] & 0xff) << 8)
// blue
| (cmap[3 * i + 2 + start] & 0xff));
+ if (trans != -1)
+ transparency = BITMASK;
}
// Generate a bigint with 1's for every pixel
@@ -236,22 +328,26 @@ public class IndexColorModel extends ColorModel
* alpha values packed in order. If hasAlpha is false, then all the colors
* are opaque except for the transparent color.
*
- * @param bits the number of bits needed to represent <code>size</code> colors
+ * @param bits the number of bits needed to represent <code>size</code>
+ * colors
* @param size the number of colors in the color map
* @param cmap packed color components
* @param start the offset of the first color component in <code>cmap</code>
* @param hasAlpha <code>cmap</code> has alpha values
* @param trans the index of the transparent color
- * @param transferType DataBuffer.TYPE_BYTE or DataBuffer.TYPE_USHORT
- * @throws IllegalArgumentException if bits < 1, bits > 16, or size < 1.
- * @throws IllegalArgumentException if transferType is something other than
- * TYPE_BYTE or TYPE_USHORT.
+ * @param transferType {@link DataBuffer#TYPE_BYTE} or
+ {@link DataBuffer#TYPE_USHORT}.
+ * @throws IllegalArgumentException if bits &lt; 1, bits &gt; 16, or size
+ * &lt; 1.
+ * @throws IllegalArgumentException if <code>transferType</code> is something
+ * other than {@link DataBuffer#TYPE_BYTE} or
+ * {@link DataBuffer#TYPE_USHORT}.
*/
- public IndexColorModel (int bits, int size, int[] cmap, int start,
- boolean hasAlpha, int trans, int transferType)
+ public IndexColorModel(int bits, int size, int[] cmap, int start,
+ boolean hasAlpha, int trans, int transferType)
{
- super(bits * 4, // total bits, sRGB, four channels
- nArray(bits, 4), // bits for each channel
+ super(bits,
+ nArray(8, 4), // bits for each channel
ColorSpace.getInstance(ColorSpace.CS_sRGB), // sRGB
true, // has alpha
false, // not premultiplied
@@ -265,7 +361,8 @@ public class IndexColorModel extends ColorModel
throw new IllegalArgumentException("size < 1");
map_size = size;
opaque = !hasAlpha;
- this.trans = trans;
+ if (0 <= trans && trans < size)
+ this.trans = trans;
rgb = new int[size];
if (!hasAlpha)
@@ -280,30 +377,34 @@ public class IndexColorModel extends ColorModel
/**
* Construct an IndexColorModel using a colormap with holes.
- *
+ * <br><br>
* The IndexColorModel is built from the array of ints defining the
* colormap. Each element contains red, green, blue, and alpha
* components. The ColorSpace is sRGB. The transparency value is
* automatically determined.
- *
+ * <br><br>
* This constructor permits indicating which colormap entries are valid,
* using the validBits argument. Each entry in cmap is valid if the
* corresponding bit in validBits is set.
*
- * @param bits the number of bits needed to represent <code>size</code> colors
- * @param size the number of colors in the color map
- * @param cmap packed color components
- * @param start the offset of the first color component in <code>cmap</code>
- * @param transferType DataBuffer.TYPE_BYTE or DataBuffer.TYPE_USHORT
- * @throws IllegalArgumentException if bits < 1, bits > 16, or size < 1.
+ * @param bits the number of bits needed to represent <code>size</code>
+ * colors.
+ * @param size the number of colors in the color map.
+ * @param cmap packed color components.
+ * @param start the offset of the first color component in <code>cmap</code>.
+ * @param transferType {@link DataBuffer#TYPE_BYTE} or
+ * {@link DataBuffer#TYPE_USHORT}.
+ * @param validBits a map of the valid entries in <code>cmap</code>.
+ * @throws IllegalArgumentException if bits &lt; 1, bits &gt; 16, or size
+ * &lt; 1.
* @throws IllegalArgumentException if transferType is something other than
- * TYPE_BYTE or TYPE_USHORT.
+ * {@link DataBuffer#TYPE_BYTE} or {@link DataBuffer#TYPE_USHORT}.
*/
- public IndexColorModel (int bits, int size, int[] cmap, int start,
- int transferType, BigInteger validBits)
+ public IndexColorModel(int bits, int size, int[] cmap, int start,
+ int transferType, BigInteger validBits)
{
- super(bits * 4, // total bits, sRGB, four channels
- nArray(bits, 4), // bits for each channel
+ super(bits, // total bits, sRGB, four channels
+ nArray(8, 4), // bits for each channel
ColorSpace.getInstance(ColorSpace.CS_sRGB), // sRGB
true, // has alpha
false, // not premultiplied
@@ -328,112 +429,181 @@ public class IndexColorModel extends ColorModel
System.arraycopy(cmap, start, rgb, 0, size);
}
- public final int getMapSize ()
+ /**
+ * Returns the size of the color lookup table.
+ *
+ * @return The size of the color lookup table.
+ */
+ public final int getMapSize()
{
return map_size;
}
/**
- * Get the index of the transparent color in this color model
+ * Get the index of the transparent color in this color model.
+ *
+ * @return The index of the color that is considered transparent, or -1 if
+ * there is no transparent color.
*/
- public final int getTransparentPixel ()
+ public final int getTransparentPixel()
{
return trans;
}
/**
- * <br>
+ * Fills the supplied array with the red component of each color in the
+ * lookup table.
+ *
+ * @param r an array that is at least as large as {@link #getMapSize()}.
+ * @throws NullPointerException if <code>r</code> is <code>null</code>.
+ * @throws ArrayIndexOutOfBoundsException if <code>r</code> has less
+ * than {@link #getMapSize()} elements.
*/
- public final void getReds (byte[] r)
+ public final void getReds(byte[] r)
{
- getComponents (r, 2);
+ int i;
+ for (i = 0; i < map_size; i++)
+ r[i] = (byte) ((0x00FF0000 & rgb[i]) >> 16);
}
/**
- * <br>
+ * Fills the supplied array with the green component of each color in the
+ * lookup table.
+ *
+ * @param g an array that is at least as large as {@link #getMapSize()}.
+ * @throws NullPointerException if <code>g</code> is <code>null</code>.
+ * @throws ArrayIndexOutOfBoundsException if <code>g</code> has less
+ * than {@link #getMapSize()} elements.
*/
- public final void getGreens (byte[] g)
+ public final void getGreens(byte[] g)
{
- getComponents (g, 1);
+ int i;
+ for (i = 0; i < map_size; i++)
+ g[i] = (byte) ((0x0000FF00 & rgb[i]) >> 8);
}
/**
- * <br>
+ * Fills the supplied array with the blue component of each color in the
+ * lookup table.
+ *
+ * @param b an array that is at least as large as {@link #getMapSize()}.
+ * @throws NullPointerException if <code>b</code> is <code>null</code>.
+ * @throws ArrayIndexOutOfBoundsException if <code>b</code> has less
+ * than {@link #getMapSize()} elements.
*/
- public final void getBlues (byte[] b)
+ public final void getBlues(byte[] b)
{
- getComponents (b, 0);
+ int i;
+ for (i = 0; i < map_size; i++)
+ b[i] = (byte) (0x000000FF & rgb[i]);
}
/**
- * <br>
+ * Fills the supplied array with the alpha component of each color in the
+ * lookup table. If the model has a transparent pixel specified, the alpha
+ * for that pixel will be 0.
+ *
+ * @param a an array that is at least as large as {@link #getMapSize()}.
+ * @throws NullPointerException if <code>a</code> is <code>null</code>.
+ * @throws ArrayIndexOutOfBoundsException if <code>a</code> has less
+ * than {@link #getMapSize()} elements.
*/
- public final void getAlphas (byte[] a)
+ public final void getAlphas(byte[] a)
{
- getComponents (a, 3);
+ int i;
+ for (i = 0; i < map_size; i++)
+ if (i == trans)
+ a[i] = (byte) 0;
+ else
+ a[i] = (byte) ((0xFF000000 & rgb[i]) >> 24);
}
- private void getComponents (byte[] c, int ci)
- {
- int i, max = (map_size < c.length) ? map_size : c.length;
- for (i = 0; i < max; i++)
- c[i] = (byte) ((generateMask (ci) & rgb[i]) >> (ci * pixel_bits));
- }
-
/**
- * Get the red component of the given pixel.
+ * Returns the red component of the color in the lookup table for the
+ * given pixel value.
+ *
+ * @param pixel the pixel lookup value.
+ *
+ * @return The red component of the color in the lookup table.
+ * @throws ArrayIndexOutOfBoundsException if <code>pixel</code> is negative.
*/
- public final int getRed (int pixel)
+ public final int getRed(int pixel)
{
if (pixel < map_size)
- return (int) ((generateMask (2) & rgb[pixel]) >> (2 * pixel_bits));
+ return (0x00FF0000 & rgb[pixel]) >> 16;
return 0;
}
/**
- * Get the green component of the given pixel.
+ * Returns the green component of the color in the lookup table for the
+ * given pixel value.
+ *
+ * @param pixel the pixel lookup value.
+ *
+ * @return The green component of the color in the lookup table.
+ * @throws ArrayIndexOutOfBoundsException if <code>pixel</code> is negative.
*/
- public final int getGreen (int pixel)
+ public final int getGreen(int pixel)
{
if (pixel < map_size)
- return (int) ((generateMask (1) & rgb[pixel]) >> (1 * pixel_bits));
+ return (0x0000FF00 & rgb[pixel]) >> 8;
return 0;
}
/**
- * Get the blue component of the given pixel.
+ * Returns the blue component of the color in the lookup table for the
+ * given pixel value.
+ *
+ * @param pixel the pixel lookup value.
+ *
+ * @return The blue component of the color in the lookup table.
+ * @throws ArrayIndexOutOfBoundsException if <code>pixel</code> is negative.
*/
- public final int getBlue (int pixel)
+ public final int getBlue(int pixel)
{
- if (pixel < map_size)
- return (int) (generateMask (0) & rgb[pixel]);
+ if (pixel < map_size)
+ return 0x000000FF & rgb[pixel];
return 0;
}
/**
- * Get the alpha component of the given pixel.
+ * Returns the alpha component of the color in the lookup table for the
+ * given pixel value. If no alpha channel was specified when the color model
+ * was created, then 255 is returned for all pixels except the transparent
+ * pixel (if one is defined - see {@link #getTransparentPixel()}) which
+ * returns an alpha of 0.
+ *
+ * @param pixel the pixel lookup value.
+ *
+ * @return The alpha component of the color in the lookup table (in the
+ * range 0 to 255).
+ * @throws ArrayIndexOutOfBoundsException if <code>pixel</code> is negative.
*/
- public final int getAlpha (int pixel)
+ public final int getAlpha(int pixel)
{
- if (opaque || pixel >= map_size)
+ if (opaque && pixel != trans)
return 255;
+ if ((pixel == trans && trans != -1) || pixel >= map_size)
+ return 0;
- return (int) ((generateMask (3) & rgb[pixel]) >> (3 * pixel_bits));
+ return (0xFF000000 & rgb[pixel]) >> 24;
}
/**
* Get the RGB color value of the given pixel using the default
* RGB color model.
*
- * @param pixel a pixel value
+ * @param pixel the pixel lookup value.
+ * @return The RGB color value.
+ * @throws ArrayIndexOutOfBoundsException if <code>pixel</code> is negative.
*/
- public final int getRGB (int pixel)
+ public final int getRGB(int pixel)
{
if (pixel >= 0 && pixel < map_size)
- return rgb[pixel];
+ return rgb[pixel];
return 0;
}
@@ -444,36 +614,47 @@ public class IndexColorModel extends ColorModel
*
* @param rgb The destination array.
*/
- public final void getRGBs (int[] rgb)
+ public final void getRGBs(int[] rgb)
{
System.arraycopy(this.rgb, 0, rgb, 0, map_size);
}
- //pixel_bits is number of bits to be in generated mask
- private int generateMask (int offset)
- {
- return (((2 << pixel_bits ) - 1) << (pixel_bits * offset));
- }
-
- /** Return true if pixel is valid, false otherwise. */
+ /**
+ * Return <code>true</code> if the lookup table contains valid data for
+ * <code>pixel</code>, and <code>false</code> otherwise.
+ *
+ * @param pixel the pixel value used to index the color lookup table.
+ * @return <code>true</code> if <code>pixel</code> is valid,
+ * <code>false</code> otherwise.
+ */
public boolean isValid(int pixel)
{
- return validBits.testBit(pixel);
+ if (pixel >= 0)
+ return validBits.testBit(pixel);
+ return false;
}
- /** Return true if all pixels are valid, false otherwise. */
+ /**
+ * Return <code>true</code> if all pixels are valid, <code>false</code>
+ * otherwise.
+ *
+ * @return <code>true</code> if all pixels are valid, <code>false</code>
+ * otherwise.
+ */
public boolean isValid()
{
// Generate a bigint with 1's for every pixel
BigInteger allbits = new BigInteger("0");
- allbits.setBit(map_size);
- allbits.subtract(new BigInteger("1"));
+ allbits = allbits.setBit(map_size);
+ allbits = allbits.subtract(new BigInteger("1"));
return allbits.equals(validBits);
}
/**
- * Returns a BigInteger where each bit represents an entry in the color
- * model. If the bit is on, the entry is valid.
+ * Returns a binary value ({@link BigInteger}) where each bit represents an
+ * entry in the color lookup table. If the bit is on, the entry is valid.
+ *
+ * @return The binary value.
*/
public BigInteger getValidPixels()
{
@@ -481,7 +662,8 @@ public class IndexColorModel extends ColorModel
}
/**
- * Construct a BufferedImage with rgb pixel values from a Raster.
+ * Construct a {@link BufferedImage} with rgb pixel values from a
+ * {@link Raster}.
*
* Constructs a new BufferedImage in which each pixel is an RGBA int from
* a Raster with index-valued pixels. If this model has no alpha component
@@ -513,4 +695,3 @@ public class IndexColorModel extends ColorModel
return im;
}
}
-
diff --git a/java/io/FileInputStream.java b/java/io/FileInputStream.java
index c71995543..9d573e6ab 100644
--- a/java/io/FileInputStream.java
+++ b/java/io/FileInputStream.java
@@ -107,7 +107,7 @@ public class FileInputStream extends InputStream
if (s != null)
s.checkRead(file.getPath());
- ch = new FileChannelImpl (file, FileChannelImpl.READ);
+ ch = FileChannelImpl.create(file, FileChannelImpl.READ);
}
/**
diff --git a/java/io/FileOutputStream.java b/java/io/FileOutputStream.java
index e8784429e..281ae8797 100644
--- a/java/io/FileOutputStream.java
+++ b/java/io/FileOutputStream.java
@@ -155,7 +155,7 @@ public class FileOutputStream extends OutputStream
if (s != null)
s.checkWrite(file.getPath());
- ch = new FileChannelImpl (file, (append
+ ch = FileChannelImpl.create(file, (append
? FileChannelImpl.WRITE
| FileChannelImpl.APPEND
: FileChannelImpl.WRITE));
diff --git a/java/io/ObjectInputStream.java b/java/io/ObjectInputStream.java
index c4fe56064..2119917f0 100644
--- a/java/io/ObjectInputStream.java
+++ b/java/io/ObjectInputStream.java
@@ -790,8 +790,8 @@ public class ObjectInputStream extends InputStream
}
/**
- * Returns he most recent user defined ClassLoader on the execution stack
- * or null of none is found.
+ * Returns the most recent user defined ClassLoader on the execution stack
+ * or null if none is found.
*/
private ClassLoader currentLoader()
{
diff --git a/java/io/RandomAccessFile.java b/java/io/RandomAccessFile.java
index 772dd7ac2..ead37a31d 100644
--- a/java/io/RandomAccessFile.java
+++ b/java/io/RandomAccessFile.java
@@ -122,7 +122,7 @@ public class RandomAccessFile implements DataOutput, DataInput, Closeable
s.checkWrite(fileName);
}
- ch = new FileChannelImpl (file, fdmode);
+ ch = FileChannelImpl.create(file, fdmode);
fd = new FileDescriptor(ch);
out = new DataOutputStream (new FileOutputStream (fd));
in = new DataInputStream (new FileInputStream (fd));
diff --git a/java/net/ServerSocket.java b/java/net/ServerSocket.java
index 50ea0bebe..9ad2557ac 100644
--- a/java/net/ServerSocket.java
+++ b/java/net/ServerSocket.java
@@ -76,9 +76,9 @@ public class ServerSocket
private SocketImpl impl;
/**
- * True if socket is bound.
+ * We need to retain the local address even after the socket is closed.
*/
- private boolean bound;
+ private InetSocketAddress local;
/*
* This constructor is only used by java.nio.
@@ -238,7 +238,9 @@ public class ServerSocket
{
impl.bind(addr, tmp.getPort());
impl.listen(backlog);
- bound = true;
+ local = new InetSocketAddress(
+ (InetAddress) impl.getOption(SocketOptions.SO_BINDADDR),
+ impl.getLocalPort());
}
catch (IOException exception)
{
@@ -264,18 +266,10 @@ public class ServerSocket
*/
public InetAddress getInetAddress()
{
- if (! isBound())
+ if (local == null)
return null;
- try
- {
- return (InetAddress) impl.getOption(SocketOptions.SO_BINDADDR);
- }
- catch (SocketException e)
- {
- // This never happens as we are bound.
- return null;
- }
+ return local.getAddress();
}
/**
@@ -285,10 +279,10 @@ public class ServerSocket
*/
public int getLocalPort()
{
- if (! isBound())
+ if (local == null)
return -1;
- return impl.getLocalPort();
+ return local.getPort();
}
/**
@@ -300,10 +294,7 @@ public class ServerSocket
*/
public SocketAddress getLocalSocketAddress()
{
- if (! isBound())
- return null;
-
- return new InetSocketAddress(getInetAddress(), getLocalPort());
+ return local;
}
/**
@@ -392,7 +383,6 @@ public class ServerSocket
impl.close();
impl = null;
- bound = false;
if (getChannel() != null)
getChannel().close();
@@ -423,7 +413,7 @@ public class ServerSocket
*/
public boolean isBound()
{
- return bound;
+ return local != null;
}
/**
diff --git a/java/util/Calendar.java b/java/util/Calendar.java
index dc1e0298a..ed86bafa6 100644
--- a/java/util/Calendar.java
+++ b/java/util/Calendar.java
@@ -647,6 +647,7 @@ public abstract class Calendar
clear();
this.time = time;
isTimeSet = true;
+ computeFields();
}
/**
diff --git a/java/util/LinkedHashMap.java b/java/util/LinkedHashMap.java
index 6655a6ecf..2b6009b4d 100644
--- a/java/util/LinkedHashMap.java
+++ b/java/util/LinkedHashMap.java
@@ -188,6 +188,7 @@ public class LinkedHashMap<K,V> extends HashMap<K,V>
succ = null;
pred = root.pred;
pred.succ = this;
+ root.pred = this;
}
}
}
diff --git a/java/util/TimeZone.java b/java/util/TimeZone.java
index 7b7947f63..94082fbd2 100644
--- a/java/util/TimeZone.java
+++ b/java/util/TimeZone.java
@@ -1,5 +1,5 @@
/* java.util.TimeZone
- Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004
+ Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -810,13 +810,20 @@ public abstract class TimeZone implements java.io.Serializable, Cloneable
* with the result of <code>System.getProperty("user.timezone")</code>
* or <code>getDefaultTimeZoneId()</code>. Note that giving one of
* the standard tz data names from ftp://elsie.nci.nih.gov/pub/ is
- * preferred. The time zone name can be given as follows:
- * <code>(standard zone name)[(GMT offset)[(daylight time zone name)]]</code>
+ * preferred.
+ * The time zone name can be given as follows:
+ * <code>(standard zone name)[(GMT offset)[(DST zone name)[DST offset]]]
+ * </code>
* <p>
* If only a (standard zone name) is given (no numbers in the
* String) then it gets mapped directly to the TimeZone with that
* name, if that fails null is returned.
* <p>
+ * Alternately, a POSIX-style TZ string can be given, defining the time zone:
+ * <code>std offset dst offset,date/time,date/time</code>
+ * See the glibc manual, or the man page for <code>tzset</code> for details
+ * of this format.
+ * <p>
* A GMT offset is the offset to add to the local time to get GMT.
* If a (GMT offset) is included (either in seconds or hours) then
* an attempt is made to find a TimeZone name matching both the name
@@ -843,93 +850,278 @@ public abstract class TimeZone implements java.io.Serializable, Cloneable
*/
static TimeZone getDefaultTimeZone(String sysTimeZoneId)
{
- // First find start of GMT offset info and any Daylight zone name.
- int startGMToffset = 0;
- int sysTimeZoneIdLength = sysTimeZoneId.length();
- for (int i = 0; i < sysTimeZoneIdLength && startGMToffset == 0; i++)
+ String stdName = null;
+ String dstName;
+ int stdOffs;
+ int dstOffs;
+ try
+ {
+ int idLength = sysTimeZoneId.length();
+
+ int index = 0;
+ int prevIndex;
+ char c;
+
+ // get std
+ do
+ c = sysTimeZoneId.charAt(index++);
+ while (c != '+' && c != '-' && c != ',' && c != ':'
+ && ! Character.isDigit(c) && c != '\0' && index < idLength);
+
+ if (index >= idLength)
+ return (TimeZone)timezones().get(sysTimeZoneId);
+
+ stdName = sysTimeZoneId.substring(0, --index);
+ prevIndex = index;
+
+ // get the std offset
+ do
+ c = sysTimeZoneId.charAt(index++);
+ while ((c == '-' || c == '+' || c == ':' || Character.isDigit(c))
+ && index < idLength);
+ if (index < idLength)
+ index--;
+
+ { // convert the dst string to a millis number
+ String offset = sysTimeZoneId.substring(prevIndex, index);
+ prevIndex = index;
+
+ if (offset.charAt(0) == '+' || offset.charAt(0) == '-')
+ stdOffs = parseTime(offset.substring(1));
+ else
+ stdOffs = parseTime(offset);
+
+ if (offset.charAt(0) == '-')
+ stdOffs = -stdOffs;
+
+ // TZ timezone offsets are positive when WEST of the meridian.
+ stdOffs = -stdOffs;
+ }
+
+ // Done yet? (Format: std offset)
+ if (index >= idLength)
+ {
+ // Do we have an existing timezone with that name and offset?
+ TimeZone tz = (TimeZone) timezones().get(stdName);
+ if (tz != null)
+ if (tz.getRawOffset() == stdOffs)
+ return tz;
+
+ // Custom then.
+ return new SimpleTimeZone(stdOffs, stdName);
+ }
+
+ // get dst
+ do
+ c = sysTimeZoneId.charAt(index++);
+ while (c != '+' && c != '-' && c != ',' && c != ':'
+ && ! Character.isDigit(c) && c != '\0' && index < idLength);
+
+ // Done yet? (Format: std offset dst)
+ if (index >= idLength)
+ {
+ // Do we have an existing timezone with that name and offset
+ // which has DST?
+ TimeZone tz = (TimeZone) timezones().get(stdName);
+ if (tz != null)
+ if (tz.getRawOffset() == stdOffs && tz.useDaylightTime())
+ return tz;
+
+ // Custom then.
+ return new SimpleTimeZone(stdOffs, stdName);
+ }
+
+ // get the dst offset
+ dstName = sysTimeZoneId.substring(prevIndex, --index);
+ prevIndex = index;
+ do
+ c = sysTimeZoneId.charAt(index++);
+ while ((c == '-' || c == '+' || c == ':' || Character.isDigit(c))
+ && index < idLength);
+ if (index < idLength)
+ index--;
+
+ { // convert the dst string to a millis number
+ String offset = sysTimeZoneId.substring(prevIndex, index);
+ prevIndex = index;
+
+ if (offset.charAt(0) == '+' || offset.charAt(0) == '-')
+ dstOffs = parseTime(offset.substring(1));
+ else
+ dstOffs = parseTime(offset);
+
+ if (offset.charAt(0) == '-')
+ dstOffs = -dstOffs;
+
+ // TZ timezone offsets are positive when WEST of the meridian.
+ dstOffs = -dstOffs;
+ }
+
+ // Done yet? (Format: std offset dst offset)
+ // FIXME: We don't support DST without a rule given. Should we?
+ if (index >= idLength)
+ {
+ // Time Zone existing with same name, dst and offsets?
+ TimeZone tz = (TimeZone) timezones().get(stdName);
+ if (tz != null)
+ if (tz.getRawOffset() == stdOffs && tz.useDaylightTime()
+ && tz.getDSTSavings() == (dstOffs - stdOffs))
+ return tz;
+
+ return new SimpleTimeZone(stdOffs, stdName);
+ }
+
+ // get the DST rule
+ if (sysTimeZoneId.charAt(index) == ','
+ || sysTimeZoneId.charAt(index) == ';')
+ {
+ index++;
+ int offs = index;
+ while (sysTimeZoneId.charAt(index) != ','
+ && sysTimeZoneId.charAt(index) != ';')
+ index++;
+ String startTime = sysTimeZoneId.substring(offs, index);
+ index++;
+ String endTime = sysTimeZoneId.substring(index);
+
+ index = startTime.indexOf('/');
+ int startMillis;
+ int endMillis;
+ String startDate;
+ String endDate;
+ if (index != -1)
+ {
+ startDate = startTime.substring(0, index);
+ startMillis = parseTime(startTime.substring(index + 1));
+ }
+ else
+ {
+ startDate = startTime;
+ // if time isn't given, default to 2:00:00 AM.
+ startMillis = 2 * 60 * 60 * 1000;
+ }
+ index = endTime.indexOf('/');
+ if (index != -1)
+ {
+ endDate = endTime.substring(0, index);
+ endMillis = parseTime(endTime.substring(index + 1));
+ }
+ else
+ {
+ endDate = endTime;
+ // if time isn't given, default to 2:00:00 AM.
+ endMillis = 2 * 60 * 60 * 1000;
+ }
+
+ int[] start = getDateParams(startDate);
+ int[] end = getDateParams(endDate);
+ return new SimpleTimeZone(stdOffs, stdName, start[0], start[1],
+ start[2], startMillis, end[0], end[1],
+ end[2], endMillis, (dstOffs - stdOffs));
+ }
+ }
+
+ // FIXME: Produce a warning here?
+ catch (IndexOutOfBoundsException _)
{
- char c = sysTimeZoneId.charAt(i);
- if (Character.isDigit(c))
- startGMToffset = i;
- else if ((c == '+' || c == '-')
- && i + 1 < sysTimeZoneIdLength
- && Character.isDigit(sysTimeZoneId.charAt(i + 1)))
- startGMToffset = i;
}
-
- String tzBasename;
- if (startGMToffset == 0)
- tzBasename = sysTimeZoneId;
- else
- tzBasename = sysTimeZoneId.substring (0, startGMToffset);
-
- int startDaylightZoneName = 0;
- for (int i = sysTimeZoneIdLength - 1;
- i >= 0 && !Character.isDigit(sysTimeZoneId.charAt(i)); --i)
- startDaylightZoneName = i;
-
- boolean useDaylightTime = startDaylightZoneName > 0;
-
- // Integer.parseInt() doesn't handle leading +.
- if (sysTimeZoneId.charAt(startGMToffset) == '+')
- startGMToffset++;
-
- int gmtOffset = 0;
- if (startGMToffset > 0)
+ catch (NumberFormatException _)
{
- gmtOffset = Integer.parseInt
- (startDaylightZoneName == 0
- ? sysTimeZoneId.substring(startGMToffset)
- : sysTimeZoneId.substring(startGMToffset,
- startDaylightZoneName));
-
- // Offset could be in hours or seconds. Convert to millis.
- // The offset is given as the time to add to local time to get GMT
- // we need the time to add to GMT to get localtime.
- if (Math.abs(gmtOffset) < 24)
- gmtOffset *= 60 * 60;
- gmtOffset *= -1000;
}
-
- // Try to be optimistic and get the timezone that matches the base name.
- // If we only have the base name then just accept this timezone.
- // Otherwise check the gmtOffset and day light attributes.
- TimeZone tz = (TimeZone) timezones().get(tzBasename);
- if (tz != null
- && (tzBasename == sysTimeZoneId
- || (tz.getRawOffset() == gmtOffset
- && tz.useDaylightTime() == useDaylightTime)))
- return tz;
-
- // Maybe there is one with the daylight zone name?
- if (useDaylightTime)
+
+ return null;
+ }
+
+ /**
+ * Parses and returns the params for a POSIX TZ date field,
+ * in the format int[]{ month, day, dayOfWeek }, following the
+ * SimpleTimeZone constructor rules.
+ */
+ private static int[] getDateParams(String date)
+ {
+ int[] dayCount = { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 };
+ int month;
+
+ if (date.charAt(0) == 'M' || date.charAt(0) == 'm')
{
- String daylightZoneName;
- daylightZoneName = sysTimeZoneId.substring(startDaylightZoneName);
- if (!daylightZoneName.equals(tzBasename))
- {
- tz = (TimeZone) timezones().get(tzBasename);
- if (tz != null
- && tz.getRawOffset() == gmtOffset
- && tz.useDaylightTime())
- return tz;
- }
+ int day;
+
+ // Month, week of month, day of week
+ month = Integer.parseInt(date.substring(1, date.indexOf('.')));
+ int week = Integer.parseInt(date.substring(date.indexOf('.') + 1,
+ date.lastIndexOf('.')));
+ int dayOfWeek = Integer.parseInt(date.substring(date.lastIndexOf('.')
+ + 1));
+ if (week == 5)
+ day = -1; // last day of month is -1 in java, 5 in TZ
+ else
+ // first day of week starting on or after.
+ day = (week - 1) * 7 + 1;
+
+ dayOfWeek++; // Java day of week is one-based, Sunday is first day.
+ month--; // Java month is zero-based.
+ return new int[] { month, day, dayOfWeek };
}
-
- // If no match, see if a valid timezone has similar attributes as this
- // and then use it instead. We take the first one that looks OKish.
- if (startGMToffset > 0)
+
+ // julian day, either zero-based 0<=n<=365 (incl feb 29)
+ // or one-based 1<=n<=365 (no feb 29)
+ int julianDay; // Julian day,
+
+ if (date.charAt(0) != 'J' || date.charAt(0) != 'j')
{
- String[] ids = getAvailableIDs(gmtOffset);
- for (int i = 0; i < ids.length; i++)
- {
- tz = (TimeZone) timezones().get(ids[i]);
- if (tz.useDaylightTime() == useDaylightTime)
- return tz;
- }
+ julianDay = Integer.parseInt(date.substring(1));
+ julianDay++; // make 1-based
+ // Adjust day count to include feb 29.
+ dayCount = new int[]
+ {
+ 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335
+ };
}
-
- return null;
+ else
+ // 1-based julian day
+ julianDay = Integer.parseInt(date);
+
+ int i = 11;
+ while (i > 0)
+ if (dayCount[i] < julianDay)
+ break;
+ else
+ i--;
+ julianDay -= dayCount[i];
+ month = i;
+ return new int[] { month, julianDay, 0 };
+ }
+
+ /**
+ * Parses a time field hh[:mm[:ss]], returning the result
+ * in milliseconds. No leading sign.
+ */
+ private static int parseTime(String time)
+ {
+ int millis = 0;
+ int i = 0;
+
+ while (i < time.length())
+ if (time.charAt(i) == ':')
+ break;
+ else
+ i++;
+ millis = 60 * 60 * 1000 * Integer.parseInt(time.substring(0, i));
+ if (i >= time.length())
+ return millis;
+
+ int iprev = ++i;
+ while (i < time.length())
+ if (time.charAt(i) == ':')
+ break;
+ else
+ i++;
+ if (i >= time.length())
+ return millis;
+
+ millis += 60 * 1000 * Integer.parseInt(time.substring(iprev, i));
+ millis += 1000 * Integer.parseInt(time.substring(++i));
+ return millis;
}
/**
diff --git a/javax/swing/AbstractButton.java b/javax/swing/AbstractButton.java
index c7b9420e1..6f465b738 100644
--- a/javax/swing/AbstractButton.java
+++ b/javax/swing/AbstractButton.java
@@ -160,6 +160,8 @@ public abstract class AbstractButton extends JComponent
protected class ButtonChangeListener
implements ChangeListener, Serializable
{
+ private static final long serialVersionUID = 1471056094226600578L;
+
/**
* Notified when the target of the listener changes its state.
*
diff --git a/javax/swing/ActionMap.java b/javax/swing/ActionMap.java
index 26d1d6fa9..939affe85 100644
--- a/javax/swing/ActionMap.java
+++ b/javax/swing/ActionMap.java
@@ -133,7 +133,8 @@ public class ActionMap
*/
public void setParent(ActionMap parentMap)
{
- parent = parentMap;
+ if (parentMap != this)
+ parent = parentMap;
}
/**
diff --git a/javax/swing/ImageIcon.java b/javax/swing/ImageIcon.java
index 8c2401c8e..062c5d8a0 100644
--- a/javax/swing/ImageIcon.java
+++ b/javax/swing/ImageIcon.java
@@ -63,6 +63,8 @@ public class ImageIcon
extends AccessibleContext
implements AccessibleIcon, Serializable
{
+ private static final long serialVersionUID = 2113430526551336564L;
+
/**
* Creates a new instance of AccessibleImageIcon.
*/
diff --git a/javax/swing/JButton.java b/javax/swing/JButton.java
index df9f34839..eca53750e 100644
--- a/javax/swing/JButton.java
+++ b/javax/swing/JButton.java
@@ -79,6 +79,7 @@ public class JButton extends AbstractButton
{
super(text, icon);
setModel(new DefaultButtonModel());
+ setActionCommand(text);
}
public Object[] getSelectedObjects()
diff --git a/javax/swing/JComponent.java b/javax/swing/JComponent.java
index 3bc8b71af..08f13ed0f 100644
--- a/javax/swing/JComponent.java
+++ b/javax/swing/JComponent.java
@@ -73,6 +73,7 @@ import java.util.Locale;
import javax.accessibility.Accessible;
import javax.accessibility.AccessibleContext;
+import javax.accessibility.AccessibleExtendedComponent;
import javax.accessibility.AccessibleKeyBinding;
import javax.accessibility.AccessibleRole;
import javax.accessibility.AccessibleStateSet;
@@ -104,6 +105,7 @@ public abstract class JComponent extends Container implements Serializable
public abstract class AccessibleJComponent
extends AccessibleAWTContainer
+ implements AccessibleExtendedComponent
{
protected class AccessibleFocusHandler
implements FocusListener
@@ -1786,6 +1788,8 @@ public abstract class JComponent extends Container implements Serializable
*/
protected void processKeyEvent(KeyEvent e)
{
+ // let the AWT event processing send KeyEvents to registered listeners
+ super.processKeyEvent(e);
processComponentKeyEvent(e);
// FIXME: this needs to be elaborated significantly, to do all the
diff --git a/javax/swing/JFileChooser.java b/javax/swing/JFileChooser.java
index bed85f938..07a67a041 100644
--- a/javax/swing/JFileChooser.java
+++ b/javax/swing/JFileChooser.java
@@ -58,6 +58,8 @@ import javax.swing.plaf.FileChooserUI;
*/
public class JFileChooser extends JComponent implements Accessible
{
+ private static final long serialVersionUID = 3162921138695327837L;
+
/** DOCUMENT ME! */
public static final int OPEN_DIALOG = 0;
@@ -112,10 +114,11 @@ public class JFileChooser extends JComponent implements Accessible
/** DOCUMENT ME! */
public static final String SELECTED_FILE_CHANGED_PROPERTY =
- "SelectedFilesChangedProperty";
+ "SelectedFileChangedProperty";
/** DOCUMENT ME! */
- public static final String SELECTED_FILES_CHANGED_PROPERTY = "selectedFiles";
+ public static final String SELECTED_FILES_CHANGED_PROPERTY =
+ "SelectedFilesChangedProperty";
/** DOCUMENT ME! */
public static final String MULTI_SELECTION_ENABLED_CHANGED_PROPERTY =
diff --git a/javax/swing/JInternalFrame.java b/javax/swing/JInternalFrame.java
index f8e10f850..8a29d2fff 100644
--- a/javax/swing/JInternalFrame.java
+++ b/javax/swing/JInternalFrame.java
@@ -76,6 +76,8 @@ public class JInternalFrame extends JComponent implements Accessible,
protected class AccessibleJInternalFrame extends AccessibleJComponent
implements AccessibleValue
{
+ private static final long serialVersionUID = 5931936924175476797L;
+
/**
* Creates a new AccessibleJInternalFrame object.
*/
@@ -168,6 +170,8 @@ public class JInternalFrame extends JComponent implements Accessible,
protected class AccessibleJDesktopIcon extends AccessibleJComponent
implements AccessibleValue
{
+ private static final long serialVersionUID = 5035560458941637802L;
+
/**
* Creates a new AccessibleJDesktopIcon object.
*/
@@ -239,6 +243,8 @@ public class JInternalFrame extends JComponent implements Accessible,
}
}
+ private static final long serialVersionUID = 4672973344731387687L;
+
/** The JInternalFrame this DesktopIcon represents. */
JInternalFrame frame;
diff --git a/javax/swing/JLayeredPane.java b/javax/swing/JLayeredPane.java
index 603dc8710..f07d36e99 100644
--- a/javax/swing/JLayeredPane.java
+++ b/javax/swing/JLayeredPane.java
@@ -599,4 +599,15 @@ public class JLayeredPane extends JComponent implements Accessible
revalidate();
repaint();
}
+
+ /**
+ * Sets the layer property for a JComponent.
+ *
+ * @param component the component for which to set the layer
+ * @param layer the layer property to set
+ */
+ public static void putLayer(JComponent component, int layer)
+ {
+ getLayeredPaneAbove(component).setLayer(component, layer);
+ }
}
diff --git a/javax/swing/JList.java b/javax/swing/JList.java
index d9e9fee7f..e5ca14a2a 100644
--- a/javax/swing/JList.java
+++ b/javax/swing/JList.java
@@ -53,6 +53,7 @@ import javax.swing.event.ListDataListener;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.plaf.ListUI;
+import javax.swing.text.Position;
/**
* <p>This class is a facade over three separate objects: {@link
@@ -1335,4 +1336,81 @@ public class JList extends JComponent implements Accessible, Scrollable
layoutOrientation = orientation;
firePropertyChange("layoutOrientation", old, orientation);
}
+
+ /**
+ * Returns the bounds of the rectangle that encloses both list cells
+ * with index0 and index1.
+ *
+ * @param index0 the index of the first cell
+ * @param index1 the index of the second cell
+ *
+ * @return the bounds of the rectangle that encloses both list cells
+ * with index0 and index1, <code>null</code> if one of the indices is
+ * not valid
+ */
+ public Rectangle getCellBounds(int index0, int index1)
+ {
+ return ((ListUI) ui).getCellBounds(this, index0, index1);
+ }
+
+ /**
+ * Returns the next list element (beginning from <code>startIndex</code>
+ * that starts with <code>prefix</code>. Searching is done in the direction
+ * specified by <code>bias</code>.
+ *
+ * @param prefix the prefix to search for in the cell values
+ * @param startIndex the index where to start searching from
+ * @param bias the search direction, either {@link Position.Bias.Forward}
+ * or {@link Position.Bias.Backward}
+ *
+ * @return the index of the found element or -1 if no such element has
+ * been found
+ *
+ * @throws IllegalArgumentException if prefix is <code>null</code> or
+ * startIndex is not valid
+ *
+ * @since 1.4
+ */
+ public int getNextMatch(String prefix, int startIndex, Position.Bias bias)
+ {
+ if (prefix == null)
+ throw new IllegalArgumentException("The argument 'prefix' must not be"
+ + " null.");
+ if (startIndex < 0)
+ throw new IllegalArgumentException("The argument 'startIndex' must not"
+ + " be less than zero.");
+
+ int size = model.getSize();
+ if (startIndex > model.getSize())
+ throw new IllegalArgumentException("The argument 'startIndex' must not"
+ + " be greater than the number of"
+ + " elements in the ListModel.");
+
+ int index = -1;
+ if (bias == Position.Bias.Forward)
+ {
+ for (int i = startIndex; i < size; i++)
+ {
+ String item = model.getElementAt(i).toString();
+ if (item.startsWith(prefix))
+ {
+ index = i;
+ break;
+ }
+ }
+ }
+ else
+ {
+ for (int i = startIndex; i >= 0; i--)
+ {
+ String item = model.getElementAt(i).toString();
+ if (item.startsWith(prefix))
+ {
+ index = i;
+ break;
+ }
+ }
+ }
+ return index;
+ }
}
diff --git a/javax/swing/JMenu.java b/javax/swing/JMenu.java
index 6fdf266fd..e93ec0533 100644
--- a/javax/swing/JMenu.java
+++ b/javax/swing/JMenu.java
@@ -797,6 +797,8 @@ public class JMenu extends JMenuItem implements Accessible, MenuElement
protected class AccessibleJMenu extends AccessibleJMenuItem
implements AccessibleSelection
{
+ private static final long serialVersionUID = -8131864021059524309L;
+
protected AccessibleJMenu()
{
}
diff --git a/javax/swing/JPopupMenu.java b/javax/swing/JPopupMenu.java
index 00998b81a..f1ec51156 100644
--- a/javax/swing/JPopupMenu.java
+++ b/javax/swing/JPopupMenu.java
@@ -261,9 +261,6 @@ public class JPopupMenu extends JComponent implements Accessible, MenuElement
constraints.weightx = 100.0;
constraints.weighty = 100.0;
- if (index == -1)
- index = getComponents().length;
-
constraints.gridy = index;
super.add(component, constraints, index);
diff --git a/javax/swing/JRadioButton.java b/javax/swing/JRadioButton.java
index da8c8395a..10f7e81fd 100644
--- a/javax/swing/JRadioButton.java
+++ b/javax/swing/JRadioButton.java
@@ -79,6 +79,7 @@ public class JRadioButton extends JToggleButton
protected class AccessibleJRadioButton
extends AccessibleJToggleButton
{
+ private static final long serialVersionUID = 4850967637026120674L;
/**
* Constructor for the accessible toggle button.
diff --git a/javax/swing/JScrollPane.java b/javax/swing/JScrollPane.java
index dfe5a76b1..baa0a6a85 100644
--- a/javax/swing/JScrollPane.java
+++ b/javax/swing/JScrollPane.java
@@ -645,6 +645,8 @@ public class JScrollPane
extends JScrollBar
implements UIResource
{
+ private static final long serialVersionUID = -42032395320987283L;
+
public ScrollBar(int orientation)
{
super(orientation);
diff --git a/javax/swing/JSpinner.java b/javax/swing/JSpinner.java
index fbf2bbf5f..4efb1c27e 100644
--- a/javax/swing/JSpinner.java
+++ b/javax/swing/JSpinner.java
@@ -279,6 +279,8 @@ public class JSpinner extends JComponent
}
}
+ private static final long serialVersionUID = 3412663575706551720L;
+
/** DOCUMENT ME! */
private SpinnerModel model;
diff --git a/javax/swing/JTabbedPane.java b/javax/swing/JTabbedPane.java
index 748ee2140..5a37d1b9b 100644
--- a/javax/swing/JTabbedPane.java
+++ b/javax/swing/JTabbedPane.java
@@ -530,6 +530,8 @@ public class JTabbedPane extends JComponent implements Serializable,
}
}
+ private static final long serialVersionUID = 1614381073220130939L;
+
/** The changeEvent used to fire changes to listeners. */
protected ChangeEvent changeEvent;
diff --git a/javax/swing/JTextArea.java b/javax/swing/JTextArea.java
index 6513b58d2..12e5a4e50 100644
--- a/javax/swing/JTextArea.java
+++ b/javax/swing/JTextArea.java
@@ -188,6 +188,7 @@ public class JTextArea extends JTextComponent
setText(text);
setRows(rows);
setColumns(columns);
+ setPreferredSize(new Dimension(440, 150));
}
/**
diff --git a/javax/swing/JToggleButton.java b/javax/swing/JToggleButton.java
index 4e18c438a..d5fcdd76c 100644
--- a/javax/swing/JToggleButton.java
+++ b/javax/swing/JToggleButton.java
@@ -69,6 +69,7 @@ public class JToggleButton extends AbstractButton implements Accessible
extends AccessibleAbstractButton
implements ItemListener
{
+ private static final long serialVersionUID = -8652952712161229225L;
/**
* Constructor for the accessible toggle button.
diff --git a/javax/swing/JToolTip.java b/javax/swing/JToolTip.java
index 8099ef938..871f15cca 100644
--- a/javax/swing/JToolTip.java
+++ b/javax/swing/JToolTip.java
@@ -60,6 +60,8 @@ public class JToolTip extends JComponent implements Accessible
*/
protected class AccessibleJToolTip extends AccessibleJComponent
{
+ private static final long serialVersionUID = -6222548177795408476L;
+
/**
* Creates a new AccessibleJToolTip object.
*/
diff --git a/javax/swing/JTree.java b/javax/swing/JTree.java
index 5a0e78abe..823c5b104 100644
--- a/javax/swing/JTree.java
+++ b/javax/swing/JTree.java
@@ -56,6 +56,7 @@ import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener;
import javax.swing.event.TreeWillExpandListener;
import javax.swing.plaf.TreeUI;
+import javax.swing.text.Position;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeCellRenderer;
import javax.swing.tree.DefaultTreeModel;
@@ -1704,4 +1705,79 @@ public class JTree extends JComponent
}
return relevantPaths.elements();
}
+
+ /**
+ * Returns the next table element (beginning from the row
+ * <code>startingRow</code>
+ * that starts with <code>prefix</code>. Searching is done in the direction
+ * specified by <code>bias</code>.
+ *
+ * @param prefix the prefix to search for in the cell values
+ * @param startingRow the index of the row where to start searching from
+ * @param bias the search direction, either {@link Position.Bias.Forward}
+ * or {@link Position.Bias.Backward}
+ *
+ * @return the path to the found element or -1 if no such element has
+ * been found
+ *
+ * @throws IllegalArgumentException if prefix is <code>null</code> or
+ * startingRow is not valid
+ *
+ * @since 1.4
+ */
+ public TreePath getNextMatch(String prefix, int startingRow,
+ Position.Bias bias)
+ {
+ if (prefix == null)
+ throw new IllegalArgumentException("The argument 'prefix' must not be"
+ + " null.");
+ if (startingRow < 0)
+ throw new IllegalArgumentException("The argument 'startingRow' must not"
+ + " be less than zero.");
+
+ int size = getRowCount();
+ if (startingRow > size)
+ throw new IllegalArgumentException("The argument 'startingRow' must not"
+ + " be greater than the number of"
+ + " elements in the TreeModel.");
+
+ TreePath foundPath = null;
+ if (bias == Position.Bias.Forward)
+ {
+ for (int i = startingRow; i < size; i++)
+ {
+ TreePath path = getPathForRow(i);
+ Object o = path.getLastPathComponent();
+ // FIXME: in the following call to convertValueToText the
+ // last argument (hasFocus) should be done right.
+ String item = convertValueToText(o, isRowSelected(i),
+ isExpanded(i),
+ treeModel.isLeaf(o), i, false);
+ if (item.startsWith(prefix))
+ {
+ foundPath = path;
+ break;
+ }
+ }
+ }
+ else
+ {
+ for (int i = startingRow; i >= 0; i--)
+ {
+ TreePath path = getPathForRow(i);
+ Object o = path.getLastPathComponent();
+ // FIXME: in the following call to convertValueToText the
+ // last argument (hasFocus) should be done right.
+ String item = convertValueToText(o, isRowSelected(i),
+ isExpanded(i),
+ treeModel.isLeaf(o), i, false);
+ if (item.startsWith(prefix))
+ {
+ foundPath = path;
+ break;
+ }
+ }
+ }
+ return foundPath;
+ }
}
diff --git a/javax/swing/JViewport.java b/javax/swing/JViewport.java
index ff3e9a8be..d097081fb 100644
--- a/javax/swing/JViewport.java
+++ b/javax/swing/JViewport.java
@@ -107,6 +107,8 @@ public class JViewport extends JComponent
extends ComponentAdapter
implements Serializable
{
+ private static final long serialVersionUID = -2812489404285958070L;
+
/**
* Creates a new instance of ViewListener.
*/
diff --git a/javax/swing/LayoutFocusTraversalPolicy.java b/javax/swing/LayoutFocusTraversalPolicy.java
index ab47a3c9f..e61f724eb 100644
--- a/javax/swing/LayoutFocusTraversalPolicy.java
+++ b/javax/swing/LayoutFocusTraversalPolicy.java
@@ -79,6 +79,8 @@ public class LayoutFocusTraversalPolicy
return 1;
}
}
+
+ private static final long serialVersionUID = 4312146927238881442L;
public LayoutFocusTraversalPolicy()
{
diff --git a/javax/swing/SpinnerDateModel.java b/javax/swing/SpinnerDateModel.java
index 53bf9ec0c..8e577fad5 100644
--- a/javax/swing/SpinnerDateModel.java
+++ b/javax/swing/SpinnerDateModel.java
@@ -61,9 +61,9 @@ public class SpinnerDateModel extends AbstractSpinnerModel
/**
* For compatability with Sun's JDK
- * FIXME: what's the number? And which fields should be serialized?
+ * FIXME: Which fields should be serialized?
*/
- private static final long serialVersionUID = 1L;
+ private static final long serialVersionUID = -4802518107105940612L;
/**
* Constructs a SpinnerDateModel using the current date,
diff --git a/javax/swing/SwingUtilities.java b/javax/swing/SwingUtilities.java
index 29d769b90..13470f304 100644
--- a/javax/swing/SwingUtilities.java
+++ b/javax/swing/SwingUtilities.java
@@ -365,7 +365,7 @@ public class SwingUtilities
* @return the first ancestor Window of <code>comp</code> or
* <code>null</code> if <code>comp</code> is not contained in a Window
*/
- public Window getWindowAncestor(Component comp)
+ public static Window getWindowAncestor(Component comp)
{
return (Window) getAncestorOfClass(Window.class, comp);
}
@@ -1128,9 +1128,13 @@ public class SwingUtilities
component.setActionMap(uiActionMap);
else
{
- while(child.getParent() != null
- && !(child.getParent() instanceof ActionMapUIResource))
- child = child.getParent();
+ ActionMap parent = child.getParent();
+ while(parent != null)
+ {
+ child = parent;
+ parent = child.getParent();
+ }
+
if (child != null)
child.setParent(uiActionMap);
}
diff --git a/javax/swing/TransferHandler.java b/javax/swing/TransferHandler.java
index 62acbca58..85d4a8c4d 100644
--- a/javax/swing/TransferHandler.java
+++ b/javax/swing/TransferHandler.java
@@ -102,7 +102,7 @@ public class TransferHandler implements Serializable
}
}
- private static final long serialVersionUID = -7908749299918704233L;
+ private static final long serialVersionUID = -967749805571669910L;
private static final String COMMAND_COPY = "copy";
private static final String COMMAND_CUT = "cut";
diff --git a/javax/swing/plaf/basic/BasicCheckBoxUI.java b/javax/swing/plaf/basic/BasicCheckBoxUI.java
index 0efc7ab35..5e1e0f5a9 100644
--- a/javax/swing/plaf/basic/BasicCheckBoxUI.java
+++ b/javax/swing/plaf/basic/BasicCheckBoxUI.java
@@ -1,5 +1,5 @@
/* BasicCheckBoxUI.java
- Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -59,7 +59,13 @@ public class BasicCheckBoxUI extends BasicRadioButtonUI
public void installUI(final JComponent c) {
super.installUI(c);
- }
+ }
+
+ // Overridden to change method access.
+ public String getPropertyPrefix()
+ {
+ return super.getPropertyPrefix();
+ }
}
diff --git a/javax/swing/plaf/basic/BasicFileChooserUI.java b/javax/swing/plaf/basic/BasicFileChooserUI.java
index 517d4ecec..d425ad324 100644
--- a/javax/swing/plaf/basic/BasicFileChooserUI.java
+++ b/javax/swing/plaf/basic/BasicFileChooserUI.java
@@ -101,6 +101,10 @@ public class BasicFileChooserUI extends FileChooserUI
*/
protected class AcceptAllFileFilter extends FileFilter
{
+ public AcceptAllFileFilter()
+ {
+ }
+
/**
* DOCUMENT ME!
*
@@ -168,6 +172,10 @@ public class BasicFileChooserUI extends FileChooserUI
/** DOCUMENT ME! */
protected Hashtable iconCache = new Hashtable();
+ public BasicFileView()
+ {
+ }
+
/**
* DOCUMENT ME!
*
@@ -1299,19 +1307,10 @@ public class BasicFileChooserUI extends FileChooserUI
c.anchor = GridBagConstraints.EAST;
bottomPanel.add(closePanel, c);
- filechooser.setLayout(new GridBagLayout());
-
- c.anchor = GridBagConstraints.WEST;
- c.gridx = 0;
- c.gridy = 0;
- filechooser.add(topPanel, c);
-
- c.gridy = 1;
- filechooser.add(centrePanel, c);
-
- c.gridy = 2;
- c.fill = GridBagConstraints.HORIZONTAL;
- filechooser.add(bottomPanel, c);
+ filechooser.setLayout(new BorderLayout());
+ filechooser.add(topPanel, BorderLayout.NORTH);
+ filechooser.add(centrePanel, BorderLayout.CENTER);
+ filechooser.add(bottomPanel, BorderLayout.SOUTH);
}
/**
diff --git a/javax/swing/plaf/basic/BasicInternalFrameTitlePane.java b/javax/swing/plaf/basic/BasicInternalFrameTitlePane.java
index 75de12811..f3939ac6b 100644
--- a/javax/swing/plaf/basic/BasicInternalFrameTitlePane.java
+++ b/javax/swing/plaf/basic/BasicInternalFrameTitlePane.java
@@ -77,6 +77,10 @@ public class BasicInternalFrameTitlePane extends JComponent
{
/**
* The Action responsible for closing the JInternalFrame.
+ *
+ * @specnote Apparently this class was intended to be protected,
+ * but was made public by a compiler bug and is now
+ * public for compatibility.
*/
public class CloseAction extends AbstractAction
{
@@ -102,6 +106,10 @@ public class BasicInternalFrameTitlePane extends JComponent
/**
* This Action is responsible for iconifying the JInternalFrame.
+ *
+ * @specnote Apparently this class was intended to be protected,
+ * but was made public by a compiler bug and is now
+ * public for compatibility.
*/
public class IconifyAction extends AbstractAction
{
@@ -128,6 +136,10 @@ public class BasicInternalFrameTitlePane extends JComponent
/**
* This Action is responsible for maximizing the JInternalFrame.
+ *
+ * @specnote Apparently this class was intended to be protected,
+ * but was made public by a compiler bug and is now
+ * public for compatibility.
*/
public class MaximizeAction extends AbstractAction
{
@@ -154,6 +166,10 @@ public class BasicInternalFrameTitlePane extends JComponent
/**
* This Action is responsible for dragging the JInternalFrame.
+ *
+ * @specnote Apparently this class was intended to be protected,
+ * but was made public by a compiler bug and is now
+ * public for compatibility.
*/
public class MoveAction extends AbstractAction
{
@@ -171,6 +187,10 @@ public class BasicInternalFrameTitlePane extends JComponent
/**
* This Action is responsible for restoring the JInternalFrame. Restoring
* the JInternalFrame is the same as setting the maximum property to false.
+ *
+ * @specnote Apparently this class was intended to be protected,
+ * but was made public by a compiler bug and is now
+ * public for compatibility.
*/
public class RestoreAction extends AbstractAction
{
@@ -197,6 +217,10 @@ public class BasicInternalFrameTitlePane extends JComponent
/**
* This action is responsible for sizing the JInternalFrame.
+ *
+ * @specnote Apparently this class was intended to be protected,
+ * but was made public by a compiler bug and is now
+ * public for compatibility.
*/
public class SizeAction extends AbstractAction
{
@@ -214,8 +238,12 @@ public class BasicInternalFrameTitlePane extends JComponent
/**
* This class is responsible for handling property change events from the
* JInternalFrame and adjusting the Title Pane as necessary.
+ *
+ * @specnote Apparently this class was intended to be protected,
+ * but was made public by a compiler bug and is now
+ * public for compatibility.
*/
- protected class PropertyChangeHandler implements PropertyChangeListener
+ public class PropertyChangeHandler implements PropertyChangeListener
{
/**
* This method is called when a PropertyChangeEvent is received by the
@@ -236,6 +264,10 @@ public class BasicInternalFrameTitlePane extends JComponent
/**
* This class acts as the MenuBar for the TitlePane. Clicking on the Frame
* Icon in the top left corner will activate it.
+ *
+ * @specnote Apparently this class was intended to be protected,
+ * but was made public by a compiler bug and is now
+ * public for compatibility.
*/
public class SystemMenuBar extends JMenuBar
{
@@ -284,8 +316,12 @@ public class BasicInternalFrameTitlePane extends JComponent
/**
* This class acts as the Layout Manager for the TitlePane.
+ *
+ * @specnote Apparently this class was intended to be protected,
+ * but was made public by a compiler bug and is now
+ * public for compatibility.
*/
- protected class TitlePaneLayout implements LayoutManager
+ public class TitlePaneLayout implements LayoutManager
{
/**
* Creates a new <code>TitlePaneLayout</code> object.
diff --git a/javax/swing/plaf/basic/BasicInternalFrameUI.java b/javax/swing/plaf/basic/BasicInternalFrameUI.java
index 594bb7ecf..088c26272 100644
--- a/javax/swing/plaf/basic/BasicInternalFrameUI.java
+++ b/javax/swing/plaf/basic/BasicInternalFrameUI.java
@@ -1,5 +1,5 @@
/* BasicInternalFrameUI.java --
- Copyright (C) 2004 Free Software Foundation, Inc.
+ Copyright (C) 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -162,7 +162,7 @@ public class BasicInternalFrameUI extends InternalFrameUI
implements SwingConstants
{
/** FIXME: Use for something. */
- protected int RESIZE_NONE;
+ protected final int RESIZE_NONE = 0;
/** The x offset from the top left corner of the JInternalFrame. */
private transient int xOffset = 0;
diff --git a/javax/swing/plaf/basic/BasicListUI.java b/javax/swing/plaf/basic/BasicListUI.java
index 589ec9d43..baaa04655 100644
--- a/javax/swing/plaf/basic/BasicListUI.java
+++ b/javax/swing/plaf/basic/BasicListUI.java
@@ -304,19 +304,20 @@ public class BasicListUI extends ListUI
}
/** The current focus listener. */
- protected FocusHandler focusListener;
+ protected FocusListener focusListener;
/** The data listener listening to the model. */
- protected ListDataHandler listDataListener;
+ protected ListDataListener listDataListener;
/** The selection listener listening to the selection model. */
- protected ListSelectionHandler listSelectionListener;
+ protected ListSelectionListener listSelectionListener;
/** The mouse listener listening to the list. */
- protected MouseInputHandler mouseInputListener;
+ protected MouseInputListener mouseInputListener;
/** The property change listener listening to the list. */
- protected PropertyChangeHandler propertyChangeListener;
+ protected PropertyChangeListener propertyChangeListener;
+
/** The component listener that receives notification for resizing the
* JList component.*/
@@ -498,7 +499,8 @@ public class BasicListUI extends ListUI
void damageLayout()
{
updateLayoutStateNeeded = 1;
- list.revalidate();
+ if (list != null)
+ list.revalidate();
}
/**
diff --git a/javax/swing/plaf/basic/BasicMenuUI.java b/javax/swing/plaf/basic/BasicMenuUI.java
index 932024aa9..89daf3245 100644
--- a/javax/swing/plaf/basic/BasicMenuUI.java
+++ b/javax/swing/plaf/basic/BasicMenuUI.java
@@ -1,5 +1,5 @@
/* BasicMenuUI.java
- Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -424,7 +424,10 @@ public class BasicMenuUI extends BasicMenuItemUI
}
}
- protected class ChangeHandler implements ChangeListener
+ /**
+ * @deprecated
+ */
+ public class ChangeHandler implements ChangeListener
{
public void stateChanged(ChangeEvent e)
{
diff --git a/javax/swing/plaf/basic/BasicOptionPaneUI.java b/javax/swing/plaf/basic/BasicOptionPaneUI.java
index e0cabce0d..21bdf33ae 100644
--- a/javax/swing/plaf/basic/BasicOptionPaneUI.java
+++ b/javax/swing/plaf/basic/BasicOptionPaneUI.java
@@ -85,8 +85,12 @@ public class BasicOptionPaneUI extends OptionPaneUI
/**
* This is a helper class that listens to the buttons located at the bottom
* of the JOptionPane.
+ *
+ * @specnote Apparently this class was intended to be protected,
+ * but was made public by a compiler bug and is now
+ * public for compatibility.
*/
- protected class ButtonActionListener implements ActionListener
+ public class ButtonActionListener implements ActionListener
{
/** The index of the option this button represents. */
protected int buttonIndex;
@@ -152,8 +156,13 @@ public class BasicOptionPaneUI extends OptionPaneUI
* This helper layout manager is responsible for the layout of the button
* area. The button area is the panel that holds the buttons which
* represent the options.
+ *
+ * @specnote Apparently this class was intended to be protected,
+ * but was made public by a compiler bug and is now
+ * public for compatibility.
*/
- protected class ButtonAreaLayout implements LayoutManager
+ // FIXME: should be static
+ public class ButtonAreaLayout implements LayoutManager
{
/** Whether this layout will center the buttons. */
protected boolean centersChildren = true;
@@ -366,6 +375,10 @@ public class BasicOptionPaneUI extends OptionPaneUI
/**
* This helper class handles property change events from the JOptionPane.
+ *
+ * @specnote Apparently this class was intended to be protected,
+ * but was made public by a compiler bug and is now
+ * public for compatibility.
*/
public class PropertyChangeHandler implements PropertyChangeListener
{
@@ -453,19 +466,15 @@ public class BasicOptionPaneUI extends OptionPaneUI
private transient Border buttonBorder;
/** The string used to describe OK buttons. */
- // FIXME: wrong name for a constant.
private static final String OK_STRING = "OK";
/** The string used to describe Yes buttons. */
- // FIXME: wrong name for a constant.
private static final String YES_STRING = "Yes";
/** The string used to describe No buttons. */
- // FIXME: wrong name for a constant.
private static final String NO_STRING = "No";
/** The string used to describe Cancel buttons. */
- // FIXME: wrong name for a constant.
private static final String CANCEL_STRING = "Cancel";
/** The container for the message area.
diff --git a/javax/swing/plaf/basic/BasicProgressBarUI.java b/javax/swing/plaf/basic/BasicProgressBarUI.java
index cf71ffb3e..acf6a97d7 100644
--- a/javax/swing/plaf/basic/BasicProgressBarUI.java
+++ b/javax/swing/plaf/basic/BasicProgressBarUI.java
@@ -75,8 +75,12 @@ public class BasicProgressBarUI extends ProgressBarUI
/**
* A helper class that listens for ChangeEvents
* from the progressBar's model.
+ *
+ * @specnote Apparently this class was intended to be protected,
+ * but was made public by a compiler bug and is now
+ * public for compatibility.
*/
- protected class ChangeHandler implements ChangeListener
+ public class ChangeHandler implements ChangeListener
{
/**
* Called every time the state of the model changes.
diff --git a/javax/swing/plaf/basic/BasicSliderUI.java b/javax/swing/plaf/basic/BasicSliderUI.java
index 9879d8ddb..9169a6bb7 100644
--- a/javax/swing/plaf/basic/BasicSliderUI.java
+++ b/javax/swing/plaf/basic/BasicSliderUI.java
@@ -138,6 +138,10 @@ public class BasicSliderUI extends SliderUI
{
/**
* Helper class that listens to the {@link JSlider}'s model for changes.
+ *
+ * @specnote Apparently this class was intended to be protected,
+ * but was made public by a compiler bug and is now
+ * public for compatibility.
*/
public class ChangeHandler implements ChangeListener
{
@@ -160,8 +164,12 @@ public class BasicSliderUI extends SliderUI
/**
* Helper class that listens for resize events.
+ *
+ * @specnote Apparently this class was intended to be protected,
+ * but was made public by a compiler bug and is now
+ * public for compatibility.
*/
- protected class ComponentHandler extends ComponentAdapter
+ public class ComponentHandler extends ComponentAdapter
{
/**
* Called when the size of the component changes. The UI delegate should
@@ -181,6 +189,10 @@ public class BasicSliderUI extends SliderUI
/**
* Helper class that listens for focus events.
+ *
+ * @specnote Apparently this class was intended to be protected,
+ * but was made public by a compiler bug and is now
+ * public for compatibility.
*/
public class FocusHandler implements FocusListener
{
@@ -246,6 +258,10 @@ public class BasicSliderUI extends SliderUI
* Helper class that listens to our swing timer. This class is responsible
* for listening to the timer and moving the thumb in the proper direction
* every interval.
+ *
+ * @specnote Apparently this class was intended to be protected,
+ * but was made public by a compiler bug and is now
+ * public for compatibility.
*/
public class ScrollListener implements ActionListener
{
@@ -320,6 +336,10 @@ public class BasicSliderUI extends SliderUI
/**
* Helper class that listens for mouse events.
+ *
+ * @specnote Apparently this class was intended to be protected,
+ * but was made public by a compiler bug and is now
+ * public for compatibility.
*/
public class TrackListener extends MouseInputAdapter
{
diff --git a/javax/swing/plaf/basic/BasicSplitPaneUI.java b/javax/swing/plaf/basic/BasicSplitPaneUI.java
index e6270d8f0..b701a63d6 100644
--- a/javax/swing/plaf/basic/BasicSplitPaneUI.java
+++ b/javax/swing/plaf/basic/BasicSplitPaneUI.java
@@ -1,5 +1,5 @@
/* BasicSplitPaneUI.java --
- Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+ Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -71,8 +71,12 @@ public class BasicSplitPaneUI extends SplitPaneUI
/**
* This Layout Manager controls the position and size of the components when
* the JSplitPane's orientation is HORIZONTAL_SPLIT.
+ *
+ * @specnote Apparently this class was intended to be protected,
+ * but was made public by a compiler bug and is now
+ * public for compatibility.
*/
- protected class BasicHorizontalLayoutManager implements LayoutManager2
+ public class BasicHorizontalLayoutManager implements LayoutManager2
{
// 3 components at a time.
// LEFT/TOP = 0
@@ -485,8 +489,12 @@ public class BasicSplitPaneUI extends SplitPaneUI
/**
* This class is the Layout Manager for the JSplitPane when the orientation
* is VERTICAL_SPLIT.
+ *
+ * @specnote Apparently this class was intended to be protected,
+ * but was made public by a compiler bug and is now
+ * public for compatibility.
*/
- protected class BasicVerticalLayoutManager
+ public class BasicVerticalLayoutManager
extends BasicHorizontalLayoutManager
{
/**
@@ -653,8 +661,12 @@ public class BasicSplitPaneUI extends SplitPaneUI
/**
* This class handles FocusEvents from the JComponent.
+ *
+ * @specnote Apparently this class was intended to be protected,
+ * but was made public by a compiler bug and is now
+ * public for compatibility.
*/
- protected class FocusHandler extends FocusAdapter
+ public class FocusHandler extends FocusAdapter
{
/**
* This method is called when the JSplitPane gains focus.
@@ -680,6 +692,10 @@ public class BasicSplitPaneUI extends SplitPaneUI
/**
* This is a deprecated class. It is supposed to be used for handling down
* and right key presses.
+ *
+ * @specnote Apparently this class was intended to be protected,
+ * but was made public by a compiler bug and is now
+ * public for compatibility.
*/
public class KeyboardDownRightHandler implements ActionListener
{
@@ -697,6 +713,10 @@ public class BasicSplitPaneUI extends SplitPaneUI
/**
* This is a deprecated class. It is supposed to be used for handling end
* key presses.
+ *
+ * @specnote Apparently this class was intended to be protected,
+ * but was made public by a compiler bug and is now
+ * public for compatibility.
*/
public class KeyboardEndHandler implements ActionListener
{
@@ -714,6 +734,10 @@ public class BasicSplitPaneUI extends SplitPaneUI
/**
* This is a deprecated class. It is supposed to be used for handling home
* key presses.
+ *
+ * @specnote Apparently this class was intended to be protected,
+ * but was made public by a compiler bug and is now
+ * public for compatibility.
*/
public class KeyboardHomeHandler implements ActionListener
{
@@ -731,6 +755,10 @@ public class BasicSplitPaneUI extends SplitPaneUI
/**
* This is a deprecated class. It is supposed to be used for handling resize
* toggles.
+ *
+ * @specnote Apparently this class was intended to be protected,
+ * but was made public by a compiler bug and is now
+ * public for compatibility.
*/
public class KeyboardResizeToggleHandler implements ActionListener
{
@@ -748,6 +776,10 @@ public class BasicSplitPaneUI extends SplitPaneUI
/**
* This is a deprecated class. It is supposed to be used for handler up and
* left key presses.
+ *
+ * @specnote Apparently this class was intended to be protected,
+ * but was made public by a compiler bug and is now
+ * public for compatibility.
*/
public class KeyboardUpLeftHandler implements ActionListener
{
@@ -765,6 +797,10 @@ public class BasicSplitPaneUI extends SplitPaneUI
/**
* This helper class handles PropertyChangeEvents from the JSplitPane. When
* a property changes, this will update the UI accordingly.
+ *
+ * @specnote Apparently this class was intended to be protected,
+ * but was made public by a compiler bug and is now
+ * public for compatibility.
*/
public class PropertyHandler implements PropertyChangeListener
{
diff --git a/javax/swing/plaf/basic/BasicTabbedPaneUI.java b/javax/swing/plaf/basic/BasicTabbedPaneUI.java
index aca704987..9ea653e7f 100644
--- a/javax/swing/plaf/basic/BasicTabbedPaneUI.java
+++ b/javax/swing/plaf/basic/BasicTabbedPaneUI.java
@@ -83,6 +83,10 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
{
/**
* A helper class that handles focus.
+ *
+ * @specnote Apparently this class was intended to be protected,
+ * but was made public by a compiler bug and is now
+ * public for compatibility.
*/
public class FocusHandler extends FocusAdapter
{
@@ -111,6 +115,10 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
* A helper class for determining if mouse presses occur inside tabs and
* sets the index appropriately. In SCROLL_TAB_MODE, this class also
* handles the mouse clicks on the scrolling buttons.
+ *
+ * @specnote Apparently this class was intended to be protected,
+ * but was made public by a compiler bug and is now
+ * public for compatibility.
*/
public class MouseHandler extends MouseAdapter
{
@@ -173,6 +181,10 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
/**
* This class handles PropertyChangeEvents fired from the JTabbedPane.
+ *
+ * @specnote Apparently this class was intended to be protected,
+ * but was made public by a compiler bug and is now
+ * public for compatibility.
*/
public class PropertyChangeHandler implements PropertyChangeListener
{
@@ -205,8 +217,12 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
* A LayoutManager responsible for placing all the tabs and the visible
* component inside the JTabbedPane. This class is only used for
* WRAP_TAB_LAYOUT.
+ *
+ * @specnote Apparently this class was intended to be protected,
+ * but was made public by a compiler bug and is now
+ * public for compatibility.
*/
- protected class TabbedPaneLayout implements LayoutManager
+ public class TabbedPaneLayout implements LayoutManager
{
/**
* This method is called when a component is added to the JTabbedPane.
@@ -1101,6 +1117,10 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
/**
* This class handles ChangeEvents from the JTabbedPane.
+ *
+ * @specnote Apparently this class was intended to be protected,
+ * but was made public by a compiler bug and is now
+ * public for compatibility.
*/
public class TabSelectionHandler implements ChangeListener
{
diff --git a/javax/swing/plaf/basic/BasicTableUI.java b/javax/swing/plaf/basic/BasicTableUI.java
index 9be6d60e9..93483804c 100644
--- a/javax/swing/plaf/basic/BasicTableUI.java
+++ b/javax/swing/plaf/basic/BasicTableUI.java
@@ -209,12 +209,22 @@ public class BasicTableUI
protected void uninstallDefaults()
{
- table.setFont(null);
- table.setGridColor(null);
- table.setForeground(null);
- table.setBackground(null);
- table.setSelectionForeground(null);
- table.setSelectionBackground(null);
+ // TODO: this method used to do the following which is not
+ // quite right (at least it breaks apps that run fine with the
+ // JDK):
+ //
+ // table.setFont(null);
+ // table.setGridColor(null);
+ // table.setForeground(null);
+ // table.setBackground(null);
+ // table.setSelectionForeground(null);
+ // table.setSelectionBackground(null);
+ //
+ // This would leave the component in a corrupt state, which is
+ // not acceptable. A possible solution would be to have component
+ // level defaults installed, that get overridden by the UI defaults
+ // and get restored in this method. I am not quite sure about this
+ // though. / Roman Kennke
}
protected void uninstallKeyboardActions()
diff --git a/javax/swing/plaf/basic/BasicTextUI.java b/javax/swing/plaf/basic/BasicTextUI.java
index 7033a0a03..1bb0fe4b2 100644
--- a/javax/swing/plaf/basic/BasicTextUI.java
+++ b/javax/swing/plaf/basic/BasicTextUI.java
@@ -59,6 +59,7 @@ import javax.swing.UIDefaults;
import javax.swing.UIManager;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
+import javax.swing.plaf.ActionMapUIResource;
import javax.swing.plaf.TextUI;
import javax.swing.plaf.UIResource;
import javax.swing.text.BadLocationException;
@@ -416,7 +417,7 @@ public abstract class BasicTextUI extends TextUI
ActionMap createActionMap()
{
Action[] actions = textComponent.getActions();
- ActionMap am = new ActionMap();
+ ActionMap am = new ActionMapUIResource();
for (int i = 0; i < actions.length; ++i)
{
String name = (String) actions[i].getValue(Action.NAME);
diff --git a/javax/swing/plaf/metal/MetalSplitPaneUI.java b/javax/swing/plaf/metal/MetalSplitPaneUI.java
index 5c2e141b1..eda17f508 100644
--- a/javax/swing/plaf/metal/MetalSplitPaneUI.java
+++ b/javax/swing/plaf/metal/MetalSplitPaneUI.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package javax.swing.plaf.metal;
+import java.util.HashMap;
+
import javax.swing.JComponent;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.basic.BasicSplitPaneUI;
@@ -46,9 +48,8 @@ public class MetalSplitPaneUI
extends BasicSplitPaneUI
{
- // FIXME: maybe replace by a Map of instances when this becomes stateful
- /** The shared UI instance for MetalSplitPaneUIs */
- private static MetalSplitPaneUI instance = null;
+ /** The UI instances for MetalSplitPaneUIs */
+ private static HashMap instances;
/**
* Constructs a new instance of MetalSplitPaneUI.
@@ -67,8 +68,19 @@ public class MetalSplitPaneUI
*/
public static ComponentUI createUI(JComponent component)
{
- if (instance == null)
- instance = new MetalSplitPaneUI();
+ if (instances == null)
+ instances = new HashMap();
+
+ Object o = instances.get(component);
+ MetalSplitPaneUI instance;
+ if (o == null)
+ {
+ instance = new MetalSplitPaneUI();
+ instances.put(component, instance);
+ }
+ else
+ instance = (MetalSplitPaneUI) o;
+
return instance;
}
}
diff --git a/javax/swing/text/DefaultStyledDocument.java b/javax/swing/text/DefaultStyledDocument.java
index 83da23a26..7b72ab246 100644
--- a/javax/swing/text/DefaultStyledDocument.java
+++ b/javax/swing/text/DefaultStyledDocument.java
@@ -181,8 +181,15 @@ public class DefaultStyledDocument extends AbstractDocument
public void setLogicalStyle(int position, Style style)
{
- // FIXME: Implement me.
- throw new Error("not implemented");
+ Element el = getParagraphElement(position);
+ if (el instanceof AbstractElement)
+ {
+ AbstractElement ael = (AbstractElement) el;
+ ael.setResolveParent(style);
+ }
+ else
+ throw new AssertionError("paragraph elements are expected to be"
+ + "instances of javax.swing.text.AbstractDocument.AbstractElement");
}
public void setParagraphAttributes(int offset, int length,
diff --git a/javax/swing/text/PlainDocument.java b/javax/swing/text/PlainDocument.java
index 3a44725fc..352df7a88 100644
--- a/javax/swing/text/PlainDocument.java
+++ b/javax/swing/text/PlainDocument.java
@@ -117,8 +117,8 @@ public class PlainDocument extends AbstractDocument
super.removeUpdate(event);
int p0 = event.getOffset();
- int p1 = event.getLength() + p0;
int len = event.getLength();
+ int p1 = len + p0;
// check if we must collapse some elements
int i1 = rootElement.getElementIndex(p0);
@@ -133,7 +133,7 @@ public class PlainDocument extends AbstractDocument
Element newEl = createLeafElement(rootElement,
SimpleAttributeSet.EMPTY,
start, end - len);
- rootElement.replace(start, end - start, new Element[]{ newEl });
+ rootElement.replace(i1, i2 - i1, new Element[]{ newEl });
}
else
{
diff --git a/javax/swing/text/PlainView.java b/javax/swing/text/PlainView.java
index cc58dd065..c9e064362 100644
--- a/javax/swing/text/PlainView.java
+++ b/javax/swing/text/PlainView.java
@@ -123,7 +123,7 @@ public class PlainView extends View
{
metrics = g.getFontMetrics();
// FIXME: Selected text are not drawn yet.
- Element line = getDocument().getDefaultRootElement().getElement(lineIndex);
+ Element line = getElement().getElement(lineIndex);
drawUnselectedText(g, x, y, line.getStartOffset(), line.getEndOffset());
//drawSelectedText(g, , , , );
}
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 3740d2d97..f5d9f1419 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -5,8 +5,9 @@ JAVA_DEPEND = java.dep
## this file and restart the make process again
sinclude $(JAVA_DEPEND)
-propertydirs := $(shell cd $(top_srcdir)/resource && $(FIND) gnu java org -type d ! -name CVS -print)
+propertydirs := $(shell cd $(top_srcdir)/resource && $(FIND) gnu java org META-INF -type d ! -name CVS -print)
propertyfiles := $(shell cd $(top_srcdir)/resource && $(FIND) gnu java org -name \*\.properties -print)
+metafiles := $(shell cd $(top_srcdir)/resource && $(FIND) META-INF -print)
compile_classpath = $(top_srcdir):$(top_srcdir)/vm/reference:$(top_srcdir)/external/w3c_dom:$(top_srcdir)/external/sax:.:$(USER_CLASSLIB)
@@ -87,8 +88,9 @@ resources:
@list='$(propertyfiles)'; for p in $$list; do \
cp $(top_srcdir)/resource/$$p $$p; \
done
- if [ -e META-INF ]; then rm -rf META-INF; fi
- cp -r $(top_srcdir)/resource/META-INF .
+ @list='$(metafiles)'; for p in $$list; do \
+ cp $(top_srcdir)/resource/$$p $$p; \
+ done
touch resources
classes: genclasses
diff --git a/native/jni/gtk-peer/Makefile.am b/native/jni/gtk-peer/Makefile.am
index bd7826caa..8c3965b1b 100644
--- a/native/jni/gtk-peer/Makefile.am
+++ b/native/jni/gtk-peer/Makefile.am
@@ -29,7 +29,7 @@ libgtkpeer_la_SOURCES = $(gtk_cairo_c_source_files) \
gnu_java_awt_peer_gtk_GtkFileDialogPeer.c \
gnu_java_awt_peer_gtk_GtkFramePeer.c \
gnu_java_awt_peer_gtk_GtkGenericPeer.c \
- gnu_java_awt_peer_gtk_GtkImagePainter.c \
+ gnu_java_awt_peer_gtk_GtkImage.c \
gnu_java_awt_peer_gtk_GtkLabelPeer.c \
gnu_java_awt_peer_gtk_GtkListPeer.c \
gnu_java_awt_peer_gtk_GtkMenuBarPeer.c \
diff --git a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c
index 99b151126..f80343f22 100644
--- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c
+++ b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c
@@ -97,6 +97,32 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics_initState__II
NSA_SET_PTR (env, obj, g);
}
+JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_GdkGraphics_initFromImage
+ (JNIEnv *env, jobject obj, jobject source)
+{
+ struct graphics *g;
+ GdkPixmap *pixmap =
+ gnu_java_awt_peer_gtk_GtkImage_getPixmap(env, source);
+ g_assert(pixmap != NULL);
+ gdk_pixmap_ref (pixmap);
+
+ g = (struct graphics *) malloc (sizeof (struct graphics));
+ g->x_offset = g->y_offset = 0;
+
+ gdk_threads_enter ();
+
+ g->drawable = (GdkDrawable *)pixmap;
+
+ g->cm = gdk_drawable_get_colormap (g->drawable);
+ gdk_colormap_ref (g->cm);
+ g->gc = gdk_gc_new (g->drawable);
+
+ gdk_threads_leave ();
+
+ NSA_SET_PTR (env, obj, g);
+}
+
/* copy the native state of the peer (GtkWidget *) to the native state
of the graphics object */
JNIEXPORT void JNICALL
@@ -301,136 +327,6 @@ Java_gnu_java_awt_peer_gtk_GdkGraphics_copyArea
}
JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkGraphics_copyPixmap
- (JNIEnv *env, jobject obj, jobject offscreen,
- jint x, jint y, jint width, jint height)
-{
- struct graphics *g1, *g2;
-
- g1 = (struct graphics *) NSA_GET_PTR (env, obj);
- g2 = (struct graphics *) NSA_GET_PTR (env, offscreen);
-
- gdk_threads_enter ();
- gdk_window_copy_area ((GdkWindow *)g1->drawable,
- g1->gc,
- x + g1->x_offset, y + g1->y_offset,
- (GdkWindow *)g2->drawable,
- 0 + g2->x_offset, 0 + g2->y_offset,
- width, height);
- gdk_flush ();
- gdk_threads_leave ();
-}
-
-static void flip_pixbuf (GdkPixbuf *pixbuf,
- jboolean flip_x,
- jboolean flip_y,
- jint width,
- jint height)
-{
- gint src_rs;
- guchar *src_pix;
-
- src_rs = gdk_pixbuf_get_rowstride (pixbuf);
- src_pix = gdk_pixbuf_get_pixels (pixbuf);
-
- if (flip_x)
- {
- gint i, channels;
- guchar buf[4];
-
- channels = gdk_pixbuf_get_has_alpha (pixbuf) ? 4 : 3;
-
- for (i = 0; i < height; i++)
- {
- guchar *left = src_pix + i * src_rs;
- guchar *right = left + channels * (width - 1);
- while (left < right)
- {
- g_memmove (buf, left, channels);
- g_memmove (left, right, channels);
- g_memmove (right, buf, channels);
- left += channels;
- right -= channels;
- }
- }
- }
-
- if (flip_y)
- {
- guchar *top = src_pix;
- guchar *bottom = top + (height - 1) * src_rs;
- gpointer buf = g_malloc (src_rs);
-
- while (top < bottom)
- {
- g_memmove (buf, top, src_rs);
- g_memmove (top, bottom, src_rs);
- g_memmove (bottom, buf, src_rs);
- top += src_rs;
- bottom -= src_rs;
- }
-
- g_free (buf);
- }
-}
-
-JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GdkGraphics_copyAndScalePixmap
- (JNIEnv *env, jobject obj, jobject offscreen, jboolean flip_x, jboolean flip_y,
- jint src_x, jint src_y, jint src_width, jint src_height,
- jint dest_x, jint dest_y, jint dest_width, jint dest_height)
-{
- struct graphics *g1, *g2;
- GdkPixbuf *buf_src, *buf_dest;
-
- g1 = (struct graphics *) NSA_GET_PTR (env, obj);
- g2 = (struct graphics *) NSA_GET_PTR (env, offscreen);
-
- gdk_threads_enter ();
-
- buf_src = gdk_pixbuf_get_from_drawable (NULL,
- g2->drawable,
- g2->cm,
- src_x,
- src_y,
- 0,
- 0,
- src_width,
- src_height);
-
- buf_dest = gdk_pixbuf_scale_simple (buf_src,
- dest_width,
- dest_height,
- GDK_INTERP_BILINEAR);
-
- if (flip_x || flip_y)
- {
- flip_pixbuf (buf_dest, flip_x, flip_y, dest_width, dest_height);
- }
-
- gdk_pixbuf_render_to_drawable (buf_dest,
- g1->drawable,
- g1->gc,
- 0,
- 0,
- dest_x,
- dest_y,
- dest_width,
- dest_height,
- GDK_RGB_DITHER_NORMAL,
- 0,
- 0);
-
- g_object_unref (G_OBJECT (buf_src));
- g_object_unref (G_OBJECT (buf_dest));
-
- gdk_threads_leave ();
-}
-
-
-
-
-JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GdkGraphics_clearRect
(JNIEnv *env, jobject obj, jint x, jint y, jint width, jint height)
{
diff --git a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkFramePeer.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkFramePeer.c
index 52da40cae..6671a0526 100644
--- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkFramePeer.c
+++ b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkFramePeer.c
@@ -38,6 +38,10 @@
#include "gtkpeer.h"
#include "gnu_java_awt_peer_gtk_GtkFramePeer.h"
+/* lives in GtkImage.c */
+GdkPixbuf *gnu_java_awt_peer_gtk_GtkImage_getPixbuf(JNIEnv *env, jobject obj);
+jboolean gnu_java_awt_peer_gtk_GtkImage_isOffScreen(JNIEnv *env, jobject obj);
+
JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GtkFramePeer_removeMenuBarPeer
(JNIEnv *env, jobject obj)
@@ -156,68 +160,26 @@ Java_gnu_java_awt_peer_gtk_GtkFramePeer_gtkFixedSetVisible
}
JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GtkFramePeer_nativeSetIconImageFromDecoder
- (JNIEnv *env, jobject obj, jobject decoder)
+Java_gnu_java_awt_peer_gtk_GtkFramePeer_nativeSetIconImage
+ (JNIEnv *env, jobject obj, jobject gtkimage)
{
void *ptr;
- GdkPixbufLoader *loader = NULL;
- GdkPixbuf *pixbuf = NULL;
-
- ptr = NSA_GET_PTR (env, obj);
-
- loader = NSA_GET_PB_PTR (env, decoder);
- g_assert (loader != NULL);
+ GdkPixbuf *pixbuf = gnu_java_awt_peer_gtk_GtkImage_getPixbuf(env, gtkimage);
- gdk_threads_enter ();
-
- pixbuf = gdk_pixbuf_loader_get_pixbuf (loader);
g_assert (pixbuf != NULL);
- gtk_window_set_icon (GTK_WINDOW (ptr), pixbuf);
-
- gdk_threads_leave ();
-}
-
-static void
-free_pixbuf_data (guchar *pixels, gpointer data __attribute__((unused)))
-{
- free(pixels);
-}
-
-JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GtkFramePeer_nativeSetIconImageFromData
- (JNIEnv *env, jobject obj, jintArray pixelArray, jint width, jint height)
-{
- void *ptr;
- GdkPixbuf *pixbuf;
- jint *pixels;
- int pixels_length, i;
- guchar *data;
-
ptr = NSA_GET_PTR (env, obj);
- pixels = (*env)->GetIntArrayElements (env, pixelArray, 0);
- pixels_length = (*env)->GetArrayLength (env, pixelArray);
-
- data = malloc (sizeof (guchar) * pixels_length);
- for (i = 0; i < pixels_length; i++)
- data[i] = (guchar) pixels[i];
-
gdk_threads_enter ();
- pixbuf = gdk_pixbuf_new_from_data (data,
- GDK_COLORSPACE_RGB,
- TRUE,
- 8,
- width,
- height,
- width*4,
- free_pixbuf_data,
- NULL);
-
gtk_window_set_icon (GTK_WINDOW (ptr), pixbuf);
- gdk_threads_leave ();
+ /* if the GtkImage is offscreen, this is a temporary pixbuf which should
+ be thrown out. */
+ if(gnu_java_awt_peer_gtk_GtkImage_isOffScreen(env, gtkimage) == JNI_TRUE)
+ gdk_pixbuf_unref (pixbuf);
- (*env)->ReleaseIntArrayElements(env, pixelArray, pixels, 0);
+ gdk_threads_leave ();
}
+
+
diff --git a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkImage.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkImage.c
new file mode 100644
index 000000000..df76adb49
--- /dev/null
+++ b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkImage.c
@@ -0,0 +1,592 @@
+/* gtkimage.c
+ Copyright (C) 2005 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. */
+
+#include "gtkpeer.h"
+#include "gnu_java_awt_peer_gtk_GtkImage.h"
+#include <gdk-pixbuf/gdk-pixbuf.h>
+
+/* The constant fields in java.awt.Image */
+#define SCALE_DEFAULT 1
+#define SCALE_FAST 2
+#define SCALE_SMOOTH 4
+#define SCALE_REPLICATE 8
+#define SCALE_AREA_AVERAGING 16
+
+/* functions used by other gtk peer native routines */
+GdkPixbuf *gnu_java_awt_peer_gtk_GtkImage_getPixbuf(JNIEnv *env, jobject obj);
+GdkPixmap *gnu_java_awt_peer_gtk_GtkImage_getPixmap(JNIEnv *env, jobject obj);
+jboolean gnu_java_awt_peer_gtk_GtkImage_isOffScreen(JNIEnv *env, jobject obj);
+
+/* local stuff */
+static GdkInterpType mapHints(jint hints);
+static jboolean offScreen (JNIEnv * env, jobject obj);
+static void *getData (JNIEnv * env, jobject obj);
+static void createRawData (JNIEnv * env, jobject obj, void *ptr);
+static void setWidthHeight (JNIEnv * env, jobject obj, int width, int height);
+
+/**
+ * Loads a pixmap from a file.
+ */
+JNIEXPORT jboolean JNICALL
+Java_gnu_java_awt_peer_gtk_GtkImage_loadPixbuf
+ (JNIEnv *env, jobject obj, jstring name)
+{
+ const char *filename;
+ int width, height;
+ GdkPixbuf *pixbuf;
+
+ /* Don't use the JCL convert function because it throws an exception
+ on failure */
+ filename = (*env)->GetStringUTFChars (env, name, 0);
+
+ if (filename == NULL)
+ return JNI_FALSE;
+
+ gdk_threads_enter ();
+
+ pixbuf = gdk_pixbuf_new_from_file (filename, NULL);
+ if (pixbuf == NULL)
+ {
+ gdk_threads_leave ();
+ (*env)->ReleaseStringUTFChars (env, name, filename);
+ return JNI_FALSE;
+ }
+
+ width = gdk_pixbuf_get_width (pixbuf);
+ height = gdk_pixbuf_get_height (pixbuf);
+ gdk_threads_leave ();
+
+ createRawData (env, obj, pixbuf);
+ setWidthHeight(env, obj, width, height);
+ (*env)->ReleaseStringUTFChars (env, name, filename);
+ return JNI_TRUE;
+}
+
+/**
+ * Returns a copy of the pixel data as a java array.
+ */
+JNIEXPORT jintArray JNICALL
+Java_gnu_java_awt_peer_gtk_GtkImage_getPixels(JNIEnv *env, jobject obj)
+{
+ GdkPixbuf *pixbuf;
+ int width, height, rowstride;
+ guchar *pixeldata;
+ jintArray result_array;
+ jint *result_array_iter, *dst;
+ int i;
+
+ gdk_threads_enter ();
+
+ pixbuf = gnu_java_awt_peer_gtk_GtkImage_getPixbuf(env, obj);
+ width = gdk_pixbuf_get_width (pixbuf);
+ height = gdk_pixbuf_get_height (pixbuf);
+ rowstride = gdk_pixbuf_get_rowstride (pixbuf);
+
+ result_array = (*env)->NewIntArray (env, (width * height));
+ dst = result_array_iter =
+ (*env)->GetIntArrayElements (env, result_array, NULL);
+
+ pixeldata = gdk_pixbuf_get_pixels (pixbuf);
+ for(i = 0 ; i < height; i++)
+ {
+ memcpy(dst, (void *)pixeldata, width * 4);
+ dst += width;
+ pixeldata += rowstride;
+ }
+
+ if (offScreen (env, obj) == JNI_TRUE)
+ gdk_pixbuf_unref (pixbuf);
+
+ gdk_threads_leave ();
+
+ (*env)->ReleaseIntArrayElements (env, result_array, result_array_iter, 0);
+ return result_array;
+}
+
+/**
+ * Returns a copy of the pixel data as a java array.
+ * (GdkPixbuf only)
+ */
+JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_GtkImage_setPixels(JNIEnv *env, jobject obj,
+ jintArray pixels)
+{
+ GdkPixbuf *pixbuf = (GdkPixbuf *)getData (env, obj);
+ int width, height, rowstride;
+ guchar *pixeldata;
+ jint *src_array_iter, *src;
+ int i;
+
+ gdk_threads_enter ();
+
+ width = gdk_pixbuf_get_width (pixbuf);
+ height = gdk_pixbuf_get_height (pixbuf);
+ rowstride = gdk_pixbuf_get_rowstride (pixbuf);
+
+ src = src_array_iter =
+ (*env)->GetIntArrayElements (env, pixels, NULL);
+
+ pixeldata = gdk_pixbuf_get_pixels (pixbuf);
+ for(i = 0 ; i < height; i++)
+ {
+ memcpy((void *)pixeldata, (void *)src, width * 4);
+ src += width;
+ pixeldata += rowstride;
+ }
+
+ gdk_threads_leave ();
+
+ (*env)->ReleaseIntArrayElements (env, pixels, src_array_iter, 0);
+}
+
+/**
+ * Allocates a Gtk Pixbuf or Pixmap.
+ */
+JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_GtkImage_createPixmap(JNIEnv *env, jobject obj)
+{
+ int width, height;
+ jclass cls;
+ jfieldID field;
+
+ cls = (*env)->GetObjectClass (env, obj);
+ field = (*env)->GetFieldID (env, cls, "width", "I");
+ g_assert (field != 0);
+ width = (*env)->GetIntField (env, obj, field);
+
+ field = (*env)->GetFieldID (env, cls, "height", "I");
+ g_assert (field != 0);
+ height = (*env)->GetIntField (env, obj, field);
+
+ gdk_threads_enter ();
+ if (offScreen (env, obj) == JNI_FALSE)
+ createRawData (env, obj, gdk_pixbuf_new (GDK_COLORSPACE_RGB,
+ TRUE,
+ 8,
+ width,
+ height));
+ else
+ createRawData (env, obj, gdk_pixmap_new (NULL, width, height,
+ gdk_rgb_get_visual ()->depth));
+
+ gdk_threads_leave ();
+}
+
+/**
+ * Frees the Gtk Pixmap.
+ */
+JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_GtkImage_freePixmap(JNIEnv *env, jobject obj)
+{
+ gdk_threads_enter ();
+ if (offScreen (env, obj) == JNI_FALSE)
+ gdk_pixbuf_unref ((GdkPixbuf *)getData (env, obj));
+ else
+ gdk_pixmap_unref ((GdkPixmap *)getData (env, obj));
+
+ gdk_threads_leave ();
+}
+
+/**
+ * Sets this pixmap to a scaled version of the source pixmap.
+ * width and height of the destination GtkImage must be set.
+ */
+JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_GtkImage_createScaledPixmap(JNIEnv *env,
+ jobject destination,
+ jobject source,
+ jint hints)
+{
+ GdkPixbuf* dst;
+ int width, height;
+ jclass cls;
+ jfieldID field;
+
+ GdkPixbuf *pixbuf;
+
+ cls = (*env)->GetObjectClass (env, destination);
+ field = (*env)->GetFieldID (env, cls, "width", "I");
+ g_assert (field != 0);
+ width = (*env)->GetIntField (env, destination, field);
+
+ field = (*env)->GetFieldID (env, cls, "height", "I");
+ g_assert (field != 0);
+ height = (*env)->GetIntField (env, destination, field);
+
+ gdk_threads_enter ();
+
+ pixbuf = gnu_java_awt_peer_gtk_GtkImage_getPixbuf(env, source);
+
+ dst = gdk_pixbuf_scale_simple(pixbuf,
+ width, height,
+ mapHints(hints));
+
+ if (offScreen (env, source) == JNI_TRUE)
+ gdk_pixbuf_unref (pixbuf);
+
+ gdk_threads_leave ();
+
+ createRawData (env, destination, (void *)dst);
+}
+
+/**
+ * Draws the pixbuf at x, y, scaled to width and height and
+ * optionally composited with a given background color.
+ */
+JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_GtkImage_drawPixelsScaled
+ (JNIEnv *env, jobject obj, jobject gc_obj,
+ jint bg_red, jint bg_green, jint bg_blue,
+ jint x, jint y, jint width, jint height, jboolean composite)
+{
+ GdkPixbuf* dst;
+ struct graphics *g;
+ guint32 bgColor;
+
+ bgColor = ((bg_red & 0xFF) << 16) |
+ ((bg_green & 0xFF) << 8) | (bg_blue & 0xFF);
+
+ gdk_threads_enter ();
+
+ g = (struct graphics *) NSA_GET_PTR (env, gc_obj);
+
+ if (!g || !GDK_IS_DRAWABLE (g->drawable))
+ {
+ gdk_threads_leave ();
+ return;
+ }
+
+ if (offScreen (env, obj) == JNI_FALSE)
+ {
+ GdkPixbuf* pixbuf = (GdkPixbuf *)getData (env, obj);
+
+ /* Scale and composite the image */
+ if (composite == JNI_TRUE)
+ dst = gdk_pixbuf_composite_color_simple (pixbuf,
+ width,
+ height,
+ GDK_INTERP_BILINEAR,
+ 255,
+ width,
+ bgColor,
+ bgColor);
+ else
+ dst = gdk_pixbuf_scale_simple(pixbuf,
+ width, height,
+ GDK_INTERP_BILINEAR);
+
+ gdk_draw_pixbuf (g->drawable,
+ g->gc,
+ dst,
+ 0, 0,
+ x + g->x_offset, y + g->y_offset,
+ width, height,
+ GDK_RGB_DITHER_NORMAL, 0, 0);
+ gdk_pixbuf_unref (dst);
+
+ } else {
+ /* Get a pixmap */
+ GdkPixmap* pixmap = (GdkPixmap *)getData (env, obj);
+ gdk_draw_drawable (g->drawable,
+ g->gc,
+ pixmap,
+ 0, 0, /* src x,y */
+ x + g->x_offset, y + g->y_offset,
+ width, height);
+ }
+
+ gdk_threads_leave ();
+}
+
+/**
+ * Draws the pixbuf at x, y, scaled to width and height and
+ * optionally composited and/or flipped with a given background color.
+ */
+JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_GtkImage_drawPixelsScaledFlipped
+(JNIEnv *env, jobject obj, jobject gc_obj,
+ jint bg_red, jint bg_green, jint bg_blue,
+ jboolean flipx, jboolean flipy,
+ jint srcx, jint srcy, jint srcwidth, jint srcheight,
+ jint dstx, jint dsty, jint dstwidth, jint dstheight,
+ jboolean composite)
+{
+ GdkPixbuf *pixbuf;
+ GdkPixbuf *tmp, *dst;
+ struct graphics *g;
+ guint32 bgColor;
+
+ bgColor = ((bg_red & 0xFF) << 16) |
+ ((bg_green & 0xFF) << 8) | (bg_blue & 0xFF);
+
+ gdk_threads_enter ();
+
+ g = (struct graphics *) NSA_GET_PTR (env, gc_obj);
+
+ if (!g || !GDK_IS_DRAWABLE (g->drawable))
+ {
+ gdk_threads_leave ();
+ return;
+ }
+
+ if (offScreen (env, obj) == JNI_FALSE)
+ {
+ pixbuf = (GdkPixbuf *)getData (env, obj);
+
+ /* Get the source area */
+ tmp = gdk_pixbuf_new (GDK_COLORSPACE_RGB,
+ TRUE,
+ 8,
+ srcwidth,
+ srcheight);
+
+ gdk_pixbuf_copy_area (pixbuf,
+ srcx, srcy,
+ srcwidth, srcheight,
+ tmp,
+ 0, 0); /* dst x , dst y */
+ } else {
+ /* Get a pixbuf from the pixmap */
+ GdkDrawable *pixmap = (GdkDrawable *)getData(env, obj);
+ tmp = gdk_pixbuf_get_from_drawable (NULL,
+ pixmap,
+ gdk_drawable_get_colormap( pixmap ),
+ srcx, srcy,
+ 0, 0, /* dst x , dst y */
+ srcwidth, srcheight);
+ }
+
+ /* FIXME: This #if should be discarded once I feel comfortable about
+ GTK 2.6 dependence */
+#if GTK_MINOR_VERSION > 4
+ /* Flip it if necessary. */
+ if (flipx == JNI_TRUE)
+ {
+ GdkPixbuf *tmp2 = gdk_pixbuf_flip (tmp, TRUE);
+ gdk_pixbuf_unref (tmp);
+ tmp = tmp2;
+ }
+ if (flipy == JNI_TRUE)
+ {
+ GdkPixbuf *tmp2 = gdk_pixbuf_flip (tmp, FALSE);
+ gdk_pixbuf_unref (tmp);
+ tmp = tmp2;
+ }
+#endif
+
+ /* Scale and composite the image */
+ if (composite == JNI_TRUE)
+ dst = gdk_pixbuf_composite_color_simple (tmp,
+ dstwidth,
+ dstheight,
+ GDK_INTERP_BILINEAR,
+ 255,
+ dstwidth,
+ bgColor,
+ bgColor);
+ else
+ dst = gdk_pixbuf_scale_simple(tmp,
+ dstwidth, dstheight,
+ GDK_INTERP_BILINEAR);
+ gdk_pixbuf_unref (tmp);
+
+ gdk_draw_pixbuf (g->drawable,
+ g->gc,
+ dst,
+ 0, 0,
+ dstx + g->x_offset, dsty + g->y_offset,
+ dstwidth, dstheight,
+ GDK_RGB_DITHER_NORMAL, 0, 0);
+
+ gdk_pixbuf_unref (dst);
+ gdk_threads_leave ();
+}
+
+/**
+ * Used by GtkFramePeer
+ */
+GdkPixbuf *gnu_java_awt_peer_gtk_GtkImage_getPixbuf(JNIEnv *env, jobject obj)
+{
+ int width, height;
+ GdkPixbuf *pixbuf;
+ GdkPixmap* pixmap;
+ jclass cls;
+ jfieldID field;
+
+ if (offScreen (env, obj) == JNI_FALSE)
+ return (GdkPixbuf *)getData (env, obj);
+
+ cls = (*env)->GetObjectClass (env, obj);
+ field = (*env)->GetFieldID (env, cls, "width", "I");
+ g_assert (field != 0);
+ width = (*env)->GetIntField (env, obj, field);
+
+ field = (*env)->GetFieldID (env, cls, "height", "I");
+ g_assert (field != 0);
+ height = (*env)->GetIntField (env, obj, field);
+
+ /* Get a pixmap */
+ pixmap = (GdkPixmap *)getData (env, obj);
+ pixbuf = gdk_pixbuf_get_from_drawable (NULL,
+ pixmap,
+ gdk_drawable_get_colormap( pixmap ),
+ 0, 0, /* src x , src y */
+ 0, 0, /* dst x , dst y */
+ width, height);
+ return pixbuf;
+}
+
+/**
+ * Used by GdkGraphics
+ */
+GdkPixmap *gnu_java_awt_peer_gtk_GtkImage_getPixmap(JNIEnv *env, jobject obj)
+{
+ if (offScreen (env, obj) == JNI_FALSE)
+ return NULL;
+ return (GdkPixmap *)getData (env, obj);
+}
+
+jboolean gnu_java_awt_peer_gtk_GtkImage_isOffScreen(JNIEnv *env, jobject obj)
+{
+ return offScreen(env, obj);
+}
+
+/**
+ * Maps java.awt.Image scaling hints to the native GDK ones.
+ */
+static GdkInterpType mapHints(jint hints)
+{
+ switch ( hints )
+ {
+ /* For FAST, we use the nearest-neighbor. Fastest and lowest quality. */
+ case SCALE_FAST:
+ case SCALE_REPLICATE:
+ return GDK_INTERP_NEAREST;
+
+ /* Hyperbolic for smooth. Slowest too. */
+ case SCALE_SMOOTH:
+ return GDK_INTERP_HYPER;
+
+ /* the inbetweenish method */
+ case SCALE_AREA_AVERAGING:
+ return GDK_INTERP_TILES;
+
+ /* default to bilinear */
+ }
+ return GDK_INTERP_BILINEAR;
+}
+
+/* Sets the width and height fields of a GtkImage object. */
+static void setWidthHeight (JNIEnv * env, jobject obj, int width, int height)
+{
+ jclass cls;
+ jfieldID field;
+
+ cls = (*env)->GetObjectClass (env, obj);
+ g_assert (cls != 0);
+ field = (*env)->GetFieldID (env, cls, "width", "I");
+ g_assert (field != 0);
+ (*env)->SetIntField (env, obj, field, (jint)width);
+
+ field = (*env)->GetFieldID (env, cls, "height", "I");
+ g_assert (field != 0);
+ (*env)->SetIntField (env, obj, field, (jint)height);
+}
+
+/* Returns the value of the offScreen field. */
+static jboolean offScreen (JNIEnv *env, jobject obj)
+{
+ jclass cls;
+ jfieldID field;
+
+ cls = (*env)->GetObjectClass (env, obj);
+ field = (*env)->GetFieldID (env, cls, "offScreen", "Z");
+ g_assert (field != 0);
+ return (*env)->GetBooleanField (env, obj, field);
+}
+
+/* Store and get the pixbuf pointer */
+static void
+createRawData (JNIEnv * env, jobject obj, void *ptr)
+{
+ jclass cls;
+ jmethodID method;
+ jobject data;
+ jfieldID data_fid;
+
+ cls = (*env)->GetObjectClass (env, obj);
+ data_fid = (*env)->GetFieldID (env, cls, "pixmap",
+ "Lgnu/classpath/RawData;");
+ g_assert (data_fid != 0);
+
+#if SIZEOF_VOID_P == 8
+ cls = (*env)->FindClass (env, "gnu/classpath/RawData64");
+ method = (*env)->GetMethodID (env, cls, "<init>", "(J)V");
+ data = (*env)->NewObject (env, cls, method, (jlong) ptr);
+#else
+ cls = (*env)->FindClass (env, "gnu/classpath/RawData32");
+ method = (*env)->GetMethodID (env, cls, "<init>", "(I)V");
+ data = (*env)->NewObject (env, cls, method, (jint) ptr);
+#endif
+
+ (*env)->SetObjectField (env, obj, data_fid, data);
+}
+
+static void *
+getData (JNIEnv * env, jobject obj)
+{
+ jclass cls;
+ jfieldID field;
+ jfieldID data_fid;
+ jobject data;
+
+ cls = (*env)->GetObjectClass (env, obj);
+ data_fid = (*env)->GetFieldID (env, cls, "pixmap",
+ "Lgnu/classpath/RawData;");
+ g_assert (data_fid != 0);
+ data = (*env)->GetObjectField (env, obj, data_fid);
+
+#if SIZEOF_VOID_P == 8
+ cls = (*env)->FindClass (env, "gnu/classpath/RawData64");
+ field = (*env)->GetFieldID (env, cls, "data", "J");
+ return (void *) (*env)->GetLongField (env, data, field);
+#else
+ cls = (*env)->FindClass (env, "gnu/classpath/RawData32");
+ field = (*env)->GetFieldID (env, cls, "data", "I");
+ return (void *) (*env)->GetIntField (env, data, field);
+#endif
+}
diff --git a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkImagePainter.c b/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkImagePainter.c
deleted file mode 100644
index 4686fed59..000000000
--- a/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkImagePainter.c
+++ /dev/null
@@ -1,168 +0,0 @@
-/* gtkimagepainter.c
- Copyright (C) 1999, 2004 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. */
-
-#include "gtkpeer.h"
-#include "gnu_java_awt_peer_gtk_GtkImagePainter.h"
-#include <libart_lgpl/art_misc.h>
-#include <libart_lgpl/art_rgb_affine.h>
-
-
-JNIEXPORT void JNICALL
-Java_gnu_java_awt_peer_gtk_GtkImagePainter_drawPixels
- (JNIEnv *env, jobject obj __attribute__((unused)), jobject gc_obj,
- jint bg_red, jint bg_green, jint bg_blue, jint x, jint y, jint width,
- jint height, jintArray jpixels, jint offset, jint scansize,
- jdoubleArray jaffine)
-{
- struct graphics *g;
- jint *pixels, *elems;
- guchar *packed;
- int i;
- jsize num_pixels;
- guchar *j_rgba, *c_rgb;
-
- g = (struct graphics *) NSA_GET_PTR (env, gc_obj);
-
- if (!jpixels)
- return;
-
- elems = (*env)->GetIntArrayElements (env, jpixels, NULL);
- num_pixels = (*env)->GetArrayLength (env, jpixels);
-
- /* get a copy of the pixel data so we can modify it */
- pixels = malloc (sizeof (jint) * num_pixels);
- memcpy (pixels, elems, sizeof (jint) * num_pixels);
-
- (*env)->ReleaseIntArrayElements (env, jpixels, elems, 0);
-
-#ifndef WORDS_BIGENDIAN
- /* convert pixels from 0xBBGGRRAA to 0xAARRGGBB */
- for (i = 0; i < num_pixels; i++)
- pixels[i] = SWAPU32 ((unsigned)pixels[i]);
-#endif
-
- packed = (guchar *) malloc (sizeof (guchar) * 3 * num_pixels);
- j_rgba = (guchar *) pixels;
- c_rgb = packed;
-
- /* copy over pixels in DirectColorModel format to 24 bit RGB image data,
- and process the alpha channel */
- for (i = 0; i < num_pixels; i++)
- {
- jint ialpha = *j_rgba++;
-
- switch (ialpha)
- {
- case 0: /* full transparency */
- *c_rgb++ = bg_red;
- *c_rgb++ = bg_green;
- *c_rgb++ = bg_blue;
- j_rgba += 3;
- break;
- case 255: /* opaque */
- *c_rgb++ = *j_rgba++;
- *c_rgb++ = *j_rgba++;
- *c_rgb++ = *j_rgba++;
- break;
- default: /* compositing required */
- {
- jfloat alpha = ialpha / 255.0;
- jfloat comp_alpha = 1.0 - alpha;
-
- *c_rgb++ = *j_rgba++ * alpha + bg_red * comp_alpha;
- *c_rgb++ = *j_rgba++ * alpha + bg_green * comp_alpha;
- *c_rgb++ = *j_rgba++ * alpha + bg_blue * comp_alpha;
- }
- break;
- }
- }
-
- if (jaffine)
- {
- jdouble *affine;
- ArtAlphaGamma *alphagamma = NULL;
- art_u8 *dst;
- int new_width, new_height;
-
- affine = (*env)->GetDoubleArrayElements (env, jaffine, NULL);
-
- new_width = abs (width * affine[0]);
- new_height = abs (height * affine[3]);
-
- dst = (art_u8 *) malloc (sizeof (art_u8) * 3 * (new_width * new_height));
-
- art_rgb_affine (dst,
- 0, 0,
- new_width, new_height,
- new_width * 3,
- (art_u8 *) packed + offset * 3,
- width, height,
- scansize * 3,
- affine,
- ART_FILTER_NEAREST,
- alphagamma);
-
- (*env)->ReleaseDoubleArrayElements (env, jaffine, affine, JNI_ABORT);
-
- free (packed);
- packed = (guchar *) dst;
-
- width = scansize = new_width;
- height = new_height;
- offset = 0;
- }
-
- gdk_threads_enter ();
-
- if (!g || !GDK_IS_DRAWABLE (g->drawable))
- {
- gdk_threads_leave ();
- return;
- }
-
- gdk_draw_rgb_image (g->drawable,
- g->gc,
- x + g->x_offset,
- y + g->y_offset,
- width, height, GDK_RGB_DITHER_NORMAL,
- packed + offset * 3, scansize * 3);
-
- gdk_threads_leave ();
-
- free (pixels);
- free (packed);
-}
diff --git a/org/omg/CORBA/DefinitionKindHelper.java b/org/omg/CORBA/DefinitionKindHelper.java
new file mode 100644
index 000000000..6851402dc
--- /dev/null
+++ b/org/omg/CORBA/DefinitionKindHelper.java
@@ -0,0 +1,137 @@
+/* DefinitionKindHelper.java --
+ Copyright (C) 2005 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 org.omg.CORBA;
+
+import gnu.CORBA.DefinitionKindHolder;
+import gnu.CORBA.Restricted_ORB;
+import gnu.CORBA.gnuAny;
+import gnu.CORBA.primitiveTypeCode;
+
+import org.omg.CORBA.TypeCodePackage.BadKind;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+
+/**
+ * A helper operations for the definition kind.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public abstract class DefinitionKindHelper
+{
+ /**
+ * The cached typecode value, computed only once.
+ */
+ private static TypeCode typeCode;
+
+ /**
+ * Insert the definition kind into the given Any.
+ */
+ public static void insert(Any a, DefinitionKind that)
+ {
+ a.insert_Streamable(new DefinitionKindHolder(that));
+ }
+
+ /**
+ * Extract the definition kind from the given Any.
+ */
+ public static DefinitionKind extract(Any a)
+ {
+ return ((DefinitionKindHolder) a.extract_Streamable()).value;
+ }
+
+ /**
+ * Get the definition kind typecode (enumeration, named "DefinitionKind").
+ * The member names are listed as defined by java 1.4 specification.
+ * The names, defined in OMG specification only (like dk_Home or
+ * dk_Event) are not listed.
+ */
+ public static TypeCode type()
+ {
+ if (typeCode == null)
+ {
+ String[] members =
+ new String[]
+ {
+ "dk_none", "dk_all", "dk_Attribute", "dk_Constant", "dk_Exception",
+ "dk_Interface", "dk_Module", "dk_Operation", "dk_Typedef",
+ "dk_Alias", "dk_Struct", "dk_Union", "dk_Enum", "dk_Primitive",
+ "dk_String", "dk_Sequence", "dk_Array", "dk_Repository",
+ "dk_Wstring", "dk_Fixed", "dk_Value", "dk_ValueBox",
+ "dk_ValueMember", "dk_Native"
+ };
+
+ typeCode =
+ Restricted_ORB.Singleton.create_enum_tc(id(), "DefinitionKind",
+ members
+ );
+ }
+ return typeCode;
+ }
+
+ /**
+ * Get the definition kind repository id.
+ *
+ * @return "IDL:omg.org/CORBA/DefinitionKind:1.0", always.
+ */
+ public static String id()
+ {
+ return "IDL:omg.org/CORBA/DefinitionKind:1.0";
+ }
+
+ /**
+ * Read the definitin kind (as int) from the CDR intput stream.
+ *
+ * @param istream a stream to read from.
+ */
+ public static DefinitionKind read(InputStream istream)
+ {
+ return DefinitionKind.from_int(istream.read_long());
+ }
+
+ /**
+ * Write the definition kind (as int) to the CDR output stream.
+ *
+ * @param ostream a stream to write into.
+ * @param value a value to write.
+ */
+ public static void write(OutputStream ostream, DefinitionKind value)
+ {
+ ostream.write_long(value.value());
+ }
+} \ No newline at end of file
diff --git a/org/omg/CORBA/DynValue.java b/org/omg/CORBA/DynValue.java
new file mode 100644
index 000000000..5ef65659a
--- /dev/null
+++ b/org/omg/CORBA/DynValue.java
@@ -0,0 +1,88 @@
+/* DynValue.java --
+ Copyright (C) 2005 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 org.omg.CORBA;
+
+import org.omg.CORBA.DynAnyPackage.InvalidSeq;
+
+/**
+ * Represents the {@link DynAny}, holding a value type.
+ *
+ * A value type is something between CORBA structure and CORBA object.
+ * Like CORBA object, it can have methods, supporting some IDL-defined
+ * interface. However, like structures, they are always local and passed by
+ * value, not by IOR reference.
+ *
+ * The value types can have both public and private members. They support
+ * inheritance. Value types can also be abstract.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface DynValue
+ extends DynAny, org.omg.CORBA.Object
+{
+ /**
+ * Get the kind of the member, pointed by the internal pointer.
+ *
+ * @return the kind of the member.
+ */
+ TCKind current_member_kind();
+
+ /**
+ * Get the name of the member, pointed by the internal pointer.
+ *
+ * @return the name of the member.
+ */
+ String current_member_name();
+
+ /**
+ * Get all members of the enclosed value type object.
+ * @return
+ */
+ NameValuePair[] get_members();
+
+ /**
+ * Set all members for the enclosed value type object.
+ *
+ * @param value an array of members to set.
+ *
+ * @throws InvalidSeq if the passed sequence is not valid.
+ */
+ void set_members(NameValuePair[] value)
+ throws InvalidSeq;
+} \ No newline at end of file
diff --git a/org/omg/CORBA/FieldNameHelper.java b/org/omg/CORBA/FieldNameHelper.java
new file mode 100644
index 000000000..4be2e737f
--- /dev/null
+++ b/org/omg/CORBA/FieldNameHelper.java
@@ -0,0 +1,116 @@
+/* FieldNameHelper.java --
+ Copyright (C) 2005 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 org.omg.CORBA;
+
+import gnu.CORBA.Restricted_ORB;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+
+/**
+ * A formal helper for the CORBA FieldName that is identical to the
+ * narrow string.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public abstract class FieldNameHelper
+{
+ /**
+ * Insert the FieldName into Any (uses {@link Any.insert_string}).
+ *
+ * @param a the Any to insert into.
+ * @param that the string to insert.
+ */
+ public static void insert(Any a, String that)
+ {
+ a.insert_string(that);
+ }
+
+ /**
+ * Extract the FieldName from Any ((uses {@link Any.extract_string}).
+ *
+ * @param a the Any to extract from.
+ */
+ public static String extract(Any a)
+ {
+ return a.extract_string();
+ }
+
+ /**
+ * Return an string alias typecode, named "FieldName".
+ */
+ public static TypeCode type()
+ {
+ ORB orb = Restricted_ORB.Singleton;
+ return orb.create_alias_tc(id(), "FieldName", orb.create_string_tc(0));
+ }
+
+ /**
+ * Return the FieldName repository id.
+ * @return "IDL:omg.org/CORBA/FieldName:1.0", always.
+ */
+ public static String id()
+ {
+ return "IDL:omg.org/CORBA/FieldName:1.0";
+ }
+
+ /**
+ * Calls {@link InputStream#read_string()}.
+ *
+ * @param istream the stream to read from.
+ */
+ public static String read(InputStream istream)
+ {
+ return istream.read_string();
+ }
+
+ /**
+ * Calls {@link OutputStream#write_string()}.
+ *
+ * @param ostream the stream to write into.
+ * @param value the string (FieldName) value to write.
+ */
+ public static void write(OutputStream ostream, String value)
+ {
+ ostream.write_string(value);
+ }
+} \ No newline at end of file
diff --git a/org/omg/CORBA/IdentifierHelper.java b/org/omg/CORBA/IdentifierHelper.java
new file mode 100644
index 000000000..8cd612fcf
--- /dev/null
+++ b/org/omg/CORBA/IdentifierHelper.java
@@ -0,0 +1,116 @@
+/* IdentifierHelper.java --
+ Copyright (C) 2005 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 org.omg.CORBA;
+
+import gnu.CORBA.Restricted_ORB;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+
+/**
+ * A formal helper for the CORBA Identifier that is identical to the
+ * narrow string.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public abstract class IdentifierHelper
+{
+ /**
+ * Insert the Identifier into Any (uses {@link Any.insert_string}).
+ *
+ * @param a the Any to insert into.
+ * @param that the string to insert.
+ */
+ public static void insert(Any a, String that)
+ {
+ a.insert_string(that);
+ }
+
+ /**
+ * Extract the Identifier from Any ((uses {@link Any.extract_string}).
+ *
+ * @param a the Any to extract from.
+ */
+ public static String extract(Any a)
+ {
+ return a.extract_string();
+ }
+
+ /**
+ * Return an string alias typecode, named "Identifier".
+ */
+ public static TypeCode type()
+ {
+ ORB orb = Restricted_ORB.Singleton;
+ return orb.create_alias_tc(id(), "Identifier", orb.create_string_tc(0));
+ }
+
+ /**
+ * Return the Identifier repository id.
+ * @return "IDL:omg.org/CORBA/Identifier:1.0", always.
+ */
+ public static String id()
+ {
+ return "IDL:omg.org/CORBA/Identifier:1.0";
+ }
+
+ /**
+ * Calls {@link InputStream#read_string()}.
+ *
+ * @param istream the stream to read from.
+ */
+ public static String read(InputStream istream)
+ {
+ return istream.read_string();
+ }
+
+ /**
+ * Calls {@link OutputStream#write_string()}.
+ *
+ * @param ostream the stream to write into.
+ * @param value the string (Identifier) value to write.
+ */
+ public static void write(OutputStream ostream, String value)
+ {
+ ostream.write_string(value);
+ }
+} \ No newline at end of file
diff --git a/org/omg/CORBA/ORB.java b/org/omg/CORBA/ORB.java
index 2a46ddb69..8625cf8e9 100644
--- a/org/omg/CORBA/ORB.java
+++ b/org/omg/CORBA/ORB.java
@@ -39,6 +39,7 @@ exception statement from your version. */
package org.omg.CORBA;
import gnu.CORBA.Restricted_ORB;
+import gnu.CORBA.primitiveTypeCode;
import gnu.CORBA.fixedTypeCode;
import gnu.CORBA.generalTypeCode;
import gnu.CORBA.gnuContext;
@@ -152,6 +153,43 @@ public abstract class ORB
throw new NO_IMPLEMENT();
}
+ /**
+ * Create a typecode, representing a tree-like structure.
+ * This structure contains a member that is a sequence of the same type,
+ * as the structure itself. You can imagine as if the folder definition
+ * contains a variable-length array of the enclosed (nested) folder
+ * definitions. In this way, it is possible to have a tree like
+ * structure that can be transferred via CORBA CDR stream.
+ *
+ * @deprecated It is easier and clearler to use a combination of
+ * create_recursive_tc and create_sequence_tc instead.
+ *
+ * @param bound the maximal expected number of the nested components
+ * on each node; 0 if not limited.
+ *
+ * @param offset the position of the field in the returned structure
+ * that contains the sequence of the structures of the same field.
+ * The members before this field are intialised using parameterless
+ * StructMember constructor.
+ *
+ * @return a typecode, defining a stucture, where a member at the
+ * <code>offset</code> position defines an array of the identical
+ * structures.
+ *
+ * @see #create_recursive_tc(String)
+ * @see #create_sequence_tc(int, TypeCode)
+ */
+ public TypeCode create_recursive_sequence_tc(int bound, int offset)
+ {
+ recordTypeCode r = new recordTypeCode(TCKind.tk_struct);
+ for (int i = 0; i < offset; i++)
+ r.add(new StructMember());
+
+ TypeCode recurs = new primitiveTypeCode(TCKind.tk_sequence);
+
+ r.add(new StructMember("", recurs, null));
+ return r;
+ }
/**
* Create alias typecode for the given typecode.
@@ -194,6 +232,7 @@ public abstract class ORB
* @throws NO_IMPLEMENT, always.
*/
public DynAny create_basic_dyn_any(org.omg.CORBA.TypeCode t)
+ throws InconsistentTypeCode
{
throw new NO_IMPLEMENT();
};
@@ -209,7 +248,6 @@ public abstract class ORB
* @throws NO_IMPLEMENT, always.
*/
public DynAny create_dyn_any(org.omg.CORBA.Any a)
- throws InconsistentTypeCode
{
throw new NO_IMPLEMENT();
};
@@ -444,6 +482,25 @@ public abstract class ORB
public abstract org.omg.CORBA.portable.OutputStream create_output_stream();
/**
+ * This should create the list, initialised with the argument descriptions
+ * for the given operation definition (CORBA <code>OperationDef</code>).
+ * The information should be obtained from the interface repository.
+ * However this method is oficially documented as not implemented at least
+ * till v1.4 inclusive.
+ *
+ * @param peration_definition the operation definition, must be
+ * CORBA <code>OperationDef</code>.
+ *
+ * @return never
+ *
+ * @throws NO_IMPLEMENT, always.
+ */
+ public NVList create_operation_list(Object operation_definition)
+ {
+ throw new NO_IMPLEMENT();
+ }
+
+ /**
* This should create the new policy with the specified type and initial
* state. The policies and methods for getting them are not implemented till
* v1.4 inclusive.
@@ -461,6 +518,8 @@ public abstract class ORB
throw new NO_IMPLEMENT();
}
+
+
/**
* Create typecode, defining the sequence of the elements, having
* the given type.
@@ -523,6 +582,41 @@ public abstract class ORB
*/
public abstract TypeCode create_wstring_tc(int bound);
+
+ /**
+ * Create a typecode for an abstract interface. The abstract interface
+ * can be either CORBA object or CORBA value type.
+ *
+ * @param id the id of the abstract interface.
+ * @param name the name of the abstract interface.
+ *
+ * @return the created typecode.
+ */
+ public TypeCode create_abstract_interface_tc(String id, String name)
+ {
+ generalTypeCode t = new generalTypeCode(TCKind.tk_abstract_interface);
+ t.setName(name);
+ t.setId(id);
+ return t;
+ }
+
+ /**
+ * Create a typecode for a native interface.
+ *
+ * @param id the id of the native interface.
+ * @param name the name of the native interface.
+ *
+ * @return the created typecode.
+ */
+ public TypeCode create_native_tc(String id, String name)
+ {
+ generalTypeCode t = new generalTypeCode(TCKind.tk_native);
+ t.setName(name);
+ t.setId(id);
+ return t;
+ }
+
+
/**
* Create a typecode which serves as a placeholder for typcode, containing
* recursion.
@@ -588,6 +682,29 @@ public abstract class ORB
}
/**
+ * This should return the information about the CORBA facilities and
+ * services, available from this ORB. However this method is oficially
+ * documented as not implemented at least till v1.4 inclusive.
+ *
+ * @param service_type a type of the service being requested. The OMG
+ * specification currently defines only one value, 1, for security
+ * related services.
+ *
+ * @param service_info a holder, where the returned information should
+ * be stored.
+ *
+ * @return should return true if the service information is available
+ * from the ORB, but this method never returns.
+ *
+ * @throws NO_IMPLEMENT, always.
+ */
+ public boolean get_service_information(short service_type,
+ ServiceInformationHolder service_info)
+ {
+ throw new NO_IMPLEMENT();
+ }
+
+ /**
* Get the default context of this ORB. This is an initial root of all
* contexts.
*
diff --git a/org/omg/CORBA/ParameterMode.java b/org/omg/CORBA/ParameterMode.java
new file mode 100644
index 000000000..592369895
--- /dev/null
+++ b/org/omg/CORBA/ParameterMode.java
@@ -0,0 +1,170 @@
+/* ParameterMode.java --
+ Copyright (C) 2005 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. */
+/* ParameterMode.java --
+ Copyright (C) 2005 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 org.omg.CORBA;
+
+
+/**
+ * Defines the parameter modes (the ways in that a method parameter
+ * is used during invocation).
+ *
+ * In CORBA, a method parameter can pass the value (PARAM_IN),
+ * be used as a placeholder to return the value (PARAM_OUT) or
+ * both pass the data and be used as a placeholder to return the
+ * changed value (PARAM_INOUT).
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class ParameterMode
+{
+ /**
+ * This value means that the parameter is an IN parameter.
+ */
+ public static int _PARAM_IN = 0;
+
+ /**
+ * This value means that the parameter is an OUT parameter.
+ */
+ public static int _PARAM_OUT = 1;
+
+ /**
+ * This value means that the parameter is an INOUT parameter.
+ */
+ public static int _PARAM_INOUT = 2;
+
+ /**
+ * This value means that the parameter is an IN parameter.
+ */
+ public static ParameterMode PARAM_IN = new ParameterMode(_PARAM_IN);
+
+ /**
+ * This value means that the parameter is an OUT parameter.
+ */
+ public static ParameterMode PARAM_OUT = new ParameterMode(_PARAM_OUT);
+
+ /**
+ * This value means that the parameter is an INOUT parameter.
+ */
+ public static ParameterMode PARAM_INOUT = new ParameterMode(_PARAM_INOUT);
+
+ /**
+ * The value of this parameter mode instance.
+ */
+ private final int value;
+
+ /**
+ * The conversion table.
+ */
+ private static final ParameterMode[] table =
+ new ParameterMode[] { PARAM_IN, PARAM_OUT, PARAM_INOUT };
+
+ /**
+ * Create an instance of the parameter mode with the given value.
+ */
+ protected ParameterMode(int a_value)
+ {
+ value = a_value;
+ }
+
+ /**
+ * Return the integer value code for the given parameter mode.
+ *
+ * @return 0 for PARAM_IN, 1 for PARAM_OUT, 3 for PARAM_INOUT.
+ */
+ public int value()
+ {
+ return value;
+ }
+
+ /**
+ * Get a parameter mode instance for the integer parameter mode code.
+ *
+ * @param p_mode a parameter mode (0..2).
+ *
+ * @return a corresponding parameter mode instance.
+ *
+ * @throws BAD_PARAM for the invalid parameter mode code.
+ */
+ public static ParameterMode from_int(int p_mode)
+ {
+ try
+ {
+ return table [ p_mode ];
+ }
+ catch (ArrayIndexOutOfBoundsException ex)
+ {
+ throw new BAD_PARAM("Invalid parameter mode: " + p_mode);
+ }
+ }
+} \ No newline at end of file
diff --git a/org/omg/CORBA/ParameterModeHelper.java b/org/omg/CORBA/ParameterModeHelper.java
new file mode 100644
index 000000000..067607c83
--- /dev/null
+++ b/org/omg/CORBA/ParameterModeHelper.java
@@ -0,0 +1,125 @@
+/* ParameterModeHelper.java --
+ Copyright (C) 2005 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 org.omg.CORBA;
+
+import gnu.CORBA.Restricted_ORB;
+
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+
+/**
+ * A helper operations for a method parameter modes.
+ * A method parameter can pass the value (PARAM_IN), be used as a placeholder
+ * to return the value (PARAM_OUT) or both pass the data and be used as a
+ * placeholder to return the changed value (PARAM_INOUT).
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public abstract class ParameterModeHelper
+{
+ /**
+ * The cached typecode value, computed only once.
+ */
+ private static TypeCode typeCode;
+
+ /**
+ * Insert the parameter mode into the given Any.
+ */
+ public static void insert(Any any, ParameterMode that)
+ {
+ any.insert_Streamable(new ParameterModeHolder(that));
+ }
+
+ /**
+ * Extract the parameter mode from the given Any.
+ */
+ public static ParameterMode extract(Any any)
+ {
+ return ((ParameterModeHolder) any.extract_Streamable()).value;
+ }
+
+ /**
+ * Get the parameter mode typecode (enumeration, named "ParameterMode").
+ * The typecode states that the enumeration can obtain one of
+ * the following values: PARAM_IN ,PARAM_OUT ,PARAM_INOUT .
+ */
+ public static TypeCode type()
+ {
+ if (typeCode == null)
+ {
+ String[] members =
+ new String[] { "PARAM_IN", "PARAM_OUT", "PARAM_INOUT" };
+
+ typeCode =
+ Restricted_ORB.Singleton.create_enum_tc(id(), "ParameterMode", members);
+ }
+ return typeCode;
+ }
+
+ /**
+ * Get the parameter mode repository id.
+ *
+ * @return "IDL:omg.org/CORBA/ParameterMode:1.0", always.
+ */
+ public static String id()
+ {
+ return "IDL:omg.org/CORBA/ParameterMode:1.0";
+ }
+
+ /**
+ * Read the enumeration value (as int) from the CDR intput stream.
+ *
+ * @param istream a stream to read from.
+ */
+ public static ParameterMode read(InputStream istream)
+ {
+ return ParameterMode.from_int(istream.read_long());
+ }
+
+ /**
+ * Write the enumeration value (as int) to the CDR output stream.
+ *
+ * @param ostream a stream to write into.
+ * @param value a value to write.
+ */
+ public static void write(OutputStream ostream, ParameterMode value)
+ {
+ ostream.write_long(value.value());
+ }
+} \ No newline at end of file
diff --git a/gnu/java/awt/peer/gtk/GtkOffScreenImage.java b/org/omg/CORBA/ParameterModeHolder.java
index 786c4b449..6f9d0b74e 100644
--- a/gnu/java/awt/peer/gtk/GtkOffScreenImage.java
+++ b/org/omg/CORBA/ParameterModeHolder.java
@@ -1,5 +1,5 @@
-/* GtkOffScreenImage.java
- Copyright (C) 1999 Free Software Foundation, Inc.
+/* ParameterModeHolder.java --
+ Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -36,58 +36,51 @@ obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
-package gnu.java.awt.peer.gtk;
+package org.omg.CORBA;
-import java.awt.Graphics;
-import java.awt.Image;
-import java.awt.image.ImageObserver;
-import java.awt.image.ImageProducer;
-
-public class GtkOffScreenImage extends Image
+/**
+ * The holder for ParameterMode.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public class ParameterModeHolder
+ implements org.omg.CORBA.portable.Streamable
{
- int width, height;
- ImageProducer source;
- Graphics g;
-
- public GtkOffScreenImage (ImageProducer source, Graphics g,
- int width, int height)
- {
- this.width = width;
- this.height = height;
-
- this.source = source;
- this.g = g;
- }
-
- public int getWidth (ImageObserver observer)
- {
- return width;
- }
-
- public int getHeight (ImageObserver observer)
- {
- return height;
- }
-
- public ImageProducer getSource ()
+ /**
+ * The stored ParameterMode value.
+ */
+ public ParameterMode value;
+
+ /**
+ * Create the initialised instance.
+ * @param initialValue
+ */
+ public ParameterModeHolder(ParameterMode initialValue)
{
- return source;
+ value = initialValue;
}
- public Graphics getGraphics ()
+ /**
+ * Fill in the {@link value} by data from the CDR stream.
+ */
+ public void _read(org.omg.CORBA.portable.InputStream in)
{
- if (g instanceof GdkGraphics2D)
- return new GdkGraphics2D ((GdkGraphics2D) this.g);
- else
- return new GdkGraphics ((GdkGraphics) this.g);
+ value = ParameterModeHelper.read(in);
}
- public Object getProperty (String name, ImageObserver observer)
+ /**
+ * Get the typecode of the ParameterMode.
+ */
+ public org.omg.CORBA.TypeCode _type()
{
- return Image.UndefinedProperty;
+ return ParameterModeHelper.type();
}
- public void flush ()
+ /**
+ * Write the stored value into the CDR stream.
+ */
+ public void _write(org.omg.CORBA.portable.OutputStream out)
{
+ ParameterModeHelper.write(out, value);
}
}
diff --git a/org/omg/CORBA/RepositoryIdHelper.java b/org/omg/CORBA/RepositoryIdHelper.java
new file mode 100644
index 000000000..59f2d2b22
--- /dev/null
+++ b/org/omg/CORBA/RepositoryIdHelper.java
@@ -0,0 +1,116 @@
+/* RepositoryIdHelper.java --
+ Copyright (C) 2005 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 org.omg.CORBA;
+
+import gnu.CORBA.Restricted_ORB;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+
+/**
+ * A formal helper for the CORBA Repository Id that is identical to the
+ * narrow string.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public abstract class RepositoryIdHelper
+{
+ /**
+ * Insert the Repository Id into Any (uses {@link Any.insert_string}).
+ *
+ * @param a the Any to insert into.
+ * @param that the string to insert.
+ */
+ public static void insert(Any a, String that)
+ {
+ a.insert_string(that);
+ }
+
+ /**
+ * Extract the Repository Id from Any ((uses {@link Any.extract_string}).
+ *
+ * @param a the Any to extract from.
+ */
+ public static String extract(Any a)
+ {
+ return a.extract_string();
+ }
+
+ /**
+ * Return an string alias typecode, named "RepositoryId"
+ */
+ public static TypeCode type()
+ {
+ ORB orb = Restricted_ORB.Singleton;
+ return orb.create_alias_tc(id(), "RepositoryId", orb.create_string_tc(0));
+ }
+
+ /**
+ * Return the Repository Id repository id.
+ * @return "IDL:omg.org/CORBA/RepositoryId:1.0", always.
+ */
+ public static String id()
+ {
+ return "IDL:omg.org/CORBA/RepositoryId:1.0";
+ }
+
+ /**
+ * Calls {@link InputStream#read_string()}.
+ *
+ * @param istream the stream to read from.
+ */
+ public static String read(InputStream istream)
+ {
+ return istream.read_string();
+ }
+
+ /**
+ * Calls {@link OutputStream#write_string()}.
+ *
+ * @param ostream the stream to write into.
+ * @param value the string (Repository Id) value to write.
+ */
+ public static void write(OutputStream ostream, String value)
+ {
+ ostream.write_string(value);
+ }
+} \ No newline at end of file
diff --git a/org/omg/CORBA/SendingContext/RunTimeOperations.java b/org/omg/CORBA/SendingContext/RunTimeOperations.java
new file mode 100644
index 000000000..978bae40e
--- /dev/null
+++ b/org/omg/CORBA/SendingContext/RunTimeOperations.java
@@ -0,0 +1,57 @@
+/* RunTimeOperations.java --
+ Copyright (C) 2005 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 org.omg.CORBA.SendingContext;
+
+
+/**
+ * Defines the operations, applicable for Sending Context. The sending
+ * context provides access to information about the originator of a
+ * GIOP message. For example, when a value type is sent in a GIOP
+ * Request, the receiver may need to ask the sender about
+ * the CodeBase for the implementation of the value type.
+ *
+ * Unfortunately, no public operations are defined up till 1.4 inclusive.
+ *
+ * @since 1.3
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface RunTimeOperations
+{
+} \ No newline at end of file
diff --git a/org/omg/CORBA/SendingContext/Runtime.java b/org/omg/CORBA/SendingContext/Runtime.java
new file mode 100644
index 000000000..3834a3483
--- /dev/null
+++ b/org/omg/CORBA/SendingContext/Runtime.java
@@ -0,0 +1,60 @@
+/* Runtime.java --
+ Copyright (C) 2005 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 org.omg.CORBA.SendingContext;
+
+import org.omg.CORBA.Object;
+import org.omg.CORBA.portable.IDLEntity;
+
+import java.io.Serializable;
+
+/**
+ * Defines the base class that represents the Sending Context. The sending
+ * context provides access to information about the originator of a
+ * GIOP message. For example, when a value type is sent in a GIOP
+ * Request, the receiver may need to ask the sender about
+ * the CodeBase for the implementation of the value type.
+ *
+ * @since 1.3
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface Runtime
+ extends IDLEntity, Object, RunTimeOperations, Serializable
+{
+} \ No newline at end of file
diff --git a/org/omg/CORBA/ServerRequest.java b/org/omg/CORBA/ServerRequest.java
index 598e5f4b2..99653e520 100644
--- a/org/omg/CORBA/ServerRequest.java
+++ b/org/omg/CORBA/ServerRequest.java
@@ -115,7 +115,9 @@ public abstract class ServerRequest
}
/**
- * @deprecated, use {@link #set_result} (same parameter).
+ * This method is deprecated, {@link #set_result} (same parameter).
+ *
+ * @deprecated since 1.2
*
* @throws NO_IMPLEMENT, always.
*/
@@ -125,7 +127,9 @@ public abstract class ServerRequest
}
/**
- * @deprecated, use {@link #set_exception} (same parameter).
+ * This method is deprecated, use {@link #set_exception} (same parameter).
+ *
+ * @deprecated since 1.2.
*
* @throws NO_IMPLEMENT, always.
*/
@@ -135,7 +139,9 @@ public abstract class ServerRequest
}
/**
- * @deprecated, use {@link #arguments} (same parameter).
+ * This method is deprecated, use {@link #arguments} (same parameter).
+ *
+ * @deprecated since 1.2
*
* @throws NO_IMPLEMENT, always.
*/
@@ -145,7 +151,9 @@ public abstract class ServerRequest
}
/**
- * @deprecated, use {@link #operation} (same parameter).
+ * This method is deprecated, use {@link #operation} (same parameter).
+ *
+ * @deprecated since 1.2
*
* @throws NO_IMPLEMENT, always.
*/
diff --git a/org/omg/CORBA/SetOverrideTypeHelper.java b/org/omg/CORBA/SetOverrideTypeHelper.java
new file mode 100644
index 000000000..b3b3218d3
--- /dev/null
+++ b/org/omg/CORBA/SetOverrideTypeHelper.java
@@ -0,0 +1,128 @@
+/* SetOverrideTypeHelper.java --
+ Copyright (C) 2005 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 org.omg.CORBA;
+
+import gnu.CORBA.SetOverrideTypeHolder;
+import gnu.CORBA.Restricted_ORB;
+
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+
+/**
+ * A helper operations for the definition kind.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public abstract class SetOverrideTypeHelper
+{
+ /**
+ * The cached typecode value, computed only once.
+ */
+ private static TypeCode typeCode;
+
+ /**
+ * Insert the definition kind into the given Any.
+ */
+ public static void insert(Any any, SetOverrideType that)
+ {
+ any.insert_Streamable(new SetOverrideTypeHolder(that));
+ }
+
+ /**
+ * Extract the definition kind from the given Any.
+ */
+ public static SetOverrideType extract(Any any)
+ {
+ return ((SetOverrideTypeHolder) any.extract_Streamable()).value;
+ }
+
+ /**
+ * Get the definition kind typecode (enumeration, named "SetOverrideType").
+ * The typecode states that the enumeration can obtain one of
+ * the following values: SET_OVERRIDE ,ADD_OVERRIDE .
+ */
+ public static TypeCode type()
+ {
+ if (typeCode == null)
+ {
+ String[] members =
+ new String[]
+ {
+ "SET_OVERRIDE" ,"ADD_OVERRIDE"
+ };
+
+ typeCode =
+ Restricted_ORB.Singleton.create_enum_tc(id(), "SetOverrideType",
+ members
+ );
+ }
+ return typeCode;
+ }
+
+ /**
+ * Get the definition kind repository id.
+ *
+ * @return "IDL:omg.org/CORBA/SetOverrideType:1.0", always.
+ */
+ public static String id()
+ {
+ return "IDL:omg.org/CORBA/SetOverrideType:1.0";
+ }
+
+ /**
+ * Read the enumeration value (as int) from the CDR intput stream.
+ *
+ * @param istream a stream to read from.*
+ */
+ public static SetOverrideType read(InputStream istream)
+ {
+ return SetOverrideType.from_int(istream.read_long());
+ }
+
+ /**
+ * Write the enumeration value (as int) to the CDR output stream.
+ *
+ * @param ostream a stream to write into.
+ * @param value a value to write.
+ */
+ public static void write(OutputStream ostream, SetOverrideType value)
+ {
+ ostream.write_long(value.value());
+ }
+}
diff --git a/org/omg/CORBA/UnknownUserException.java b/org/omg/CORBA/UnknownUserException.java
new file mode 100644
index 000000000..c1c4b76e3
--- /dev/null
+++ b/org/omg/CORBA/UnknownUserException.java
@@ -0,0 +1,87 @@
+/* UnknownUserException.java --
+ Copyright (C) 2005 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 org.omg.CORBA;
+
+import org.omg.CORBA.portable.IDLEntity;
+
+import java.io.Serializable;
+
+/**
+ * A wrapper against an unknown user exception that has been thrown
+ * on remote side and returned by the server. The instance of this
+ * class is returned by {@link Request#env()}.
+ *
+ * @see Environment#exception().
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class UnknownUserException
+ extends UserException
+ implements IDLEntity, Serializable
+{
+ /**
+ * The Any, holding the actual exception, that has been thrown
+ * by the server.
+ */
+ public Any except;
+
+ /**
+ * Use serialVersionUID (v1.4) for interoperability.
+ */
+ private static final long serialVersionUID = 3106202258203879281L;
+
+ /**
+ * Create an unitialised instance of the unknown user exception.
+ */
+ public UnknownUserException()
+ {
+ }
+
+ /**
+ * Create the instance of the unknow user exception, initialised
+ * to the given value.
+ *
+ * @param an_exception the exception, that has actually been thrown
+ * by the server.
+ */
+ public UnknownUserException(Any an_exception)
+ {
+ except = an_exception;
+ }
+} \ No newline at end of file
diff --git a/org/omg/CORBA/ValueBaseHelper.java b/org/omg/CORBA/ValueBaseHelper.java
index 0197566fa..31e5686a4 100644
--- a/org/omg/CORBA/ValueBaseHelper.java
+++ b/org/omg/CORBA/ValueBaseHelper.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package org.omg.CORBA;
+import gnu.CORBA.CDR.uncObjectInputStream;
+import gnu.CORBA.CDR.uncObjectOutputStream;
import gnu.CORBA.recordTypeCode;
import org.omg.CORBA.portable.InputStream;
@@ -109,13 +111,7 @@ public abstract class ValueBaseHelper
// in its finalizer.
try
{
- ObjectInputStream oin =
- new ObjectInputStream(output)
- {
- public void close()
- {
- }
- };
+ ObjectInputStream oin = new uncObjectInputStream(output);
return (Serializable) oin.readObject();
}
catch (Exception ex)
@@ -151,15 +147,7 @@ public abstract class ValueBaseHelper
// in its finalizer.
try
{
- ObjectOutputStream oout =
- new ObjectOutputStream(input)
- {
- public void close()
- throws IOException
- {
- flush();
- }
- };
+ ObjectOutputStream oout = new uncObjectOutputStream(input);
oout.writeObject(value);
oout.flush();
}
diff --git a/org/omg/CORBA/VersionSpecHelper.java b/org/omg/CORBA/VersionSpecHelper.java
new file mode 100644
index 000000000..d0d590054
--- /dev/null
+++ b/org/omg/CORBA/VersionSpecHelper.java
@@ -0,0 +1,116 @@
+/* VersionSpecHelper.java --
+ Copyright (C) 2005 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 org.omg.CORBA;
+
+import gnu.CORBA.Restricted_ORB;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+
+/**
+ * A formal helper for the CORBA VersionSpec that is identical to the
+ * narrow string.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public abstract class VersionSpecHelper
+{
+ /**
+ * Insert the VersionSpec into Any (uses {@link Any.insert_string}).
+ *
+ * @param a the Any to insert into.
+ * @param that the string to insert.
+ */
+ public static void insert(Any a, String that)
+ {
+ a.insert_string(that);
+ }
+
+ /**
+ * Extract the VersionSpec from Any ((uses {@link Any.extract_string}).
+ *
+ * @param a the Any to extract from.
+ */
+ public static String extract(Any a)
+ {
+ return a.extract_string();
+ }
+
+ /**
+ * Return an string alias typecode, named "VersionSpec".
+ */
+ public static TypeCode type()
+ {
+ ORB orb = Restricted_ORB.Singleton;
+ return orb.create_alias_tc(id(), "VersionSpec", orb.create_string_tc(0));
+ }
+
+ /**
+ * Return the VersionSpec repository id.
+ * @return "IDL:omg.org/CORBA/VersionSpec:1.0", always.
+ */
+ public static String id()
+ {
+ return "IDL:omg.org/CORBA/VersionSpec:1.0";
+ }
+
+ /**
+ * Calls {@link InputStream#read_string()}.
+ *
+ * @param istream the stream to read from.
+ */
+ public static String read(InputStream istream)
+ {
+ return istream.read_string();
+ }
+
+ /**
+ * Calls {@link OutputStream#write_string()}.
+ *
+ * @param ostream the stream to write into.
+ * @param value the string (VersionSpec) value to write.
+ */
+ public static void write(OutputStream ostream, String value)
+ {
+ ostream.write_string(value);
+ }
+} \ No newline at end of file
diff --git a/org/omg/CORBA/package.html b/org/omg/CORBA/package.html
index cda65d0ed..87ab8ba28 100644
--- a/org/omg/CORBA/package.html
+++ b/org/omg/CORBA/package.html
@@ -40,22 +40,37 @@ exception statement from your version. -->
<head><title>GNU Classpath - org.omg.CORBA</title></head>
<body>
-This package will provide the support of <a href="www.omg.org">OMG</a> <a href="www.CORBA.org">CORBA</a>; see <a href="#overview">overview</a> of the implemented functionality. CORBA is an open, vendor independent system that applications use to work together over networks. Thie purpose of this package is to provide CORBA APIs to java programming language, including the fully functional Object Request Broker ({@link org.omg.CORBA.ORB}).
+This package provides the support of <a href="www.omg.org">OMG</a>
+<a href="www.CORBA.org">CORBA</a>; see <a href="#overview">overview</a>
+of the implemented functionality. CORBA is an open, vendor independent
+system that applications use to work together over networks. Thie purpose
+of this package is to provide CORBA APIs to java programming language,
+including the fully functional Object Request Broker ({@link org.omg.CORBA.ORB}).
<a name="overview">
-<h4>Overview of the currently <u>implemented</u> CORBA classes (all packages)</h4>
-<ol>
-<li>The <b>holder</b> classes are containers to store and pass values both to and from the method being executed. In java, the primitive types (int, boolean, etc) are passed by value (one way) only. While Objects are passed by reference, some of them (like String or Integer) are unmodifyable and the arrays cannot be resized. To work around this, such values are passed wrapped into a holder class, where the object instance can be modified and, if needed, replaced. The holders for the most of the types are located in the org.omg.CORBA package, having the suffix *Holder and implementing {@link org.omg.CORBA.portable.Streamable}.
-</li><li>
-The <b>helper</b> classes, having suffix *Helper, provide several convenience methods to manipulate the particular type of holder.
-</li><li>
-The <b>typecode</b> classes provide means to define all large variety of the CORBA types, from strings and arrays till structures, unions and enumerations. The typecodes (instances of the {@link org.omg.CORBA.TypeCode}) are created by invoking the methods of the ORB class. The instance of the restricted ORB (no networking) can be obtained by invoking {@link org.omg.CORBA.ORB#init()}. The typecodes can be used everywhere where the means to define data structures are required.
-</li><li>
-The {@link org.omg.CORBA.Any} class is be used as a container to store the arbitray data type and has the numerous methods for inserting and extracting all primitive types, supported by CORBA. The {@link org.omg.CORBA.Any} is a convienient structure for storing, and passing and returning the values of the arbitrary type.
-</li><li>
-The <b>CDR</b> (Commond Data Representation) streams, {@link org.omg.CORBA.portable.InputStream} and {@link org.omg.CORBA.portable.OutputStream}) are very much like DataInputStream and DataOutputStream in java.io. They read and write data in the binary form, standard for the CORBA messages. The working instances of these abstract classes can be obtained by calling methods on {@link org.omg.CORBA.ORB} or {@link org.omg.CORBA.Any}.
-</li>
-</ol>
+<h4>Overview of the currently implemented CORBA functionality</h4>
+<p>The CORBA implementation in the Classpath project is now a working prototype.
+ This prototype is interoperable with Sun's implementation v 1.4, transferring
+ object references, primitive types, narrow and wide strings, arrays, structures
+ and trees between these two platforms. The thrown exceptions are also transferred
+ and handled. The support for stringified object references (IORs) is implemented.
+ The redirection commands works, LOCATION_FORWARD_PERM changing the target address
+ until the application is restarted and LOCATION_FORWARD redirecting for the
+ current session only. Both Little and Big Endian encoded messages
+ are accepted. The encoding of the sent messages is the same as used in the
+ stringified IOR reference of that object or Big Endian, if no such data
+ available.
+ </p>
+ <p>
+ You can use both request-oriented (based on {@link org.omg.CORBA.Request})
+ and stream-oriented (based on {@link org.omg.CORBA.portable.ObjectImpl})
+ invocation models. The current release includes the working examples, demonstrating
+ the client-server communication using both methods. These examples also show,
+ how to use the Classpath naming service. The IDL compiler is not yet written,
+ but as a side effect of the required compatibility, the implementation seems
+ accepting the output of the Sun's 1.3 idlj.</p>
+
+ @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
</body>
</html>
diff --git a/org/omg/CORBA/portable/BoxedValueHelper.java b/org/omg/CORBA/portable/BoxedValueHelper.java
new file mode 100644
index 000000000..58c95e84c
--- /dev/null
+++ b/org/omg/CORBA/portable/BoxedValueHelper.java
@@ -0,0 +1,76 @@
+/* BoxedValueHelper.java --
+ Copyright (C) 2005 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 org.omg.CORBA.portable;
+
+import java.io.Serializable;
+
+/**
+ * Provides a helper operations for the value type.
+ * The value type may have its own helper, implementing
+ * this interface.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface BoxedValueHelper {
+
+ /**
+ * Get the repository id of this value type.
+ *
+ * @return a repository id.
+ */
+ String get_id();
+
+ /**
+ * Read this value type from the CDR stream.
+ *
+ * @param is a stream to read from.
+ *
+ * @return a loaded value type.
+ */
+ Serializable read_value(InputStream istream);
+
+ /**
+ * Write this value type to the CDR stream.
+ *
+ * @param os a stream to write to.
+ * @param value a value to write.
+ */
+ void write_value(OutputStream ostream, Serializable value);
+
+} \ No newline at end of file
diff --git a/org/omg/CORBA/portable/ValueFactory.java b/org/omg/CORBA/portable/ValueFactory.java
new file mode 100644
index 000000000..b2532e5c5
--- /dev/null
+++ b/org/omg/CORBA/portable/ValueFactory.java
@@ -0,0 +1,62 @@
+/* ValueFactory.java --
+ Copyright (C) 2005 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 org.omg.CORBA.portable;
+
+import java.io.Serializable;
+
+/**
+ * An interface for reading an instance of the value type
+ * from the input stream.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public interface ValueFactory
+{
+ /**
+ * Read the value type. The method is responsible both
+ * for creating a new instance of the value type and
+ * reading the content of this nstance from the stream.
+ *
+ * @param from_stream a stream to read from.
+ *
+ * @return a created value type, intialised with the data from
+ * the stream.
+ */
+ Serializable read_value(InputStream from_stream);
+} \ No newline at end of file
diff --git a/org/omg/CORBA_2_3/ORB.java b/org/omg/CORBA_2_3/ORB.java
new file mode 100644
index 000000000..a8a42250f
--- /dev/null
+++ b/org/omg/CORBA_2_3/ORB.java
@@ -0,0 +1,130 @@
+/* ORB.java --
+ Copyright (C) 2005 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 org.omg.CORBA_2_3;
+
+import org.omg.CORBA.BAD_PARAM;
+import org.omg.CORBA.NO_IMPLEMENT;
+import org.omg.CORBA.portable.ValueFactory;
+
+/**
+ * This class should provide the {@link org.omg.CORBA.ORB) ORB extensions,
+ * defined in the OMG CORBA version 2.3 specification. However in the
+ * Sun's API specification is written that this functionality is not
+ * implemented at least at least till 1.4 inclusive.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public abstract class ORB
+ extends org.omg.CORBA.ORB
+{
+ /**
+ * Should return a defintion of the value type as described
+ * in the interface repository.
+ *
+ * @param repository_id a value type repository id.
+ *
+ * @return never
+ * @throws BAD_PARAM never
+ * @throws NO_IMPLEMENT, always.
+ *
+ * @see org.omg.CORBA.portable.ValueBase
+ */
+ public org.omg.CORBA.Object get_value_def(String repository_id)
+ throws BAD_PARAM
+ {
+ throw new NO_IMPLEMENT();
+ }
+
+ /**
+ * This should register the given value factory under the given
+ * repository id.
+ *
+ * @param repository_id a repository id
+ *
+ * @return never
+ * @throws NO_IMPLEMENT, always.
+ */
+ public ValueFactory register_value_factory(String repository_id,
+ ValueFactory factory
+ )
+ {
+ throw new NO_IMPLEMENT();
+ }
+
+ /**
+ * This should unregister the given value factory under the given
+ * repository id.
+ *
+ * @param repository_id a repository id
+ *
+ * @return never
+ * @throws NO_IMPLEMENT, always.
+ */
+ public void unregister_value_factory(String id)
+ {
+ throw new NO_IMPLEMENT();
+ }
+
+ /**
+ * This should find a suitable value factory to create an instance
+ * of the value type when is being read (unmarshaled) from the
+ * stream.
+ *
+ * @param repository_id a repository id
+ *
+ * @return never
+ * @throws NO_IMPLEMENT, always.
+ */
+ public ValueFactory lookup_value_factory(String repository_id)
+ {
+ throw new NO_IMPLEMENT();
+ }
+
+ /**
+ * Up till OMG 3.0.3 inclusive and also in Suns API till 1.4
+ * inclusive this is totally undocumented. No problem, though,
+ * because is in addition not implemented.
+ *
+ * @throws NO_IMPLEMENT, always.
+ */
+ public void set_delegate(java.lang.Object wrapper)
+ {
+ throw new NO_IMPLEMENT();
+ }
+} \ No newline at end of file
diff --git a/org/omg/CORBA_2_3/portable/Delegate.java b/org/omg/CORBA_2_3/portable/Delegate.java
new file mode 100644
index 000000000..cfb8b8997
--- /dev/null
+++ b/org/omg/CORBA_2_3/portable/Delegate.java
@@ -0,0 +1,67 @@
+/* Delegate.java --
+ Copyright (C) 2005 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 org.omg.CORBA_2_3.portable;
+
+/**
+ * Extends the previous version of the Delegate by one additional method,
+ * defined in CORBA 2_3 .
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public abstract class Delegate
+ extends org.omg.CORBA.portable.Delegate
+{
+ /**
+ * Returns the codebase for the provided object reference.
+ * A codebase is a location information (for instance, URL), specifying,
+ * where the missing parts of the object code can be downloaded. This
+ * is important for the value type objects that handle they method calls
+ * locally and hence must have the local copy of the implementing code.
+ *
+ * This method must be overridden to get functionality, the default method
+ * always returns an empty string.
+ *
+ * @return normally, an agreed location information, specifying, where
+ * the supporting code (like java classes) can be found.
+ */
+ public String get_codebase(org.omg.CORBA.Object self)
+ {
+ return "";
+ }
+} \ No newline at end of file
diff --git a/org/omg/CORBA_2_3/portable/InputStream.java b/org/omg/CORBA_2_3/portable/InputStream.java
new file mode 100644
index 000000000..48953dfa4
--- /dev/null
+++ b/org/omg/CORBA_2_3/portable/InputStream.java
@@ -0,0 +1,189 @@
+/* InputStream.java --
+ Copyright (C) 2005 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 org.omg.CORBA_2_3.portable;
+
+import org.omg.CORBA.MARSHAL;
+import org.omg.CORBA.ValueBaseHelper;
+
+import java.io.Serializable;
+
+/**
+ * This class defines a new CDR input stream methods, added since
+ * CORBA 2.3.
+ *
+ * This class is abstract; no direct instances can be instantiated.
+ * Also, up till v 1.4 inclusive there are no methods that would
+ * return it, and only one unimplemented interface,
+ * {@link org.omg.CORBA.portable.ValueFactory }, needs it as a parameter.
+ *
+ * However since 1.3 all methods, declared as returning an
+ * org.omg.CORBA.portable.InputStream actually return the instance of this
+ * derived class and the new methods are accessible after the casting
+ * operation.
+ *
+ * OMG specification states the writing format of the value types
+ * is outside the scope of GIOP definition. This implementation uses
+ * java serialization mechanism, calling {@link ObjectInputStream#readObject}.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public abstract class InputStream
+ extends org.omg.CORBA.portable.InputStream
+{
+ /**
+ * Read the abstract interface. An abstract interface can be either
+ * CORBA value type or CORBA object and is returned as an abstract
+ * java.lang.Object.
+ *
+ * As specified in OMG specification, this reads a single
+ * boolean and then delegates either to {@link #read_Object()} (for false)
+ * or to {@link #read_Value()} (for true).
+ *
+ * @return an abstract interface, unmarshaled from the stream
+ */
+ public Object read_abstract_interface()
+ {
+ boolean isValue = read_boolean();
+
+ if (isValue)
+ return read_value();
+ else
+ return read_Object();
+ }
+
+ /**
+ * Read the abstract interface, corresponding to the passed type.
+ * An abstract interface can be either CORBA value type or CORBA
+ * object and is returned as an abstract java.lang.Object.
+ *
+ * As specified in OMG specification, this reads a single
+ * boolean and then delegates either to {@link #read_Object(Class)} (for false)
+ * or to {@link #read_Value(Class)} (for true).
+ *
+ * @param clz a base class for the abstract interface.
+ *
+ * @return an abstract interface, unmarshaled from the stream
+ */
+ public Object read_abstract_interface(Class clz)
+ {
+ boolean isValue = read_boolean();
+
+ if (isValue)
+ return read_value(clz);
+ else
+ return read_Object(clz);
+ }
+
+ /**
+ * Read a value type structure from the stream.
+ *
+ * OMG specification states the writing format is outside the scope
+ * of GIOP definition. This implementation uses java serialization
+ * mechanism, calling {@link ObjectInputStream#readObject}
+ *
+ * @return an value type structure, unmarshaled from the stream
+ */
+ public Serializable read_value()
+ {
+ return read_value((Class) null);
+ }
+
+ /**
+ * Read a value type structure, corresponing to the passed type.
+ *
+ * OMG specification states the writing format is outside the scope
+ * of GIOP definition. This implementation uses java serialization
+ * mechanism, calling {@link ObjectInputStream#readObject}
+ *
+ * @param clz a base class for a value type. The class information
+ * is currently used for security check only.
+ *
+ * @return an value type structure, unmarshaled from the stream
+ */
+ public Serializable read_value(Class clz)
+ {
+ Serializable rt = (Serializable) ValueBaseHelper.read(this);
+
+ if (rt != null && clz != null)
+ {
+ if (!(clz.isAssignableFrom(rt.getClass())))
+ {
+ throw new MARSHAL(rt.getClass().getName() +
+ " is not an instance of " + clz.getName()
+ );
+ }
+ }
+ return rt;
+ }
+
+ /**
+ * Read a value type structure content, when the unitialised
+ * instance is passed as a parameter.
+ *
+ * OMG specification states the writing format is outside the scope
+ * of GIOP definition. This implementation uses java serialization
+ * mechanism, calling {@link ObjectInputStream#readObject}
+ * and then compares the loaded instance with the given class
+ * of the passed instance for equality.
+ *
+ * @param unitialised_value, used for class check only.
+ *
+ * @return same value, filled in by the stream content.
+ */
+ public Serializable read_value(Serializable unitialised_value)
+ {
+ return read_value(unitialised_value.getClass());
+ }
+
+ /**
+ * Read a value type structure, having the given repository id.
+ * The casts the streams ORB into a CORBA 2.3 ORB and then
+ * searched for a suitable value factory, where it delegates
+ * the functionality.
+ *
+ * @param repository_id a repository id of the value type.
+ *
+ * @return an value type structure, unmarshaled from the stream
+ */
+ public Serializable read_value(String repository_id)
+ {
+ return ((org.omg.CORBA_2_3.ORB) orb()).lookup_value_factory(repository_id)
+ .read_value(this);
+ }
+} \ No newline at end of file
diff --git a/org/omg/CORBA_2_3/portable/ObjectImpl.java b/org/omg/CORBA_2_3/portable/ObjectImpl.java
new file mode 100644
index 000000000..198500d30
--- /dev/null
+++ b/org/omg/CORBA_2_3/portable/ObjectImpl.java
@@ -0,0 +1,82 @@
+/* ObjectImpl.java --
+ Copyright (C) 2005 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 org.omg.CORBA_2_3.portable;
+
+import org.omg.CORBA.BAD_OPERATION;
+
+/**
+ * Extends the previous version of the CORBA object by one additional method,
+ * defined in CORBA 2_3 . See ancestor for details about the CORBA object.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public abstract class ObjectImpl
+ extends org.omg.CORBA.portable.ObjectImpl
+{
+ /**
+ * Returns the codebase for the provided object reference.
+ * A codebase is a location information (for instance, URL), specifying,
+ * where the missing parts of the object code can be downloaded. This
+ * is important for the value type objects that handle they method calls
+ * locally and hence must have the local copy of the implementing code.
+ *
+ * This implementation expects that the object delegate is set and is
+ * an instance of the org.omg.CORBA_2_3.portable.Delegate. If casts
+ * the set delegate to the given type and invokes
+ * {@link org.omg.CORBA_2_3.portable.Delegate#get_codebase}.
+ *
+ * @return normally, an agreed location information, specifying, where
+ * the supporting code (like java classes) can be found.
+ *
+ * @throws BAD_OPERATION if the object delegate is not an instance
+ * of org.omg.CORBA_2_3.portable.Delegate.
+ */
+ public String _get_codebase()
+ {
+ Object delegate = _get_delegate();
+ if (delegate instanceof org.omg.CORBA_2_3.portable.Delegate)
+ return ((org.omg.CORBA_2_3.portable.Delegate) delegate).get_codebase(this);
+ else if (delegate != null)
+ throw new BAD_OPERATION(delegate.getClass().getName() +
+ " is not a org.omg.CORBA_2_3.portable.Delegate"
+ );
+ else
+ throw new BAD_OPERATION("The delegate not set.");
+ }
+} \ No newline at end of file
diff --git a/org/omg/CORBA_2_3/portable/OutputStream.java b/org/omg/CORBA_2_3/portable/OutputStream.java
new file mode 100644
index 000000000..bc317a662
--- /dev/null
+++ b/org/omg/CORBA_2_3/portable/OutputStream.java
@@ -0,0 +1,145 @@
+/* OutputStream.java --
+ Copyright (C) 2005 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 org.omg.CORBA_2_3.portable;
+
+import org.omg.CORBA.MARSHAL;
+import org.omg.CORBA.ValueBaseHelper;
+import org.omg.CORBA.portable.BoxedValueHelper;
+import org.omg.CORBA.portable.ValueBase;
+
+import java.io.Serializable;
+
+/**
+ * This class defines a new CDR input stream methods, added since
+ * CORBA 2.3.
+ *
+ * This class is abstract; no direct instances can be instantiated.
+ * Also, up till v 1.4 inclusive there are no methods that would
+ * return it directly.
+ *
+ * However since 1.3 all methods, declared as returning an
+ * org.omg.CORBA.portable.InputStream actually return the instance of this
+ * derived class and the new methods are accessible after the casting
+ * operation.
+ *
+ * OMG specification states the writing format of the value types
+ * is outside the scope of GIOP definition. This implementation uses
+ * java serialization mechanism, calling {@link ObjectInputStream#readObject}.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public abstract class OutputStream
+ extends org.omg.CORBA.portable.OutputStream
+{
+ /**
+ * Writes an abstract interface to the stream. An abstract interface can
+ * be eithe CORBA object or value type and is written as a union with
+ * the boolean discriminator (false for objects, true for value types).
+ *
+ * The object from value is separated by fact that all values implement
+ * the {@link ValueBase} interface.
+ *
+ * @param an_interface an abstract interface to write.
+ */
+ public void write_abstract_interface(org.omg.CORBA.Object an_interface)
+ {
+ boolean isValue = an_interface instanceof ValueBase;
+
+ write_boolean(isValue);
+
+ if (isValue)
+ write_value((ValueBase) an_interface);
+ else
+ write_Object(an_interface);
+ }
+
+ /**
+ * Writes a value type into the output stream as java Serializable.
+ *
+ * The functionality is delegated to the {@link ValueBaseHelper}.
+ *
+ * @param value a value type object to write.
+ */
+ public void write_value(Serializable value)
+ {
+ ValueBaseHelper.write(this, value);
+ }
+
+ /**
+ * Write value to the stream using the boxed value helper.
+ *
+ * @param value a value to write.
+ * @param helper a helper, responsible for the writing operation.
+ */
+ public void write_value(Serializable value, BoxedValueHelper helper)
+ {
+ helper.write_value(this, value);
+ }
+
+ /**
+ * Writes a value type into the output stream as java Serializable,
+ * stating it is an instance of the given class.
+ *
+ * The functionality is delegated to the {@link ValueBaseHelper}.
+ * The passed class is used for the check only.
+ *
+ * @param value a value type object to write.
+ */
+ public void write_value(Serializable value, Class clz)
+ {
+ if (!clz.isAssignableFrom(value.getClass()))
+ throw new MARSHAL("The class is not the same");
+ ValueBaseHelper.write(this, value);
+ }
+
+ /**
+ * Writes a value type into the output stream as java Serializable,
+ * stating it has the given repository id.
+ *
+ * The functionality is delegated to the {@link ValueBaseHelper}.
+ *
+ * @param repository_id a repository id of the value type.
+ *
+ * @param value a value type object to write.
+ */
+ public void write_value(Serializable value, String repository_id)
+ {
+ ValueBaseHelper.write(this, value);
+ }
+} \ No newline at end of file
diff --git a/org/omg/CORBA_2_3/portable/package.html b/org/omg/CORBA_2_3/portable/package.html
new file mode 100644
index 000000000..9be95fcb4
--- /dev/null
+++ b/org/omg/CORBA_2_3/portable/package.html
@@ -0,0 +1,46 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!-- package.html -
+ Copyright (C) 2005 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. -->
+
+<html>
+<head><title>GNU Classpath - org.omg.CORBA_2_3.portable</title></head>
+
+<body>
+<p>This package mainly provides methods for the input and output of value types. It also contains other extensions, required for CORBA 2_3.</p>
+
+</body>
+</html>
diff --git a/org/omg/CosNaming/BindingIteratorHelper.java b/org/omg/CosNaming/BindingIteratorHelper.java
index 4519fdd17..c284d40df 100644
--- a/org/omg/CosNaming/BindingIteratorHelper.java
+++ b/org/omg/CosNaming/BindingIteratorHelper.java
@@ -76,7 +76,9 @@ public abstract class BindingIteratorHelper
}
catch (ClassCastException ex)
{
- throw new BAD_OPERATION("Binding iterator expected");
+ BAD_OPERATION bad = new BAD_OPERATION("Binding iterator expected");
+ bad.initCause(ex);
+ throw bad;
}
}
diff --git a/org/omg/CosNaming/BindingListHelper.java b/org/omg/CosNaming/BindingListHelper.java
index a49090f30..fffcb97d5 100644
--- a/org/omg/CosNaming/BindingListHelper.java
+++ b/org/omg/CosNaming/BindingListHelper.java
@@ -73,7 +73,9 @@ public abstract class BindingListHelper
}
catch (ClassCastException ex)
{
- throw new BAD_OPERATION("Binding list expected");
+ BAD_OPERATION bad = new BAD_OPERATION("Binding list expected");
+ bad.initCause(ex);
+ throw bad;
}
}
diff --git a/org/omg/CosNaming/BindingType.java b/org/omg/CosNaming/BindingType.java
index 5e0e5466e..207a4d328 100644
--- a/org/omg/CosNaming/BindingType.java
+++ b/org/omg/CosNaming/BindingType.java
@@ -49,6 +49,11 @@ public class BindingType
implements org.omg.CORBA.portable.IDLEntity
{
/**
+ * Use serialVersionUID (v1.4) for interoperability.
+ */
+ private static final long serialVersionUID = 3735105633408228513L;
+
+ /**
* This constant means that the binding has been created
* with operations bind_context, rebind_context or
* bind_new_context.
@@ -121,4 +126,4 @@ public class BindingType
{
return type;
}
-}
+} \ No newline at end of file
diff --git a/org/omg/CosNaming/BindingTypeHelper.java b/org/omg/CosNaming/BindingTypeHelper.java
index f2a455246..1b8dcb8b9 100644
--- a/org/omg/CosNaming/BindingTypeHelper.java
+++ b/org/omg/CosNaming/BindingTypeHelper.java
@@ -69,7 +69,9 @@ public abstract class BindingTypeHelper
}
catch (ClassCastException ex)
{
- throw new BAD_OPERATION("Binding type expected");
+ BAD_OPERATION bad = new BAD_OPERATION("Binding type expected");
+ bad.initCause(ex);
+ throw bad;
}
}
diff --git a/org/omg/CosNaming/IstringHelper.java b/org/omg/CosNaming/IstringHelper.java
new file mode 100644
index 000000000..ea1e30c85
--- /dev/null
+++ b/org/omg/CosNaming/IstringHelper.java
@@ -0,0 +1,120 @@
+/* IstringHelper.java --
+ Copyright (C) 2005 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 org.omg.CosNaming;
+
+import gnu.CORBA.Restricted_ORB;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+
+/**
+ * "Istring" was a "placeholder for a future IDL internationalized
+ * string data type" in the original specification. It is maintained
+ * solely for compatibility reasons. In both java and CORBA,
+ * Istring is now identical to the narrow (not wide) string and needs
+ * no helper. This class is implemented just for compatibility
+ * reasons.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public abstract class IstringHelper
+{
+ /**
+ * Insert the IString into Any (uses {@link Any.insert_string}).
+ *
+ * @param a the Any to insert into.
+ * @param that the string to insert.
+ */
+ public static void insert(Any a, String that)
+ {
+ a.insert_string(that);
+ }
+
+ /**
+ * Extract the IString from Any ((uses {@link Any.extract_string}).
+ *
+ * @param a the Any to extract from.
+ */
+ public static String extract(Any a)
+ {
+ return a.extract_string();
+ }
+
+ /**
+ * Return an alias typecode.
+ */
+ public static TypeCode type()
+ {
+ ORB orb = Restricted_ORB.Singleton;
+ return orb.create_alias_tc(id(), "Istring", orb.create_string_tc(0));
+ }
+
+ /**
+ * Return the IString repository id.
+ * @return "IDL:omg.org/CosNaming/Istring:1.0", always.
+ */
+ public static String id()
+ {
+ return "IDL:omg.org/CosNaming/Istring:1.0";
+ }
+
+ /**
+ * Calls {@link InputStream#read_string()}.
+ *
+ * @param instream the stream to read from.
+ */
+ public static String read(InputStream istream)
+ {
+ return istream.read_string();
+ }
+
+ /**
+ * Calls {@link OutputStream#write_string()}.
+ *
+ * @param ostream the stream to write into.
+ * @param value the string (IString) value to write.
+ */
+ public static void write(OutputStream ostream, String value)
+ {
+ ostream.write_string(value);
+ }
+} \ No newline at end of file
diff --git a/org/omg/CosNaming/NameComponent.java b/org/omg/CosNaming/NameComponent.java
index 5ec003a50..08ba94aed 100644
--- a/org/omg/CosNaming/NameComponent.java
+++ b/org/omg/CosNaming/NameComponent.java
@@ -49,6 +49,11 @@ public final class NameComponent
implements IDLEntity
{
/**
+ * Use serialVersionUID (v1.4) for interoperability.
+ */
+ private static final long serialVersionUID = -1052538183391762390L;
+
+ /**
* The name component identifier.
*/
public String id;
@@ -110,4 +115,4 @@ public final class NameComponent
{
return id + "." + kind;
}
-}
+} \ No newline at end of file
diff --git a/org/omg/CosNaming/NameComponentHelper.java b/org/omg/CosNaming/NameComponentHelper.java
index 71286e50f..1cfa46345 100644
--- a/org/omg/CosNaming/NameComponentHelper.java
+++ b/org/omg/CosNaming/NameComponentHelper.java
@@ -74,7 +74,9 @@ public abstract class NameComponentHelper
}
catch (ClassCastException ex)
{
- throw new BAD_OPERATION("Name component expected");
+ BAD_OPERATION bad = new BAD_OPERATION("Name component expected");
+ bad.initCause(ex);
+ throw bad;
}
}
diff --git a/org/omg/CosNaming/NameHelper.java b/org/omg/CosNaming/NameHelper.java
index f0dbe9d4f..499f6c4ab 100644
--- a/org/omg/CosNaming/NameHelper.java
+++ b/org/omg/CosNaming/NameHelper.java
@@ -75,7 +75,9 @@ public abstract class NameHelper
}
catch (ClassCastException ex)
{
- throw new BAD_OPERATION("Name expected");
+ BAD_OPERATION bad = new BAD_OPERATION("Name expected");
+ bad.initCause(ex);
+ throw bad;
}
}
diff --git a/org/omg/CosNaming/NamingContextExtHelper.java b/org/omg/CosNaming/NamingContextExtHelper.java
index 890c6db14..2d60ac89d 100644
--- a/org/omg/CosNaming/NamingContextExtHelper.java
+++ b/org/omg/CosNaming/NamingContextExtHelper.java
@@ -76,7 +76,9 @@ public abstract class NamingContextExtHelper
}
catch (ClassCastException ex)
{
- throw new BAD_OPERATION("NamingContextExt expected");
+ BAD_OPERATION bad = new BAD_OPERATION("NamingContextExt expected");
+ bad.initCause(ex);
+ throw bad;
}
}
diff --git a/org/omg/CosNaming/NamingContextHelper.java b/org/omg/CosNaming/NamingContextHelper.java
index 140c63657..93a2ff67b 100644
--- a/org/omg/CosNaming/NamingContextHelper.java
+++ b/org/omg/CosNaming/NamingContextHelper.java
@@ -76,7 +76,9 @@ public abstract class NamingContextHelper
}
catch (ClassCastException ex)
{
- throw new BAD_OPERATION("Naming context expected");
+ BAD_OPERATION bad = new BAD_OPERATION("Naming context expected");
+ bad.initCause(ex);
+ throw bad;
}
}
diff --git a/org/omg/CosNaming/NamingContextPackage/AlreadyBound.java b/org/omg/CosNaming/NamingContextPackage/AlreadyBound.java
index cf0792162..9cae87aa8 100644
--- a/org/omg/CosNaming/NamingContextPackage/AlreadyBound.java
+++ b/org/omg/CosNaming/NamingContextPackage/AlreadyBound.java
@@ -53,6 +53,11 @@ public final class AlreadyBound
implements IDLEntity
{
/**
+ * Use serialVersionUID (v1.4) for interoperability.
+ */
+ private static final long serialVersionUID = -5456929050527586560L;
+
+ /**
* Creates the expection with no details.
*/
public AlreadyBound()
@@ -67,4 +72,4 @@ public final class AlreadyBound
{
super(why);
}
-}
+} \ No newline at end of file
diff --git a/org/omg/CosNaming/NamingContextPackage/CannotProceed.java b/org/omg/CosNaming/NamingContextPackage/CannotProceed.java
index 8b53cc3a6..4ee0df89b 100644
--- a/org/omg/CosNaming/NamingContextPackage/CannotProceed.java
+++ b/org/omg/CosNaming/NamingContextPackage/CannotProceed.java
@@ -54,6 +54,11 @@ public final class CannotProceed
implements IDLEntity
{
/**
+ * Use serialVersionUID (v1.4) for interoperability.
+ */
+ private static final long serialVersionUID = -8627405252527310782L;
+
+ /**
* The relevant naming contex.
*/
public NamingContext cxt;
@@ -79,4 +84,4 @@ public final class CannotProceed
cxt = _cxt;
rest_of_name = _rest_of_name;
}
-}
+} \ No newline at end of file
diff --git a/org/omg/CosNaming/NamingContextPackage/InvalidName.java b/org/omg/CosNaming/NamingContextPackage/InvalidName.java
index 3e953b005..830bdf448 100644
--- a/org/omg/CosNaming/NamingContextPackage/InvalidName.java
+++ b/org/omg/CosNaming/NamingContextPackage/InvalidName.java
@@ -53,6 +53,11 @@ public final class InvalidName
implements IDLEntity
{
/**
+ * Use serialVersionUID (v1.4) for interoperability.
+ */
+ private static final long serialVersionUID = 786404864997961704L;
+
+ /**
* The default constructor.
*/
public InvalidName()
@@ -68,4 +73,4 @@ public final class InvalidName
{
super(why);
}
-}
+} \ No newline at end of file
diff --git a/org/omg/CosNaming/NamingContextPackage/NotEmpty.java b/org/omg/CosNaming/NamingContextPackage/NotEmpty.java
index 5915f89ac..f2d6004b5 100644
--- a/org/omg/CosNaming/NamingContextPackage/NotEmpty.java
+++ b/org/omg/CosNaming/NamingContextPackage/NotEmpty.java
@@ -50,4 +50,8 @@ public final class NotEmpty
extends UserException
implements IDLEntity
{
-}
+ /**
+ * Use serialVersionUID (v1.4) for interoperability.
+ */
+ private static final long serialVersionUID = 7120362687417045881L;
+} \ No newline at end of file
diff --git a/org/omg/CosNaming/NamingContextPackage/NotFound.java b/org/omg/CosNaming/NamingContextPackage/NotFound.java
index 69a6ecdda..6bfff3a71 100644
--- a/org/omg/CosNaming/NamingContextPackage/NotFound.java
+++ b/org/omg/CosNaming/NamingContextPackage/NotFound.java
@@ -53,6 +53,11 @@ public final class NotFound
implements IDLEntity
{
/**
+ * Use serialVersionUID (v1.4) for interoperability.
+ */
+ private static final long serialVersionUID = -7539098836265502514L;
+
+ /**
* The reason, explaining, why the binding cannot be found.
* This might be either the missing node or the wrong binding type.
*/
@@ -78,4 +83,4 @@ public final class NotFound
why = _why;
rest_of_name = _rest_of_name;
}
-}
+} \ No newline at end of file
diff --git a/org/omg/CosNaming/NamingContextPackage/NotFoundReason.java b/org/omg/CosNaming/NamingContextPackage/NotFoundReason.java
index f7ba14521..5c6d47e73 100644
--- a/org/omg/CosNaming/NamingContextPackage/NotFoundReason.java
+++ b/org/omg/CosNaming/NamingContextPackage/NotFoundReason.java
@@ -50,6 +50,11 @@ public class NotFoundReason
implements IDLEntity
{
/**
+ * Use serialVersionUID (v1.4) for interoperability.
+ */
+ private static final long serialVersionUID = -5689237060527596081L;
+
+ /**
* The code for reason, when the node is missing.
*/
public static final int _missing_node = 0;
@@ -126,4 +131,4 @@ public class NotFoundReason
{
return value;
}
-}
+} \ No newline at end of file
diff --git a/org/omg/CosNaming/_BindingIteratorImplBase.java b/org/omg/CosNaming/_BindingIteratorImplBase.java
index 585fcaeff..ea7e1521e 100644
--- a/org/omg/CosNaming/_BindingIteratorImplBase.java
+++ b/org/omg/CosNaming/_BindingIteratorImplBase.java
@@ -39,12 +39,15 @@ exception statement from your version. */
package org.omg.CosNaming;
import org.omg.CORBA.BAD_OPERATION;
+import org.omg.CORBA.BooleanHolder;
import org.omg.CORBA.CompletionStatus;
+import org.omg.CORBA.DynamicImplementation;
+import org.omg.CORBA.ServerRequest;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.InvokeHandler;
-import org.omg.CORBA.portable.ObjectImpl;
import org.omg.CORBA.portable.OutputStream;
import org.omg.CORBA.portable.ResponseHandler;
+import org.omg.CORBA.portable.Streamable;
/**
* The binding iterator implementation base.
@@ -52,10 +55,15 @@ import org.omg.CORBA.portable.ResponseHandler;
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
public abstract class _BindingIteratorImplBase
- extends ObjectImpl
+ extends DynamicImplementation
implements BindingIterator, InvokeHandler
{
/**
+ * Use serialVersionUID (v1.4) for interoperability.
+ */
+ private static final long serialVersionUID = 3472591176635005503L;
+
+ /**
* The binding interator repository id.
*/
private static String[] ids = { BindingIteratorHelper.id() };
@@ -110,4 +118,19 @@ public abstract class _BindingIteratorImplBase
return out;
}
-}
+
+ /**
+ * The obsolete invocation using server request. Implemented for
+ * compatibility reasons, but is it more effectinve to use
+ * {@link #_invoke}.
+ *
+ * @param request a server request.
+ */
+ public void invoke(ServerRequest request)
+ {
+ // "destroy" has a void return type, the two other methods - boolean.
+ Streamable result =
+ request.operation().equals("destroy") ? null : new BooleanHolder();
+ gnu.CORBA.ServiceRequestAdapter.invoke(request, this, result);
+ }
+} \ No newline at end of file
diff --git a/org/omg/CosNaming/_BindingIteratorStub.java b/org/omg/CosNaming/_BindingIteratorStub.java
index 3bb71b6b6..aca7fda38 100644
--- a/org/omg/CosNaming/_BindingIteratorStub.java
+++ b/org/omg/CosNaming/_BindingIteratorStub.java
@@ -57,6 +57,11 @@ public class _BindingIteratorStub
implements BindingIterator
{
/**
+ * Use serialVersionUID (v1.4) for interoperability.
+ */
+ private static final long serialVersionUID = 359397876031922059L;
+
+ /**
* The object can be destroyed only once.
*/
private boolean destroyed;
@@ -195,4 +200,4 @@ public class _BindingIteratorStub
destroy();
super.finalize();
}
-}
+} \ No newline at end of file
diff --git a/org/omg/CosNaming/_NamingContextExtImplBase.java b/org/omg/CosNaming/_NamingContextExtImplBase.java
index 80bea5a08..64af05fb0 100644
--- a/org/omg/CosNaming/_NamingContextExtImplBase.java
+++ b/org/omg/CosNaming/_NamingContextExtImplBase.java
@@ -38,14 +38,16 @@ exception statement from your version. */
package org.omg.CosNaming;
+import org.omg.CORBA.ObjectHolder;
+import org.omg.CORBA.ServerRequest;
+import org.omg.CORBA.StringHolder;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.InvokeHandler;
import org.omg.CORBA.portable.OutputStream;
import org.omg.CORBA.portable.ResponseHandler;
-import org.omg.CosNaming.NamingContextExtPackage.AddressHelper;
+import org.omg.CORBA.portable.Streamable;
import org.omg.CosNaming.NamingContextExtPackage.InvalidAddress;
import org.omg.CosNaming.NamingContextExtPackage.InvalidAddressHelper;
-import org.omg.CosNaming.NamingContextExtPackage.StringNameHelper;
import org.omg.CosNaming.NamingContextPackage.CannotProceed;
import org.omg.CosNaming.NamingContextPackage.CannotProceedHelper;
import org.omg.CosNaming.NamingContextPackage.InvalidName;
@@ -192,4 +194,44 @@ public abstract class _NamingContextExtImplBase
}
return out;
}
-}
+
+ /**
+ * The obsolete invocation using server request. Implemented for
+ * compatibility reasons, but is it more effectinve to use
+ * {@link #_invoke}.
+ *
+ * @param request a server request.
+ */
+ public void invoke(ServerRequest request)
+ {
+ Streamable result = null;
+
+ Integer call_method = (Integer) _methods.get(request.operation());
+
+ if (call_method == null)
+ {
+ super.invoke(request);
+ return;
+ }
+
+ switch (call_method.intValue())
+ {
+ case 0 : // to_string, String
+ result = new StringHolder();
+ break;
+
+ case 1 : // to_name, Name
+ result = new NameHolder();
+ break;
+
+ case 2 : // to_url, String
+ result = new StringHolder();
+ break;
+
+ case 3 : // resolve_str, Object
+ result = new ObjectHolder();
+ break;
+ }
+ gnu.CORBA.ServiceRequestAdapter.invoke(request, this, result);
+ }
+} \ No newline at end of file
diff --git a/org/omg/CosNaming/_NamingContextExtStub.java b/org/omg/CosNaming/_NamingContextExtStub.java
index b6939a746..78c33eba9 100644
--- a/org/omg/CosNaming/_NamingContextExtStub.java
+++ b/org/omg/CosNaming/_NamingContextExtStub.java
@@ -72,6 +72,11 @@ public class _NamingContextExtStub
implements NamingContextExt
{
/**
+ * Use serialVersionUID (v1.4) for interoperability.
+ */
+ private static final long serialVersionUID = 6333293895664182866L;
+
+ /**
* This stub can be the base of the two CORBA objects, so it
* has two repository ids.
*/
@@ -202,4 +207,4 @@ public class _NamingContextExtStub
_releaseReply(in);
}
}
-}
+} \ No newline at end of file
diff --git a/org/omg/CosNaming/_NamingContextImplBase.java b/org/omg/CosNaming/_NamingContextImplBase.java
index dd43c7dbb..549b5336c 100644
--- a/org/omg/CosNaming/_NamingContextImplBase.java
+++ b/org/omg/CosNaming/_NamingContextImplBase.java
@@ -38,16 +38,17 @@ exception statement from your version. */
package org.omg.CosNaming;
-import java.util.Hashtable;
-
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.CompletionStatus;
+import org.omg.CORBA.DynamicImplementation;
import org.omg.CORBA.ObjectHelper;
+import org.omg.CORBA.ObjectHolder;
+import org.omg.CORBA.ServerRequest;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.InvokeHandler;
-import org.omg.CORBA.portable.ObjectImpl;
import org.omg.CORBA.portable.OutputStream;
import org.omg.CORBA.portable.ResponseHandler;
+import org.omg.CORBA.portable.Streamable;
import org.omg.CosNaming.NamingContextPackage.AlreadyBound;
import org.omg.CosNaming.NamingContextPackage.AlreadyBoundHelper;
import org.omg.CosNaming.NamingContextPackage.CannotProceed;
@@ -59,16 +60,23 @@ import org.omg.CosNaming.NamingContextPackage.NotEmptyHelper;
import org.omg.CosNaming.NamingContextPackage.NotFound;
import org.omg.CosNaming.NamingContextPackage.NotFoundHelper;
+import java.util.Hashtable;
+
/**
* The naming context implementation base.
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
public abstract class _NamingContextImplBase
- extends ObjectImpl
+ extends DynamicImplementation
implements NamingContext, InvokeHandler
{
/**
+ * Use serialVersionUID (v1.4) for interoperability.
+ */
+ private static final long serialVersionUID = -114280294134561035L;
+
+ /**
* As there are quite many methods, it may be sensible to use the hashtable.
*/
private static Hashtable methods = new Hashtable();
@@ -365,4 +373,40 @@ public abstract class _NamingContextImplBase
return out;
}
-}
+
+ /**
+ * The obsolete invocation using server request. Implemented for
+ * compatibility reasons, but is it more effectinve to use
+ * {@link #_invoke}.
+ *
+ * @param request a server request.
+ */
+ public void invoke(ServerRequest request)
+ {
+ Streamable result = null;
+
+ // The server request contains no required result type.
+ Integer call_method = (Integer) methods.get(request.operation());
+ if (call_method == null)
+ throw new BAD_OPERATION(0, CompletionStatus.COMPLETED_MAYBE);
+
+ switch (call_method.intValue())
+ {
+ case 4 : // resolve, object
+ result = new ObjectHolder();
+ break;
+
+ case 6 : // new_context, NamingContext
+ case 7 : // bind_new_context, NamingContext
+ {
+ result = new NamingContextHolder();
+ break;
+ }
+
+ default : // void for others.
+ result = null;
+ }
+
+ gnu.CORBA.ServiceRequestAdapter.invoke(request, this, result);
+ }
+} \ No newline at end of file
diff --git a/org/omg/CosNaming/_NamingContextStub.java b/org/omg/CosNaming/_NamingContextStub.java
index 0f921f012..6e3e934bc 100644
--- a/org/omg/CosNaming/_NamingContextStub.java
+++ b/org/omg/CosNaming/_NamingContextStub.java
@@ -70,6 +70,11 @@ public class _NamingContextStub
implements NamingContext
{
/**
+ * Use serialVersionUID (v1.4) for interoperability.
+ */
+ private static final long serialVersionUID = -389233044945385889L;
+
+ /**
* Create the naming context stub.
*/
public _NamingContextStub()
@@ -109,6 +114,7 @@ public class _NamingContextStub
catch (ApplicationException ex)
{
in = ex.getInputStream();
+
String id = ex.getId();
throw5(in, id);
}
@@ -169,6 +175,7 @@ public class _NamingContextStub
catch (ApplicationException ex)
{
in = ex.getInputStream();
+
String id = ex.getId();
throw5(in, id);
throw new InternalError();
@@ -284,6 +291,7 @@ public class _NamingContextStub
catch (ApplicationException ex)
{
in = ex.getInputStream();
+
String id = ex.getId();
throw4(in, id);
}
@@ -312,6 +320,7 @@ public class _NamingContextStub
catch (ApplicationException ex)
{
in = ex.getInputStream();
+
String id = ex.getId();
throw4(in, id);
}
@@ -342,6 +351,7 @@ public class _NamingContextStub
catch (ApplicationException ex)
{
in = ex.getInputStream();
+
String id = ex.getId();
throw4(in, id);
throw new InternalError();
@@ -406,8 +416,7 @@ public class _NamingContextStub
* @throws MARSHAL if the id does not match any of the previous 4 exceptions.
*/
protected void throw4(InputStream in, String id)
- throws MARSHAL, InvalidName, CannotProceed,
- NotFound
+ throws MARSHAL, InvalidName, CannotProceed, NotFound
{
if (id.equals(NotFoundHelper.id()))
throw NotFoundHelper.read(in);
@@ -435,12 +444,12 @@ public class _NamingContextStub
* @throws MARSHAL if the id does not match any of the previous 4 exceptions.
*/
protected void throw5(InputStream in, String id)
- throws MARSHAL, AlreadyBound, InvalidName, CannotProceed,
- NotFound
+ throws MARSHAL, AlreadyBound, InvalidName, CannotProceed,
+ NotFound
{
if (id.equals(AlreadyBoundHelper.id()))
throw AlreadyBoundHelper.read(in);
else
throw4(in, id);
}
-}
+} \ No newline at end of file
diff --git a/org/omg/Messaging/SYNC_WITH_TRANSPORT.java b/org/omg/Messaging/SYNC_WITH_TRANSPORT.java
new file mode 100644
index 000000000..6a4c6150e
--- /dev/null
+++ b/org/omg/Messaging/SYNC_WITH_TRANSPORT.java
@@ -0,0 +1,74 @@
+/* SYNC_WITH_TRANSPORT.java --
+ Copyright (C) 2005 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 org.omg.Messaging;
+
+
+/**
+ * A CORBA synchronization mode, defining how far the request shall
+ * progress before control is returned to the client for one way
+ * operations (when no response is required). OMG specification
+ * defines the following modes:
+ * <ul>
+ * <li>
+ * SYNC_NONE (0) - The ORB returns control before sending the request message.
+ * </li><li>
+ * SYNC_WITH_TRANSPORT (1) - The ORB returns control to the client only after the
+ * transport has accepted the request message.
+ * </li><li>
+ * SYNC_WITH_SERVER (2) - The ORB waits for the reply message from the
+ * server side ORB.
+ * </li><li>
+ * SYNC_WITH_TARGET (3) is equivalent for the synchronous, no one
+ * way operations. It is the most realiable, also the slowest one.
+ * </ul>
+ * The java API specification up till 1.4 inclusive defines only one
+ * constant, SYNC_WITH_TRANSPORT.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface SYNC_WITH_TRANSPORT
+{
+ /**
+ * The mode, indicating, that the ORB returns control to the client only
+ * after the transport has accepted the request message. There is stil no
+ * guarantee that the request will be delivered, but the server should
+ * send a reply message.
+ */
+ short value = 1;
+} \ No newline at end of file
diff --git a/org/omg/Messaging/SyncScopeHelper.java b/org/omg/Messaging/SyncScopeHelper.java
new file mode 100644
index 000000000..2916d07ed
--- /dev/null
+++ b/org/omg/Messaging/SyncScopeHelper.java
@@ -0,0 +1,121 @@
+/* SyncScopeHelper.java --
+ Copyright (C) 2005 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 org.omg.Messaging;
+
+import gnu.CORBA.primitiveTypeCode;
+import gnu.CORBA.recordTypeCode;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.TCKind;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+
+/**
+ * A helper operations for synchronization scope as an alias of
+ * <code>short</code>.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ *
+ * @see SYNC_WITH_TRANSPORT
+ */
+public class SyncScopeHelper
+{
+ /**
+ * A cached typecode value, computed only once.
+ */
+ private static TypeCode typecode;
+
+ /**
+ * Delegates call to {@link Any.extract_short()}.
+ */
+ static short extract(Any a)
+ {
+ return a.extract_short();
+ }
+
+ /**
+ * Returns synchronization scope repository id.
+ *
+ * @return "IDL:omg.org/Messaging/SyncScope:1.0", always.
+ */
+ static String id()
+ {
+ return "IDL:omg.org/Messaging/SyncScope:1.0";
+ }
+
+ /**
+ * Delegates call to {@link Any.insert_short(short)}.
+ */
+ static void insert(Any a, short that)
+ {
+ a.insert_short(that);
+ }
+
+ /**
+ * Delegates call to {@link InputStream.read_short()}.
+ */
+ static short read(InputStream istream)
+ {
+ return istream.read_short();
+ }
+
+ /**
+ * Returns a typecode of the synchronization scope, stating it
+ * is an alias of <code>short</code>, named "SyncScope".
+ *
+ * @return a typecode of synchronization scope.
+ */
+ static TypeCode type()
+ {
+ recordTypeCode r = new recordTypeCode(TCKind.tk_alias);
+ r.setName("SyncScope");
+ r.setId(id());
+ r.setContentType(new primitiveTypeCode(TCKind.tk_short));
+ return r;
+ }
+
+ /**
+ * Delegates call to {@link OutputStream.write_short()}.
+ */
+ static void write(OutputStream ostream, short value)
+ {
+ ostream.write_short(value);
+ }
+} \ No newline at end of file
diff --git a/org/omg/Messaging/package.html b/org/omg/Messaging/package.html
new file mode 100644
index 000000000..423b9511c
--- /dev/null
+++ b/org/omg/Messaging/package.html
@@ -0,0 +1,64 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!-- package.html --
+ Copyright (C) 2002 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. -->
+
+<html>
+<head><title>GNU Classpath - org.omg.CORBA.Messaging</title></head>
+
+<body>
+Contains CORBA synchronization modes, specifying how far the request shall
+progress before control is returned to the client for one way operations.
+The one way operation is an operation when no response is required.
+OMG specification defines the following modes:
+<ul>
+<li>
+SYNC_NONE (0) - The ORB returns control before sending the request message.
+</li><li>
+SYNC_WITH_TRANSPORT (1) - The ORB returns control to the client only after the
+transport has accepted the request message. There is stil no guarantee that the
+request will be delivered.
+</li><li>
+SYNC_WITH_SERVER (2) - The ORB waits for the reply message from the server side ORB.
+</li><li>
+SYNC_WITH_TARGET (3) is equivalent for the synchronous, no one way operations.
+It is the most realiable, also the slowest one.
+</ul>
+The java API specification up till 1.4 inclusive defines only one
+constant, SYNC_WITH_TRANSPORT. Others may appear in the future versions.
+
+@author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)</body>
+</html>
diff --git a/org/omg/stub/java/rmi/_Remote_Stub.java b/org/omg/stub/java/rmi/_Remote_Stub.java
new file mode 100644
index 000000000..81d327fd8
--- /dev/null
+++ b/org/omg/stub/java/rmi/_Remote_Stub.java
@@ -0,0 +1,65 @@
+/* _Remote_Stub.java --
+ Copyright (C) 2005 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 org.omg.stub.java.rmi;
+
+import org.omg.CORBA_2_3.portable.ObjectImpl;
+
+/**
+ * Provides a stub for Remote type.
+ *
+ * Despite this class has appeared since v 1.3, it is oficially marked
+ * as incomplete at least till v 1.4 inclusive. Hence significant alterations
+ * are expected in the future.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public final class _Remote_Stub
+ extends ObjectImpl
+{
+ /**
+ * Returs the array of repository ids, implemented by this object.
+ * The method must be overridden to return the meaningful information.
+ *
+ * @return a single member array, containing empty string (if not overridden).
+ */
+ public String[] _ids()
+ {
+ return new String[] { "" };
+ }
+} \ No newline at end of file
diff --git a/org/omg/stub/java/rmi/package.html b/org/omg/stub/java/rmi/package.html
new file mode 100644
index 000000000..cf9febd2c
--- /dev/null
+++ b/org/omg/stub/java/rmi/package.html
@@ -0,0 +1,48 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!-- package.html -
+ Copyright (C) 2005 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. -->
+
+<html>
+<head><title>GNU Classpath - org.omg.stub.java.rmi</title></head>
+
+<body>
+<p>Contains RMI-IIOP Stubs for the Remote types from java.rmi package.
+The RMI-IIOP system provides means to use the standard CORBA protocol
+for RMI.</p>
+
+</body>
+</html>